Fix #6464 - card header
[roojs1] / Roo / bootstrap / Popover.js
index 5a542a9..da35540 100644 (file)
 
 Roo.bootstrap.Popover = function(config){
     Roo.bootstrap.Popover.superclass.constructor.call(this, config);
+    
+    this.addEvents({
+        // raw events
+         /**
+         * @event show
+         * After the popover show
+         * 
+         * @param {Roo.bootstrap.Popover} this
+         */
+        "show" : true,
+        /**
+         * @event hide
+         * After the popover hide
+         * 
+         * @param {Roo.bootstrap.Popover} this
+         */
+        "hide" : true
+    });
 };
 
 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
@@ -45,7 +63,7 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
     },
     
     getAutoCreate : function(){
-         Roo.log('make popover?');
+         
         var cfg = {
            cls : 'popover roo-dynamic',
            style: 'display:block',
@@ -58,11 +76,11 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
                     cn : [
                         {
                             tag: 'h3',
-                            cls: 'popover-title',
+                            cls: 'popover-title popover-header',
                             html : this.title
                         },
                         {
-                            cls : 'popover-content',
+                            cls : 'popover-content popover-body',
                             html : this.html
                         }
                     ]
@@ -75,10 +93,12 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
     },
     setTitle: function(str)
     {
+        this.title = str;
         this.el.select('.popover-title',true).first().dom.innerHTML = str;
     },
     setContent: function(str)
     {
+        this.html = str;
         this.el.select('.popover-content',true).first().dom.innerHTML = str;
     },
     // as it get's added to the bottom of the page.
@@ -95,9 +115,9 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
             if (this.style) {
                 cfg.style = this.style;
             }
-            Roo.log("adding to ")
+            //Roo.log("adding to ");
             this.el = Roo.get(document.body).createChild(cfg, position);
-            Roo.log(this.el);
+//            Roo.log(this.el);
         }
         this.initEvents();
     },
@@ -114,11 +134,7 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
             return;
         }
         var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
-        Roo.log('Popover init!!!!');
-        Roo.log(on_el);
         var triggers = this.trigger ? this.trigger.split(' ') : [];
-        
-        Roo.log(triggers);
         Roo.each(triggers, function(trigger) {
         
             if (trigger == 'click') {
@@ -144,8 +160,7 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
     },
     
     enter : function () {
-       
-    
+        
         clearTimeout(this.timeout);
     
         this.hoverState = 'in';
@@ -161,6 +176,7 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
             }
         }, this.delay.show)
     },
+    
     leave : function() {
         clearTimeout(this.timeout);
     
@@ -183,12 +199,16 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
         if (!on_el) {
             on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
         }
+        
         // set content.
         this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
         if (this.html !== false) {
-            this.el.select('.popover-content',true).first().dom.innerHtml = this.title;
+            this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
         }
-        this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
+        this.el.removeClass([
+            'fade','top','bottom', 'left', 'right','in',
+            'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
+        ]);
         if (!this.title.length) {
             this.el.select('.popover-title',true).hide();
         }
@@ -218,33 +238,41 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
             // fixme..
         }
         var align = Roo.bootstrap.Popover.alignment[placement];
+        
+//        Roo.log(align);
         this.el.alignTo(on_el, align[0],align[1]);
         //var arrow = this.el.select('.arrow',true).first();
         //arrow.set(align[2], 
         
         this.el.addClass('in');
-        this.hoverState = null;
+        
         
         if (this.el.hasClass('fade')) {
             // fade it?
         }
         
+        this.hoverState = 'in';
+        
+        this.fireEvent('show', this);
+        
     },
     hide : function()
     {
         this.el.setXY([0,0]);
         this.el.removeClass('in');
         this.el.hide();
+        this.hoverState = null;
         
+        this.fireEvent('hide', this);
     }
     
 });
 
 Roo.bootstrap.Popover.alignment = {
-    'left' : ['r-l', [-10,0], 'right'],
-    'right' : ['l-r', [10,0], 'left'],
-    'bottom' : ['t-b', [0,10], 'top'],
-    'top' : [ 'b-t', [0,-10], 'bottom']
+    'left' : ['r-l', [-10,0], 'right bs-popover-right'],
+    'right' : ['l-r', [10,0], 'left bs-popover-left'],
+    'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
+    'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
 };
 
  
\ No newline at end of file