rng: require('modules/rng'),\r
skelton: require('modules/skelton'),\r
sourceEditor: require('modules/sourceEditor'),\r
- tabsManager: require('modules/tabsManager'),\r
visualEditor: require('modules/visualEditor'),\r
\r
documentCanvas: require('modules/documentCanvas/documentCanvas'),\r
-define(function() {\r
+define(['views/tabs/tabs'], function(tabs) {\r
\r
return function(sandbox) {\r
'use strict';\r
\r
+ var mainTabs = (new tabs.View()).render();\r
+ \r
function addTab(title, slug, view) {\r
- sandbox.getModule('tabsManager').addTab(title, slug, view);\r
+ mainTabs.addTab(title, slug, view);\r
}\r
\r
/* Events handling */\r
\r
eventHandlers.skelton = {\r
ready: function() {\r
- sandbox.getModule('tabsManager').start();\r
- },\r
- 'cmd.save': function() {\r
- var editorSlugs = ['visual', 'source'];\r
- var slug = sandbox.getModule('tabsManager').getCurrentSlug();\r
- if(_.contains(editorSlugs, slug)) {\r
- var editor = sandbox.getModule(slug+'Editor');\r
- if(editor.isDirty()) {\r
- sandbox.getModule('data').commitDocument(editor.getDocument(), slug + '_edit');\r
- editor.setDirty(false);\r
- }\r
- }\r
- sandbox.getModule('data').saveDocument();\r
- }\r
- };\r
- \r
- eventHandlers.tabsManager = {\r
- ready: function() {\r
- sandbox.getModule('skelton').setMainView(sandbox.getModule('tabsManager').getView());\r
+ sandbox.getModule('skelton').setMainView(mainTabs.getAsView());\r
+ \r
_.each(['visualEditor', 'sourceEditor', 'rng2'], function(moduleName) {\r
sandbox.getModule(moduleName).start();\r
});\r
},\r
- leaving: function(slug) {\r
- if(slug === 'source' || slug === 'visual') {\r
- var editor = sandbox.getModule(slug+'Editor');\r
- if(editor.isDirty()) {\r
- sandbox.getModule('data').commitDocument(editor.getDocument(), slug + '_edit');\r
- editor.setDirty(false);\r
- }\r
- }\r
- },\r
- showed: function(slug) {\r
- if(slug === 'visual')\r
- sandbox.getModule('visualEditor').onShowed();\r
+ 'cmd.save': function() {\r
+ //todo\r
}\r
};\r
- \r
+ \r
eventHandlers.sourceEditor = {\r
ready: function() {\r
addTab(gettext('Source'), 'source', sandbox.getModule('sourceEditor').getView());\r
+++ /dev/null
-define(['views/tabs/tabs'], function(tabsView) {\r
-\r
-return function(sandbox) {\r
- \r
- var view = new tabsView.View();\r
- view.on('leaving', function(slug) {\r
- sandbox.publish('leaving', slug);\r
- });\r
- view.on('tabSelected', function(slug) {\r
- sandbox.publish('showed', slug);\r
- });\r
- \r
- return {\r
- start: function() {\r
- view.render();\r
- sandbox.publish('ready');\r
- },\r
- \r
- getView: function() {\r
- return view.$el;\r
- },\r
- \r
- addTab: function(title, slug, contentView) {\r
- view.addTab(title, slug, contentView);\r
- \r
- },\r
- getCurrentSlug: function() {\r
- return view.selectedTab;\r
- }\r
- }\r
-};\r
-\r
-});
\ No newline at end of file