]> _ Git - fluidbook-html5.git/commitdiff
wip #8009 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Feb 2026 17:43:16 +0000 (18:43 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Feb 2026 17:43:16 +0000 (18:43 +0100)
js/libs/fluidbook/fluidbook.search.js

index 1bef2bfeba7af5d9972f93f2f3e0498eeddc6b9e..e7efcea37322e57a2dc78d7ccf66da39bb363573 100644 (file)
@@ -42,7 +42,7 @@ FluidbookSearch.prototype = {
 
         this.initResultsNav();
 
-        if($('body').hasClass('floatmode')) {
+        if ($('body').hasClass('floatmode')) {
             this.isSearchfloatActive = true;
         }
 
@@ -110,9 +110,9 @@ FluidbookSearch.prototype = {
         });
 
         $(document).on(this.fluidbook.input.clickEvent, '.searchResultsNavClose', function () {
-            if($this.fluidbook.search.isSearchfloatActive) {
+            if ($this.fluidbook.search.isSearchfloatActive) {
                 $this.closeResultsNavInFloatMode();
-            }else {
+            } else {
                 $this.closeResultsNav();
             }
         });
@@ -131,14 +131,14 @@ FluidbookSearch.prototype = {
 
     updateResultsNav: function (resultPage) {
         // To avoid double calls causing problems
-        if(!this.isSearchfloatActive) {
+        if (!this.isSearchfloatActive) {
             this.callNumber = 0;
         }
         // If we are in landscape view, there are 2 pages visible,
         // 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.callNumber < 1) {
+        if (this.callNumber < 1) {
             if (this.fluidbook.resize.orientation === "landscape") {
 
                 const noOddPages = this.resultPages.map(function (page) {
@@ -218,7 +218,7 @@ FluidbookSearch.prototype = {
         $('body').removeClass(this.resultsActiveClass);
     },
 
-    closeResultsNavInFloatMode: function() {
+    closeResultsNavInFloatMode: function () {
         this.hideableElements.removeClass('hidden');
         this.resultsNav.addClass('hideUp').addClass('hidden');
         setTimeout(() => {
@@ -377,7 +377,10 @@ FluidbookSearch.prototype = {
             if (k.indexOf(q) !== 0) {
                 continue;
             }
-            res.push([k, v.t]);
+            for (var w in v.w){
+                break;
+            }
+            res.push([w, v.t]);
         }
 
         for (var p in this.plugins) {
@@ -1114,12 +1117,12 @@ FluidbookSearch.prototype = {
         this.highlightSearchTerms(this.fluidbook.currentPage);
 
         // 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) {
+        if (this.fluidbook.search.isSearchfloatActive && $this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').length > 0) {
             this.callNumber = 0;
             setTimeout(function () {
                 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") {
+                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);
@@ -1137,8 +1140,8 @@ FluidbookSearch.prototype = {
             }
         }
 
-        if(!this.fluidbook.search.isSearchfloatActive) {
-        this.menuSearchResults.fadeIn(300).scrollTop(0);
+        if (!this.fluidbook.search.isSearchfloatActive) {
+            this.menuSearchResults.fadeIn(300).scrollTop(0);
         }
 
         // On some phones, the height of the search results is miscalculated due to the