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/public/index.html') 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: '', - 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 From cd21694652383a49077e15439adf717f631cdd50 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 16 Feb 2014 11:27:05 -0600 Subject: Ensure correct value gets submitted on package search typeahead Populate the form field with the chosen item before submitting the form. Signed-off-by: Dan McGee --- templates/public/index.html | 1 + 1 file changed, 1 insertion(+) (limited to 'templates/public/index.html') diff --git a/templates/public/index.html b/templates/public/index.html index 515ce582..ab836569 100644 --- a/templates/public/index.html +++ b/templates/public/index.html @@ -226,6 +226,7 @@ function setupTypeahead() { menu: '
    ', items: 10, updater: function(item) { + $('#pkgsearch-field').val(item); $('#pkgsearch-form').submit(); return item; } -- cgit v1.2.3