"+b+""})},render:function(b){var c=this;return b=a(b).map(function(b,d){return b=a(c.options.item).attr("data-value",d),b.find("a").html(c.highlighter(d)),b[0]}),b.first().addClass("active"),this.$menu.html(b),this},next:function(b){var c=this.$menu.find(".active").removeClass("active"),d=c.next();d.length||(d=a(this.$menu.find("li")[0])),d.addClass("active")},prev:function(a){var b=this.$menu.find(".active").removeClass("active"),c=b.prev();c.length||(c=this.$menu.find("li").last()),c.addClass("active")},listen:function(){this.$element.on("blur",a.proxy(this.blur,this)).on("keypress",a.proxy(this.keypress,this)).on("keyup",a.proxy(this.keyup,this)),(a.browser.webkit||a.browser.msie)&&this.$element.on("keydown",a.proxy(this.keydown,this)),this.$menu.on("click",a.proxy(this.click,this)).on("mouseenter","li",a.proxy(this.mouseenter,this))},move:function(a){if(!this.shown)return;switch(a.keyCode){case 9:case 13:case 27:a.preventDefault();break;case 38:a.preventDefault(),this.prev();break;case 40:a.preventDefault(),this.next()}a.stopPropagation()},keydown:function(b){this.suppressKeyPressRepeat=!~a.inArray(b.keyCode,[40,38,9,13,27]),this.move(b)},keypress:function(a){if(this.suppressKeyPressRepeat)return;this.move(a)},keyup:function(a){switch(a.keyCode){case 40:case 38:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}a.stopPropagation(),a.preventDefault()},blur:function(a){var b=this;setTimeout(function(){b.hide()},150)},click:function(a){a.stopPropagation(),a.preventDefault(),this.select()},mouseenter:function(b){this.$menu.find(".active").removeClass("active"),a(b.currentTarget).addClass("active")}},a.fn.typeahead=function(c){return this.each(function(){var d=a(this),e=d.data("typeahead"),f=typeof c=="object"&&c;e||d.data("typeahead",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.typeahead.defaults={source:[],items:8,menu:'',item:'',minLength:1},a.fn.typeahead.Constructor=b,a(function(){a("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);if(c.data("typeahead"))return;b.preventDefault(),c.typeahead(c.data())})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.options=a.extend({},a.fn.affix.defaults,c),this.$window=a(window).on("scroll.affix.data-api",a.proxy(this.checkPosition,this)),this.$element=a(b),this.checkPosition()};b.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var b=a(document).height(),c=this.$window.scrollTop(),d=this.$element.offset(),e=this.options.offset,f=e.bottom,g=e.top,h="affix affix-top affix-bottom",i;typeof e!="object"&&(f=g=e),typeof g=="function"&&(g=e.top()),typeof f=="function"&&(f=e.bottom()),i=this.unpin!=null&&c+this.unpin<=d.top?!1:f!=null&&d.top+this.$element.height()>=b-f?"bottom":g!=null&&c<=g?"top":!1;if(this.affixed===i)return;this.affixed=i,this.unpin=i=="bottom"?d.top-c:null,this.$element.removeClass(h).addClass("affix"+(i?"-"+i:""))},a.fn.affix=function(c){return this.each(function(){var d=a(this),e=d.data("affix"),f=typeof c=="object"&&c;e||d.data("affix",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.affix.Constructor=b,a.fn.affix.defaults={offset:0},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var b=a(this),c=b.data();c.offset=c.offset||{},c.offsetBottom&&(c.offset.bottom=c.offsetBottom),c.offsetTop&&(c.offset.top=c.offsetTop),b.affix(c)})})}(window.jQuery);
\ No newline at end of file
diff --git a/docs/javascript.html b/docs/javascript.html
index 31ad87eddae1..3a207dd48479 100644
--- a/docs/javascript.html
+++ b/docs/javascript.html
@@ -566,7 +566,7 @@ three
Usage
Via data attributes
- To easily add scrollspy behavior to your topbar navigation, just add data-spy="scroll"
to the element you want to spy on (most typically this would be the body) and data-target=".navbar"
to select which nav to use. You'll want to scrollspy with the .nav
class.
+ To easily add scrollspy behavior to your topbar navigation, just add data-spy="scroll"
to the element you want to spy on (most typically this would be the body) and data-target=".navbar"
to select which nav to use. You'll want to use scrollspy with a .nav
component.
<body data-spy="scroll" data-target=".navbar">...</body>
Via JavaScript
@@ -829,7 +829,7 @@ Options
trigger |
string |
'hover' |
- how tooltip is triggered - hover | focus | manual |
+ how tooltip is triggered - click | hover | focus | manual |
delay |
@@ -922,7 +922,7 @@ Popover left
Live demo
@@ -972,8 +972,8 @@ Options
trigger |
string |
- 'hover' |
- how popover is triggered - hover | focus | manual |
+ 'click' |
+ how popover is triggered - click | hover | focus | manual |
title |
diff --git a/docs/templates/pages/javascript.mustache b/docs/templates/pages/javascript.mustache
index b419fb3142a1..c91ed3eb028b 100644
--- a/docs/templates/pages/javascript.mustache
+++ b/docs/templates/pages/javascript.mustache
@@ -759,7 +759,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
{{_i}}trigger{{/i}} |
{{_i}}string{{/i}} |
'hover' |
- {{_i}}how tooltip is triggered{{/i}} - hover | focus | manual |
+ {{_i}}how tooltip is triggered{{/i}} - click | hover | focus | manual |
{{_i}}delay{{/i}} |
@@ -852,7 +852,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
Live demo
@@ -902,8 +902,8 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
{{_i}}trigger{{/i}} |
{{_i}}string{{/i}} |
- 'hover' |
- {{_i}}how popover is triggered{{/i}} - hover | focus | manual |
+ 'click' |
+ {{_i}}how popover is triggered{{/i}} - click | hover | focus | manual |
{{_i}}title{{/i}} |
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js
index b7883c5d2c0d..bbf0ba4bc2ee 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: ''
})
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index 1e681627ad85..0b3230bc1f9c 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 daffe215c994..04d5279d24aa 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 = $('').popover().on('click.foo', function(){})
+ var popover = $('').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')