9 * @class Roo.bootstrap.Popover
10 * @extends Roo.bootstrap.Component
11 * Bootstrap Element class
12 * @cfg {String} html contents of the popover (or false to use children..)
13 * @cfg {String} title of popover (or false to hide)
14 * @cfg {String} placement how it is placed
15 * @cfg {String} trigger (or false to trigger manually)
16 * @cfg {String} over what (parent or false to trigger manually.)
19 * Create a new Popover
20 * @param {Object} config The config object
23 Roo.bootstrap.Popover = function(config){
24 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
27 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
29 title: 'Fill in a title',
37 getChildContainer : function()
39 return this.el.select('.popover-content',true).first();
42 getAutoCreate : function(){
51 cls : 'popover-inner',
59 cls : 'popover-content',
70 // as it get's added to the bottom of the page.
71 onRender : function(ct, position)
73 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
75 var cfg = Roo.apply({}, this.getAutoCreate());
79 cfg.cls += ' ' + this.cls;
82 cfg.style = this.style;
84 this.el = Roo.get(document.body).createChild(cfg, position);
89 initEvents : function()
91 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
92 this.el.setVisibilityMode(Roo.Element.DISPLAY);
97 if (this.triggers === false) {
100 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
101 var triggers = this.trigger.split(' ');
102 Roo.each(triggers, function(trigger) {
104 if (trigger == 'click') {
105 this.on_el.on('click', this.toggle, this);
106 } else if (trigger != 'manual') {
107 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
108 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
110 this.on_el.on(eventIn ,this.enter, this);
111 this.$element.on(eventOut, this.leave, this);
122 toggle : function () {
123 this.hoverState == 'in' ? this.leave() : this.enter();
126 enter : function () {
129 clearTimeout(this.timeout);
131 this.hoverState = 'in'
133 if (!this.delay || !this.delay.show) {
138 this.timeout = setTimeout(function () {
139 if (_t.hoverState == 'in') {
145 clearTimeout(this.timeout);
147 this.hoverState = 'out'
149 if (!this.delay || !this.delay.hide) {
154 this.timeout = setTimeout(function () {
155 if (_t.hoverState == 'out') {
161 show : function (on_el)
164 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
167 this.el.select('.popover-title').dom.innerHtml = this.title;
168 if (this.html !== false) {
169 this.el.select('.popover-content',true).dom.innerHtml = this.title;
171 this.el.removeClass('fade top bottom left right in');
172 if (!this.title.length) {
173 this.el.select('.popover-title',true).hide();
176 var placement = typeof this.placement == 'function' ?
177 this.placement.call(this, this.el, on_el) :
180 var autoToken = /\s?auto?\s?/i;
181 var autoPlace = autoToken.test(placement);
183 placement = placement.replace(autoToken, '') || 'top';
187 this.el.setXY([0,0]);