From 7c0756ff7b0dd2d81fded8c18937120e4f482efe Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 24 Mar 2023 12:38:55 +0100 Subject: [PATCH] wait #5827 @0.75 --- js/libs/fluidbook/fluidbook.search.js | 39 ++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index f6791468..a5a1a79f 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -48,6 +48,7 @@ FluidbookSearch.prototype = { }); }, + // 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 () { @@ -181,7 +182,9 @@ FluidbookSearch.prototype = { } $('body').removeClass(this.resultsActiveClass); - }, nextResultsPage: function () { + }, + + nextResultsPage: function () { var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage); var nextIndex = currentIndex + 1; @@ -193,7 +196,9 @@ FluidbookSearch.prototype = { this.updateResultsNav(nextPage); this.fluidbook.setCurrentPage(nextPage); - }, previousResultsPage: function () { + }, + + previousResultsPage: function () { var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage); var prevIndex = currentIndex - 1; @@ -212,12 +217,14 @@ FluidbookSearch.prototype = { this._loadLib(function () { $this._getHints(q, callback); }); - }, find: function (q, callback) { + }, + find: function (q, callback) { var $this = this; this._loadLib(function () { $this._find(q, callback); }); - }, _loadLib: function (callback) { + }, + _loadLib: function (callback) { if (this.indexLoaded) { return callback(); } @@ -245,7 +252,8 @@ FluidbookSearch.prototype = { } else { callback(); } - }, _getHints: function (q, callback) { + }, + _getHints: function (q, callback) { var words = this.normalizeQuery(q, true); q = words.pop(); var res = []; @@ -409,17 +417,21 @@ FluidbookSearch.prototype = { sortHints: function (a, b) { return b[1] - a[1]; - }, kill: function () { + }, + kill: function () { - }, normalizeQuery: function (q, split) { + }, + normalizeQuery: function (q, split) { q = this.noAccents(q); + q = q.trim(); + q = q.replace(/\s+/g, ' '); q = q.toLowerCase(); if (split) { return q.split(' '); } return q; - - }, noAccents: function (source) { + }, + noAccents: function (source) { source = source.replace(/[àáâãäå]/g, "a"); source = source.replace(/[ÀÁÂÃÄÅ]/g, "A"); source = source.replace(/[èéêë]/g, "e"); @@ -445,7 +457,8 @@ FluidbookSearch.prototype = { source = source.replace(/[œ]/g, "oe"); source = source.replace(/[Œ]/g, "OE"); return source; - }, setHighlightTerms: function (terms) { + }, + setHighlightTerms: function (terms) { if (!this.highlightEnabled || window.HIGHLIGHTS === undefined) { return; } @@ -482,13 +495,15 @@ FluidbookSearch.prototype = { this.highlights.push(h); } } - }, clearHighlights: function () { + }, + clearHighlights: function () { $("#searchHighlights").html(''); for (var p in this.plugins) { var plugin = this.plugins[p]; plugin.clearHighlights(); } - }, highlightSearchTerms: function (pageNr) { + }, + highlightSearchTerms: function (pageNr) { if (!this.highlightEnabled) { console.warn('hightlight disabled'); return; -- 2.39.5