]> _ Git - fluidbook-html5.git/commitdiff
wip #2251 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 1 Oct 2018 16:57:04 +0000 (18:57 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 1 Oct 2018 16:57:04 +0000 (18:57 +0200)
js/libs/fluidbook/fluidbook.menu.js
js/libs/fluidbook/fluidbook.search.js
js/libs/fluidbook/special/wescosales.js

index b7eca1e45a20e2a2ee09d162ecfcbc1cd403a457..9f805665d14aaffa5ad24450e423384f369a087e 100644 (file)
@@ -70,7 +70,7 @@ FluidbookMenu.prototype = {
         var $this = this;
         var camelView = view.charAt(0).toUpperCase() + view.substr(1);
         var cb = function () {
-            $this.openingView(callback);
+            $this.openingView(callback, view);
         };
         if (view == 'index') {
             this.openIndex(this.fluidbook.l10n.__('overview'), undefined, true, cb);
@@ -104,7 +104,7 @@ FluidbookMenu.prototype = {
     openSearch: function (q, cb) {
         this.fluidbook.nav.openSearch(q, cb);
     },
-    openingView: function (callback) {
+    openingView: function (callback, view) {
         var $this = this;
         this.fluidbook.resize.resizeView();
         this.fluidbook.tooltip.hideTooltip();
@@ -120,7 +120,7 @@ FluidbookMenu.prototype = {
         var to = {y: "0px", opacity: 1};
         if (mview.hasClass('fs')) {
             from.y = "0px";
-        } else {
+        } else if (view !== 'search') {
             this.showOverlay();
         }
 
index 37ef9e1fd576b8caa927641dec8fdeffc8270505..ba76d3b6d30f324cea41bfd23bfd8d5218c16f9c 100644 (file)
@@ -91,7 +91,6 @@ FluidbookSearch.prototype = {
         for (var p in this.plugins) {
             var plugin = this.plugins[p];
             var h = plugin.getHints(q);
-            console.log(h);
             res = res.concat(h);
         }
 
@@ -318,6 +317,10 @@ FluidbookSearch.prototype = {
     },
     clearHighlights: function () {
         $("#searchHighlights").html('');
+        for (var p in this.plugins) {
+            var plugin = this.plugins[p];
+            plugin.clearHighlights();
+        }
     },
     highlightSearchTerms: function (pageNr) {
         if (!this.highlightEnabled) {
@@ -328,6 +331,11 @@ FluidbookSearch.prototype = {
             return;
         }
 
+        for (var p in this.plugins) {
+            var plugin = this.plugins[p];
+            plugin.highlight(pageNr, this.termsToHighlight);
+        }
+
         // Test if we highlight results
         if (!this.fluidbook.datas.highlightAllOccurences) {
             var evenPageNumber = pageNr;
@@ -425,8 +433,6 @@ FluidbookSearch.prototype = {
 
         this.menuSearchHints.fadeIn(300);
 
-        this.initSearchResults();
-
         // if (this.menuSearchHints.hasClass('mm-hidden')) {
         //     this.nav.menuAPI.openPanel(this.menuSearchHints, false);
         // }
index e43d06ac197bba078a5b94a04d0805a5a8232ac9..c83a747d9db99b514b6ba35d1198e7f053129e61 100644 (file)
@@ -337,4 +337,16 @@ WescoSalesSearchPlugin.prototype = {
 
         return !res;
     },
+
+    highlight: function (pageNr, terms) {
+        console.log(terms);
+        this.clearHighlights();
+        $.each(terms, function (k, v) {
+            console.log(v, $('[data-wescosales-ref="' + v + '"]'));
+            $('[data-wescosales-ref="' + v + '"]').addClass('highlight');
+        });
+    },
+    clearHighlights: function () {
+        $('[data-wescosales-ref].highlight').removeClass('highlight');
+    },
 };
\ No newline at end of file