]> _ Git - fluidbook-html5.git/commitdiff
wait #8004 @0:45
authorsoufiane <soufiane@cubedesigners.com>
Wed, 11 Feb 2026 11:05:52 +0000 (12:05 +0100)
committersoufiane <soufiane@cubedesigners.com>
Wed, 11 Feb 2026 11:05:52 +0000 (12:05 +0100)
js/libs/fluidbook/fluidbook.search.js

index af8ada54275c583eccf4beeb99f6ec7f0095334e..c6ce59ca9c3146828268c0bf80a4602f45181969 100644 (file)
@@ -15,6 +15,7 @@ function FluidbookSearch(fluidbook) {
     this.resultsActiveClass = 'searchResultsNavActive';
     this.robust = fluidbook.settings.search_mode === 'robust';
     this.hintsEnabled = !this.robust;
+    this.callNumber = 0;
 
     this.init();
 }
@@ -117,7 +118,7 @@ FluidbookSearch.prototype = {
         });
 
         $(this.fluidbook).on('fluidbook.resize.orientation', function (event, details) {
-            if (!$this.resultsNavActive() || $this.isSearchfloatActive) {
+            if (!$this.resultsNavActive()) {
                 return;
             }
             $this.updateResultsNav($this.fluidbook.currentPage);
@@ -133,31 +134,35 @@ FluidbookSearch.prototype = {
         // so we only want even pages in our results. The resultPages
         // includes all pages by default so we need to convert odd pages
         // to even and remove duplicates created.
-        if (this.fluidbook.resize.orientation === "landscape") {
+        if(this.callNumber < 1) {
+            if (this.fluidbook.resize.orientation === "landscape") {
+                console.log("is landscape =====>",this.fluidbook.resize.orientation);
 
-            const noOddPages = this.resultPages.map(function (page) {
-                if (page % 2 === 1) page--; // Change to preceding even number
-                return page;
-            });
+                const noOddPages = this.resultPages.map(function (page) {
+                    if (page % 2 === 1) page--; // Change to preceding even number
+                    return page;
+                });
 
-            // Remove any duplicates created when converting pages to even numbers
-            // Ref: https://stackoverflow.com/a/14438954
-            this.resultNavPages = noOddPages.filter(function (value, index, self) {
-                return self.indexOf(value) === index;
-            });
+                // Remove any duplicates created when converting pages to even numbers
+                // Ref: https://stackoverflow.com/a/14438954
+                this.resultNavPages = noOddPages.filter(function (value, index, self) {
+                    return self.indexOf(value) === index;
+                });
 
-        } else {
-            this.resultNavPages = this.resultPages;
-        }
+            } else {
+                this.resultNavPages = this.resultPages;
+            }
 
-        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;
+            let resultPagePosition = this.resultNavPages.indexOf(parseInt(resultPage));
+            // Convert from zero-based index. If page clicked isn't found in results pages, default to 1
+            resultPagePosition = (resultPagePosition === -1) ? 1 : resultPagePosition + 1;
 
-        const counterText = resultPagePosition + '/' + this.resultNavPages.length;
+            const counterText = resultPagePosition + '/' + this.resultNavPages.length;
 
-        this.resultsNav.find('.searchResultsNavQuery').text($('#q').val());
-        this.resultsNav.find('.searchResultsNavCounter').text(counterText);
+            this.resultsNav.find('.searchResultsNavQuery').text($('#q').val());
+            this.resultsNav.find('.searchResultsNavCounter').text(counterText);
+            this.callNumber = 1;
+        }
     },
 
     openResultsNav: function (resultPage) {
@@ -221,6 +226,7 @@ FluidbookSearch.prototype = {
     },
 
     nextResultsPage: function () {
+        this.callNumber = 0
         var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage);
         var nextIndex = currentIndex + 1;
 
@@ -235,6 +241,7 @@ FluidbookSearch.prototype = {
     },
 
     previousResultsPage: function () {
+        this.callNumber = 0
         var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage);
         var prevIndex = currentIndex - 1;
 
@@ -1097,11 +1104,15 @@ FluidbookSearch.prototype = {
 
         // Redirect to the only result page if the flag is enabled
         if(this.fluidbook.search.isSearchfloatActive && $this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').length > 0) {
+            this.callNumber = 0;
             setTimeout(function () {
-                fluidbook.setCurrentPage($this.menuSearchResults.find('.doubleThumb[data-enabled="1"][data-pages*='+parseInt(referencePage)+']').attr('page'));
-                var pageNumber = parseInt($("#menuSearchResults a").find('.doubleThumb[data-enabled="1"][data-pages*='+parseInt(referencePage)+']').attr('page'));
-                console.log(pageNumber)
-                $this.openResultsNav(pageNumber);
+                let page = referencePage;
+                let pageNumber = parseInt($("#menuSearchResults a").find('.doubleThumb[data-enabled="1"][data-pages*='+parseInt(referencePage)+']').attr('page'));
+                if($this.fluidbook.resize.orientation === "landscape") {
+                    page = pageNumber;
+                }
+                fluidbook.setCurrentPage(page);
+                $this.openResultsNav(page);
                 fluidbook.nav.burger.close();
             }, 100);
             return;