X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/072a91dee12e07caf91a693c29fd9f3be5ee177b..e6e83eed52400d6e8a6ee6339cbe212c8cac1f90:/modules/data.js diff --git a/modules/data.js b/modules/data.js index 8debbd3..df40322 100644 --- a/modules/data.js +++ b/modules/data.js @@ -1,12 +1,16 @@ -rng.modules.data = function(sandbox) { +define(function() { + +'use strict'; + +return function(sandbox) { var doc = sandbox.getBootstrappedData().document; var document_id = sandbox.getBootstrappedData().document_id; + var history = sandbox.getBootstrappedData().history; if(doc === '') { - doc = '\n\ - '; } @@ -52,13 +55,19 @@ rng.modules.data = function(sandbox) { sandbox.publish('documentChanged', doc, reason); }, saveDocument: function() { + sandbox.publish('savingStarted'); $.ajax({ method: 'post', - url: '/editor/' + document_id, - data: JSON.stringify({document:doc}) + url: '/' + gettext('editor') + '/' + document_id, + data: JSON.stringify({document:doc}), + success: function() {sandbox.publish('savingEnded', 'success');}, + error: function() {sandbox.publish('savingEnded', 'error');} }); + }, + getHistory: function() { + return history; } - } +}; -}; \ No newline at end of file +}); \ No newline at end of file