1 rng.modules.data = function(sandbox) {
\r
3 var doc = sandbox.getBootstrappedData().document;
\r
4 var document_id = sandbox.getBootstrappedData().document_id;
\r
6 function readCookie(name) {
\r
7 var nameEQ = escape(name) + "=";
\r
8 var ca = document.cookie.split(';');
\r
9 for (var i = 0; i < ca.length; i++) {
\r
11 while (c.charAt(0) == ' ') c = c.substring(1, c.length);
\r
12 if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length));
\r
19 beforeSend: function(xhr, settings) {
\r
20 if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {
\r
21 xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));
\r
28 sandbox.publish('ready');
\r
30 getDocument: function() {
\r
33 commitDocument: function(newDocument, reason) {
\r
35 sandbox.publish('documentChanged', doc, reason);
\r
37 saveDocument: function() {
\r
40 url: '/editor/' + document_id,
\r
41 data: JSON.stringify({document:doc})
\r