qtip2
Version:
Introducing... qTip2. The second generation of the advanced qTip plugin for the ever popular jQuery framework.
45 lines (35 loc) • 1.19 kB
JavaScript
PROTOTYPE.focus = function(event) {
if(!this.rendered || this.destroyed) { return this; }
var qtips = $(SELECTOR),
tooltip = this.tooltip,
curIndex = parseInt(tooltip[0].style.zIndex, 10),
newIndex = QTIP.zindex + qtips.length;
// Only update the z-index if it has changed and tooltip is not already focused
if(!tooltip.hasClass(CLASS_FOCUS)) {
// tooltipfocus event
if(this._trigger('focus', [newIndex], event)) {
// Only update z-index's if they've changed
if(curIndex !== newIndex) {
// Reduce our z-index's and keep them properly ordered
qtips.each(function() {
if(this.style.zIndex > curIndex) {
this.style.zIndex = this.style.zIndex - 1;
}
});
// Fire blur event for focused tooltip
qtips.filter('.' + CLASS_FOCUS).qtip('blur', event);
}
// Set the new z-index
tooltip.addClass(CLASS_FOCUS)[0].style.zIndex = newIndex;
}
}
return this;
};
PROTOTYPE.blur = function(event) {
if(!this.rendered || this.destroyed) { return this; }
// Set focused status to FALSE
this.tooltip.removeClass(CLASS_FOCUS);
// tooltipblur event
this._trigger('blur', [ this.tooltip.css('zIndex') ], event);
return this;
};