From: Vincent Vanwaelscappel Date: Tue, 11 Feb 2020 11:19:56 +0000 (+0100) Subject: try #3405 @0:10 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=673b04e173ba730e27970c4070bf36b6b9727a06;p=fluidbook-html5.git try #3405 @0:10 --- diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index 672be94b..fbe698e9 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -38,17 +38,19 @@ FluidbookSearch.prototype = { this.initResultsNav(); }, - debugSearch: function(keyword) { - this._loadLib(function() { - console.log('Comparison of page results for keyword "'+ keyword +'"'); - console.log('INDEX:', Object.keys(INDEX[keyword].p).join(', ')); - console.log('HIGHLIGHTS:', Array.from(new Set(HIGHLIGHTS["loutres"].map(function(h) { return h.page }))).join(', ')); - }); + debugSearch: function (keyword) { + this._loadLib(function () { + console.log('Comparison of page results for keyword "' + keyword + '"'); + console.log('INDEX:', Object.keys(INDEX[keyword].p).join(', ')); + console.log('HIGHLIGHTS:', Array.from(new Set(HIGHLIGHTS["loutres"].map(function (h) { + return h.page + }))).join(', ')); + }); }, // The results nav bar provides navigation between results without needing the menu to be open // When it is active, the rest of the interface is hidden - initResultsNav: function() { + initResultsNav: function () { var $this = this; // Previously we used buttons in the HTML for clickable elements @@ -75,26 +77,26 @@ FluidbookSearch.prototype = { this.resultsNav = $('#' + this.resultsNavID); //=== Event handlers - $(document).on('click', '#menuSearchResults a', function() { + $(document).on('click', '#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')); $this.openResultsNav(pageNumber); }); - $(document).on('click', '.searchResultsNavField', function() { + $(document).on('click', '.searchResultsNavField', function () { $this.closeResultsNav(true); $this.fluidbook.nav.openSearch(); }); - $(document).on('click', '.searchResultsNext', function() { + $(document).on('click', '.searchResultsNext', function () { $this.nextResultsPage(); }); - $(document).on('click', '.searchResultsPrev', function() { + $(document).on('click', '.searchResultsPrev', function () { $this.previousResultsPage(); }); - $(document).on('click', '.searchResultsNavClose', function() { + $(document).on('click', '.searchResultsNavClose', function () { $this.closeResultsNav(); }); @@ -105,7 +107,7 @@ FluidbookSearch.prototype = { }); // Close results nav when hitting escape - key('esc', function() { + key('esc', function () { if ($this.resultsNavActive()) { $this.closeResultsNav(); } @@ -113,10 +115,10 @@ FluidbookSearch.prototype = { }, - resultsNavActive: function() { - return $('body').hasClass(this.resultsActiveClass); + resultsNavActive: function () { + return $('body').hasClass(this.resultsActiveClass); }, - updateResultsNav: function(resultPage) { + updateResultsNav: function (resultPage) { // If we are in landscape view, there are 2 pages visible, // so we only want even pages in our results. The resultPages @@ -124,14 +126,14 @@ FluidbookSearch.prototype = { // to even and remove duplicates created. if (this.fluidbook.resize.orientation === "landscape") { - var noOddPages = this.resultPages.map(function(page) { + var 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) { + this.resultNavPages = noOddPages.filter(function (value, index, self) { return self.indexOf(value) === index; }); @@ -148,13 +150,13 @@ FluidbookSearch.prototype = { this.resultsNav.find('.searchResultsNavQuery').text($('#q').val()); this.resultsNav.find('.searchResultsNavCounter').text(counterText); }, - openResultsNav: function(resultPage) { + openResultsNav: function (resultPage) { this.updateResultsNav(resultPage); this.hideableElements.addClass('hidden'); this.resultsNav.removeClass('hidden'); $('body').addClass(this.resultsActiveClass); }, - closeResultsNav: function(keepSearch) { + closeResultsNav: function (keepSearch) { keepSearch = keepSearch !== 'undefined' ? keepSearch : false; this.hideableElements.removeClass('hidden'); @@ -166,7 +168,7 @@ FluidbookSearch.prototype = { $('body').removeClass(this.resultsActiveClass); }, - nextResultsPage: function() { + nextResultsPage: function () { var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage); var nextIndex = currentIndex + 1; @@ -179,7 +181,7 @@ FluidbookSearch.prototype = { this.updateResultsNav(nextPage); this.fluidbook.setCurrentPage(nextPage); }, - previousResultsPage: function() { + previousResultsPage: function () { var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage); var prevIndex = currentIndex - 1; @@ -489,10 +491,12 @@ FluidbookSearch.prototype = { }, highlightSearchTerms: function (pageNr) { if (!this.highlightEnabled) { + console.warn('hightlight disabled'); return; } this.clearHighlights(); if (this.termsToHighlight.length === 0) { + console.warn('no terms to highlight'); return; } @@ -508,10 +512,6 @@ FluidbookSearch.prototype = { if (!this.singleMode && evenPageNumber % 2 === 1) { evenPageNumber--; } - - if (this.resultPages.indexOf(evenPageNumber) === -1) { - return; - } } var pageNrs = [];