Fix search on NC >= 14. Issue #17

This commit is contained in:
Matias De lellis
2019-02-12 15:55:28 -03:00
parent 2245c7f00f
commit 607f1a1a33

View File

@@ -658,41 +658,30 @@ View.prototype = {
} }
}; };
var timeoutID = null; function search (query) {
function filter (query) {
window.clearTimeout(timeoutID);
timeoutID = window.setTimeout(function() {
if (query) { if (query) {
query = query.toLowerCase(); query = query.toLowerCase();
$('.notes-grid').isotope({ filter: function() { $('.notes-grid').isotope({
filter: function() {
var title = $(this).find(".note-title").html().toLowerCase(); var title = $(this).find(".note-title").html().toLowerCase();
if (title.search(query) >= 0) if (title.search(query) >= 0)
return true; return true;
var content = $(this).find(".note-content").html().toLowerCase(); var content = $(this).find(".note-content").html().toLowerCase();
if (content.search(query) >= 0) if (content.search(query) >= 0)
return true; return true;
return false; return false;
}}); }
});
} else { } else {
$('.notes-grid').isotope({ filter: '*'}); $('.notes-grid').isotope({ filter: '*'});
} }
}, 500);
}; };
var SearchProxy = { new OCA.Search(search, function() {
attach: function(search) { search('');
search.setFilter('quicknotes', this.filterProxy); });
},
filterProxy: function(query) {
filter(query);
},
setFilter: function(newFilter) {
filter = newFilter;
}
};
SearchProxy.setFilter(filter);
OC.Plugins.register('OCA.Search', SearchProxy);
var notes = new Notes(OC.generateUrl('/apps/quicknotes/notes')); var notes = new Notes(OC.generateUrl('/apps/quicknotes/notes'));
var view = new View(notes); var view = new View(notes);