Fix #6883 - image loading tidy up
[roojs1] / Roo / bootstrap / Component.js
index 749a4e5..d2632d5 100644 (file)
@@ -18,7 +18,8 @@ Roo.bootstrap = Roo.bootstrap || {};
  * @cfg {string} name Specifies name attribute
  * @cfg {string} tooltip  Text for the tooltip
  * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar -  getHeaderChildContainer)
- * 
+ * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
  * @constructor
  * Do not use directly - it does not do anything..
  * @param {Object} config The config object
@@ -116,11 +117,11 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
         }
         
         if (this.cls) {
-            cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
+            cfg.cls = (typeof(cfg.cls) == 'undefined' ? this.cls : cfg.cls) + ' ' + this.cls;
         }
         
         if (this.style) { // fixme needs to support more complex style data.
-            cfg.style = this.style;
+            cfg.style = (typeof(cfg.style) == 'undefined' ? this.style : cfg.style) + '; ' + this.style;
         }
         
         if(this.name){
@@ -148,6 +149,11 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
     {
         return this.el;
     },
+    getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work
+    {
+        return Roo.get(document.body);
+    },
+    
     /**
      * Fetch the element to display the tooltip on.
      * @return {Roo.Element} defaults to this.el
@@ -241,11 +247,17 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
         var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
                     (typeof(tree['flexy:foreach']) != 'undefined');
           
+    
         
-        
-         skip_children = false;
+        skip_children = false;
         // render the element if it's not BODY.
         if (!is_body) {
+            
+            // if parent was disabled, then do not try and create the children..
+            if(!this[cntr](true)){
+                tree.items = [];
+                return tree;
+            }
            
             cn = Roo.factory(tree);
            
@@ -308,12 +320,18 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
                 //Roo.log('render');
                 //Roo.log(this[cntr]());
                 // some elements do not have render methods.. like the layouts...
+                /*
+                if(this[cntr](true) === false){
+                    cn.items = [];
+                    return cn;
+                }
+                */
                 cn.render && cn.render(this[cntr](true));
+                
              }
             // then add the element..
         }
-        
-        
+         
         // handle the kids..
         
         var nitems = [];
@@ -352,24 +370,59 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
         
         return cn;
     },
+    
+    /**
+     * Set the element that will be used to show or hide
+     */
+    setVisibilityEl : function(el)
+    {
+       this.visibilityEl = el;
+    },
+    
+     /**
+     * Get the element that will be used to show or hide
+     */
+    getVisibilityEl : function()
+    {
+       if (typeof(this.visibilityEl) == 'object') {
+           return this.visibilityEl;
+       }
+       
+       if (typeof(this.visibilityEl) == 'string') {
+           return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
+       }
+       
+       return this.getEl();
+    },
+    
     /**
      * Show a component - removes 'hidden' class
      */
     show : function()
     {
-        if (this.el) {
-            this.el.removeClass('hidden');
+        if(!this.getVisibilityEl()){
+            return;
         }
+         
+        this.getVisibilityEl().removeClass(['hidden','d-none']);
+        
+        this.fireEvent('show', this);
+        
+        
     },
     /**
      * Hide a component - adds 'hidden' class
      */
     hide: function()
     {
-        if (this.el && !this.el.hasClass('hidden')) {
-            this.el.addClass('hidden');
+        if(!this.getVisibilityEl()){
+            return;
         }
         
+        this.getVisibilityEl().addClass(['hidden','d-none']);
+        
+        this.fireEvent('hide', this);
+        
     }
 });