4 'libs/text!./mainLayout.html'
\r
5 ], function(layout, tabs, mainLayoutTemplate) {
\r
7 return function(sandbox) {
\r
10 var mainTabs = (new tabs.View()).render();
\r
11 var mainLayout = new layout.Layout(mainLayoutTemplate);
\r
12 sandbox.getDOM().append(mainLayout.getAsView());
\r
14 function addTab(title, slug, view) {
\r
15 mainTabs.addTab(title, slug, view);
\r
18 /* Events handling */
\r
20 var eventHandlers = {};
\r
22 eventHandlers.sourceEditor = {
\r
24 addTab(gettext('Source'), 'source', sandbox.getModule('sourceEditor').getView());
\r
25 sandbox.getModule('sourceEditor').setDocument(sandbox.getModule('data').getDocument());
\r
29 eventHandlers.visualEditor = {
\r
31 sandbox.getModule('visualEditor').setDocument(sandbox.getModule('data').getDocument());
\r
32 addTab(gettext('Visual'), 'visual', sandbox.getModule('visualEditor').getView());
\r
37 eventHandlers.data = {
\r
39 mainLayout.setView('mainView', mainTabs.getAsView());
\r
41 _.each(['visualEditor', 'sourceEditor', 'rng2', 'mainBar', 'indicator'], function(moduleName) {
\r
42 sandbox.getModule(moduleName).start();
\r
45 documentChanged: function(document, reason) {
\r
46 var slug = (reason === 'visual_edit' ? 'source' : 'visual');
\r
47 sandbox.getModule(slug+'Editor').setDocument(document);
\r
49 savingStarted: function() {
\r
50 sandbox.getModule('mainBar').setCommandEnabled('save', false);
\r
51 sandbox.getModule('indicator').showMessage(gettext('Saving...'));
\r
53 savingEnded: function(status) {
\r
54 sandbox.getModule('mainBar').setCommandEnabled('save', true);
\r
55 sandbox.getModule('indicator').clearMessage();
\r
59 eventHandlers.rng2 = {
\r
61 addTab('rng2 test', 'rng2test', sandbox.getModule('rng2').getView());
\r
66 eventHandlers.mainBar = {
\r
68 mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());
\r
70 'cmd.save': function() {
\r
71 sandbox.getModule('data').fakeSave();
\r
75 eventHandlers.indicator = {
\r
77 mainLayout.setView('messages', sandbox.getModule('indicator').getView());
\r
85 sandbox.getModule('data').start();
\r
87 handleEvent: function(moduleName, eventName, args) {
\r
89 wysiwigHandler.handleEvent(moduleName, eventName, args);
\r
90 else if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) {
\r
91 eventHandlers[moduleName][eventName].apply(eventHandlers, args);
\r