X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/f8b3ddf413bc700b6c640a0da368b3a1a41c09cc..c8ea3d532e8a081a32838b09cfe268a5b2fa7302:/modules/rng/rng.js?ds=inline diff --git a/modules/rng/rng.js b/modules/rng/rng.js index a48535c..5edc7ac 100644 --- a/modules/rng/rng.js +++ b/modules/rng/rng.js @@ -13,6 +13,22 @@ return function(sandbox) { views.mainTabs.addTab(title, slug, view); } + var commands = { + highlightDocumentNode: function(wlxmlNode, origin) { + ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) { + if(!origin || moduleName != origin) + sandbox.getModule(moduleName).highlightNode(wlxmlNode) + }); + }, + dimDocumentNode: function(wlxmlNode, origin) { + ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) { + if(!origin || moduleName != origin) + sandbox.getModule(moduleName).dimNode(wlxmlNode) + }); + } + } + + var views = { mainLayout: new layout.Layout(mainLayoutTemplate), mainTabs: (new tabs.View()).render(), @@ -22,13 +38,11 @@ return function(sandbox) { } views.visualEditing.setView('rightColumn', views.visualEditingSidebar.getAsView()); - addMainTab('rng2 test', 'rng2test', views.visualEditing.getAsView()); + addMainTab('Edytor', 'editor', views.visualEditing.getAsView()); sandbox.getDOM().append(views.mainLayout.getAsView()); views.visualEditingSidebar.addTab({icon: 'pencil'}, 'edit', views.currentNodePaneLayout.getAsView()); - - /* Events handling */ @@ -42,19 +56,11 @@ return function(sandbox) { } }; - eventHandlers.visualEditor = { - ready: function() { - sandbox.getModule('visualEditor').setDocument(sandbox.getModule('data').getDocument()); - addMainTab(gettext('Visual'), 'visual', sandbox.getModule('visualEditor').getView()); - - } - }; - eventHandlers.data = { ready: function() { views.mainLayout.setView('mainView', views.mainTabs.getAsView()); - _.each(['visualEditor', 'sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'mainBar', 'indicator'], function(moduleName) { + _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator'], function(moduleName) { sandbox.getModule(moduleName).start(); }); }, @@ -72,13 +78,6 @@ return function(sandbox) { } } - eventHandlers.rng2 = { - ready: function() { - addMainTab('rng2 test', 'rng2test', sandbox.getModule('rng2').getView()); - - } - } - eventHandlers.mainBar = { ready: function() { views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView()); @@ -105,18 +104,19 @@ return function(sandbox) { nodeSelected: function(node) { sandbox.getModule('nodePane').setNode(node); sandbox.getModule('nodeFamilyTree').setNode(node); + sandbox.getModule('nodeBreadCrumbs').setNode(node); }, contentChanged: function() { }, - nodeHovered: function(node) { - sandbox.getModule('nodeFamilyTree').highlightNode(node.attr('id')); + nodeHovered: function(wlxmlNode) { + commands.highlightDocumentNode(wlxmlNode); }, - nodeBlured: function(node) { - sandbox.getModule('nodeFamilyTree').dimNode(node.attr('id')); + nodeBlured: function(wlxmlNode) { + commands.dimDocumentNode(wlxmlNode); } }; @@ -141,14 +141,14 @@ return function(sandbox) { ready: function() { views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView()); }, - nodeEntered: function(id) { - sandbox.getModule('documentCanvas').highlightNode(id); + nodeEntered: function(wlxmlNode) { + commands.highlightDocumentNode(wlxmlNode, 'nodeFamilyTree'); }, - nodeLeft: function(id) { - sandbox.getModule('documentCanvas').dimNode(id); + nodeLeft: function(wlxmlNode) { + commands.dimDocumentNode(wlxmlNode, 'nodeFamilyTree'); }, - nodeSelected: function(id) { - sandbox.getModule('documentCanvas').selectNode(id); + nodeSelected: function(wlxmlNode) { + sandbox.getModule('documentCanvas').selectNode(wlxmlNode); } }; @@ -166,6 +166,21 @@ return function(sandbox) { sandbox.getModule('documentCanvas').wrapSelectionWithNewNode(wlxmlTag, wlxmlClass); } } + }; + + eventHandlers.nodeBreadCrumbs = { + ready: function() { + views.visualEditing.setView('statusBar', sandbox.getModule('nodeBreadCrumbs').getView()); + }, + nodeHighlighted: function(wlxmlNode) { + commands.highlightDocumentNode(wlxmlNode, 'nodeBreadCrumbs'); + }, + nodeDimmed: function(wlxmlNode) { + commands.dimDocumentNode(wlxmlNode, 'nodeBreadCrumbs'); + }, + nodeSelected: function(wlxmlNode) { + sandbox.getModule('documentCanvas').selectNode(wlxmlNode); + } } /* api */