Roo/bootstrap/Popover.js
[roojs1] / Roo / bootstrap / Popover.js
1 /*
2  * - LGPL
3  *
4  * element
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.Popover
10  * @extends Roo.bootstrap.Component
11  * Bootstrap Element class
12  * @cfg {String} html contents of the popover
13  * @cfg {String} title of popover
14  * 
15  * @constructor
16  * Create a new Popover
17  * @param {Object} config The config object
18  */
19
20 Roo.bootstrap.Popover = function(config){
21     Roo.bootstrap.Popover.superclass.constructor.call(this, config);
22 };
23
24 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
25     
26     title: 'Fill in a title',
27     html: '',
28     
29     placement : 'right',
30     trigger : 'click'
31     
32     
33     getAutoCreate : function(){
34          
35         var cfg = {
36            cls : 'popover',
37            cn : [
38                 {
39                     cls : 'arrow'
40                 },
41                 {
42                     cls : 'popover-inner',
43                     cn : [
44                         {
45                             tag: 'h3',
46                             cls: 'popover-title',
47                             html : this.title
48                         },
49                         {
50                             cls : 'popover-content',
51                             html : this.html
52                         }
53                     ]
54                     
55                 }
56            ]
57         };
58         
59         return cfg;
60     },
61     // as it get's added to the bottom of the page.
62     onRender : function(ct, position)
63     {
64         Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
65         if(!this.el){
66             var cfg = Roo.apply({},  this.getAutoCreate());
67             cfg.id = Roo.id();
68             
69             if (this.cls) {
70                 cfg.cls += ' ' + this.cls;
71             }
72             if (this.style) {
73                 cfg.style = this.style;
74             }
75             this.el = Roo.get(document.body).createChild(cfg, position);
76         }
77     }
78 });
79
80  
81
82