From: Vincent Vanwaelscappel Date: Mon, 12 May 2025 11:09:48 +0000 (+0200) Subject: wip #7461 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c63cd4612f23956f6a0459147ceea5fa7fa16db8;p=fluidbook-html5.git wip #7461 @0.5 --- diff --git a/js/libs/fluidbook/fluidbook.burger.js b/js/libs/fluidbook/fluidbook.burger.js index 4be87c94..1672e542 100644 --- a/js/libs/fluidbook/fluidbook.burger.js +++ b/js/libs/fluidbook/fluidbook.burger.js @@ -179,28 +179,34 @@ FluidbookBurger.prototype = { }); }, - open: function () { + open: function (focusClose) { + if (focusClose === undefined) { + focusClose = true; + } let $this = this; - this.isOpened = true; - $('body').addClass('menu-open'); clearTimeout(this.closeTimeout); - $("#menu,#menuOverlay").show(); - setTimeout(function () { - $("#menu").addClass('open'); + if (!this.isOpened) { + $('body').addClass('menu-open'); + $("#menu,#menuOverlay").show(); setTimeout(function () { - if ($this.fluidbook.input.isUsingKeyboard()) { - console.log('focus close') - $("#menuClose").get(0).focus(); + $("#menu").addClass('open'); + if (focusClose) { + setTimeout(function () { + if ($this.fluidbook.input.isUsingKeyboard()) { + $("#menuClose").get(0).focus(); + } + }, 500); } - }, 500); - }, 10); - - $("#main").attr('aria-hidden', 'true'); - $("#view").attr('aria-hidden', 'true'); - $("#menu").attr('aria-hidden', 'false'); - $("#menuOpener").attr('aria-expanded', 'true'); - + }, 10); + $("#main").attr('aria-hidden', 'true'); + $("#view").attr('aria-hidden', 'true'); + $("#menu").attr('aria-hidden', 'false'); + $("#menuOpener").attr('aria-expanded', 'true'); + } else { + console.log('already opened'); + } + this.isOpened = true; }, closeAll: function () { @@ -231,11 +237,11 @@ FluidbookBurger.prototype = { }, hideMenuItems: function () { - gsap.to($('#menuList > li, #shareLinks,footer#mobile-credits'), {duration: 0.1, autoAlpha: 0}); + gsap.to($('#menuList > li, #shareLinks,footer#mobile-credits'), {duration: 0.1, opacity: 0, display: 'none'}); }, showMenuItems: function () { - gsap.to($('#menuList > li, #shareLinks,footer#mobile-credits'), {duration: 0.3, autoAlpha: 1}); + gsap.to($('#menuList > li, #shareLinks,footer#mobile-credits'), {duration: 0.3, opacity: 1, display: 'block'}); }, openSearch: function (q, cb) { @@ -252,7 +258,7 @@ FluidbookBurger.prototype = { this.fluidbook.search.submitForm(); } } else { - this.open(); + this.open(false); $('#q').focus(); // Put cursor in the search field } @@ -330,9 +336,10 @@ FluidbookBurger.prototype = { case 38: // Up arrow case 39: // Right arrow case 40: // Down arrow + case 9: // Tab return; // Ignore these keys default: - searchHints(); + $this.fluidbook.search.searchHints(); } }); diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index 3c6110ff..fc7d0b64 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -751,6 +751,22 @@ FluidbookSearch.prototype = { }); }, + searchHints: function () { + this.hideSearchResults(); + if ($("#q").val().length >= 1) { + this.initSearchHints(); + this.getSearchHints($("#q").val()); + } else { + try { + if ($("#q").val().length == 0) { + this.hideSearchHints(); + this.fluidbook.nav.burger.showMenuItems(); // Show main menu items that were hidden previously + } + } catch (err) { + } + } + }, + displaySearchHints: function (hints) { if (!this.hintsEnabled) { return; diff --git a/js/main.js b/js/main.js index 7dda1d0d..fcf2cf76 100644 --- a/js/main.js +++ b/js/main.js @@ -1,4 +1,4 @@ -window.stats=new FluidbookStats(); +window.stats = new FluidbookStats(); var DEVICE_READY_BEFORE_JQUERY = false; var JQUERY_READY = false; @@ -267,7 +267,7 @@ try { } try { window.fluidbook.loadPlugins(); - }catch (e){ + } catch (e) { } $(document).trigger('fluidbook.init'); @@ -281,10 +281,10 @@ try { window.fluidbook.ready(); } - if(this.fluidbook.secureOKDone) { + if (this.fluidbook.secureOKDone) { initEvents(); - }else{ - this.fluidbook.initEventsWhenSecureOK=true; + } else { + this.fluidbook.initEventsWhenSecureOK = true; } } @@ -308,7 +308,6 @@ try { } - $(window).on('hashchange', function () { if (maskHashChange) { return; @@ -481,21 +480,7 @@ function setBackground(page, resolution) { fluidbook.setBackground(page, resolution); } -function searchHints() { - if ($("#q").val().length >= 1) { - fluidbook.search.initSearchHints(); - fluidbook.search.getSearchHints($("#q").val()); - } else { - try { - if ($("#q").val().length == 0) { - fluidbook.search.hideSearchHints(); - fluidbook.search.hideSearchResults(); - fluidbook.nav.burger.showMenuItems(); // Show main menu items that were hidden previously - } - } catch (err) { - } - } -} + function lazy() {