X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/efe36f4f1b5df351eeb4d40a54c3900cf9a7079b..d5dade387d7f6885880f3a5ca8229252be8f0234:/src/editor/modules/documentHistory/documentHistory.js diff --git a/src/editor/modules/documentHistory/documentHistory.js b/src/editor/modules/documentHistory/documentHistory.js index f595594..8cd4475 100644 --- a/src/editor/modules/documentHistory/documentHistory.js +++ b/src/editor/modules/documentHistory/documentHistory.js @@ -1,10 +1,9 @@ define([ 'libs/jquery', 'libs/underscore', -'./restoreDialog', 'libs/text!./templates/main.html', 'libs/text!./templates/item.html' -], function($, _, restoreDialog, mainTemplateSrc, itemTemplateSrc) { +], function($, _, mainTemplateSrc, itemTemplateSrc) { 'use strict'; @@ -17,22 +16,21 @@ return function(sandbox) { var itemViews = []; - dom.find('.btn.compare').click(function(e) { + dom.find('.btn.compare').click(function() { var selected = historyItems.getSelected(); sandbox.publish('compare', selected[0], selected[1]); }); - dom.find('.btn.restore').click(function(e) { - var dialog = restoreDialog.create(); - dialog.on('restore', function(event) { - sandbox.publish('restoreVersion', {version: historyItems.getSelected()[0], description: event.data.description}); - event.success(); - }); - dialog.show(); + dom.find('.btn.restore').click(function() { + sandbox.publish('restoreVersion', historyItems.getSelected()[0]); }); - dom.find('.btn.display').click(function(e) { - sandbox.publish('displayVersion', {version: historyItems.getSelected()[0]}); + dom.find('.btn.display').click(function() { + sandbox.publish('displayVersion', historyItems.getSelected()[0]); + }); + + dom.find('.btn.publish').click(function() { + sandbox.publish('publishVersion', historyItems.getSelected()[0]); }); var addHistoryItem = function(item, options) { @@ -47,8 +45,9 @@ return function(sandbox) { var toggleItemViews = function(toggle) { itemViews.forEach(function(view) { - if(!historyItems.isSelected(view.item)) + if(!historyItems.isSelected(view.item)) { view.toggle(toggle); + } }); }; @@ -61,21 +60,21 @@ return function(sandbox) { _selected: [], select: function(item) { if(this._selected.length < 2) { - this._selected.push(item.version); + this._selected.push(item.revision); this._updateUI(); return true; } return false; }, unselect: function(item) { - this._selected = _.without(this._selected, item.version); + this._selected = _.without(this._selected, item.revision); this._updateUI(); }, add: function(item) { this._itemsById[item.version] = item; }, isSelected: function(item) { - return _.contains(this._selected, item.version); + return _.contains(this._selected, item.revision); }, getSelected: function() { return this._selected; @@ -86,17 +85,20 @@ return function(sandbox) { toggleButton('compare', false); toggleButton('display', false); toggleButton('restore', false); + toggleButton('publish', false); } if(len === 1) { toggleButton('compare', false); toggleButton('display', true); toggleButton('restore', true); + toggleButton('publish', true); } if(len === 2) { toggleItemViews(false); toggleButton('compare', true); toggleButton('display', false); toggleButton('restore', false); + toggleButton('publish', false); } else { toggleItemViews(true); } @@ -116,7 +118,7 @@ return function(sandbox) { this.dimItem(); } else if(historyItems.select(this.item)) { this.highlightItem(); - } + } }; ItemView.prototype.highlightItem = function() { this.dom.addClass('highlighted');