From 3275caa8a62e4a118b0f95ee0ebed098eeebdca9 Mon Sep 17 00:00:00 2001 From: soufiane Date: Mon, 9 Feb 2026 19:48:15 +0100 Subject: [PATCH] wait #7995 --- js/libs/fluidbook/fluidbook.burger.js | 11 +++++------ js/libs/fluidbook/fluidbook.js | 6 ++++++ js/libs/fluidbook/fluidbook.nav.js | 3 +-- js/libs/fluidbook/fluidbook.search.float.js | 10 ++++++++++ js/libs/fluidbook/fluidbook.search.js | 16 ++++++++++++---- 5 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 js/libs/fluidbook/fluidbook.search.float.js diff --git a/js/libs/fluidbook/fluidbook.burger.js b/js/libs/fluidbook/fluidbook.burger.js index 5023f0b2..1388d320 100644 --- a/js/libs/fluidbook/fluidbook.burger.js +++ b/js/libs/fluidbook/fluidbook.burger.js @@ -3,7 +3,6 @@ function FluidbookBurger(nav) { this.fluidbook = nav.fluidbook; this.closeTimeout; this.isOpened = false; - this.floatmode = this.fluidbook.floatmode; } FluidbookBurger.prototype = { @@ -66,7 +65,7 @@ FluidbookBurger.prototype = { // Add holder list element for menu items $("#menu").append(''); - if(this.floatmode) { + if(this.fluidbook.search.isSearchfloatActive) { $('body').append(this.initSearch()); } else { this.searchHTML = this.initSearch() @@ -133,7 +132,7 @@ FluidbookBurger.prototype = { if (!this.isOpened) { $('body').addClass('menu-open'); $("#menuOverlay").show(); - if(!this.floatmode) { + if(!this.fluidbook.search.isSearchfloatActive) { $("#menu").show() } setTimeout(function () { @@ -216,7 +215,7 @@ FluidbookBurger.prototype = { } else { this.open(false); - if(this.floatmode && !floatSearchVisible) { + if(this.fluidbook.search.isSearchfloatActive && !floatSearchVisible) { $("#menuSearch").hide().removeClass('hidden') setTimeout(function(){ $("#menuSearch").show() @@ -298,7 +297,7 @@ FluidbookBurger.prototype = { let $this = this; let res = this.getSearchHtml(); - if(this.floatmode) { + if(this.fluidbook.search.isSearchfloatActive) { res = this.getFloatSearchHTML() } search.append(res); @@ -338,7 +337,7 @@ FluidbookBurger.prototype = { // Close floatSearch const menuSearchClose = $("#menuSearchClose") - if(!this.floatmode) { + if(!this.fluidbook.search.isSearchfloatActive) { menuSearchClose.hide() } diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 1898e0ec..131c1d21 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -180,6 +180,7 @@ Fluidbook.prototype = { this.help = new FluidbookHelp(this); this.articles = new FluidbookArticles(this); + try { $('head').append(''); } catch (e) { @@ -235,6 +236,11 @@ Fluidbook.prototype = { this.datas = this.settings; $('html').addClass('linksanimation-' + this.settings.linksAnimation); $('html').addClass('linksanimationlayer-' + this.settings.linksAnimationLayer); + + // Add class if search is float + if(this.settings.search_field === "float") { + $('body').addClass('floatmode'); + } }, setMaxPage: function (p, allowbackwards) { diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index d2a9015e..fe9381cd 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -197,7 +197,6 @@ FluidbookNav.prototype = { // MMenu specific elements if (navType === 'menu') { this.burger.initNav(); - this.burger.initSearch(); if (this.fluidbook.settings.navOrderH.length > 0) { navOrder = this.fluidbook.settings.navOrderH; } @@ -546,7 +545,7 @@ FluidbookNav.prototype = { // Search icon in horizontal menu $(document).on(this.fluidbook.input.clickEvent, '#horizontalNav_searchIcon', function (event) { - event.preventDefault() + event.preventDefault(); $this.burger.openSearch(); }); diff --git a/js/libs/fluidbook/fluidbook.search.float.js b/js/libs/fluidbook/fluidbook.search.float.js new file mode 100644 index 00000000..c0b35cd9 --- /dev/null +++ b/js/libs/fluidbook/fluidbook.search.float.js @@ -0,0 +1,10 @@ +function FluidbookSearchFloat(fluidbook) { + this.fluidbook = fluidbook; + this.init(); +} + +FluidbookSearchFloat.prototype = { + init: function() { + console.log('ok search float') + } +} \ No newline at end of file diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index afc69bfc..dbecec4f 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -1,6 +1,6 @@ function FluidbookSearch(fluidbook) { this.fluidbook = fluidbook; - //this.searchfloat = new FluidbookSearchFloat(fluidbook); + this.isSearchfloatActive = null; this.indexLoaded = false; this.indexLoading = false; this.termsToHighlight = []; @@ -40,6 +40,12 @@ FluidbookSearch.prototype = { }); this.initResultsNav(); + + if($('body').hasClass('floatmode')) { + this.isSearchfloatActive = true; + } + + this.searchfloat = new FluidbookSearchFloat(this.fluidbook); }, debugSearch: function (keyword) { @@ -110,7 +116,7 @@ FluidbookSearch.prototype = { }); $(document).on(this.fluidbook.input.clickEvent, '.searchResultsNavClose', function () { - if($this.fluidbook.floatmode) { + if($this.fluidbook.search.isSearchfloatActive) { $this.closeResultsNavInFloatMode(); }else { $this.closeResultsNav(); @@ -993,7 +999,7 @@ FluidbookSearch.prototype = { var $this = this; this.find(q, function (results) { - $this.openResults(results, this.fluidbook.floatmode); + $this.openResults(results); }); }, @@ -1093,7 +1099,7 @@ FluidbookSearch.prototype = { this.highlightSearchTerms(this.fluidbook.currentPage); // Redirect to the only result page if the flag is enabled - if(this.fluidbook.nav.burger.floatmode && gotoPageIfOneResult) { + if(this.fluidbook.search.isSearchfloatActive && $this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').length > 0) { setTimeout(function () { fluidbook.setCurrentPage($this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').attr('page')); var pageNumber = parseInt($("#menuSearchResults a").find('.doubleThumb').attr('page')); @@ -1111,7 +1117,9 @@ FluidbookSearch.prototype = { } } + 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 // keyboard being open and reducing the available window height. We need to wait until -- 2.39.5