summaryrefslogtreecommitdiffstats
path: root/js/directive
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-03-21 12:24:39 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2015-03-21 13:36:50 +0100
commit6c2ff7efef4b316358f6b22d742a2ada2339d45c (patch)
tree09263994e75da7ebc008ba780fc653fda63c92e6 /js/directive
parent7b7b0fd5eefddf03a94274f99b8e117c9651166b (diff)
only search on enter to counter focus issues
Diffstat (limited to 'js/directive')
-rw-r--r--js/directive/NewsSearch.js16
1 files changed, 5 insertions, 11 deletions
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 <dev@bernhard-posselt.com>
* @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