X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/0add3b13ce4ef42557d9ca33342a159b80a4f42f..8e0830cb8d24b4d81d12a4df96d03c9d78f88343:/modules/rng.js?ds=sidebyside diff --git a/modules/rng.js b/modules/rng.js index baa400d..0a39ed8 100644 --- a/modules/rng.js +++ b/modules/rng.js @@ -11,6 +11,18 @@ rng.modules.rng = function(sandbox) { eventHandlers.skelton = { ready: function() { sandbox.getModule('tabsManager').start(); + }, + 'cmd.save': function() { + var editorSlugs = ['visual', 'source']; + var slug = sandbox.getModule('tabsManager').getCurrentSlug(); + if(_.contains(editorSlugs, slug)) { + var editor = sandbox.getModule(slug+'Editor'); + if(editor.isDirty()) { + sandbox.getModule('data').commitDocument(editor.getDocument(), slug + '_edit'); + editor.setDirty(false); + } + } + sandbox.getModule('data').saveDocument(); } }; @@ -29,20 +41,25 @@ rng.modules.rng = function(sandbox) { editor.setDirty(false); } } + }, + showed: function(slug) { + if(slug === 'visual') + sandbox.getModule('visualEditor').onShowed(); } }; 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()); } }; eventHandlers.visualEditor = { ready: function() { - addTab('Visual', 'visual', sandbox.getModule('visualEditor').getView()); sandbox.getModule('visualEditor').setDocument(sandbox.getModule('data').getDocument()); + addTab(gettext('Visual'), 'visual', sandbox.getModule('visualEditor').getView()); + } };