From 6c2ff7efef4b316358f6b22d742a2ada2339d45c Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sat, 21 Mar 2015 12:24:39 +0100 Subject: only search on enter to counter focus issues --- js/directive/NewsSearch.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'js/directive/NewsSearch.js') diff --git a/js/directive/NewsSearch.js b/js/directive/NewsSearch.js index 4005c2db7..cee956109 100644 --- a/js/directive/NewsSearch.js +++ b/js/directive/NewsSearch.js @@ -7,11 +7,9 @@ * @author Bernhard Posselt * @copyright Bernhard Posselt 2014 */ -app.directive('newsSearch', function ($document, $timeout, $location) { +app.directive('newsSearch', function ($document, $location) { 'use strict'; - var timer; - return { restrict: 'E', scope: { @@ -21,17 +19,13 @@ app.directive('newsSearch', function ($document, $timeout, $location) { var box = $('#searchbox'); box.val($location.search().search); - box.on('search keyup', function () { - var value = $(this).val(); - if (timer) { - $timeout.cancel(timer); - } - - timer = $timeout(function () { + box.on('keyup', function (e) { + if (e.keyCode === 13) { + var value = $(this).val(); scope.$apply(function () { scope.onSearch(value); }); - }, 500); + } }); // carry over search on route change -- cgit v1.2.3