From f2b74d1a157449d5fc89d37680d95737ef8eb3b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 13 Jun 2013 16:29:07 +0200 Subject: [PATCH] documentHistory wip: toolbar --- modules/documentHistory/documentHistory.js | 30 ++++++++++++++++--- modules/documentHistory/documentHistory.less | 13 +++++++- modules/documentHistory/templates/main.html | 9 +++++- .../documentHistory/templates/toolbar.html | 7 +++++ 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 modules/documentHistory/templates/toolbar.html diff --git a/modules/documentHistory/documentHistory.js b/modules/documentHistory/documentHistory.js index d5f20d4..2c3a3b6 100644 --- a/modules/documentHistory/documentHistory.js +++ b/modules/documentHistory/documentHistory.js @@ -32,30 +32,52 @@ return function(sandbox) { }); } + var toggleButton = function(btn, toggle) { + dom.find('button.'+btn).toggleClass('disabled', !toggle); + } + var historyItems = { _itemsById: {}, _selected: [], select: function(item) { if(this._selected.length < 2) { this._selected.push(item.version); - if(this._selected.length === 2) - toggleItemViews(false); + this._updateUI(); return true; } return false; }, unselect: function(item) { this._selected = _.without(this._selected, item.version); - if(this._selected.length < 2) - toggleItemViews(true); + this._updateUI(); }, add: function(item) { this._itemsById[item.version] = item; }, selected: function(item) { return _.contains(this._selected, item.version); + }, + _updateUI: function() { + var len = this._selected.length; + if(len === 0) { + toggleButton('compare', false); + toggleButton('show2', false); + toggleButton('restore', false); + } + if(len === 1) { + toggleButton('compare', false); + toggleButton('show2', true); + toggleButton('restore', true); + } + if(len === 2) { + toggleItemViews(false); + toggleButton('compare', true); + toggleButton('show2', false); + toggleButton('restore', false); + } } }; + historyItems._updateUI(); var itemView = function(item) { this.item = item; diff --git a/modules/documentHistory/documentHistory.less b/modules/documentHistory/documentHistory.less index 9a73977..57cd63c 100644 --- a/modules/documentHistory/documentHistory.less +++ b/modules/documentHistory/documentHistory.less @@ -27,4 +27,15 @@ .item.disabled { cursor: default; } -} \ No newline at end of file + + .toolbar { + margin: -15px 0 15px 0; + white-space:nowrap; + word-spacing:0; + min-height: 22px; + button { + margin-right: 10px; + } + } +} + diff --git a/modules/documentHistory/templates/main.html b/modules/documentHistory/templates/main.html index 68f1f66..ff4ea79 100644 --- a/modules/documentHistory/templates/main.html +++ b/modules/documentHistory/templates/main.html @@ -1,4 +1,11 @@
-
+
+
+ + + +
+
+
\ No newline at end of file diff --git a/modules/documentHistory/templates/toolbar.html b/modules/documentHistory/templates/toolbar.html new file mode 100644 index 0000000..709cdc7 --- /dev/null +++ b/modules/documentHistory/templates/toolbar.html @@ -0,0 +1,7 @@ +
+
+ + + +
+
\ No newline at end of file -- 2.20.1