diff options
| author | Jacob Thornton <[email protected]> | 2012-06-02 19:31:30 -0700 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2012-06-02 19:31:30 -0700 |
| commit | 0b827965d36f87feddcee1ecb3f6e2f9c6dec9dc (patch) | |
| tree | d748a162751b689e79d4679d648ba0d6e29a8e4a /js | |
| parent | 354f99f0bd8e1c2dcf9e094245b71e2587bd78c1 (diff) | |
| download | bootstrap-0b827965d36f87feddcee1ecb3f6e2f9c6dec9dc.tar.xz bootstrap-0b827965d36f87feddcee1ecb3f6e2f9c6dec9dc.zip | |
fix regression in typeahead #3313
Diffstat (limited to 'js')
| -rw-r--r-- | js/bootstrap-typeahead.js | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index ad44b9085..e5197a331 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -169,7 +169,7 @@ .on('keyup', $.proxy(this.keyup, this)) if ($.browser.webkit || $.browser.msie) { - this.$element.on('keydown', $.proxy(this.keypress, this)) + this.$element.on('keydown', $.proxy(this.keydown, this)) } this.$menu @@ -177,6 +177,40 @@ .on('mouseenter', 'li', $.proxy(this.mouseenter, this)) } + , move: function (e) { + if (!this.shown) return + + switch(e.keyCode) { + case 9: // tab + case 13: // enter + case 27: // escape + e.preventDefault() + break + + case 38: // up arrow + e.preventDefault() + this.prev() + break + + case 40: // down arrow + e.preventDefault() + this.next() + break + } + + e.stopPropagation() + } + + , keydown: function (e) { + this.suppressKeyPressRepeat = !~[40,38,9,13,27].indexOf(e.keyCode) + this.move(e) + } + + , keypress: function (e) { + if (this.suppressKeyPressRepeat) return + this.move(e) + } + , keyup: function (e) { switch(e.keyCode) { case 40: // down arrow @@ -202,32 +236,6 @@ e.preventDefault() } - , keypress: function (e) { - if (!this.shown) return - - switch(e.keyCode) { - case 9: // tab - case 13: // enter - case 27: // escape - e.preventDefault() - break - - case 38: // up arrow - if (e.type != 'keydown') break - e.preventDefault() - this.prev() - break - - case 40: // down arrow - if (e.type != 'keydown') break - e.preventDefault() - this.next() - break - } - - e.stopPropagation() - } - , blur: function (e) { var that = this setTimeout(function () { that.hide() }, 150) |
