Clean up search

This commit is contained in:
Peter Stuifzand 2020-08-31 16:16:49 +02:00
parent 55ad112924
commit db121b4fa3

View File

@ -234,9 +234,12 @@ if (holder) {
}
}
let editor = listEditor(holder, JSON.parse(holder.dataset.input), options);
let inputData = JSON.parse(holder.dataset.input)
$(document).on('click', '.content input[type="checkbox"]', function (event) {
let editor = listEditor(holder, inputData, options);
holder.$listEditor = editor
$(holder).on('click', '.content input[type="checkbox"]', function (event) {
let that = this
let id = $(this).closest('.list-item').data('id')
editor.update(id, function (item, prev, next) {
@ -465,29 +468,21 @@ if (holder) {
let timeout = null;
let searchInput = document.getElementById('search-input');
search(searchInput).then(searcher => {
let showSearch = _.debounce(function (searcher) {
let query = $(searchInput).val()
if (query === '') {
let autocomplete = document.getElementById('autocomplete');
$(autocomplete).hide()
return false
}
$(document).on('keyup', '#search-input', function (event) {
clearTimeout(timeout);
timeout = setTimeout(function () {
let query = $(searchInput).val()
if (query === '') {
let autocomplete = document.getElementById('autocomplete');
$(autocomplete).hide()
return false
}
showSearchResultsExtended('#autocomplete', 'result-template', query => searcher.search(query), query, searchInput, query, 'search-result')
// $('#autocomplete').show()
// let result = searcher.search(query)
// const newpage = query.replace(/\s+/g, '_')
// var template = document.getElementById('result-template').innerHTML;
// var rendered = Mustache.render(template, {page: newpage, results: result}, {}, ['[[', ']]']);
// let autocomplete = document.getElementById('autocomplete');
// autocomplete.innerHTML = rendered;
}, 200)
showSearchResultsExtended('#autocomplete', 'result-template', query => searcher.search(query), query, searchInput, query, 'search-result')
return true;
}, 200)
$(searchInput).on('keyup', function (event) {
showSearch.cancel()
showSearch(searcher)
return true
})
})