This commit is contained in:
matcornic 2017-04-23 12:35:11 +02:00
parent c42f7aa6c1
commit 797ac73ff9
2 changed files with 2 additions and 15 deletions

View file

@ -1,6 +1,6 @@
<div class="searchbox">
<label for="search-by"><i class="fa fa-search"></i></label>
<input id="search-by" type="text" placeholder="Search">
<input data-search-input id="search-by" type="text" placeholder="Search">
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="{{ .Site.BaseURL }}/js/lunr.min.js"></script>

View file

@ -139,20 +139,7 @@ jQuery(document).ready(function() {
$(".highlightable").unhighlight({ element: 'mark' }).highlight(value, { element: 'mark' });
if (ajax && ajax.abort) ajax.abort();
ajax = jQuery.ajax({
url: input.data('search-input') + ':' + value
}).done(function(data) {
if (data && data.results && data.results.length) {
items.css('display', 'none');
$('ul.topics').addClass('searched');
data.results.forEach(function(navitem) {
jQuery('[data-nav-id="' + navitem + '"]').css('display', 'block').addClass('search-match');
jQuery('[data-nav-id="' + navitem + '"]').parents('li').css('display', 'block');
});
}
;
});
jQuery('[data-search-clear]').on('click', function() {
jQuery('[data-search-input]').val('').trigger('input');
sessionStorage.removeItem('search-input');