]> _ Git - fluidbook-html5.git/commitdiff
wip #6188 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 12 Sep 2023 19:24:35 +0000 (21:24 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 12 Sep 2023 19:24:35 +0000 (21:24 +0200)
js/libs/fluidbook/fluidbook.search.js

index 093b9df08f718015ad5f3d6c64d76b2ea831cc6f..21814953b31f5327941b980deef27b84e0e5e127 100644 (file)
@@ -85,7 +85,7 @@ FluidbookSearch.prototype = {
         //=== Event handlers
         $(document).on(this.fluidbook.input.clickEvent, '#menuSearchResults a', function () {
             // Find the page number of the result so we can see where it sits in the list of returned results
-            var pageNumber = parseInt($(this).parents('.doubleThumb').attr('page'));
+            var pageNumber = parseInt($(this).find('.doubleThumb').attr('page'));
             $this.openResultsNav(pageNumber);
         });
 
@@ -107,11 +107,15 @@ FluidbookSearch.prototype = {
         });
 
         $(this.fluidbook).on('fluidbook.resize.orientation', function (event, details) {
-            if (!$this.resultsNavActive()) return;
+            if (!$this.resultsNavActive()) {
+                return;
+            }
 
             $this.updateResultsNav($this.fluidbook.currentPage);
         });
-    }, resultsNavActive: function () {
+    },
+
+    resultsNavActive: function () {
         return $('body').hasClass(this.resultsActiveClass);
     },
 
@@ -123,7 +127,7 @@ FluidbookSearch.prototype = {
         // to even and remove duplicates created.
         if (this.fluidbook.resize.orientation === "landscape") {
 
-            var noOddPages = this.resultPages.map(function (page) {
+            const noOddPages = this.resultPages.map(function (page) {
                 if (page % 2 === 1) page--; // Change to preceding even number
                 return page;
             });
@@ -138,11 +142,11 @@ FluidbookSearch.prototype = {
             this.resultNavPages = this.resultPages;
         }
 
-        var resultPagePosition = this.resultNavPages.indexOf(resultPage);
+        let resultPagePosition = this.resultNavPages.indexOf(resultPage);
         // Convert from zero-based index. If page clicked isn't found in results pages, default to 1
         resultPagePosition = (resultPagePosition === -1) ? 1 : resultPagePosition + 1;
 
-        var counterText = resultPagePosition + '/' + this.resultNavPages.length;
+        const counterText = resultPagePosition + '/' + this.resultNavPages.length;
 
         this.resultsNav.find('.searchResultsNavQuery').text($('#q').val());
         this.resultsNav.find('.searchResultsNavCounter').text(counterText);
@@ -322,13 +326,14 @@ FluidbookSearch.prototype = {
             } catch (e) {
 
             }
-            if (nb == 0) {
+            if (nb === 0) {
                 continue;
             }
             page = parseInt(p);
             if (page > maxPage) {
                 continue;
             }
+            this.resultPages.push(page);
 
             if (!this.singleMode && (page % 2) === 1) {
                 page--;
@@ -338,6 +343,7 @@ FluidbookSearch.prototype = {
             doublesPages[page][q] = nb;
 
             res[page] = nb;
+
             total += nb;
         }
         if (total > 0) {
@@ -347,8 +353,6 @@ FluidbookSearch.prototype = {
             total: total, results: res, terms: terms
         };
 
-        console.log(returnVal);
-
         callback(returnVal);
     },
 
@@ -472,6 +476,7 @@ FluidbookSearch.prototype = {
             doublesPages[page][q] = nb;
 
             res[page] = nb;
+            this.resultPages.push(page);
             total += nb;
         }
         if (total > 0) {