X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/c0e11a8f6d0d9a4c030aa90fe91f0fc49cd05e0e..3eaf5e66203b1afafc81dfb1214660b20a11739f:/modules/data.js diff --git a/modules/data.js b/modules/data.js index 5f3fd39..0fab1a7 100644 --- a/modules/data.js +++ b/modules/data.js @@ -1,12 +1,13 @@ -rng.modules.data = function(sandbox) { +define(function() { + +return function(sandbox) { var doc = sandbox.getBootstrappedData().document; var document_id = sandbox.getBootstrappedData().document_id; if(doc === '') { - doc = '\n\ - '; } @@ -52,13 +52,23 @@ rng.modules.data = function(sandbox) { sandbox.publish('documentChanged', doc, reason); }, saveDocument: function() { + sandbox.publish('savingStarted'); $.ajax({ method: 'post', url: '/' + gettext('editor') + '/' + document_id, - data: JSON.stringify({document:doc}) + data: JSON.stringify({document:doc}), + success: function() {sandbox.publish('savingEnded', 'success');}, + error: function() {sandbox.publish('savingEnded', 'error');} }); + }, + fakeSave: function() { + sandbox.publish('savingStarted'); + window.setTimeout(function() { + sandbox.publish('savingEnded', 'success') + }, 2000); } } +}; -}; \ No newline at end of file +}); \ No newline at end of file