X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/ccd0a4f745a6fab17a228d822e80d8bbb6fa7d5d..f21a91b10cced1d0fd3be6b183bc64303e7f4f94:/modules/sourceEditor/sourceEditor.js?ds=sidebyside diff --git a/modules/sourceEditor/sourceEditor.js b/modules/sourceEditor/sourceEditor.js index 248c02d..431fcb8 100644 --- a/modules/sourceEditor/sourceEditor.js +++ b/modules/sourceEditor/sourceEditor.js @@ -1,19 +1,20 @@ define(function() { +'use strict'; + return function(sandbox) { var view = $(sandbox.getTemplate('main')()); - var isDirty = false; var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]); editor.setTheme("ace/theme/chrome"); editor.getSession().setMode("ace/mode/xml"); $('textarea', view).on('keyup', function() { - isDirty = true; + sandbox.publish('xmlChanged'); }); editor.getSession().on('change', function() { - isDirty = true; + sandbox.publish('xmlChanged'); }) return { start: function() { @@ -25,18 +26,11 @@ return function(sandbox) { setDocument: function(document) { editor.setValue(document); editor.gotoLine(0) - isDirty = false; + sandbox.publish('documentSet'); }, getDocument: function() { return editor.getValue(); - }, - isDirty: function() { - return isDirty; - }, - setDirty: function(dirty) { - isDirty = dirty; } - } };