Merging rng2 and rng modules
[fnpeditor.git] / modules / rng / rng.js
index 4b9aecf..e1277e5 100644 (file)
@@ -1,14 +1,18 @@
 define([\r
 'fnpjs/layout',\r
+'fnpjs/vbox',\r
 'views/tabs/tabs',\r
-'libs/text!./mainLayout.html'\r
-], function(layout, tabs, mainLayoutTemplate) {\r
+'libs/text!./mainLayout.html',\r
+'libs/text!./editingLayout.html',\r
+], function(layout, vbox, tabs, mainLayoutTemplate, editingLayoutTemplate) {\r
 \r
 return function(sandbox) {\r
     'use strict';\r
     \r
     var mainTabs = (new tabs.View()).render();\r
     var mainLayout = new layout.Layout(mainLayoutTemplate);\r
+    var editingLayout = new layout.Layout(editingLayoutTemplate);\r
+    \r
     sandbox.getDOM().append(mainLayout.getAsView());\r
     \r
     function addTab(title, slug, view) {\r
@@ -38,7 +42,7 @@ return function(sandbox) {
         ready: function() {\r
             mainLayout.setView('mainView', mainTabs.getAsView());\r
             \r
-            _.each(['visualEditor', 'sourceEditor', 'rng2', 'mainBar', 'indicator'], function(moduleName) {\r
+            _.each(['visualEditor', 'sourceEditor', 'documentCanvas', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'mainBar', 'indicator'], function(moduleName) {\r
                 sandbox.getModule(moduleName).start();\r
             });\r
         },\r
@@ -76,6 +80,71 @@ return function(sandbox) {
         ready: function() {\r
             mainLayout.setView('messages', sandbox.getModule('indicator').getView());\r
         }\r
+    };\r
+    \r
+    \r
+    var sidebar = (new tabs.View({stacked: true})).render();\r
+    var box = new vbox.VBox();\r
+    editingLayout.setView('rightColumn', sidebar.getAsView());\r
+    addTab('rng2 test', 'rng2test', editingLayout.getAsView());\r
+    \r
+    eventHandlers.documentCanvas = {\r
+        ready: function() {\r
+            sandbox.getModule('documentCanvas').setDocument(sandbox.getModule('data').getDocument());\r
+            editingLayout.setView('leftColumn', sandbox.getModule('documentCanvas').getView());\r
+        },\r
+        \r
+        nodeSelected: function(node) {\r
+            sandbox.getModule('nodePane').setNode(node);\r
+            sandbox.getModule('nodeFamilyTree').setNode(node);\r
+        },\r
+        \r
+        contentChanged: function() {\r
+        \r
+        },\r
+        \r
+        nodeHovered: function(node) {\r
+            \r
+        },\r
+        \r
+        nodeBlured: function(node) {\r
+        \r
+        }\r
+    };\r
+\r
+    eventHandlers.nodePane = {\r
+        ready: function() {\r
+            //sidebar.addTab({icon: 'pencil'}, 'nodePane', sandbox.getModule('nodePane').getView());\r
+            box.appendView(sandbox.getModule('nodePane').getView());\r
+            sidebar.addTab({icon: 'pencil'}, 'edit', box.getAsView());\r
+        },\r
+        \r
+        nodeChanged: function(attr, value) {\r
+            sandbox.getModule('documentCanvas').modifyCurrentNode(attr, value);\r
+        }\r
+    };\r
+    \r
+    eventHandlers.metadataEditor = {\r
+        ready: function() {\r
+            sandbox.getModule('metadataEditor').setMetadata(sandbox.getModule('data').getDocument());\r
+            sidebar.addTab({icon: 'info-sign'}, 'metadataEditor', sandbox.getModule('metadataEditor').getView());\r
+        }\r
+    };\r
+    \r
+    eventHandlers.nodeFamilyTree = {\r
+        ready: function() {\r
+            //sidebar.addTab({icon: 'home'}, 'family', sandbox.getModule('nodeFamilyTree').getView());\r
+            box.appendView(sandbox.getModule('nodeFamilyTree').getView());\r
+        },\r
+        nodeEntered: function(id) {\r
+            sandbox.getModule('documentCanvas').highlightNode(id);\r
+        },\r
+        nodeLeft: function(id) {\r
+            sandbox.getModule('documentCanvas').dimNode(id);\r
+        },\r
+        nodeSelected: function(id) {\r
+            sandbox.getModule('documentCanvas').selectNode(id);\r
+        }\r
     }\r
     \r
     /* api */\r