]> _ Git - fluidbook-html5.git/commitdiff
wait #7951 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 28 Jan 2026 16:08:38 +0000 (17:08 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 28 Jan 2026 16:08:38 +0000 (17:08 +0100)
js/libs/fluidbook/fluidbook.search.js
js/libs/fluidbook/fluidbook.utils.js

index 791fe678380b7a095bb67fa53bc253432f4fab2a..94118c4e809e84c76a2461d5a83a60a8a20b9c82 100644 (file)
@@ -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 () {
index 33805080f1f31776c0986e9062d759b05dc4330b..9a18a463f71d66f718351a34fde172c73ea5ccf4 100644 (file)
@@ -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