Merge branch 'master' of stigma.nowoczesnapolska.org.pl:platforma
[redakcja.git] / platforma / static / js / models.js
old mode 100644 (file)
new mode 100755 (executable)
index d148640..ba2f3ce
@@ -228,7 +228,7 @@ Editor.HTMLModel = Editor.Model.extend({
 
     getXMLPart: function(elem, callback)
     {
 
     getXMLPart: function(elem, callback)
     {
-        var path = elem.attr('wl2o:path');
+        var path = elem.attr('x-pointer');
         if(!this.xmlParts[path])
             this.loadXMLPart(elem, callback);
         else
         if(!this.xmlParts[path])
             this.loadXMLPart(elem, callback);
         else
@@ -237,7 +237,7 @@ Editor.HTMLModel = Editor.Model.extend({
 
     loadXMLPart: function(elem, callback)
     {
 
     loadXMLPart: function(elem, callback)
     {
-        var path = elem.attr('wl2o:path');
+        var path = elem.attr('x-pointer');
         var self = this;
 
         $.ajax({
         var self = this;
 
         $.ajax({
@@ -246,8 +246,8 @@ Editor.HTMLModel = Editor.Model.extend({
             data: {
                 revision: this.get('revision'),
                 user: this.document.get('user'),
             data: {
                 revision: this.get('revision'),
                 user: this.document.get('user'),
-                chunk: path,
-                format: 'nl'
+                chunk: path
+                // format: 'nl'
             },
             success: function(data) {
                 self.xmlParts[path] = data;
             },
             success: function(data) {
                 self.xmlParts[path] = data;
@@ -262,13 +262,13 @@ Editor.HTMLModel = Editor.Model.extend({
         });
     },
 
         });
     },
 
-    putXMLPart: function(elem, data) {
+    putXMLPart: function(elem, data, callback) {
         var self = this;
       
         var self = this;
       
-        var path = elem.attr('wl2o:path');
+        var path = elem.attr('x-pointer');
         this.xmlParts[path] = data;
 
         this.xmlParts[path] = data;
 
-        this.set('state', 'unsynced');
+        this.set('state', 'dirty');
 
         /* re-render the changed fragment */
         $.ajax({
 
         /* re-render the changed fragment */
         $.ajax({
@@ -277,11 +277,11 @@ Editor.HTMLModel = Editor.Model.extend({
             dataType: 'text; charset=utf-8',
             data: {
                 fragment: data,
             dataType: 'text; charset=utf-8',
             data: {
                 fragment: data,
-                chunk: path,
-                format: 'nl'
+                chunk: path
+                // format: 'nl'
             },
             success: function(htmldata) {
             },
             success: function(htmldata) {
-                elem.replaceWith(htmldata);
+                callback(elem, htmldata);
                 self.set('state', 'dirty');
             }
         });
                 self.set('state', 'dirty');
             }
         });
@@ -596,10 +596,13 @@ Editor.DocumentModel = Editor.Model.extend({
     mergeCompleted: function(xhr, textStatus) {
         console.log(xhr.status, xhr.responseText);
         var response = parseXHRResponse(xhr);
     mergeCompleted: function(xhr, textStatus) {
         console.log(xhr.status, xhr.responseText);
         var response = parseXHRResponse(xhr);
-        if(response.success)
-        {
-            if( (response.data.result == 'no-op')
-             || (response.data.shared_timestamp == response.data.shared_parent_timestamp))
+        
+        if(response.success) {
+        
+            if( (response.data.result == 'no-op') ||             
+             ( response.data.shared_parent_timestamp
+               && response.data.shared_timestamp
+               && (response.data.shared_timestamp == response.data.shared_parent_timestamp)) )
             {
                 if( (response.data.revision) && (response.data.revision != this.get('revision')) )
                 {
             {
                 if( (response.data.revision) && (response.data.revision != this.get('revision')) )
                 {