From 7c70083ed5b7cf0fbd1f66551c088a3c963b258c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 27 Jan 2014 17:27:54 -0600 Subject: 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 --- templates/public/index.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/public/index.html b/templates/public/index.html index 58dd372..515ce58 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: '', - 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() { -- cgit v1.2.3-24-g4f1b