1 rng.modules.rng = function(sandbox) {
\r
3 function addTab(title, slug, view) {
\r
4 sandbox.getModule('tabsManager').addTab(title, slug, view);
\r
7 /* Events handling */
\r
11 eventHandlers.skelton = {
\r
13 sandbox.getModule('tabsManager').start();
\r
17 eventHandlers.tabsManager = {
\r
19 sandbox.getModule('skelton').setMainView(sandbox.getModule('tabsManager').getView());
\r
20 _.each(['visualEditor', 'sourceEditor'], function(moduleName) {
\r
21 sandbox.getModule(moduleName).start();
\r
24 leaving: function(slug) {
\r
25 if(slug === 'source' || slug === 'visual') {
\r
26 var editor = sandbox.getModule(slug+'Editor');
\r
27 if(editor.isDirty()) {
\r
28 sandbox.getModule('data').commitDocument(editor.getDocument(), slug + '_edit');
\r
29 editor.setDirty(false);
\r
35 eventHandlers.sourceEditor = {
\r
37 addTab('Source', 'source', sandbox.getModule('sourceEditor').getView());
\r
38 sandbox.getModule('sourceEditor').setDocument(sandbox.getModule('data').getDocument());
\r
42 eventHandlers.visualEditor = {
\r
44 addTab('Visual', 'visual', sandbox.getModule('visualEditor').getView());
\r
45 sandbox.getModule('visualEditor').setDocument(sandbox.getModule('data').getDocument());
\r
49 eventHandlers.data = {
\r
51 sandbox.getModule('skelton').start();
\r
53 documentChanged: function(document, reason) {
\r
54 var slug = (reason === 'visual_edit' ? 'source' : 'visual');
\r
55 sandbox.getModule(slug+'Editor').setDocument(document);
\r
64 sandbox.getModule('data').start();
\r
66 handleEvent: function(moduleName, eventName, args) {
\r
67 if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) {
\r
68 eventHandlers[moduleName][eventName].apply(eventHandlers, args);
\r