'views/tabs/tabs',\r
'libs/text!./mainLayout.html',\r
'libs/text!./editingLayout.html',\r
-], function(layout, vbox, tabs, mainLayoutTemplate, editingLayoutTemplate) {\r
+], function(layout, vbox, tabs, mainLayoutTemplate, visualEditingLayoutTemplate) {\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
+ function addMainTab(title, slug, view) {\r
+ views.mainTabs.addTab(title, slug, view);\r
+ }\r
\r
- function addTab(title, slug, view) {\r
- mainTabs.addTab(title, slug, view);\r
+ var views = {\r
+ mainLayout: new layout.Layout(mainLayoutTemplate),\r
+ mainTabs: (new tabs.View()).render(),\r
+ visualEditing: new layout.Layout(visualEditingLayoutTemplate),\r
+ visualEditingSidebar: (new tabs.View({stacked: true})).render(),\r
+ currentNodePaneLayout: new vbox.VBox()\r
}\r
\r
+ views.visualEditing.setView('rightColumn', views.visualEditingSidebar.getAsView());\r
+ addMainTab('rng2 test', 'rng2test', views.visualEditing.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
var eventHandlers = {};\r
\r
eventHandlers.sourceEditor = {\r
ready: function() {\r
- addTab(gettext('Source'), 'source', sandbox.getModule('sourceEditor').getView());\r
+ addMainTab(gettext('Source'), 'source', sandbox.getModule('sourceEditor').getView());\r
sandbox.getModule('sourceEditor').setDocument(sandbox.getModule('data').getDocument());\r
}\r
};\r
eventHandlers.visualEditor = {\r
ready: function() {\r
sandbox.getModule('visualEditor').setDocument(sandbox.getModule('data').getDocument());\r
- addTab(gettext('Visual'), 'visual', sandbox.getModule('visualEditor').getView());\r
+ addMainTab(gettext('Visual'), 'visual', sandbox.getModule('visualEditor').getView());\r
\r
}\r
};\r
\r
eventHandlers.data = {\r
ready: function() {\r
- mainLayout.setView('mainView', mainTabs.getAsView());\r
+ views.mainLayout.setView('mainView', views.mainTabs.getAsView());\r
\r
_.each(['visualEditor', 'sourceEditor', 'documentCanvas', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'mainBar', 'indicator'], function(moduleName) {\r
sandbox.getModule(moduleName).start();\r
\r
eventHandlers.rng2 = {\r
ready: function() {\r
- addTab('rng2 test', 'rng2test', sandbox.getModule('rng2').getView());\r
+ addMainTab('rng2 test', 'rng2test', sandbox.getModule('rng2').getView());\r
\r
}\r
}\r
\r
eventHandlers.mainBar = {\r
ready: function() {\r
- mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());\r
+ views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());\r
},\r
'cmd.save': function() {\r
sandbox.getModule('data').fakeSave();\r
\r
eventHandlers.indicator = {\r
ready: function() {\r
- mainLayout.setView('messages', sandbox.getModule('indicator').getView());\r
+ views.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
\r
eventHandlers.documentCanvas = {\r
ready: function() {\r
sandbox.getModule('documentCanvas').setDocument(sandbox.getModule('data').getDocument());\r
- editingLayout.setView('leftColumn', sandbox.getModule('documentCanvas').getView());\r
+ views.visualEditing.setView('leftColumn', sandbox.getModule('documentCanvas').getView());\r
},\r
\r
nodeSelected: function(node) {\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
+ views.currentNodePaneLayout.appendView(sandbox.getModule('nodePane').getView());\r
},\r
\r
nodeChanged: function(attr, value) {\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
+ views.visualEditingSidebar.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
+ views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView());\r
},\r
nodeEntered: function(id) {\r
sandbox.getModule('documentCanvas').highlightNode(id);\r