From: Aleksander Łukasz Date: Thu, 13 Jun 2013 14:29:07 +0000 (+0200) Subject: documentHistory wip: toolbar X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/f2b74d1a157449d5fc89d37680d95737ef8eb3b8?ds=sidebyside documentHistory wip: toolbar --- 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