editor: fix - changes made via source editor now get correctly committed event if...
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 5 Mar 2014 10:25:38 +0000 (11:25 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 5 Mar 2014 10:25:38 +0000 (11:25 +0100)
src/editor/modules/rng/rng.js
src/editor/modules/sourceEditor/sourceEditor.js

index 801473b..05e0620 100644 (file)
@@ -142,6 +142,10 @@ return function(sandbox) {
             views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());
         },
         'cmd.save': function() {
             views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());
         },
         'cmd.save': function() {
+            var sourceEditor = sandbox.getModule('sourceEditor');
+            if(!sourceEditor.changesCommited()) {
+                sourceEditor.commitChanges();
+            }
             sandbox.getModule('data').saveDocument();
         }
     };
             sandbox.getModule('data').saveDocument();
         }
     };
index 1930939..8f0c833 100644 (file)
@@ -22,10 +22,14 @@ return function(sandbox) {
 
     view.onHide = function() {
         if(documentEditedHere) {
 
     view.onHide = function() {
         if(documentEditedHere) {
-            documentEditedHere = false;
-            wlxmlDocument.loadXML(editor.getValue());
+            commitDocument();
         }
     };
         }
     };
+
+    var commitDocument = function() {
+        documentEditedHere = false;
+        wlxmlDocument.loadXML(editor.getValue());
+    };
     
     /* globals ace */
     var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]),
     
     /* globals ace */
     var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]),
@@ -53,6 +57,10 @@ return function(sandbox) {
                 documentIsDirty = true;
             });
         },
                 documentIsDirty = true;
             });
         },
+        changesCommited: function() {
+            return !documentEditedHere;
+        },
+        commitChanges: commitDocument,
         getDocument: function() {
             return editor.getValue();
         }
         getDocument: function() {
             return editor.getValue();
         }