Ticket 818: better 'save' button styling.
[redakcja.git] / redakcja / static / js / wiki / wikiapi.js
index b6388f1..bce1f89 100644 (file)
@@ -39,6 +39,9 @@
                if (vname == "ajax_document_diff")
                        return base_path + "/" + arguments[1] + "/diff";
 
+        if (vname == "ajax_document_rev")
+            return base_path + "/" + arguments[1] + "/rev";
+
                if (vname == "ajax_document_addtag")
                        return base_path + "/" + arguments[1] + "/tags";
 
                });
        };
 
+    WikiDocument.prototype.checkRevision = function(params) {
+        /* this doesn't modify anything, so no locks */
+        var self = this;
+        $.ajax({
+            method: "GET",
+            url: reverse("ajax_document_rev", self.id),
+            dataType: 'text',
+            success: function(data) {
+                if (data != self.revision)
+                    params.error();
+            }
+        });
+    };
+
        /*
         * Fetch gallery
         */
                        },
                        error: function() {
                                self.galleryImages = [];
-                               params['failure'](self, "<p>Nie udało się wczytać gallerii pod nazwą: '" + self.galleryLink + "'.</p>");
+                               params['failure'](self, "<p>Nie udało się wczytać galerii pod nazwą: '" + self.galleryLink + "'.</p>");
                        }
                });
        };