+ var view = $(sandbox.getTemplate('main')()),
+ documentIsDirty = true,
+ documentEditedHere = false,
+ wlxmlDocument;
+
+ view.onShow = function() {
+ if(documentIsDirty) {
+ editor.setValue(wlxmlDocument.toXML());
+ editor.gotoLine(0);
+ documentEditedHere = false;
+
+ sandbox.publish('documentSet');
+ documentIsDirty = false;
+ }
+ }
+
+ view.onHide = function() {
+ if(documentEditedHere) {
+ documentEditedHere = false;
+ wlxmlDocument.loadXML(editor.getValue());
+ }
+ }