From dca8afa333f47dcdaf44162d66a0ac18f9ea126b Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Fri, 25 Jul 2014 18:33:43 +0200 Subject: Remove `aria-describedby` attribute later Fixes #14241 --- js/tooltip.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index 0758b07ee..8a3c2b346 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -281,11 +281,11 @@ var $tip = this.tip() var e = $.Event('hide.bs.' + this.type) - this.$element.removeAttr('aria-describedby') - function complete() { if (that.hoverState != 'in') $tip.detach() - that.$element.trigger('hidden.bs.' + that.type) + that.$element + .removeAttr('aria-describedby') + .trigger('hidden.bs.' + that.type) } this.$element.trigger(e) -- cgit v1.2.3 From ea0e1606dc8f6a351c850a3e51889872c0f07c31 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 4 Aug 2014 10:04:00 -0700 Subject: Assume Element.getBoundingClientRect() exists; Fixes #14093 [skip validator] --- 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 0758b07ee..e730db6e9 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -323,7 +323,7 @@ var isBody = el.tagName == 'BODY' var isSvg = window.SVGElement && el instanceof window.SVGElement - var elRect = el.getBoundingClientRect ? el.getBoundingClientRect() : null + var elRect = el.getBoundingClientRect() var elOffset = isBody ? { top: 0, left: 0 } : $element.offset() var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() } var outerDims = isSvg ? {} : { -- cgit v1.2.3 From aac0e16452301a4735a668dc228b6b084b2d63d0 Mon Sep 17 00:00:00 2001 From: Scott Gonyea Date: Mon, 4 Aug 2014 13:03:11 -0700 Subject: Fix hover-tooltip flickering when mouse re-enters - is(':visible') seems to be the only reliable check, without a refactoring of how hoverState is used - tests need improvement --- js/tooltip.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index 0758b07ee..1444a7131 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -105,6 +105,11 @@ var self = obj instanceof this.constructor ? obj : $(obj.currentTarget).data('bs.' + this.type) + if (self && self.$tip && self.$tip.is(':visible')) { + self.hoverState = 'in' + return + } + if (!self) { self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) $(obj.currentTarget).data('bs.' + this.type, self) -- cgit v1.2.3 From 989dafb153c927645c1afe93c7184b535a321038 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sat, 30 Aug 2014 13:02:05 -0700 Subject: Handle lack of .width and .height from getBoundingClientRect() in IE8 Closes #14093 Correction to #14090 Relevant docs: https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClientRect#Browser_compatibility --- js/tooltip.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index e730db6e9..93e21e691 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -324,6 +324,10 @@ var isSvg = window.SVGElement && el instanceof window.SVGElement var elRect = el.getBoundingClientRect() + if (elRect.width == null) { + // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093 + elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top }) + } var elOffset = isBody ? { top: 0, left: 0 } : $element.offset() var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() } var outerDims = isSvg ? {} : { -- cgit v1.2.3 From 759a95b0fe57a07dad61786a920a860311261adb Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Tue, 9 Sep 2014 03:03:14 +0200 Subject: Make inDom check of tooltip cross document compatible Fixes #14483 --- 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 a85d0bd7b..aa6202f50 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -152,7 +152,7 @@ if (this.hasContent() && this.enabled) { this.$element.trigger(e) - var inDom = $.contains(document.documentElement, this.$element[0]) + var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0]) if (e.isDefaultPrevented() || !inDom) return var that = this -- cgit v1.2.3 From 76762169c359b381f70fa518daef09e76b0aefe3 Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Tue, 9 Sep 2014 00:17:32 +0200 Subject: Properly fire hidden event when tooltip is destroyed Fixes #13031. --- js/tooltip.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index 5192d38fc..1e10af27f 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -281,7 +281,7 @@ $tip.removeClass('fade in top bottom left right') } - Tooltip.prototype.hide = function () { + Tooltip.prototype.hide = function (callback) { var that = this var $tip = this.tip() var e = $.Event('hide.bs.' + this.type) @@ -291,6 +291,7 @@ that.$element .removeAttr('aria-describedby') .trigger('hidden.bs.' + that.type) + callback && callback() } this.$element.trigger(e) @@ -438,8 +439,11 @@ } Tooltip.prototype.destroy = function () { + var that = this clearTimeout(this.timeout) - this.hide().$element.off('.' + this.type).removeData('bs.' + this.type) + this.hide(function () { + that.$element.off('.' + that.type).removeData('bs.' + that.type) + }) } -- cgit v1.2.3 From 4c9850701069954375b19e19bd1513654130eacf Mon Sep 17 00:00:00 2001 From: Peter West Date: Tue, 3 Jun 2014 16:02:06 +0100 Subject: Correctly selects arrow placement for a tooltip Fixes #13696. Fixes #13696. Fixes #14197. Closes #13718. --- js/tooltip.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index 1e10af27f..614f41451 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -261,16 +261,18 @@ if (delta.left) offset.left += delta.left else offset.top += delta.top - var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight - var arrowPosition = delta.left ? 'left' : 'top' - var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight' + var isVertical = /top|bottom/.test(placement) + var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight + var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight' $tip.offset(offset) - this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition) + this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical) } - Tooltip.prototype.replaceArrow = function (delta, dimension, position) { - this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '') + Tooltip.prototype.replaceArrow = function (delta, dimension, isHorizontal) { + this.arrow() + .css(isHorizontal ? 'left' : 'top', 50 * (1 - delta / dimension) + '%') + .css(isHorizontal ? 'top' : 'left', '') } Tooltip.prototype.setContent = function () { -- cgit v1.2.3 From e094d470d4c679a43b5678363c7078674de56490 Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Sat, 13 Sep 2014 09:39:15 +0200 Subject: Remove unused Tooltip#validate method --- js/tooltip.js | 8 -------- 1 file changed, 8 deletions(-) (limited to 'js/tooltip.js') diff --git a/js/tooltip.js b/js/tooltip.js index 614f41451..7194b5d01 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -407,14 +407,6 @@ return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')) } - Tooltip.prototype.validate = function () { - if (!this.$element[0].parentNode) { - this.hide() - this.$element = null - this.options = null - } - } - Tooltip.prototype.enable = function () { this.enabled = true } -- cgit v1.2.3