aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/README.md2
-rw-r--r--js/bootstrap-twipsy.js29
2 files changed, 14 insertions, 17 deletions
diff --git a/js/README.md b/js/README.md
index 0d8d163a2..2f8e1716f 100644
--- a/js/README.md
+++ b/js/README.md
@@ -49,7 +49,7 @@ examples:
backdrop: true
keyboard: false
- placement: 'above'
+ placement: 'top'
---
diff --git a/js/bootstrap-twipsy.js b/js/bootstrap-twipsy.js
index 018edb97e..21cf7d20b 100644
--- a/js/bootstrap-twipsy.js
+++ b/js/bootstrap-twipsy.js
@@ -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>'