mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-29 21:52:22 +01:00
fixes #8880
This commit is contained in:
parent
f22a077f6e
commit
2b6ec38987
40
dist/js/bootstrap.js
vendored
40
dist/js/bootstrap.js
vendored
@ -1245,12 +1245,9 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
|||||||
.addClass(placement)
|
.addClass(placement)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tp = placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
var calculatedOffset = this.getCalcuatedOffset(placement, pos, actualWidth, actualHeight)
|
||||||
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 }
|
|
||||||
|
|
||||||
this.applyPlacement(tp, placement)
|
this.applyPlacement(calculatedOffset, placement)
|
||||||
this.$element.trigger('shown.bs.' + this.type)
|
this.$element.trigger('shown.bs.' + this.type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1262,25 +1259,33 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
|||||||
var height = $tip[0].offsetHeight
|
var height = $tip[0].offsetHeight
|
||||||
|
|
||||||
// manually read margins because getBoundingClientRect includes difference
|
// manually read margins because getBoundingClientRect includes difference
|
||||||
offset.top = offset.top + parseInt($tip.css('margin-top'), 10)
|
var marginTop = parseInt($tip.css('margin-top'), 10)
|
||||||
offset.left = offset.left + parseInt($tip.css('margin-left'), 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
|
$tip
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.addClass('in')
|
.addClass('in')
|
||||||
|
|
||||||
|
// check to see if placing tip in new offset caused the tip to resize itself
|
||||||
var actualWidth = $tip[0].offsetWidth
|
var actualWidth = $tip[0].offsetWidth
|
||||||
var actualHeight = $tip[0].offsetHeight
|
var actualHeight = $tip[0].offsetHeight
|
||||||
|
|
||||||
if (placement == 'top' && actualHeight != height) {
|
if (placement == 'top' && actualHeight != height) {
|
||||||
replace = true
|
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
|
var delta = 0
|
||||||
|
|
||||||
if (offset.left < 0){
|
if (offset.left < 0) {
|
||||||
delta = offset.left * -2
|
delta = offset.left * -2
|
||||||
offset.left = 0
|
offset.left = 0
|
||||||
|
|
||||||
@ -1353,6 +1358,13 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
|||||||
}, this.$element.offset())
|
}, 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 () {
|
Tooltip.prototype.getTitle = function () {
|
||||||
var title
|
var title
|
||||||
var $e = this.$element
|
var $e = this.$element
|
||||||
@ -1368,8 +1380,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
|||||||
return this.$tip = this.$tip || $(this.options.template)
|
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")
|
return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.validate = function () {
|
Tooltip.prototype.validate = function () {
|
||||||
@ -1508,6 +1520,10 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
|||||||
o.content)
|
o.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Popover.prototype.arrow =function () {
|
||||||
|
return this.$arrow = this.$arrow || this.tip().find('.arrow')
|
||||||
|
}
|
||||||
|
|
||||||
Popover.prototype.tip = function () {
|
Popover.prototype.tip = function () {
|
||||||
if (!this.$tip) this.$tip = $(this.options.template)
|
if (!this.$tip) this.$tip = $(this.options.template)
|
||||||
return this.$tip
|
return this.$tip
|
||||||
|
2
dist/js/bootstrap.min.js
vendored
2
dist/js/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
@ -75,6 +75,10 @@
|
|||||||
o.content)
|
o.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Popover.prototype.arrow =function () {
|
||||||
|
return this.$arrow = this.$arrow || this.tip().find('.arrow')
|
||||||
|
}
|
||||||
|
|
||||||
Popover.prototype.tip = function () {
|
Popover.prototype.tip = function () {
|
||||||
if (!this.$tip) this.$tip = $(this.options.template)
|
if (!this.$tip) this.$tip = $(this.options.template)
|
||||||
return this.$tip
|
return this.$tip
|
||||||
|
@ -179,12 +179,9 @@
|
|||||||
.addClass(placement)
|
.addClass(placement)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tp = placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
var calculatedOffset = this.getCalcuatedOffset(placement, pos, actualWidth, actualHeight)
|
||||||
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 }
|
|
||||||
|
|
||||||
this.applyPlacement(tp, placement)
|
this.applyPlacement(calculatedOffset, placement)
|
||||||
this.$element.trigger('shown.bs.' + this.type)
|
this.$element.trigger('shown.bs.' + this.type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,25 +193,33 @@
|
|||||||
var height = $tip[0].offsetHeight
|
var height = $tip[0].offsetHeight
|
||||||
|
|
||||||
// manually read margins because getBoundingClientRect includes difference
|
// manually read margins because getBoundingClientRect includes difference
|
||||||
offset.top = offset.top + parseInt($tip.css('margin-top'), 10)
|
var marginTop = parseInt($tip.css('margin-top'), 10)
|
||||||
offset.left = offset.left + parseInt($tip.css('margin-left'), 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
|
$tip
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.addClass('in')
|
.addClass('in')
|
||||||
|
|
||||||
|
// check to see if placing tip in new offset caused the tip to resize itself
|
||||||
var actualWidth = $tip[0].offsetWidth
|
var actualWidth = $tip[0].offsetWidth
|
||||||
var actualHeight = $tip[0].offsetHeight
|
var actualHeight = $tip[0].offsetHeight
|
||||||
|
|
||||||
if (placement == 'top' && actualHeight != height) {
|
if (placement == 'top' && actualHeight != height) {
|
||||||
replace = true
|
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
|
var delta = 0
|
||||||
|
|
||||||
if (offset.left < 0){
|
if (offset.left < 0) {
|
||||||
delta = offset.left * -2
|
delta = offset.left * -2
|
||||||
offset.left = 0
|
offset.left = 0
|
||||||
|
|
||||||
@ -287,6 +292,13 @@
|
|||||||
}, this.$element.offset())
|
}, 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 () {
|
Tooltip.prototype.getTitle = function () {
|
||||||
var title
|
var title
|
||||||
var $e = this.$element
|
var $e = this.$element
|
||||||
@ -302,8 +314,8 @@
|
|||||||
return this.$tip = this.$tip || $(this.options.template)
|
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")
|
return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.validate = function () {
|
Tooltip.prototype.validate = function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user