},
highlightOccurence: function (position, word, term, color, offset) {
+ let $this = this;
if (word == term) {
width = position.width;
x = 0;
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 () {
}
}
+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