removing unused code
[fnpeditor.git] / src / editor / modules / data / data.js
index dd81909..7488390 100644 (file)
@@ -41,11 +41,14 @@ return function(sandbox) {
         });
         
         var modificationFlag = true;
-        wlxmlDocument.on('change', function() {
+        var handleChange = function() {
             documentDirty = true;
             draftDirty = true;
             modificationFlag = true;
-        });
+        };
+        wlxmlDocument.on('change', handleChange);
+        wlxmlDocument.on('contentSet', handleChange);
+
         if(window.localStorage) {
             window.setInterval(function() {
                 if(modificationFlag) {
@@ -54,9 +57,9 @@ return function(sandbox) {
                 }
                 if(wlxmlDocument && documentDirty && draftDirty) {
                     logger.debug('Saving draft to local storage.');
-                    sandbox.publish('savingStarted');
+                    sandbox.publish('savingStarted', 'local');
                     window.localStorage.setItem(getLocalStorageKey(), wlxmlDocument.toXML());
-                    sandbox.publish('savingEnded', 'success');
+                    sandbox.publish('savingEnded', 'success', 'local');
                     draftDirty = false;
                 }
             }, sandbox.getConfig().autoSaveInterval || 2500);
@@ -156,7 +159,7 @@ return function(sandbox) {
                 });
             
             dialog.on('execute', function(event) {
-                sandbox.publish('savingStarted');
+                sandbox.publish('savingStarted', 'remote');
 
                 var formData = event.formData;
                 formData[documentSaveForm.content_field_name] = wlxmlDocument.toXML();
@@ -172,11 +175,11 @@ return function(sandbox) {
                     data: formData,
                     success: function(data) {
                         event.success();
-                        sandbox.publish('savingEnded', 'success', data.version);
+                        sandbox.publish('savingEnded', 'success', 'remote', data.version);
                         document_version = data.version;
                         reloadHistory();
                     },
-                    error: function() {event.error(); sandbox.publish('savingEnded', 'error');}
+                    error: function() {event.error(); sandbox.publish('savingEnded', 'error', 'remote');}
                 });
             });
             dialog.on('cancel', function() {