X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/4bec9ecf52da4c7f83bc8bb8c1b7d5ee148e732e..dc88a3110d5f44a8240cdd637b22716545763578:/src/editor/modules/data/data.js?ds=inline diff --git a/src/editor/modules/data/data.js b/src/editor/modules/data/data.js index dd81909..7488390 100644 --- a/src/editor/modules/data/data.js +++ b/src/editor/modules/data/data.js @@ -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() {