documentHistory wip: toolbar
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 13 Jun 2013 14:29:07 +0000 (16:29 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 13 Jun 2013 14:29:07 +0000 (16:29 +0200)
modules/documentHistory/documentHistory.js
modules/documentHistory/documentHistory.less
modules/documentHistory/templates/main.html
modules/documentHistory/templates/toolbar.html [new file with mode: 0644]

index d5f20d4..2c3a3b6 100644 (file)
@@ -32,30 +32,52 @@ return function(sandbox) {
         });\r
     }\r
     \r
+    var toggleButton = function(btn, toggle) {\r
+        dom.find('button.'+btn).toggleClass('disabled', !toggle);\r
+    }\r
+    \r
     var historyItems = {\r
         _itemsById: {},\r
         _selected: [],\r
         select: function(item) {\r
             if(this._selected.length < 2) {\r
                 this._selected.push(item.version);\r
-                if(this._selected.length === 2)\r
-                    toggleItemViews(false);\r
+                this._updateUI();\r
                 return true;\r
             }\r
             return false;\r
         },\r
         unselect: function(item) {\r
             this._selected = _.without(this._selected, item.version);\r
-            if(this._selected.length < 2)\r
-                toggleItemViews(true);\r
+            this._updateUI();\r
         },\r
         add: function(item) {\r
             this._itemsById[item.version] = item;\r
         },\r
         selected: function(item) {\r
             return _.contains(this._selected, item.version);\r
+        },\r
+        _updateUI: function() {\r
+            var len = this._selected.length;\r
+            if(len === 0) {\r
+                toggleButton('compare', false);\r
+                toggleButton('show2', false);\r
+                toggleButton('restore', false);\r
+            }\r
+            if(len === 1) {\r
+                toggleButton('compare', false);\r
+                toggleButton('show2', true);\r
+                toggleButton('restore', true);\r
+            }\r
+            if(len === 2) {\r
+                toggleItemViews(false);\r
+                toggleButton('compare', true);\r
+                toggleButton('show2', false);\r
+                toggleButton('restore', false);\r
+            }\r
         }\r
     };\r
+    historyItems._updateUI();\r
     \r
     var itemView = function(item) {\r
         this.item = item;\r
index 9a73977..57cd63c 100644 (file)
     .item.disabled {\r
         cursor: default;\r
     }\r
-}
\ No newline at end of file
+    \r
+    .toolbar {\r
+        margin: -15px 0 15px 0;\r
+        white-space:nowrap; \r
+        word-spacing:0;\r
+        min-height: 22px;\r
+        button {\r
+            margin-right: 10px;\r
+        }\r
+    }\r
+}\r
+\r
index 68f1f66..ff4ea79 100644 (file)
@@ -1,4 +1,11 @@
 <div class="rng-module-documentHistory">\r
-    <div class="rng-module-documentHistory-toolbar"></div>\r
+    <div class="toolbar">\r
+        <div class="group">\r
+            <button class="btn btn-mini compare">Porównaj</button>\r
+            <button class="btn btn-mini restore">Przywróć</button>\r
+            <button class="btn btn-mini show2">Zobacz</button>\r
+        </div>\r
+    </div>\r
+    <div style="clear:both;"></div>\r
     <div class="rng-module-documentHistory-itemsList"></div>\r
 <div>
\ No newline at end of file
diff --git a/modules/documentHistory/templates/toolbar.html b/modules/documentHistory/templates/toolbar.html
new file mode 100644 (file)
index 0000000..709cdc7
--- /dev/null
@@ -0,0 +1,7 @@
+<div class="toolbar">\r
+    <div class="group">\r
+        <button class="btn btn-mini compare">Porównaj</button>\r
+        <button class="btn btn-mini restore">Przywróć</button>\r
+        <button class="btn btn-mini show">Zobacz</button>\r
+    </div>\r
+</div>
\ No newline at end of file