aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorfat <[email protected]>2012-12-22 13:24:37 -0800
committerfat <[email protected]>2012-12-22 13:24:37 -0800
commitfad0fb683bdcc71f5ffc9c18300dd19427b588ae (patch)
treec0db6c6bb38e13ec266475b74dc67d1fc0c0b71c /js
parente2434fefbd9d68e79d4ecae1f41b018b2c1d4199 (diff)
downloadbootstrap-fad0fb683bdcc71f5ffc9c18300dd19427b588ae.tar.xz
bootstrap-fad0fb683bdcc71f5ffc9c18300dd19427b588ae.zip
allow multiple trigger types in tooltip and popover + default tooltip to hover & focus
Diffstat (limited to 'js')
-rw-r--r--js/bootstrap-tooltip.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index 25bba1589..adcff7017 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/bootstrap-tooltip.js
@@ -38,19 +38,27 @@
, init: function (type, element, options) {
var eventIn
, eventOut
+ , triggers
+ , trigger
+ , i
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
this.enabled = true
- if (this.options.trigger == 'click') {
- this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
- } else if (this.options.trigger != 'manual') {
- eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
- eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
- this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
- this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
+ triggers = this.options.trigger.split(' ')
+
+ for (i = triggers.length; i--;) {
+ trigger = triggers[i]
+ if (trigger == 'click') {
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
+ } else if (trigger != 'manual') {
+ eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
+ eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
+ }
}
this.options.selector ?
@@ -267,7 +275,7 @@
, placement: 'top'
, selector: false
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
- , trigger: 'hover'
+ , trigger: 'hover focus'
, title: ''
, delay: 0
, html: false