X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/cf7d465ce6ed2acbc2b1c028e46847ead5320e9c..0214643f72c6aaa8e85eaba2ad27f2ca03ca6401:/modules/rng.js diff --git a/modules/rng.js b/modules/rng.js index 6ea6f40..0106f03 100644 --- a/modules/rng.js +++ b/modules/rng.js @@ -1,12 +1,15 @@ -rng.modules.rng = function(sandbox) { +define(function() { +return function(sandbox) { + 'use strict'; + function addTab(title, slug, view) { sandbox.getModule('tabsManager').addTab(title, slug, view); } /* Events handling */ - eventHandlers = {}; + var eventHandlers = {}; eventHandlers.skelton = { ready: function() { @@ -29,7 +32,7 @@ rng.modules.rng = function(sandbox) { eventHandlers.tabsManager = { ready: function() { sandbox.getModule('skelton').setMainView(sandbox.getModule('tabsManager').getView()); - _.each(['visualEditor', 'sourceEditor'], function(moduleName) { + _.each(['visualEditor', 'sourceEditor', 'rng2'], function(moduleName) { sandbox.getModule(moduleName).start(); }); }, @@ -50,7 +53,7 @@ rng.modules.rng = function(sandbox) { eventHandlers.sourceEditor = { ready: function() { - addTab('Source', 'source', sandbox.getModule('sourceEditor').getView()); + addTab(gettext('Source'), 'source', sandbox.getModule('sourceEditor').getView()); sandbox.getModule('sourceEditor').setDocument(sandbox.getModule('data').getDocument()); } }; @@ -58,7 +61,7 @@ rng.modules.rng = function(sandbox) { eventHandlers.visualEditor = { ready: function() { sandbox.getModule('visualEditor').setDocument(sandbox.getModule('data').getDocument()); - addTab('Visual', 'visual', sandbox.getModule('visualEditor').getView()); + addTab(gettext('Visual'), 'visual', sandbox.getModule('visualEditor').getView()); } }; @@ -70,9 +73,23 @@ rng.modules.rng = function(sandbox) { documentChanged: function(document, reason) { var slug = (reason === 'visual_edit' ? 'source' : 'visual'); sandbox.getModule(slug+'Editor').setDocument(document); + }, + savingStarted: function() { + sandbox.getModule('skelton').deactivateCommand('save'); + sandbox.getModule('skelton').showMessage(gettext('Saving...')); + }, + savingEnded: function(status) { + sandbox.getModule('skelton').activateCommand('save'); + sandbox.getModule('skelton').clearMessage(); } } + eventHandlers.rng2 = { + ready: function() { + addTab('rng2 test', 'rng2test', sandbox.getModule('rng2').getView()); + + } + } /* api */ @@ -81,9 +98,13 @@ rng.modules.rng = function(sandbox) { sandbox.getModule('data').start(); }, handleEvent: function(moduleName, eventName, args) { - if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) { + if('') + wysiwigHandler.handleEvent(moduleName, eventName, args); + else if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) { eventHandlers[moduleName][eventName].apply(eventHandlers, args); } } } -}; \ No newline at end of file +}; + +}); \ No newline at end of file