From 607f1a1a33d50ff759725c8786e575c3a91500db Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Tue, 12 Feb 2019 15:55:28 -0300 Subject: [PATCH] Fix search on NC >= 14. Issue #17 --- js/script.js | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/js/script.js b/js/script.js index e624050..df9c200 100644 --- a/js/script.js +++ b/js/script.js @@ -658,41 +658,30 @@ View.prototype = { } }; -var timeoutID = null; -function filter (query) { - window.clearTimeout(timeoutID); - timeoutID = window.setTimeout(function() { - if (query) { - query = query.toLowerCase(); - $('.notes-grid').isotope({ filter: function() { +function search (query) { + if (query) { + query = query.toLowerCase(); + $('.notes-grid').isotope({ + filter: function() { var title = $(this).find(".note-title").html().toLowerCase(); if (title.search(query) >= 0) return true; + var content = $(this).find(".note-content").html().toLowerCase(); if (content.search(query) >= 0) return true; - return false; - }}); - } else { - $('.notes-grid').isotope({ filter: '*'}); - } - }, 500); -}; -var SearchProxy = { - attach: function(search) { - search.setFilter('quicknotes', this.filterProxy); - }, - filterProxy: function(query) { - filter(query); - }, - setFilter: function(newFilter) { - filter = newFilter; + return false; + } + }); + } else { + $('.notes-grid').isotope({ filter: '*'}); } }; -SearchProxy.setFilter(filter); -OC.Plugins.register('OCA.Search', SearchProxy); +new OCA.Search(search, function() { + search(''); +}); var notes = new Notes(OC.generateUrl('/apps/quicknotes/notes')); var view = new View(notes);