Detach/attach facet nodes when switching facets instead of
hiding/showing.

Keeps dom-tree more simple.


This patch is not really needed. I implemented it while testing something in IE. But it might have positive effect for poorly written parts of Web UI(if there are any :) ) or plugins. Basically it simplifies DOM tree to contain nodes only for the active facet. Therefore ugly expressions like $('button .foobar') are much more performant.

--
Petr Vobornik
From 46e9b59f526a4beccba02dbe815f21c3aa688eaa Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Tue, 22 Jul 2014 14:15:30 +0200
Subject: [PATCH] webui: detach facet nodes

Detach/attach facet nodes when switching facets instead of
hiding/showing.

Keeps dom-tree more simple.
---
 install/ui/src/freeipa/facet.js        | 5 +++++
 install/ui/src/freeipa/facets/Facet.js | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index 0bb697be0b606743279b661d2e901372d735f8c3..50c12d49c4716e2e8d799663b79e04fdeb4d3d86 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -672,6 +672,8 @@ exp.facet = IPA.facet = function(spec, no_init) {
 
         if (!that.dom_node) {
             that.create();
+        } else if (!that.dom_node.parentElement) {
+            construct.place(that.dom_node[0], that.container_node);
         }
 
         var state = that.state.clone();
@@ -728,6 +730,9 @@ exp.facet = IPA.facet = function(spec, no_init) {
      */
     that.hide = function() {
         that.is_shown = false;
+        if (that.dom_node[0].parentElement) {
+            that.container_node.removeChild(that.dom_node[0]);
+        }
         that.dom_node.removeClass('active-facet');
     };
 
diff --git a/install/ui/src/freeipa/facets/Facet.js b/install/ui/src/freeipa/facets/Facet.js
index e015329c94c69b6c316c2ce65a1bfda2a98a8c91..0608ab6fb1e1983fbbb51f9795c4aabb49cb535a 100644
--- a/install/ui/src/freeipa/facets/Facet.js
+++ b/install/ui/src/freeipa/facets/Facet.js
@@ -285,6 +285,8 @@ define(['dojo/_base/declare',
             if (!this.dom_node) {
                 this.create();
                 this.render_children();
+            } else if (!this.dom_node.parentElement) {
+                construct.place(this.dom_node, this.container_node);
             }
 
             dom_class.add(this.dom_node, 'active-facet');
@@ -295,6 +297,9 @@ define(['dojo/_base/declare',
          * Un-mark itself as active facet
          */
         hide: function() {
+            if (this.dom_node.parentElement) {
+                this.container_node.removeChild(this.dom_node);
+            }
             dom_class.remove(this.dom_node, 'active-facet');
             this.emit('hide', { source: this });
         },
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to