X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/ccd0a4f745a6fab17a228d822e80d8bbb6fa7d5d..530d5b117e9513fa9282015d3eb231088275c615:/modules/sourceEditor/sourceEditor.js diff --git a/modules/sourceEditor/sourceEditor.js b/modules/sourceEditor/sourceEditor.js index 248c02d..2fca370 100644 --- a/modules/sourceEditor/sourceEditor.js +++ b/modules/sourceEditor/sourceEditor.js @@ -1,43 +1,37 @@ -define(function() { - -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; - }); - - editor.getSession().on('change', function() { - isDirty = true; - }) - return { - start: function() { - sandbox.publish('ready'); - }, - getView: function() { - return view; - }, - setDocument: function(document) { - editor.setValue(document); - editor.gotoLine(0) - isDirty = false; - }, - getDocument: function() { - return editor.getValue(); - }, - isDirty: function() { - return isDirty; - }, - setDirty: function(dirty) { - isDirty = dirty; - } - - } -}; - +define(function() { + +'use strict'; + +return function(sandbox) { + + var view = $(sandbox.getTemplate('main')()); + + 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() { + sandbox.publish('xmlChanged'); + }); + + editor.getSession().on('change', function() { + sandbox.publish('xmlChanged'); + }); + return { + start: function() { + sandbox.publish('ready'); + }, + getView: function() { + return view; + }, + setDocument: function(document) { + editor.setValue(document); + editor.gotoLine(0); + sandbox.publish('documentSet'); + }, + getDocument: function() { + return editor.getValue(); + } + }; +}; + }); \ No newline at end of file