5 return function(sandbox) {
\r
7 var doc = sandbox.getBootstrappedData().document;
\r
8 var document_id = sandbox.getBootstrappedData().document_id;
\r
9 var history = sandbox.getBootstrappedData().history;
\r
14 xmlns="http://nowoczesnapolska.org.pl/sst#"\n\
\r
15 xmlns:xlink="http://www.w3.org/1999/xlink"\n\
\r
16 xmlns:dc="http://purl.org/dc/elements/1.1/"\n\
\r
17 xmlns:dcterms="http://purl.org/dc/terms/"\n\
\r
21 <div class="p"></div>\n\
\r
26 function readCookie(name) {
\r
27 var nameEQ = escape(name) + "=";
\r
28 var ca = document.cookie.split(';');
\r
29 for (var i = 0; i < ca.length; i++) {
\r
31 while (c.charAt(0) == ' ') c = c.substring(1, c.length);
\r
32 if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length));
\r
39 beforeSend: function(xhr, settings) {
\r
40 if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {
\r
41 xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));
\r
46 var reloadHistory = function() {
\r
49 url: '/' + gettext('editor') + '/' + document_id + '/history',
\r
50 success: function(data) {
\r
52 sandbox.publish('historyItemAdded', data.slice(-1)[0]);
\r
59 sandbox.publish('ready');
\r
61 getDocument: function() {
\r
64 commitDocument: function(newDocument, reason) {
\r
66 sandbox.publish('documentChanged', doc, reason);
\r
68 saveDocument: function() {
\r
69 sandbox.publish('savingStarted');
\r
72 url: '/' + gettext('editor') + '/' + document_id,
\r
73 data: JSON.stringify({document:doc}),
\r
74 success: function() {sandbox.publish('savingEnded', 'success'); reloadHistory();},
\r
75 error: function() {sandbox.publish('savingEnded', 'error');}
\r
78 getHistory: function() {
\r