From 11e399ae217f634e841803e6d27646bccc560410 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 27 Feb 2016 21:18:51 +0200 Subject: [PATCH] Add method and state for manage the clipboard. --- src/uxbox/ui/workspace/clipboard.cljs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/uxbox/ui/workspace/clipboard.cljs b/src/uxbox/ui/workspace/clipboard.cljs index 798173d4f..6ea6f90c1 100644 --- a/src/uxbox/ui/workspace/clipboard.cljs +++ b/src/uxbox/ui/workspace/clipboard.cljs @@ -3,6 +3,25 @@ [uxbox.ui.mixins :as mx] [uxbox.ui.lightbox :as lightbox])) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; State +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defonce ^:private state (atom #queue [])) +(defonce ^:private ^:const +max-items+ 5) + +(defn add + [item] + (swap! state (fn [v] + (let [v (conj v item)] + (if (> (count v) +max-items+) + (pop v) + v))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Component +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (defn- clipboard-dialog-render [own] (html