clear existing matches when searching for empty string #1909
This commit is contained in:
parent
7d0d3c24ca
commit
a781b6a22b
@ -138,12 +138,19 @@ function Hilitor(id, tag)
|
|||||||
if (searchboxDirty) {
|
if (searchboxDirty) {
|
||||||
var searchstring = document.getElementById("searchinput").value;
|
var searchstring = document.getElementById("searchinput").value;
|
||||||
|
|
||||||
|
if (searchstring === '') {
|
||||||
|
if(myHilitor) myHilitor.remove();
|
||||||
|
matchedSlides = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
//find the keyword amongst the slides
|
//find the keyword amongst the slides
|
||||||
myHilitor = new Hilitor("slidecontent");
|
myHilitor = new Hilitor("slidecontent");
|
||||||
matchedSlides = myHilitor.apply(searchstring);
|
matchedSlides = myHilitor.apply(searchstring);
|
||||||
currentMatchedIndex = 0;
|
currentMatchedIndex = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchedSlides) {
|
||||||
//navigate to the next slide that has the keyword, wrapping to the first if necessary
|
//navigate to the next slide that has the keyword, wrapping to the first if necessary
|
||||||
if (matchedSlides.length && (matchedSlides.length <= currentMatchedIndex)) {
|
if (matchedSlides.length && (matchedSlides.length <= currentMatchedIndex)) {
|
||||||
currentMatchedIndex = 0;
|
currentMatchedIndex = 0;
|
||||||
@ -153,6 +160,7 @@ function Hilitor(id, tag)
|
|||||||
currentMatchedIndex++;
|
currentMatchedIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var dom = {};
|
var dom = {};
|
||||||
dom.wrapper = document.querySelector( '.reveal' );
|
dom.wrapper = document.querySelector( '.reveal' );
|
||||||
|
Loading…
Reference in New Issue
Block a user