X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/e8c45077de2d4ada496850fd77fa5035f07f8a4d..969f365b3ee6d3cb54f98b23e1ebb97df9f801dd:/modules/rng/rng.js diff --git a/modules/rng/rng.js b/modules/rng/rng.js index cd7122c..980e6ff 100644 --- a/modules/rng/rng.js +++ b/modules/rng/rng.js @@ -38,7 +38,7 @@ return function(sandbox) { dirty.sourceEditor = false; } if(slug === 'editor') { - var doc = dirty.documentCanvas ? sandbox.getModule('documentCanvas').getDocument() : sandbox.getModule('data').getDocument(); + doc = dirty.documentCanvas ? sandbox.getModule('documentCanvas').getDocument() : sandbox.getModule('data').getDocument(); if(dirty.metadataEditor) { doc = sandbox.getModule('metadataEditor').attachMetadata(doc); } @@ -47,26 +47,26 @@ return function(sandbox) { } sandbox.getModule('data').commitDocument(doc, reason); } - } + }; var commands = { - highlightDocumentNode: function(wlxmlNode, origin) { + highlightDocumentNode: function(canvasNode, origin) { ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) { if(!origin || moduleName != origin) - sandbox.getModule(moduleName).highlightNode(wlxmlNode) + sandbox.getModule(moduleName).highlightNode(canvasNode); }); }, - dimDocumentNode: function(wlxmlNode, origin) { + dimDocumentNode: function(canvasNode, origin) { ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) { if(!origin || moduleName != origin) - sandbox.getModule(moduleName).dimNode(wlxmlNode) + sandbox.getModule(moduleName).dimNode(canvasNode); }); }, - selectNode: function(wlxmlNode, origin) { - sandbox.getModule('documentCanvas').selectNode(wlxmlNode); - sandbox.getModule('nodePane').setNode(wlxmlNode); - sandbox.getModule('nodeFamilyTree').setNode(wlxmlNode); - sandbox.getModule('nodeBreadCrumbs').setNode(wlxmlNode); + selectNode: function(canvasNode, origin) { + sandbox.getModule('documentCanvas').selectNode(canvasNode); + sandbox.getModule('nodePane').setNode(canvasNode); + sandbox.getModule('nodeFamilyTree').setNode(canvasNode); + sandbox.getModule('nodeBreadCrumbs').setNode(canvasNode); }, resetDocument: function(document, reason) { @@ -82,7 +82,7 @@ return function(sandbox) { sandbox.getModule(moduleName).setDocument(document); }); } - } + }; var views = { @@ -92,11 +92,11 @@ return function(sandbox) { visualEditingSidebar: (new tabs.View({stacked: true})).render(), currentNodePaneLayout: new vbox.VBox(), diffLayout: new layout.Layout(diffLayoutTemplate) - } + }; views.visualEditing.setView('rightColumn', views.visualEditingSidebar.getAsView()); addMainTab('Edytor', 'editor', views.visualEditing.getAsView()); - + addMainTab(gettext('Source'), 'sourceEditor', ''); addMainTab('Historia', 'history', views.diffLayout.getAsView()); sandbox.getDOM().append(views.mainLayout.getAsView()); @@ -147,7 +147,7 @@ return function(sandbox) { }, restoringStarted: function(event) { sandbox.getModule('mainBar').setCommandEnabled('save', false); - sandbox.getModule('indicator').showMessage(gettext('Restoring version ' + event.version + '...')); + sandbox.getModule('indicator').showMessage(gettext('Restoring version ') + event.version + '...'); }, historyItemAdded: function(item) { sandbox.getModule('documentHistory').addHistory([item], {animate: true}); @@ -158,19 +158,21 @@ return function(sandbox) { documentReverted: function(event) { commands.resetDocument(event.document, 'revert'); sandbox.getModule('mainBar').setCommandEnabled('save', true); - sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.version + ' przywrócona'}); + sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.reverted_version + ' przywrócona'}); + sandbox.getModule('mainBar').setVersion(event.current_version); } - } + }; eventHandlers.mainBar = { ready: function() { + sandbox.getModule('mainBar').setVersion(sandbox.getModule('data').getDocumentVersion()); views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView()); }, 'cmd.save': function() { synchronizeTab(views.mainTabs.getCurrentSlug()); sandbox.getModule('data').saveDocument(); } - } + }; eventHandlers.indicator = { ready: function() { @@ -189,20 +191,20 @@ return function(sandbox) { dirty.documentCanvas = false; }, - nodeSelected: function(wlxmlNode) { - commands.selectNode(wlxmlNode); + nodeSelected: function(canvasNode) { + commands.selectNode(canvasNode); }, contentChanged: function() { dirty.documentCanvas = true; }, - nodeHovered: function(wlxmlNode) { - commands.highlightDocumentNode(wlxmlNode); + nodeHovered: function(canvasNode) { + commands.highlightDocumentNode(canvasNode); }, - nodeBlured: function(wlxmlNode) { - commands.dimDocumentNode(wlxmlNode); + nodeBlured: function(canvasNode) { + commands.dimDocumentNode(canvasNode); } }; @@ -233,14 +235,14 @@ return function(sandbox) { ready: function() { views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView()); }, - nodeEntered: function(wlxmlNode) { - commands.highlightDocumentNode(wlxmlNode, 'nodeFamilyTree'); + nodeEntered: function(canvasNode) { + commands.highlightDocumentNode(canvasNode, 'nodeFamilyTree'); }, - nodeLeft: function(wlxmlNode) { - commands.dimDocumentNode(wlxmlNode, 'nodeFamilyTree'); + nodeLeft: function(canvasNode) { + commands.dimDocumentNode(canvasNode, 'nodeFamilyTree'); }, - nodeSelected: function(wlxmlNode) { - commands.selectNode(wlxmlNode); + nodeSelected: function(canvasNode) { + commands.selectNode(canvasNode); } }; @@ -252,11 +254,10 @@ return function(sandbox) { sandbox.getModule('documentCanvas').toggleGrid(toggle); }, newNodeRequested: function(wlxmlTag, wlxmlClass) { - if(window.getSelection().isCollapsed) { sandbox.getModule('documentCanvas').insertNewNode(wlxmlTag, wlxmlClass); - } else { - sandbox.getModule('documentCanvas').wrapSelectionWithNewNode(wlxmlTag, wlxmlClass); - } + }, + command: function(cmd, meta) { + sandbox.getModule('documentCanvas').command(cmd, meta); } }; @@ -264,16 +265,16 @@ return function(sandbox) { ready: function() { views.visualEditing.setView('statusBar', sandbox.getModule('nodeBreadCrumbs').getView()); }, - nodeHighlighted: function(wlxmlNode) { - commands.highlightDocumentNode(wlxmlNode, 'nodeBreadCrumbs'); + nodeHighlighted: function(canvasNode) { + commands.highlightDocumentNode(canvasNode, 'nodeBreadCrumbs'); }, - nodeDimmed: function(wlxmlNode) { - commands.dimDocumentNode(wlxmlNode, 'nodeBreadCrumbs'); + nodeDimmed: function(canvasNode) { + commands.dimDocumentNode(canvasNode, 'nodeBreadCrumbs'); }, - nodeSelected: function(wlxmlNode) { - commands.selectNode(wlxmlNode); + nodeSelected: function(canvasNode) { + commands.selectNode(canvasNode); } - } + }; eventHandlers.documentHistory = { ready: function() { @@ -285,14 +286,17 @@ return function(sandbox) { }, restoreVersion: function(event) { sandbox.getModule('data').restoreVersion(event); + }, + displayVersion: function(event) { + window.open('/' + gettext('editor') + '/' + sandbox.getModule('data').getDocumentId() + '?version=' + event.version, _.uniqueId()); } - } + }; eventHandlers.diffViewer = { ready: function() { views.diffLayout.setView('right', sandbox.getModule('diffViewer').getView()); } - } + }; /* api */ @@ -307,7 +311,7 @@ return function(sandbox) { eventHandlers[moduleName][eventName].apply(eventHandlers, args); } } - } + }; }; }); \ No newline at end of file