1 rng.modules.data = function(sandbox) {
\r
3 var doc = sandbox.getBootstrappedData().document;
\r
4 var document_id = sandbox.getBootstrappedData().document_id;
\r
9 xmlns="http://nowoczesnapolska.org.pl/sst#"\n\
\r
10 xmlns:xlink="http://www.w3.org/1999/xlink"\n\
\r
11 xmlns:dc="http://purl.org/dc/elements/1.1/"\n\
\r
12 xmlns:dcterms="http://purl.org/dc/terms/"\n\
\r
16 <div class="p"></div>\n\
\r
21 function readCookie(name) {
\r
22 var nameEQ = escape(name) + "=";
\r
23 var ca = document.cookie.split(';');
\r
24 for (var i = 0; i < ca.length; i++) {
\r
26 while (c.charAt(0) == ' ') c = c.substring(1, c.length);
\r
27 if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length));
\r
34 beforeSend: function(xhr, settings) {
\r
35 if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {
\r
36 xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));
\r
43 sandbox.publish('ready');
\r
45 getDocument: function() {
\r
48 commitDocument: function(newDocument, reason) {
\r
50 sandbox.publish('documentChanged', doc, reason);
\r
52 saveDocument: function() {
\r
53 sandbox.publish('savingStarted');
\r
56 url: '/' + gettext('editor') + '/' + document_id,
\r
57 data: JSON.stringify({document:doc}),
\r
58 success: function() {sandbox.publish('savingEnded', 'success');},
\r
59 error: function() {sandbox.publish('savingEnded', 'error');}
\r