diff options
| author | fat <[email protected]> | 2013-02-05 22:29:59 -0800 |
|---|---|---|
| committer | fat <[email protected]> | 2013-02-05 22:29:59 -0800 |
| commit | 481428154084a9fafd31d8654157d6f6f78231d0 (patch) | |
| tree | be95c0621248574864f79141c1e6103721c84354 /docs/assets/js/bootstrap-tooltip.js | |
| parent | 5e4db94c240c5ac2af18bbf4238358a043ad4037 (diff) | |
| download | bootstrap-481428154084a9fafd31d8654157d6f6f78231d0.tar.xz bootstrap-481428154084a9fafd31d8654157d6f6f78231d0.zip | |
clean up styles
Diffstat (limited to 'docs/assets/js/bootstrap-tooltip.js')
| -rw-r--r-- | docs/assets/js/bootstrap-tooltip.js | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/docs/assets/js/bootstrap-tooltip.js b/docs/assets/js/bootstrap-tooltip.js index 9ba2d1214..7a1d7254f 100644 --- a/docs/assets/js/bootstrap-tooltip.js +++ b/docs/assets/js/bootstrap-tooltip.js @@ -152,15 +152,58 @@ break } - $tip - .offset(tp) - .addClass(placement) - .addClass('in') - + this.applyPlacement(tp, placement) this.$element.trigger('shown') } } + , applyPlacement: function(offset, placement){ + var $tip = this.tip() + , width = $tip[0].offsetWidth + , height = $tip[0].offsetHeight + , actualWidth + , actualHeight + , delta + , replace + + $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 + } + + this.replaceArrow(delta - width + actualWidth, actualWidth, 'left') + } else { + this.replaceArrow(actualHeight - height, actualHeight, 'top') + } + + if (replace) $tip.offset(offset) + } + + , replaceArrow: function(delta, dimension, position){ + this + .arrow() + .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '') + } + , setContent: function () { var $tip = this.tip() , title = this.getTitle() @@ -233,6 +276,10 @@ return this.$tip = this.$tip || $(this.options.template) } + , arrow: function(){ + return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow") + } + , validate: function () { if (!this.$element[0].parentNode) { this.hide() |
