From 73b96e0e580a6921868b07abeaed476c0d94a392 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Wed, 26 Sep 2012 14:09:55 -0400 Subject: [PATCH] bug fix: clear previous highlights --- web/viewer.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/viewer.js b/web/viewer.js index 80c25aafb..214b272fd 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -2365,6 +2365,18 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) { return ret; }; + this.clearMatches = function textLayerBuilder_clearMatches() { + var textDivs = this.textDivs; + + // Clear all previous highlights + textDivs.forEach(function(div) { + var spans = div.querySelectorAll('span'); + for (var i = 0, ii = spans.length; i < ii; i++) { + spans[i].className = ''; + } + }); + } + this.renderMatches = function textLayerBuilder_renderMatches(matches) { var bidiTexts = this.textContent.bidiTexts; var textDivs = this.textDivs; @@ -2372,6 +2384,8 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) { var isSelectedPage = this.pageIdx === PDFFindController.selected.pageIdx; var selectedMatchIdx = PDFFindController.selected.matchIdx; + this.clearMatches(); + var infty = { divIdx: -1, offset: undefined