+ var view = $(template),
+ documentIsDirty = true,
+ documentEditedHere = false,
+ wlxmlDocument;
+
+ view.onShow = function() {
+ if(documentIsDirty) {
+ editor.setValue(wlxmlDocument.toXML());
+ editor.gotoLine(0);
+ documentEditedHere = false;
+
+ documentIsDirty = false;
+ }
+ };
+
+ view.onHide = function() {
+ if(documentEditedHere) {
+ commitDocument();
+ }
+ };
+
+ var commitDocument = function() {
+ documentEditedHere = false;
+ wlxmlDocument.loadXML(editor.getValue());
+ };