Fix #6464 - card header
[roojs1] / Roo / bootstrap / Component.js
index 997ebb8..01b90dc 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
@@ -364,22 +365,44 @@ 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.getEl()){
+        if(!this.getVisibilityEl()){
             return;
         }
+         
+        this.getVisibilityEl().removeClass(['hidden','d-none']);
         
-        this.getEl().removeClass('hidden');
-        
-        if(!this.hideParent){
-            return;
-        }
+        this.fireEvent('show', this);
         
-        this.parent().getEl().removeClass('hidden');
         
     },
     /**
@@ -387,17 +410,13 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
      */
     hide: function()
     {
-        if(!this.getEl() || this.getEl().hasClass('hidden')){
+        if(!this.getVisibilityEl()){
             return;
         }
         
-        this.getEl().addClass('hidden');
-        
-        if(!this.hideParent){
-            return;
-        }
+        this.getVisibilityEl().addClass(['hidden','d-none']);
         
-        this.parent().getEl().addClass('hidden');
+        this.fireEvent('hide', this);
         
     }
 });