diff options
| author | Mark Otto <[email protected]> | 2012-10-29 22:01:58 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2012-10-29 22:01:58 -0700 |
| commit | b5af762ef59e1fa97f4386f5feadb67aa5183fef (patch) | |
| tree | 3bcd0841e6938379e8c8ae7259ee16f27a49ea41 /docs/assets/js/bootstrap-typeahead.js | |
| parent | 7426ced0fb288a9e86f18da1849ad74f652d219a (diff) | |
| parent | 68cfedb34af198f178128f8c9bc8ea164e44304a (diff) | |
| download | bootstrap-2.2.0.tar.xz bootstrap-2.2.0.zip | |
Merge branch '2.1.2-wip'v2.2.0
Conflicts:
js/bootstrap-dropdown.js
Diffstat (limited to 'docs/assets/js/bootstrap-typeahead.js')
| -rw-r--r-- | docs/assets/js/bootstrap-typeahead.js | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/docs/assets/js/bootstrap-typeahead.js b/docs/assets/js/bootstrap-typeahead.js index c2ccdea21..3c8416f8c 100644 --- a/docs/assets/js/bootstrap-typeahead.js +++ b/docs/assets/js/bootstrap-typeahead.js @@ -1,5 +1,5 @@ /* ============================================================= - * bootstrap-typeahead.js v2.1.1 + * bootstrap-typeahead.js v2.2.0 * http://twitter.github.com/bootstrap/javascript.html#typeahead * ============================================================= * Copyright 2012 Twitter, Inc. @@ -174,7 +174,7 @@ .on('keypress', $.proxy(this.keypress, this)) .on('keyup', $.proxy(this.keyup, this)) - if ($.browser.chrome || $.browser.webkit || $.browser.msie) { + if (this.eventSupported('keydown')) { this.$element.on('keydown', $.proxy(this.keydown, this)) } @@ -183,6 +183,15 @@ .on('mouseenter', 'li', $.proxy(this.mouseenter, this)) } + , eventSupported: function(eventName) { + var isSupported = eventName in this.$element + if (!isSupported) { + this.$element.setAttribute(eventName, 'return;') + isSupported = typeof this.$element[eventName] === 'function' + } + return isSupported + } + , move: function (e) { if (!this.shown) return @@ -221,6 +230,9 @@ switch(e.keyCode) { case 40: // down arrow case 38: // up arrow + case 16: // shift + case 17: // ctrl + case 18: // alt break case 9: // tab @@ -288,13 +300,11 @@ /* TYPEAHEAD DATA-API * ================== */ - $(function () { - $('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { - var $this = $(this) - if ($this.data('typeahead')) return - e.preventDefault() - $this.typeahead($this.data()) - }) + $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { + var $this = $(this) + if ($this.data('typeahead')) return + e.preventDefault() + $this.typeahead($this.data()) }) }(window.jQuery); |
