Don't set has_local_changes document flag unnecessarily, fixes #3234
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 30 Dec 2013 09:30:11 +0000 (10:30 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 30 Dec 2013 09:30:11 +0000 (10:30 +0100)
redakcja/static/js/wiki/wikiapi.js

index d901e84..8df3ef5 100644 (file)
         * Set document's text
         */
        WikiDocument.prototype.setText = function(text) {
-               this.text = text;
-               this.has_local_changes = true;
+               return this.setDocumentProperty('text', text);
        };
 
        /*
         * Set document's gallery link
         */
        WikiDocument.prototype.setGalleryLink = function(gallery) {
-               this.galleryLink = gallery;
-               this.has_local_changes = true;
+               return this.setDocumentProperty('galleryLink', gallery);
+       };
+
+       /*
+        * Set document's property
+        */
+       WikiDocument.prototype.setDocumentProperty = function(property, value) {
+               if(this[property] !== value) {
+                       this[property] = value;
+                       this.has_local_changes = true;
+               }
        };
 
        /*