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  * @cfg {String} placement how it is placed
15  * @cfg {String} trigger
16  * @cfg {String} over what (parent or empty to trigger manually.)
17  * 
18  * @constructor
19  * Create a new Popover
20  * @param {Object} config The config object
21  */
22
23 Roo.bootstrap.Popover = function(config){
24     Roo.bootstrap.Popover.superclass.constructor.call(this, config);
25 };
26
27 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component,  {
28     
29     title: 'Fill in a title',
30     html: '',
31     
32     placement : 'right',
33     trigger : 'click',
34     
35     over: 'parent',
36     
37     
38     getAutoCreate : function(){
39          
40         var cfg = {
41            cls : 'popover',
42            cn : [
43                 {
44                     cls : 'arrow'
45                 },
46                 {
47                     cls : 'popover-inner',
48                     cn : [
49                         {
50                             tag: 'h3',
51                             cls: 'popover-title',
52                             html : this.title
53                         },
54                         {
55                             cls : 'popover-content',
56                             html : this.html
57                         }
58                     ]
59                     
60                 }
61            ]
62         };
63         
64         return cfg;
65     },
66     // as it get's added to the bottom of the page.
67     onRender : function(ct, position)
68     {
69         Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
70         if(!this.el){
71             var cfg = Roo.apply({},  this.getAutoCreate());
72             cfg.id = Roo.id();
73             
74             if (this.cls) {
75                 cfg.cls += ' ' + this.cls;
76             }
77             if (this.style) {
78                 cfg.style = this.style;
79             }
80             this.el = Roo.get(document.body).createChild(cfg, position);
81         }
82     }
83 });
84
85  
86
87