]> _ Git - fluidbook-html5.git/commitdiff
done #1672 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Sep 2017 13:28:24 +0000 (15:28 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Sep 2017 13:28:24 +0000 (15:28 +0200)
js/libs/fluidbook/fluidbook.search.js
style/fluidbook.less

index e333377436f11e61f1b3cd836a8600a48f715e49..9c9b1f99a62c0fa668b18676a3f2f63b1e3a4633 100644 (file)
@@ -4,6 +4,7 @@ function FluidbookSearch(fluidbook) {
     this.termsToHighlight = [];
     this.highlights = [];
     this.highlightEnabled = fluidbook.datas.highlightResults;
+    this.resultPages = [];
 
     this.init();
 }
@@ -78,6 +79,7 @@ FluidbookSearch.prototype = {
         var terms = [];
         var total = 0;
         var doublesPages = {};
+        this.resultPages = [];
 
         // var allPages=Array.apply(null, Array(this.fluidbook.datas.pages)).map(function (_, i) {return i+1;});
 
@@ -126,10 +128,12 @@ FluidbookSearch.prototype = {
                     occ += doublePageOccurences[ww];
                 }
                 res[dpNumber] = occ;
+                this.resultPages.push(parseInt(dpNumber));
                 total += occ;
             }
         }
 
+
         var returnVal = {
             total: total,
             results: res,
@@ -213,6 +217,17 @@ FluidbookSearch.prototype = {
             return;
         }
 
+        // Test if we highlight results
+        if (!this.fluidbook.datas.highlightAllOccurences) {
+            var evenPageNumber = pageNr;
+            if (evenPageNumber % 2 == 1) {
+                evenPageNumber--;
+            }
+            if (this.resultPages.indexOf(evenPageNumber) == -1) {
+                return;
+            }
+        }
+
         var pageNrs = [];
         if (this.fluidbook.resize.orientation == 'portrait') {
             pageNrs.push(pageNr);
index 61d94a1712f3d84a119adb103d662d811f68d8ff..6ec1922e373bc0dc7665c936b258e5ce3d769133 100644 (file)
@@ -303,25 +303,25 @@ body, html {
        position: absolute;
        top: 0px;
        left: 0px;
-       z-index:3;
+       z-index: 3;
        .highlight {
                position: absolute;
                border-width: 2px;
                border-radius: 2px;
                border-style: solid;
-               &[data-color="0"] {
+               &[data-color="0"], &[data-color="5"], &[data-color="10"] {
                        .highlight-area(#00ff00);
                }
-               &[data-color="1"] {
+               &[data-color="1"], &[data-color="6"], &[data-color="11"] {
                        .highlight-area(#ffff00);
                }
-               &[data-color="2"] {
+               &[data-color="2"], &[data-color="7"], &[data-color="12"] {
                        .highlight-area(#00ffff);
                }
-               &[data-color="3"] {
+               &[data-color="3"], &[data-color="8"], &[data-color="13"] {
                        .highlight-area(#ff00ff);
                }
-               &[data-color="4"] {
+               &[data-color="4"], &[data-color="9"], &[data-color="14"] {
                        .highlight-area(#ff0000);
                }
        }