diff options
Diffstat (limited to 'js/directive')
-rw-r--r-- | js/directive/NewsSearch.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/js/directive/NewsSearch.js b/js/directive/NewsSearch.js new file mode 100644 index 000000000..f09375c27 --- /dev/null +++ b/js/directive/NewsSearch.js @@ -0,0 +1,35 @@ +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright Bernhard Posselt 2014 + */ +app.directive('newsSearch', function ($timeout) { + 'use strict'; + + var timer; + + return { + restrict: 'E', + scope: { + 'onSearch': '=' + }, + link: function (scope) { + $('#searchbox').on('search keyup', function () { + var value = $(this).val(); + if (timer) { + $timeout.cancel(timer); + } + + timer = $timeout(function () { + scope.$apply(function () { + scope.onSearch(value); + }); + }, 500); + }); + } + }; +});
\ No newline at end of file |