Skip to content
Browse files

only return input if ok clicked

  • Loading branch information...
1 parent 4e76c94 commit bcc8b0f79869ddf1c98e8b722b3b8dbf5171ae8b @netguy204 committed Jul 7, 2012
Showing with 20 additions and 11 deletions.
  1. +5 −0 index-dev.html
  2. +9 −9 src-cljs/move/interactors.cljs
  3. +6 −2 src-cljs/move/views.cljs
View
5 index-dev.html
@@ -4,6 +4,11 @@
<script src="javascripts/main.js"></script>
<link rel="stylesheet" href="resources/tree.css" type="text/css" media="screen" />
<link rel="stylesheet" href="resources/dialog.css" type="text/css" media="screen" />
+ <style type="text/css" media="screen">
+ .label-input-label {
+ color: GrayText;
+ }
+ </style>
</head>
<body>
View
18 src-cljs/move/interactors.cljs
@@ -19,27 +19,27 @@
(defasync get-current-list [state]
"[async] get the current list from the server and update the model"
- [current-list [get-json "/resources/current-list.json"]
- _ (models/set-current-list state current-list)]
+ [current-list [get-json "/resources/current-list.json"]]
+ (models/set-current-list state current-list)
current-list)
(defasync get-list-data [state current-list]
"[async] get the items in a list from the server and update the model"
- [list-items [get-json "/resources/list-items.json"]
- _ (doseq [item list-items]
- (models/add-todo state current-list item))]
+ [list-items [get-json "/resources/list-items.json"]]
+ (doseq [item list-items]
+ (models/add-todo state current-list item))
+
list-items)
(defasync create-new-todo [state view]
"[async] create a new item in the current list"
[list (models/current-list state)
- input-dialog (views/make-input-dialog "Todo name?")
- input [events/register-once [:ok-clicked input-dialog]]
- item (models/add-todo state list input)]
+ input-dialog (views/make-input-dialog "What do you want to do?")
+ input [views/with-input input-dialog]]
- item)
+ (models/add-todo state list input))
(defasync run-application [state view]
"[async] start the application"
View
8 src-cljs/move/views.cljs
@@ -104,7 +104,11 @@
(.setVisible dialog true)
(.focusAndSelect input)
- (ge/listen dialog (.-SELECT goog/ui.Dialog.EventType)
- #(events/fire [:ok-clicked dialog] (.getValue input)))
+ (ge/listenOnce dialog (.-SELECT goog/ui.Dialog.EventType)
+ #(when (= (.-key %) (.-OK goog/ui.Dialog.DefaultButtonKeys))
+ (events/fire [:ok-clicked dialog] (.getValue input))))
dialog))
+
+(defn with-input [view callback]
+ (events/register-once [:ok-clicked view] callback))

0 comments on commit bcc8b0f

Please sign in to comment.
Something went wrong with that request. Please try again.