Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJacob Thornton <jacobthornton@gmail.com>2012-08-19 06:54:30 +0400
committerJacob Thornton <jacobthornton@gmail.com>2012-08-19 06:54:30 +0400
commit45dddc59a19f3e9decaa4bf0e0db3f884a0f6ff7 (patch)
tree39616e8cd0f2c6b5f7c94a90a8e637ce263137c3 /js
parent44e35e9dfa33fe618218c770f0495bd9596f3485 (diff)
add click option for tooltip, popover - make click default for popover
Diffstat (limited to 'js')
-rw-r--r--js/bootstrap-popover.js1
-rw-r--r--js/bootstrap-tooltip.js6
-rw-r--r--js/tests/unit/bootstrap-popover.js2
3 files changed, 6 insertions, 3 deletions
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js
index b7883c5d2c..bbf0ba4bc2 100644
--- a/js/bootstrap-popover.js
+++ b/js/bootstrap-popover.js
@@ -95,6 +95,7 @@
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
placement: 'right'
+ , trigger: 'click'
, content: ''
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
})
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index 1e681627ad..0b3230bc1f 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/bootstrap-tooltip.js
@@ -44,8 +44,10 @@
this.options = this.getOptions(options)
this.enabled = true
- if (this.options.trigger != 'manual') {
- eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
+ 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))
diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js
index daffe215c9..04d5279d24 100644
--- a/js/tests/unit/bootstrap-popover.js
+++ b/js/tests/unit/bootstrap-popover.js
@@ -92,7 +92,7 @@ $(function () {
})
test("should destroy popover", function () {
- var popover = $('<div/>').popover().on('click.foo', function(){})
+ var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){})
ok(popover.data('popover'), 'popover has data')
ok(popover.data('events').mouseover && popover.data('events').mouseout, 'popover has hover event')
ok(popover.data('events').click[0].namespace == 'foo', 'popover has extra click.foo event')