mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-08 11:48:26 -04:00
Remove timeout for findInArticle event listener #65
Former-commit-id: a006135103d6d7154a604a9bb0b8a890cb01f5d9 [formerly fa190c94afe28011b0c57851684501285dfc0e4e] Former-commit-id: 74626580a2597bef7340bcedd43f11f03f2d5bd7
This commit is contained in:
parent
8b722362cc
commit
97b799108d
@ -316,8 +316,6 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
localSearch.setMatchType('left');
|
||||
var timer = null;
|
||||
findInArticle.addEventListener('keyup', function (e) {
|
||||
//Ensure timeout doesn't occur if another key has been pressed within time window
|
||||
clearTimeout(timer);
|
||||
//If user pressed Alt-F or Ctrl-F, exit
|
||||
if ((e.altKey || e.ctrlKey) && e.which == 70) return;
|
||||
var val = this.value;
|
||||
@ -333,24 +331,22 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
if (~(val.length - 2)) {
|
||||
localSearch.scrollFrom = 0;
|
||||
localSearch.lastScrollValue = val;
|
||||
timer = setTimeout(function () {
|
||||
localSearch.apply(val);
|
||||
if (val.length) {
|
||||
var fullTotal = localSearch.countFullMatches(val);
|
||||
var partialTotal = localSearch.countPartialMatches();
|
||||
fullTotal = fullTotal > partialTotal ? partialTotal : fullTotal;
|
||||
document.getElementById('matches').innerHTML = '<a id="scrollLink" href="#">Full: ' + fullTotal + '</a>';
|
||||
document.getElementById('partial').innerHTML = "Partial: " + partialTotal;
|
||||
document.getElementById('scrollLink').addEventListener('click', function () {
|
||||
localSearch.scrollFrom = localSearch.scrollToFullMatch(val, localSearch.scrollFrom);
|
||||
});
|
||||
//Auto-scroll: TODO - consider making this an option
|
||||
localSearch.apply(val);
|
||||
if (val.length) {
|
||||
var fullTotal = localSearch.countFullMatches(val);
|
||||
var partialTotal = localSearch.countPartialMatches();
|
||||
fullTotal = fullTotal > partialTotal ? partialTotal : fullTotal;
|
||||
document.getElementById('matches').innerHTML = '<a id="scrollLink" href="#">Full: ' + fullTotal + '</a>';
|
||||
document.getElementById('partial').innerHTML = "Partial: " + partialTotal;
|
||||
document.getElementById('scrollLink').addEventListener('click', function () {
|
||||
localSearch.scrollFrom = localSearch.scrollToFullMatch(val, localSearch.scrollFrom);
|
||||
} else {
|
||||
document.getElementById('matches').innerHTML = "Full: 0";
|
||||
document.getElementById('partial').innerHTML = "Partial: 0";
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
//Auto-scroll: TODO - consider making this an option
|
||||
localSearch.scrollFrom = localSearch.scrollToFullMatch(val, localSearch.scrollFrom);
|
||||
} else {
|
||||
document.getElementById('matches').innerHTML = "Full: 0";
|
||||
document.getElementById('partial').innerHTML = "Partial: 0";
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user