});\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
<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