From: Vincent Vanwaelscappel Date: Wed, 28 Jan 2026 16:08:38 +0000 (+0100) Subject: wait #7951 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=936ca7f4b3c5ab6c1de6e50ad4bfc4f1dc0a716a;p=fluidbook-html5.git wait #7951 @2 --- diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index 791fe678..94118c4e 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -683,6 +683,7 @@ FluidbookSearch.prototype = { }, highlightOccurence: function (position, word, term, color, offset) { + let $this = this; if (word == term) { width = position.width; x = 0; @@ -716,17 +717,46 @@ FluidbookSearch.prototype = { if (position.rotation) { transform.rotate = -position.rotation + 'deg'; } - var hash = coords.top + '|' + coords.left + '|' + coords.width + '|' + coords.height; - if ($('[data-hash="' + hash + '"]').length > 0) { - return; - } - $(h).attr('data-hash', hash); - $(h).css(coords).transform(transform); - if (this.fluidbook.elasticslide.isActive()) { - $(".page.current .searchHighlights").append(h); + + let allCoords = []; + + if (this.fluidbook.settings.highlightMode !== undefined && this.fluidbook.settings.highlightMode === 'links') { + $(".linksHolder>div.link").each(function () { + let o = 0; + if ($this.fluidbook.displayOnePage === false && $(this).closest('.container').hasClass('rightContainer')) { + o = parseFloat($this.fluidbook.settings.width); + } + + let rLink = { + top: parseFloat($(this).css('top')), + left: parseFloat($(this).css('left')) + o, + width: parseFloat($(this).css('width')), + height: parseFloat($(this).css('height')) + }; + if (intersectRect(coords, rLink)) { + allCoords.push(rLink); + } + }); + if (allCoords.length === 0) { + allCoords.push(coords); + } } else { - $("#searchHighlights").append(h); + allCoords.push(coords); } + + $.each(allCoords, function (i, coords) { + var hash = coords.top + '|' + coords.left + '|' + coords.width + '|' + coords.height; + if ($('[data-hash="' + hash + '"]').length > 0) { + return; + } + $(h).attr('data-hash', hash); + $(h).css(coords).transform(transform); + if ($this.fluidbook.elasticslide.isActive()) { + $(".page.current .searchHighlights").append(h); + } else { + $("#searchHighlights").append(h); + } + }); }, initSearchResults: function () { diff --git a/js/libs/fluidbook/fluidbook.utils.js b/js/libs/fluidbook/fluidbook.utils.js index 33805080..9a18a463 100644 --- a/js/libs/fluidbook/fluidbook.utils.js +++ b/js/libs/fluidbook/fluidbook.utils.js @@ -517,3 +517,22 @@ class Solver { } } +function intersectRect(r1, r2) { + if (r1.width !== undefined) { + r1.right = r1.left + r1.width + } + if (r1.height !== undefined) { + r1.bottom = r1.top + r1.height + } + if (r2.width !== undefined) { + r2.right = r2.left + r2.width + } + if (r2.height !== undefined) { + r2.bottom = r2.top + r2.height + } + + return !(r2.left > r1.right || + r2.right < r1.left || + r2.top > r1.bottom || + r2.bottom < r1.top); +} \ No newline at end of file