integration wip: saving document
[fnpeditor.git] / src / editor / modules / data / data.js
index 896fc56..c9ecf7d 100644 (file)
@@ -8,26 +8,12 @@ define([
 
 return function(sandbox) {
 
 
 return function(sandbox) {
 
-    var doc = sandbox.getBootstrappedData().document;
     var document_id = sandbox.getBootstrappedData().document_id;
     var document_version = sandbox.getBootstrappedData().version;
     var history = sandbox.getBootstrappedData().history;
 
     var wlxmlDocument = wlxml.WLXMLDocumentFromXML(sandbox.getBootstrappedData().document);
     var document_id = sandbox.getBootstrappedData().document_id;
     var document_version = sandbox.getBootstrappedData().version;
     var history = sandbox.getBootstrappedData().history;
 
     var wlxmlDocument = wlxml.WLXMLDocumentFromXML(sandbox.getBootstrappedData().document);
-    
-    if(doc === '') {
-        doc = '<section\n\
-        xmlns="http://nowoczesnapolska.org.pl/sst#"\n\
-        xmlns:xlink="http://www.w3.org/1999/xlink"\n\
-        xmlns:dc="http://purl.org/dc/elements/1.1/"\n\
-        xmlns:dcterms="http://purl.org/dc/terms/"\n\
-    >\n\
-        <metadata>\n\
-        </metadata>\n\
-        <div class="p"></div>\n\
-    </section>';
-    }
-    
+     
     
     function readCookie(name) {
         var nameEQ = escape(name) + "=";
     
     function readCookie(name) {
         var nameEQ = escape(name) + "=";
@@ -65,14 +51,11 @@ return function(sandbox) {
             sandbox.publish('ready');
         },
         getDocument: function() {
             sandbox.publish('ready');
         },
         getDocument: function() {
-            return doc;
-        },
-        getDocument2: function() {
             return wlxmlDocument;
         },
         commitDocument: function(newDocument, reason) {
             return wlxmlDocument;
         },
         commitDocument: function(newDocument, reason) {
-            doc = newDocument;
-            sandbox.publish('documentChanged', doc, reason);
+            // doc = newDocument;
+            // sandbox.publish('documentChanged', doc, reason);
         },
         saveDocument: function() {
 
         },
         saveDocument: function() {
 
@@ -83,7 +66,7 @@ return function(sandbox) {
                 $.ajax({
                     method: 'post',
                     url: '/' + gettext('editor') + '/' + document_id,
                 $.ajax({
                     method: 'post',
                     url: '/' + gettext('editor') + '/' + document_id,
-                    data: JSON.stringify({document:doc, description: event.data.description}),
+                    data: JSON.stringify({document:wlxmlDocument.toXML(), description: event.data.description}),
                     success: function() {
                         event.success();
                         sandbox.publish('savingEnded', 'success');
                     success: function() {
                         event.success();
                         sandbox.publish('savingEnded', 'success');
@@ -121,7 +104,6 @@ return function(sandbox) {
                     url: '/' + gettext('editor') + '/' + document_id + '/revert',
                     data: JSON.stringify(options),
                     success: function(data) {
                     url: '/' + gettext('editor') + '/' + document_id + '/revert',
                     data: JSON.stringify(options),
                     success: function(data) {
-                        doc = data.document;
                         document_version = data.version;
                         reloadHistory();
                         sandbox.publish('documentReverted', data);
                         document_version = data.version;
                         reloadHistory();
                         sandbox.publish('documentReverted', data);