diff options
Diffstat (limited to 'js/bootstrap-tooltip.js')
| -rw-r--r-- | js/bootstrap-tooltip.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index b476f1c4e..4d06dfcc9 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -1,5 +1,5 @@ /* =========================================================== - * bootstrap-tooltip.js v2.0.4 + * bootstrap-tooltip.js v2.1.0 * http://twitter.github.com/bootstrap/javascript.html#tooltips * Inspired by the original jQuery.tipsy by Jason Frame * =========================================================== @@ -44,11 +44,13 @@ this.options = this.getOptions(options) this.enabled = true - if (this.options.trigger != 'manual') { - eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus' + if (this.options.trigger == 'click') { + this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) + } else if (this.options.trigger != 'manual') { + eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus' eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur' - this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this)) - this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this)) + this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) + this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) } this.options.selector ? @@ -148,20 +150,11 @@ } } - , isHTML: function(text) { - // html string detection logic adapted from jQuery - return typeof text != 'string' - || ( text.charAt(0) === "<" - && text.charAt( text.length - 1 ) === ">" - && text.length >= 3 - ) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text) - } - , setContent: function () { var $tip = this.tip() , title = this.getTitle() - $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title) + $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) $tip.removeClass('fade in top bottom left right') } @@ -185,6 +178,8 @@ $.support.transition && this.$tip.hasClass('fade') ? removeWithAnimation() : $tip.remove() + + return this } , fixTitle: function () { @@ -244,6 +239,10 @@ this[this.tip().hasClass('in') ? 'hide' : 'show']() } + , destroy: function () { + this.hide().$element.off('.' + this.type).removeData(this.type) + } + } @@ -270,6 +269,7 @@ , trigger: 'hover' , title: '' , delay: 0 + , html: true } }(window.jQuery); |
