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