X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/b41ddda14e70e0a8ee1705b8c8edcb7625553e5e..d4e89595e829f60443056ce65f5f275d10f882ed:/modules/visualEditor.js?ds=sidebyside diff --git a/modules/visualEditor.js b/modules/visualEditor.js index d8b30b7..ce62c6a 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -3,6 +3,23 @@ rng.modules.visualEditor = function(sandbox) { var view = { node: $(sandbox.getTemplate('main')()), + setup: function() { + var node = this.node; + node.find('#rng-visualEditor-content').on('keyup', function() { + isDirty = true; + }); + + node.find('#rng-visualEditor-meta').on('keyup', function() { + isDirty = true; + }); + + this.node.on('mouseover', '.rng', function(e) { $(e.target).addClass('rng-hover')}); + this.node.on('mouseout', '.rng', function(e) { $(e.target).removeClass('rng-hover')}); + this.node.on('click', '.rng', function(e) { + node.find('.rng').removeClass('rng-current'); + $(e.target).addClass('rng-current'); + }); + }, getMetaData: function() { var toret = {}; this.node.find('#rng-visualEditor-meta table tr').each(function() { @@ -25,21 +42,14 @@ rng.modules.visualEditor = function(sandbox) { this.node.find('#rng-visualEditor-content').html(HTMLTree); }, getBody: function() { - return this.find('#rng-visualEditor-content').html(); + return this.node.find('#rng-visualEditor-content').html(); } }; + view.setup(); var isDirty = false; - $('#rng-visualEditor-content', view).on('keyup', function() { - isDirty = true; - }); - - $('#rng-visualEditor-meta', view).on('keyup', function() { - isDirty = true; - }); - return { start: function() { sandbox.publish('ready');