From ccd4c9d7b5f90cbbef7f2c9d6b9b3dec615185fc Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 31 Jul 2013 22:28:05 -0700 Subject: fixes #8864 --- js/tooltip.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index a954923be..30e3ae140 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -249,6 +249,8 @@ var $tip = this.tip() var e = $.Event('hide.bs.' + this.type) + function complete() { $tip.detach() } + this.$element.trigger(e) if (e.isDefaultPrevented()) return @@ -257,9 +259,9 @@ $.support.transition && this.$tip.hasClass('fade') ? $tip - .one($.support.transition.end, $tip.detach) + .one($.support.transition.end, complete) .emulateTransitionEnd(150) : - $tip.detach() + complete() this.$element.trigger('hidden.bs.' + this.type) -- cgit v1.2.3 From 2b6ec389876fac116ae2a152e47be321632dd9ba Mon Sep 17 00:00:00 2001 From: fat Date: Sun, 4 Aug 2013 17:22:49 -0700 Subject: fixes #8880 --- js/tooltip.js | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index 30e3ae140..3f9df0340 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -179,12 +179,9 @@ .addClass(placement) } - var tp = placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : - placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : - placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : - /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } + var calculatedOffset = this.getCalcuatedOffset(placement, pos, actualWidth, actualHeight) - this.applyPlacement(tp, placement) + this.applyPlacement(calculatedOffset, placement) this.$element.trigger('shown.bs.' + this.type) } } @@ -196,25 +193,33 @@ var height = $tip[0].offsetHeight // manually read margins because getBoundingClientRect includes difference - offset.top = offset.top + parseInt($tip.css('margin-top'), 10) - offset.left = offset.left + parseInt($tip.css('margin-left'), 10) + var marginTop = parseInt($tip.css('margin-top'), 10) + var marginLeft = parseInt($tip.css('margin-left'), 10) + + // we must check for NaN for ie 8/9 + if (isNaN(marginTop)) marginTop = 0 + if (isNaN(marginLeft)) marginLeft = 0 + + offset.top = offset.top + marginTop + offset.left = offset.left + marginLeft $tip .offset(offset) .addClass('in') + // check to see if placing tip in new offset caused the tip to resize itself var actualWidth = $tip[0].offsetWidth var actualHeight = $tip[0].offsetHeight if (placement == 'top' && actualHeight != height) { replace = true - offset.top = offset.top + height - actualHeight + offset.top = offset.top + height - actualHeight } - if (placement == 'bottom' || placement == 'top') { + if (/bottom|top/.test(placement)) { var delta = 0 - if (offset.left < 0){ + if (offset.left < 0) { delta = offset.left * -2 offset.left = 0 @@ -287,6 +292,13 @@ }, this.$element.offset()) } + Tooltip.prototype.getCalcuatedOffset = function (placement, pos, actualWidth, actualHeight) { + return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : + placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : + placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : + /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } + } + Tooltip.prototype.getTitle = function () { var title var $e = this.$element @@ -302,8 +314,8 @@ return this.$tip = this.$tip || $(this.options.template) } - Tooltip.prototype.arrow =function(){ - return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow") + Tooltip.prototype.arrow =function () { + return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow') } Tooltip.prototype.validate = function () { -- cgit v1.2.3 From 180034a4b450fb4a6567d6dbaaeb680905d798c4 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sun, 4 Aug 2013 17:36:08 -0700 Subject: tooltip.js: add missing space --- js/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index 3f9df0340..8f2beedce 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -314,7 +314,7 @@ return this.$tip = this.$tip || $(this.options.template) } - Tooltip.prototype.arrow =function () { + Tooltip.prototype.arrow = function () { return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow') } -- cgit v1.2.3 From f86f6ee9555819468467d48387becf80c831d34f Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Thu, 8 Aug 2013 13:29:46 -0700 Subject: fix 'Calcuated' typo & run grunt; thanks @FagnerMartinsBrack fixes typo introduced in 2b6ec389876fac116ae2a152e47be321632dd9ba --- js/tooltip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index 8f2beedce..cd4ee50ed 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -179,7 +179,7 @@ .addClass(placement) } - var calculatedOffset = this.getCalcuatedOffset(placement, pos, actualWidth, actualHeight) + var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) this.applyPlacement(calculatedOffset, placement) this.$element.trigger('shown.bs.' + this.type) @@ -292,7 +292,7 @@ }, this.$element.offset()) } - Tooltip.prototype.getCalcuatedOffset = function (placement, pos, actualWidth, actualHeight) { + Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : -- cgit v1.2.3 From 1abb7947c2b24041efe02ae8e243e62e6afeb2c8 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 10 Aug 2013 14:09:05 -0700 Subject: fixes #9222 --- js/tooltip.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index cd4ee50ed..eedadcbe9 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -64,7 +64,7 @@ var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus' var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur' - this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, 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)) } } @@ -91,16 +91,20 @@ return options } - Tooltip.prototype.enter = function (obj) { - var defaults = this.getDefaults() + Tooltip.prototype.getDelegateOptions = function () { var options = {} + var defaults = this.getDefaults() this._options && $.each(this._options, function (key, value) { if (defaults[key] != value) options[key] = value }) + return options + } + + Tooltip.prototype.enter = function (obj) { var self = obj instanceof this.constructor ? - obj : $(obj.currentTarget)[this.type](options).data('bs.' + this.type) + obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) clearTimeout(self.timeout) @@ -114,7 +118,7 @@ Tooltip.prototype.leave = function (obj) { var self = obj instanceof this.constructor ? - obj : $(obj.currentTarget)[this.type](this._options).data('bs.' + this.type) + obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) clearTimeout(self.timeout) @@ -339,7 +343,7 @@ } Tooltip.prototype.toggle = function (e) { - var self = e ? $(e.currentTarget)[this.type](this._options).data('bs.' + this.type) : this + var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this self.tip().hasClass('in') ? self.leave(self) : self.enter(self) } -- cgit v1.2.3 From bf2ab457eae6d54954b8e2a22596bcdd216d0ca5 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sun, 11 Aug 2013 14:59:39 -0700 Subject: fix comment in tooltip --- js/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index eedadcbe9..e0732a5a9 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -1,6 +1,6 @@ /* ======================================================================== * Bootstrap: tooltip.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#affix + * http://twbs.github.com/bootstrap/javascript.html#tooltip * Inspired by the original jQuery.tipsy by Jason Frame * ======================================================================== * Copyright 2012 Twitter, Inc. -- cgit v1.2.3