1 define(['libs/jquery'], function($) {
5 return function(sandbox) {
7 var view = $(sandbox.getTemplate('main')()),
8 documentIsDirty = true,
9 documentEditedHere = false,
12 view.onShow = function() {
14 editor.setValue(wlxmlDocument.toXML());
16 documentEditedHere = false;
18 sandbox.publish('documentSet');
19 documentIsDirty = false;
23 view.onHide = function() {
24 if(documentEditedHere) {
25 documentEditedHere = false;
26 wlxmlDocument.loadXML(editor.getValue());
31 var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]),
32 session = editor.getSession();
33 editor.setTheme('ace/theme/chrome');
34 session.setMode('ace/mode/xml');
35 session.setUseWrapMode(true);
37 $('textarea', view).on('keyup', function() {
38 documentEditedHere = true;
41 editor.getSession().on('change', function() {
42 documentEditedHere = true;
46 sandbox.publish('ready');
51 setDocument: function(document) {
52 wlxmlDocument = document;
53 wlxmlDocument.on('change', function() {
54 documentIsDirty = true;
57 getDocument: function() {
58 return editor.getValue();