]> _ Git - fluidbook-html5.git/commitdiff
wait #5827 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 Mar 2023 11:38:55 +0000 (12:38 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 Mar 2023 11:38:55 +0000 (12:38 +0100)
js/libs/fluidbook/fluidbook.search.js

index f6791468a25ce97c09b49515eecfbf378a9a8b1d..a5a1a79f5a6fc20f699e6e78c45c31e91c5405b2 100644 (file)
@@ -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;