diff options
author | Dan McGee <dan@archlinux.org> | 2014-01-27 17:27:54 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2014-01-27 17:27:54 -0600 |
commit | 7c70083ed5b7cf0fbd1f66551c088a3c963b258c (patch) | |
tree | eb220cf9fd7ceae52d72212dbc46d943526dfc1f /templates/public | |
parent | 8af4d27cd67157b4f53286913d886d8896f7010a (diff) |
Cleanups and enhancments to JS package search typeahead
Remove the need to press enter twice when using this typeahead box.
Submit the form on enter, regardless of whether an item is selected or
not.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'templates/public')
-rw-r--r-- | templates/public/index.html | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/templates/public/index.html b/templates/public/index.html index 58dd3729..515ce582 100644 --- a/templates/public/index.html +++ b/templates/public/index.html @@ -224,8 +224,18 @@ function setupTypeahead() { matcher: function(item) { return true; }, sorter: function(items) { return items; }, menu: '<ul class="pkgsearch-typeahead"></ul>', - items: 10 + items: 10, + updater: function(item) { + $('#pkgsearch-form').submit(); + return item; + } }).attr('autocomplete', 'off'); + $('#pkgsearch-field').keyup(function(e) { + if (e.keyCode === 13 && + $('ul.pkgsearch-typeahead li.active').size() === 0) { + $('#pkgsearch-form').submit(); + } + }); } function setupKonami() { var konami = new Konami(function() { |