mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-21 18:54:30 +01:00
refactor/reformat Tooltip.getPosition per @fat's feedback
This commit is contained in:
parent
1ce5e9f3ae
commit
f9ffb49932
@ -316,16 +316,20 @@
|
|||||||
|
|
||||||
Tooltip.prototype.getPosition = function ($element) {
|
Tooltip.prototype.getPosition = function ($element) {
|
||||||
$element = $element || this.$element
|
$element = $element || this.$element
|
||||||
|
|
||||||
var el = $element[0]
|
var el = $element[0]
|
||||||
var isBody = el.tagName == 'BODY'
|
var isBody = el.tagName == 'BODY'
|
||||||
var isSvg = window.SVGElement && el instanceof window.SVGElement
|
var isSvg = window.SVGElement && el instanceof window.SVGElement
|
||||||
|
|
||||||
|
var elRect = typeof el.getBoundingClientRect == 'function' ? el.getBoundingClientRect() : null
|
||||||
|
var elOffset = isBody ? { top: 0, left: 0 } : $element.offset()
|
||||||
|
var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
|
||||||
var outerDims = isSvg ? {} : {
|
var outerDims = isSvg ? {} : {
|
||||||
width: isBody ? $(window).width() : $element.outerWidth(),
|
width: isBody ? $(window).width() : $element.outerWidth(),
|
||||||
height: isBody ? $(window).height() : $element.outerHeight()
|
height: isBody ? $(window).height() : $element.outerHeight()
|
||||||
}
|
}
|
||||||
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
|
|
||||||
scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop()
|
return $.extend({}, elRect, scroll, outerDims, elOffset)
|
||||||
}, outerDims, isBody ? { top: 0, left: 0 } : $element.offset())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
|
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user