Roo.bootstrap.Tooltip = function(config){
Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
+
+ this.alignment = Roo.bootstrap.Tooltip.alignment;
+
+ if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
+ this.alignment = config.alignment;
+ }
+
};
Roo.apply(Roo.bootstrap.Tooltip, {
}
-
-
if (this.currentTip.el) {
- this.currentTip.el.hide(); // force hiding...
+ this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
}
//Roo.log(ev);
+
+ if(!el || el.dom == document){
+ return;
+ }
+
var bindEl = el;
// you can not look for children, as if el is the body.. then everythign is the child..
placement : 'bottom',
+ alignment : false,
+
getAutoCreate : function(){
var cfg = {
}, delay);
},
- show : function ()
+ show : function (msg)
{
if (!this.el) {
this.render(document.body);
// set content.
//Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
- var tip = this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
+ var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
//this.el.setXY([0,0]);
this.el.show();
//this.el.dom.style.display='block';
- this.el.addClass(placement);
//this.el.appendTo(on_el);
// fixme..
}
- var align = Roo.bootstrap.Tooltip.alignment[placement];
+ var align = this.alignment[placement];
var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
if(xy[0] < 0){
placement = 'right';
}
+
+ if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
+ placement = 'left';
+ }
+
+ var scroll = Roo.select('body', true).first().getScroll();
+
+ if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
+ placement = 'top';
+ }
+
+ align = this.alignment[placement];
}
- align = Roo.bootstrap.Tooltip.alignment[placement];
-
- Roo.log(this.el);
-
-
this.el.alignTo(this.bindEl, align[0],align[1]);
//var arrow = this.el.select('.arrow',true).first();
//arrow.set(align[2],
+ this.el.addClass(placement);
+
this.el.addClass('in fade');
+
this.hoverState = null;
if (this.el.hasClass('fade')) {