Added find match counter

This commit is contained in:
Andy Parisi 2014-07-16 10:39:34 -04:00 committed by Yury Delendik
parent c27d3125bf
commit 17fe0b1470
5 changed files with 45 additions and 1 deletions

View file

@ -32,6 +32,7 @@ var PDFFindBar = (function PDFFindBarClosure() {
this.highlightAll = options.highlightAllCheckbox || null;
this.caseSensitive = options.caseSensitiveCheckbox || null;
this.findMsg = options.findMsg || null;
this.findResultsCount = options.findResultsCount || null;
this.findStatusIcon = options.findStatusIcon || null;
this.findPreviousButton = options.findPreviousButton || null;
this.findNextButton = options.findNextButton || null;
@ -133,6 +134,34 @@ var PDFFindBar = (function PDFFindBarClosure() {
this.findMsg.textContent = findMsg;
},
updateResultsCount: function(matches) {
if (!matches) {
return this.hideResultsCount();
}
// Loop through and add up all the matches between pages
var matchCounter = 0;
for (var i = 0, len = matches.length; i < len; i++) {
matchCounter += matches[i].length;
}
// If there are no matches, hide the counter
if (!matchCounter) {
return this.hideResultsCount();
}
// Create the match counter
this.findResultsCount.textContent = matchCounter;
// Show the counter
this.findResultsCount.classList.remove('hidden');
},
hideResultsCount: function() {
this.findResultsCount.classList.add('hidden');
},
open: function PDFFindBar_open() {
if (!this.opened) {
this.opened = true;