aboutsummaryrefslogtreecommitdiff
path: root/js/bootstrap-typeahead.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2012-12-19 23:39:40 -0800
committerMark Otto <[email protected]>2012-12-19 23:39:40 -0800
commit5d776bcfd2e7da0bcce37252dc983149d8b2d377 (patch)
tree0b46eb3b33008f4d4b4ea3bd73ce82ed77218d7d /js/bootstrap-typeahead.js
parentdc6142751feced6761f67503323c0c6e62844d4e (diff)
parentbbe4625672c5122bb2b06c495f9ea41752c10467 (diff)
downloadbootstrap-5d776bcfd2e7da0bcce37252dc983149d8b2d377.tar.xz
bootstrap-5d776bcfd2e7da0bcce37252dc983149d8b2d377.zip
Merge branch '2.2.3' of github.com:twitter/bootstrap into 2.2.3
Diffstat (limited to 'js/bootstrap-typeahead.js')
-rw-r--r--js/bootstrap-typeahead.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js
index 8324e0664..8d31954b1 100644
--- a/js/bootstrap-typeahead.js
+++ b/js/bootstrap-typeahead.js
@@ -172,6 +172,7 @@
, listen: function () {
this.$element
+ .on('focus', $.proxy(this.focus, this))
.on('blur', $.proxy(this.blur, this))
.on('keypress', $.proxy(this.keypress, this))
.on('keyup', $.proxy(this.keyup, this))
@@ -183,6 +184,7 @@
this.$menu
.on('click', $.proxy(this.click, this))
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
+ .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
}
, eventSupported: function(eventName) {
@@ -256,9 +258,13 @@
e.preventDefault()
}
+ , focus: function (e) {
+ this.focused = true
+ }
+
, blur: function (e) {
- var that = this
- setTimeout(function () { that.hide() }, 150)
+ this.focused = false
+ if (!this.mousedover && this.shown) this.hide()
}
, click: function (e) {
@@ -268,10 +274,16 @@
}
, mouseenter: function (e) {
+ this.mousedover = true
this.$menu.find('.active').removeClass('active')
$(e.currentTarget).addClass('active')
}
+ , mouseleave: function (e) {
+ this.mousedover = false
+ if (!this.focused && this.shown) this.hide()
+ }
+
}