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
| if window.DEBUG | |
| console.log "running outliner.js" | |
| # Outliner should be a window.tools object, should easily match up with selection | |
| $(window.ifrm).ready -> | |
| window.tools['outliner'] = | |
| toolbox: 0 | |
| moving: 0 | |
| move_start: [0,0] |
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 collapse-node [start] | |
| (loop [data start result []] | |
| (let [d (if (sequential? data) data [data]) | |
| sorted (map (fn [v] | |
| {:id (:uid v) :babies (:children v)}) d) | |
| uids (flatten (filter #(not (nil? %)) (map :id sorted))) | |
| babies (vec (flatten (filter #(not (nil? %)) (map :babies sorted))))] | |
| (if-not (pos? (count babies)) | |
| (concat result uids) |
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
| ;sug/private is an atomic data store that links the owner path+:react-key to a data map. | |
| ;it works much like state, but it doesn't trigger any renders and doesn't have pending/rendered versions | |
| ;it's very helpful here to stash the mouse drag meta info without triggering app updates. | |
| (defn unbind-drag [owner] | |
| (let [[mouse-up mouse-move] (sug/private owner :event-handlers)] | |
| (.unbind (js/$ js/window) "mouseup" mouse-up) | |
| (.unbind (js/$ js/window) "mousemove" mouse-move))) | |
| (defn drag-stop [e data owner] |
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
| (sug/defcomp window | |
| [data owner] | |
| {:render-state | |
| (fn [_ state] | |
| (let [[x y w h] (:xywh state)] | |
| (dom/div #js {:ref "tool" :style #js {:left x :top y :width w :height h :position "absolute" :border "1px solid red"}} | |
| (sug/make draggable data {:opts {:className (str "title") | |
| :content (str (:view state) (rand-int 100))} |
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
| (sug/defcomp report | |
| [data owner] | |
| {:render-state | |
| (fn [_ state] | |
| (dom/li nil (prn-str (rand-int 100) data) ))}) | |
| (sug/defcomp window |
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
| (sug/defcomp report | |
| [data owner] | |
| {:render-state | |
| (fn [_ state] | |
| (dom/li nil (prn-str (str (rand-int 100)) data) ))}) | |
| (sug/defcomp button | |
| [data owner] | |
| {:render-state |
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
| "will-mount: get-state: " {:s 0} " get-render-state: " {:s 0} core.cljs:55 | |
| "render-state: get-state: " {:s 0} " get-render-state: " {:s 0} core.cljs:55 | |
| "should-update: get-state: " {:s 0} " get-render-state: " {:s 0} core.cljs:55 | |
| "render-state: get-state: " {:s 0} " get-render-state: " {:s 0} core.cljs:55 | |
| "did-update: set-state!" core.cljs:55 | |
| "did-update: get-state: " {:s 1} " get-render-state: " {:s 0} core.cljs:55 | |
| "------------------" core.cljs:55 | |
| "should-update: get-state: " {:s 1} " get-render-state: " {:s 0} core.cljs:55 | |
| "render-state: get-state: " {:s 1} " get-render-state: " {:s 1} core.cljs:55 | |
| "did-update: set-state!" core.cljs:55 |
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
| (ns examples.events.core | |
| (:require [om.core :as om :include-macros true] | |
| [om.dom :as dom :include-macros true])) | |
| (enable-console-print!) | |
| (defn ticker [data owner] | |
| (reify | |
| om/IInitState | |
| (init-state [_] |
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
| (ns examples.events.core | |
| (:require [om.core :as om :include-macros true] | |
| [om.dom :as dom :include-macros true])) | |
| (enable-console-print!) | |
| (defn ticker [data owner opts] | |
| (reify | |
| om/IInitState | |
| (init-state [_] |
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 ticker2 [data owner] | |
| (reify | |
| om/IInitState | |
| (init-state [_] {:s 0}) | |
| om/IRender | |
| (render [_] | |
| (let [state (om/get-state owner)] | |
| (dom/ul #js {:onClick #(om/transact! data :t inc)} | |
| (dom/li nil (str "data: " (:t data )) ) | |
| (dom/li nil (str "state: " (:s state )) )) )))) |