aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2017-06-19 09:43:29 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2017-06-19 09:43:29 +0200
commita781b6a22bbd5a2fb2b7900b216b2054da80b9ca (patch)
treea29d06e993f1eb90b729feb35fd949646106ba11 /plugin
parent7d0d3c24ca16d17034c5891e8966b33ffc2c533c (diff)
downloadperl-software-in-gnu-guix-a781b6a22bbd5a2fb2b7900b216b2054da80b9ca.tar
perl-software-in-gnu-guix-a781b6a22bbd5a2fb2b7900b216b2054da80b9ca.tar.gz
clear existing matches when searching for empty string #1909
Diffstat (limited to 'plugin')
-rw-r--r--plugin/search/search.js30
1 files changed, 19 insertions, 11 deletions
diff --git a/plugin/search/search.js b/plugin/search/search.js
index 28c2c5f..b0be2be 100644
--- a/plugin/search/search.js
+++ b/plugin/search/search.js
@@ -138,19 +138,27 @@ function Hilitor(id, tag)
if (searchboxDirty) {
var searchstring = document.getElementById("searchinput").value;
- //find the keyword amongst the slides
- myHilitor = new Hilitor("slidecontent");
- matchedSlides = myHilitor.apply(searchstring);
- currentMatchedIndex = 0;
+ if (searchstring === '') {
+ if(myHilitor) myHilitor.remove();
+ matchedSlides = null;
+ }
+ else {
+ //find the keyword amongst the slides
+ myHilitor = new Hilitor("slidecontent");
+ matchedSlides = myHilitor.apply(searchstring);
+ currentMatchedIndex = 0;
+ }
}
- //navigate to the next slide that has the keyword, wrapping to the first if necessary
- if (matchedSlides.length && (matchedSlides.length <= currentMatchedIndex)) {
- currentMatchedIndex = 0;
- }
- if (matchedSlides.length > currentMatchedIndex) {
- Reveal.slide(matchedSlides[currentMatchedIndex].h, matchedSlides[currentMatchedIndex].v);
- currentMatchedIndex++;
+ if (matchedSlides) {
+ //navigate to the next slide that has the keyword, wrapping to the first if necessary
+ if (matchedSlides.length && (matchedSlides.length <= currentMatchedIndex)) {
+ currentMatchedIndex = 0;
+ }
+ if (matchedSlides.length > currentMatchedIndex) {
+ Reveal.slide(matchedSlides[currentMatchedIndex].h, matchedSlides[currentMatchedIndex].v);
+ currentMatchedIndex++;
+ }
}
}