1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-10-04 17:21:38 +02:00

clean up styles

This commit is contained in:
fat
2013-02-05 22:29:59 -08:00
parent 5e4db94c24
commit 4814281540
9 changed files with 151 additions and 101 deletions

View File

@@ -153,66 +153,56 @@
}
this.applyPlacement(tp, placement)
this.$element.trigger('shown')
}
}
, applyPlacement: function(offset, placement){
var $tip
, width
, height
, actualWidth
, actualHeight
, delta
, replace = false
var $tip = this.tip()
, width = $tip[0].offsetWidth
, height = $tip[0].offsetHeight
, actualWidth
, actualHeight
, delta
, replace
$tip = this.tip()
$tip
.offset(offset)
.addClass(placement)
.addClass('in')
width = $tip[0].offsetWidth
height = $tip[0].offsetHeight
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
$tip
.offset(offset)
.addClass(placement)
.addClass('in')
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
if (placement == "top" && actualHeight != height){
offset.top = offset.top + height - actualHeight
replace = true
}
if (placement == "bottom" || placement == "top"){
delta = 0
if (offset.left < 0){
delta = -offset.left * 2
offset.left = 0
$tip.offset(offset)
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) {
offset.top = offset.top + height - actualHeight
replace = true
}
this.replaceArrow(delta - width + actualWidth, actualWidth, "left")
}else{
this.replaceArrow(actualHeight - height, actualHeight, "top")
}
if (placement == 'bottom' || placement == 'top') {
delta = 0
if (replace) $tip.offset(offset)
}
if (offset.left < 0){
delta = offset.left * -2
offset.left = 0
$tip.offset(offset)
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
}
this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
} else {
this.replaceArrow(actualHeight - height, actualHeight, 'top')
}
if (replace) $tip.offset(offset)
}
, replaceArrow: function(delta, dimension, position){
var $arrow = this.arrow()
if (delta !== 0){
$arrow.css(position, 50 * (1 - delta / dimension) + "%")
}else{
$arrow.css(position, "")
this
.arrow()
.css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
}
}
, setContent: function () {
var $tip = this.tip()
@@ -287,8 +277,8 @@
}
, arrow: function(){
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
}
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
}
, validate: function () {
if (!this.$element[0].parentNode) {