X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/6384a81fa481cb43fddca23742e37761592be66d..c66ddb7dbe763b261c7dd4a037239a667f60cd95:/modules/rng/rng.js diff --git a/modules/rng/rng.js b/modules/rng/rng.js index 8202346..9abe00c 100644 --- a/modules/rng/rng.js +++ b/modules/rng/rng.js @@ -6,21 +6,14 @@ define([ 'libs/text!./editingLayout.html', ], function(layout, vbox, tabs, mainLayoutTemplate, visualEditingLayoutTemplate) { +'use strict'; + return function(sandbox) { - 'use strict'; function addMainTab(title, slug, view) { views.mainTabs.addTab(title, slug, view); } - function tabIsDirty(slug) { - if(slug === 'editor' && (dirty.documentCanvas || dirty.metadataEditor)) - return true; - if(slug === 'sourceEditor' && dirty.sourceEditor) - return true; - return false; - } - var dirty = { sourceEditor: false, documentCanvas: false, @@ -28,6 +21,14 @@ return function(sandbox) { }; var synchronizeTab = function(slug) { + function tabIsDirty(slug) { + if(slug === 'editor' && (dirty.documentCanvas || dirty.metadataEditor)) + return true; + if(slug === 'sourceEditor' && dirty.sourceEditor) + return true; + return false; + } + if(tabIsDirty(slug)) { if(slug === 'sourceEditor') { sandbox.getModule('data').commitDocument(sandbox.getModule('sourceEditor').getDocument(), 'source_edit'); @@ -107,7 +108,7 @@ return function(sandbox) { ready: function() { views.mainLayout.setView('mainView', views.mainTabs.getAsView()); - _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator'], function(moduleName) { + _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory'], function(moduleName) { sandbox.getModule(moduleName).start(); }); }, @@ -129,6 +130,9 @@ return function(sandbox) { savingEnded: function(status) { sandbox.getModule('mainBar').setCommandEnabled('save', true); sandbox.getModule('indicator').clearMessage(); + }, + historyItemAdded: function(item) { + sandbox.getModule('documentHistory').addHistory([item], {animate: true}); } } @@ -245,6 +249,13 @@ return function(sandbox) { } } + eventHandlers.documentHistory = { + ready: function() { + sandbox.getModule('documentHistory').addHistory(sandbox.getModule('data').getHistory()); + addMainTab('Historia', 'history', sandbox.getModule('documentHistory').getView()); + } + } + /* api */ return {