Created
August 8, 2012 15:33
-
-
Save jjttjj/3295977 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn make-coll [x] | |
(cond | |
(coll? x) x | |
(nil? x) nil | |
:else (list x))) | |
(defn dragdrop [source-nodes target-nodes & {:keys [source-listeners target-listeners]}] | |
(let [source-group (goog.fx.DragDropGroup.) | |
target-group (goog.fx.DragDropGroup.)] | |
(doseq [source-node (make-coll source-nodes)] | |
(.addDragDropItem source-group (goog.fx.DragDropItem. source-node))) | |
(doseq [target-node (make-coll target-nodes)] | |
(.addDragDropItem target-group (goog.fx.DragDropItem. target-node))) | |
(.addTarget source-group target-group) | |
(.init source-group) | |
(doseq [[event handler] source-listeners] | |
(listen! source-group | |
event | |
handler)) | |
(doseq [[event handler] target-listeners] | |
(listen! target-group | |
event | |
handler)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment