From: Vincent Vanwaelscappel Date: Tue, 12 Sep 2023 19:24:35 +0000 (+0200) Subject: wip #6188 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=13e88e328cad899c4bdbbab08ac89a2337f3124d;p=fluidbook-html5.git wip #6188 @1 --- diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index 093b9df0..21814953 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -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) {