X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/f61fd6fa1d5871782b079ee50fb6bb10777cadc2..edd85d12e3446e6d30ecb3b67519d53933a3b621:/modules/documentHistory/documentHistory.js diff --git a/modules/documentHistory/documentHistory.js b/modules/documentHistory/documentHistory.js index 0693469..d435617 100644 --- a/modules/documentHistory/documentHistory.js +++ b/modules/documentHistory/documentHistory.js @@ -1,9 +1,10 @@ define([ 'libs/jquery-1.9.1.min', 'libs/underscore-min', +'./restoreDialog', 'libs/text!./templates/main.html', 'libs/text!./templates/item.html' -], function($, _, mainTemplateSrc, itemTemplateSrc) { +], function($, _, restoreDialog, mainTemplateSrc, itemTemplateSrc) { 'use strict'; @@ -20,6 +21,19 @@ return function(sandbox) { 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.display').click(function(e) { + sandbox.publish('displayVersion', {version: historyItems.getSelected()[0]}); + }); var addHistoryItem = function(item, options) { historyItems.add(item); @@ -70,18 +84,18 @@ return function(sandbox) { var len = this._selected.length; if(len === 0) { toggleButton('compare', false); - toggleButton('show2', false); + toggleButton('display', false); toggleButton('restore', false); } if(len === 1) { toggleButton('compare', false); - toggleButton('show2', true); + toggleButton('display', true); toggleButton('restore', true); } if(len === 2) { toggleItemViews(false); toggleButton('compare', true); - toggleButton('show2', false); + toggleButton('display', false); toggleButton('restore', false); } else { toggleItemViews(true);