1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-08 22:56:46 +02:00

change above below to top bottom and add "inside" placement option

This commit is contained in:
Jacob Thornton
2011-12-22 19:10:32 -08:00
parent efacac0d6c
commit 87ac818253
8 changed files with 52 additions and 55 deletions

View File

@@ -49,7 +49,7 @@ examples:
backdrop: true
keyboard: false
placement: 'above'
placement: 'top'
---

View File

@@ -99,6 +99,7 @@
, show: function () {
var $tip
, inside
, pos
, actualWidth
, actualHeight
@@ -113,12 +114,18 @@
$tip.addClass('fade')
}
placement = typeof this.options.placement == 'function' ?
thing.call(this, $tip[0], this.$element[0]) :
this.options.placement
inside = /in/.test(placement)
$tip
.remove()
.css({ top: 0, left: 0, display: 'block' })
.prependTo(document.body)
.prependTo(inside ? this.$element : document.body)
pos = $.extend({}, this.$element.offset(), {
pos = $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
width: this.$element[0].offsetWidth
, height: this.$element[0].offsetHeight
})
@@ -126,13 +133,11 @@
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
placement = maybeCall(this.options.placement, this, [ $tip[0], this.$element[0] ])
switch (placement) {
case 'below':
switch (inside ? placement.split(' ')[1] : placement) {
case 'bottom':
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
break
case 'above':
case 'top':
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
break
case 'left':
@@ -226,14 +231,6 @@
}
/* TWIPSY PRIVATE METHODS
* ====================== */
function maybeCall ( thing, ctx, args ) {
return typeof thing == 'function' ? thing.apply(ctx, args) : thing
}
/* TWIPSY PLUGIN DEFINITION
* ======================== */
@@ -253,7 +250,7 @@
animation: true
, delay: 0
, selector: false
, placement: 'above'
, placement: 'top'
, trigger: 'hover'
, title: ''
, template: '<div class="twipsy"><div class="twipsy-arrow"></div><div class="twipsy-inner"></div></div>'