X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/1aba836313d1513bbe0ca947e01176806c900233..95f83648504b6552ff3cbf956f55c6bf5f542a9b:/modules/data.js diff --git a/modules/data.js b/modules/data.js index e4b564e..2848454 100644 --- a/modules/data.js +++ b/modules/data.js @@ -1,8 +1,27 @@ -rng.modules.data = function(sandbox) { +define(function() { + +'use strict'; + +return function(sandbox) { var doc = sandbox.getBootstrappedData().document; var document_id = sandbox.getBootstrappedData().document_id; + + if(doc === '') { + doc = '\n\ + \n\ + \n\ +
\n\ + '; + } + + function readCookie(name) { var nameEQ = escape(name) + "="; var ca = document.cookie.split(';'); @@ -35,13 +54,16 @@ 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');} }); - } - + } } +}; -}; \ No newline at end of file +}); \ No newline at end of file