summaryrefslogtreecommitdiffstats
path: root/js/directive
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-03-21 00:50:52 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2015-03-21 13:36:50 +0100
commitc0e6ca12e83e27b2ef86a58f9a44c0248e711a75 (patch)
treec3710a516ca17aa99e46112c2a911985174fec28 /js/directive
parentdde0b1c0e72e7ffa9ef1ea01246effc50eff9667 (diff)
implement clientside search code
Diffstat (limited to 'js/directive')
-rw-r--r--js/directive/NewsSearch.js35
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