Undo
[redakcja.git] / src / redakcja / static / js / wiki / view_properties.js
index 35d0069..a3fe432 100644 (file)
     };
 
     class PropertiesPerspective extends $.wiki.SidebarPerspective {
-        constructor(options) {
-            let oldCallback = options.callback || function() {};
+        vsplitbar = 'WŁAŚCIWOŚCI';
+        $edited = null;
 
-            options.callback = function() {
+        constructor(options) {
+            super(options);
                 let self = this;
 
-                self.vsplitbar = 'WŁAŚCIWOŚCI';
                 self.$pane = $("#side-properties");
 
                 $("#simple-editor").on('click', '[x-node]', function(e) {
@@ -79,6 +79,7 @@
                         } else {
                             $input.data("edited").text(inputval);
                         }
+                        $.wiki.perspectives.VisualPerspective.flush();
                         return;
                     }
 
                                     let htmlElem = $(html);
                                     self.$edited.replaceWith(htmlElem);
                                     self.edit(htmlElem);
+                                    $.wiki.activePerspective().flush();
                                 }
                             });
                         },
                     let $fg = $(this).closest('.form-group');
                     $('input', $fg).data('edited').remove();
                     self.displayMetaProperty($fg);
+                    $.wiki.perspectives.VisualPerspective.flush();
                     return false;
                 });
 
                 self.$pane.on('click', '#current-delete', function() {
                     self.delete();
                 });
-
-                oldCallback.call(this);
-            };
-
-            super(options);
         }
 
         edit(element) {
 
             if (element === null) {
                 self.$edited = null;
+                $("h1", self.$pane).text('');
                 return;
             }
 
             if ($.wiki.activePerspective() != 'VisualPerspective')
                 $.wiki.switchToTab('#VisualPerspective');
 
-            if (self.$edited === null) {
-                self.edit($('[x-node="utwor"]')[0]);
+            this.enable();
+        }
+
+        enable() {
+            if (this.$edited === null) {
+                this.edit($('[x-node="utwor"]')[0]);
             }
         }
+        disable() {
+            this.edit(null);
+        }
     }
     $.wiki.PropertiesPerspective = PropertiesPerspective;