3 return function(sandbox) {
\r
5 var doc = sandbox.getBootstrappedData().document;
\r
6 var document_id = sandbox.getBootstrappedData().document_id;
\r
11 xmlns="http://nowoczesnapolska.org.pl/sst#"\n\
\r
12 xmlns:xlink="http://www.w3.org/1999/xlink"\n\
\r
13 xmlns:dc="http://purl.org/dc/elements/1.1/"\n\
\r
14 xmlns:dcterms="http://purl.org/dc/terms/"\n\
\r
18 <div class="p"></div>\n\
\r
23 function readCookie(name) {
\r
24 var nameEQ = escape(name) + "=";
\r
25 var ca = document.cookie.split(';');
\r
26 for (var i = 0; i < ca.length; i++) {
\r
28 while (c.charAt(0) == ' ') c = c.substring(1, c.length);
\r
29 if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length));
\r
36 beforeSend: function(xhr, settings) {
\r
37 if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {
\r
38 xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));
\r
45 sandbox.publish('ready');
\r
47 getDocument: function() {
\r
50 commitDocument: function(newDocument, reason) {
\r
52 sandbox.publish('documentChanged', doc, reason);
\r
54 saveDocument: function() {
\r
55 sandbox.publish('savingStarted');
\r
58 url: '/' + gettext('editor') + '/' + document_id,
\r
59 data: JSON.stringify({document:doc}),
\r
60 success: function() {sandbox.publish('savingEnded', 'success');},
\r
61 error: function() {sandbox.publish('savingEnded', 'error');}
\r
64 fakeSave: function() {
\r
65 sandbox.publish('savingStarted');
\r
66 window.setTimeout(function() {
\r
67 sandbox.publish('savingEnded', 'success')
\r