Uwaga button.
[redakcja.git] / src / redakcja / static / js / wiki / view_properties.js
index fd53f04..204a4de 100644 (file)
     PropertiesPerspective.prototype.edit = function(element) {
         let self = this;
 
-        let $node = $(element);
         $("#parents", self.$pane).empty();
         $("#bubbles").empty();
 
+        $f = $("#properties-form", self.$pane);
+        $f.empty();
+
+        if (element === null) {
+            self.$edited = null;
+            return;
+        }
+
+        let $node = $(element);
         let b = $("<div class='badge badge-primary'></div>").text($node.attr('x-node'));
         b.data('node', element);
         $("#bubbles").append(b);
         node = $(element).attr('x-node');
         $("h1", self.$pane).text(node);
 
-        $f = $("#properties-form", self.$pane);
-        $f.empty();
         self.$edited = $(element);
 
         let nodeDef = elementDefs[node];
         this.edit(p);
     }
 
+    PropertiesPerspective.prototype.onEnter = function(success, failure){
+        var self = this;
+        $.wiki.SidebarPerspective.prototype.onEnter.call(this);
+
+        if ($.wiki.activePerspective() != 'VisualPerspective')
+            $.wiki.switchToTab('#VisualPerspective');
+
+        self.edit($('[x-node="utwor"]')[0]);
+    };
+
     $.wiki.PropertiesPerspective = PropertiesPerspective;
 
 })(jQuery);