1 define(['libs/jquery', 'libs/text!./template.html'], function($, template) {
5 return function(sandbox) {
7 var view = $(template),
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 editor.getSession().on('change', function() {
38 documentEditedHere = true;
42 sandbox.publish('ready');
47 setDocument: function(document) {
48 wlxmlDocument = document;
49 wlxmlDocument.on('change', function() {
50 documentIsDirty = true;
53 getDocument: function() {
54 return editor.getValue();