From 8e9aed0cbfe0f1559ce1219979e91e14604acafc Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 25 Jun 2025 15:06:36 +0200 Subject: [PATCH] wip #7547 @4 --- js/libs/fluidbook/fluidbook.js | 3 ++ js/libs/fluidbook/fluidbook.keyboard.js | 43 ++++++++++++++++++------- js/libs/fluidbook/fluidbook.links.js | 4 +-- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index c1a1b624..8e6429fc 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -202,6 +202,9 @@ Fluidbook.prototype = { return false; }); + if (this.settings.logo === '') { + $("#logo").hide(); + } if (this.settings.url_link !== '' && this.settings.url_link !== 'http://' && this.settings.url_link !== 'https://') { $("#logo").attr('href', '#'); $(document).on(this.input.clickEvent, '#logo', function () { diff --git a/js/libs/fluidbook/fluidbook.keyboard.js b/js/libs/fluidbook/fluidbook.keyboard.js index 687ab1ee..8d780d76 100644 --- a/js/libs/fluidbook/fluidbook.keyboard.js +++ b/js/libs/fluidbook/fluidbook.keyboard.js @@ -40,13 +40,15 @@ FluidbookKeyboard.prototype = { $this.tabNavigation('.mview', dir); e.preventDefault(); } else { - $this.tabNavigationSections(['#horizontalNav', '#menuOpener', //. + if ($this.tabNavigationSections(['#horizontalNav', '#menuOpener', //. '.audio-description-wrapper.left', '.audio-description-wrapper.right', //. - '#links .leftContainer', '#links .rightContainer', //. + '#links .leftContainer .linksHolder', '#links .rightContainer .linksHolder', //. '#next-arrows', '#prev-arrows', //. + '#links .leftContainer .bookmark', '#links .rightContainer .bookmark', '#logo', //. - '#credits',], dir); - e.preventDefault(); + '#credits',], dir)) { + e.preventDefault(); + } } }, false, false); @@ -71,8 +73,9 @@ FluidbookKeyboard.prototype = { tabNavigationSections: function (selectors, dir) { let currentSection = -1; let active = $(document.activeElement); + $.each(selectors, function (k, s) { - if ($(s).has(active) || $(s).is(active)) { + if (active.is(s) || active.closest(s).length > 0) { currentSection = k; return false; } @@ -81,18 +84,31 @@ FluidbookKeyboard.prototype = { if (currentSection === -1) { currentSection = 0; } - if (!this.tabNavigation(selectors[currentSection], dir, false)) { - currentSection = (currentSection + selectors.length + dir) % selectors.length; - this.tabNavigation(selectors[currentSection], dir, false); + let loop = 0; + while (!this.tabNavigation(selectors[currentSection], dir, false)) { + currentSection += dir; + if (currentSection >= selectors.length || currentSection < 0) { + return false; + } + loop++; + if (loop++ > selectors.length) { + break; + } } + return true; }, tabNavigation: function (selector, dir, loop) { if (loop === undefined) { loop = true; } - var focusableElementsString = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"]:not(.ps__thumb-x):not(.ps__thumb-y), [contenteditable]'; - var elements = $(selector).find(focusableElementsString); + const focusableElementsString = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"]:not(.ps__thumb-x):not(.ps__thumb-y), [contenteditable]'; + let elements; + if ($(selector).is(focusableElementsString)) { + elements = $(selector); + } else { + elements = $(selector).find(focusableElementsString); + } var list = []; $(elements).each(function () { if (parseInt($(this).attr('tabindex')) < 0) { @@ -103,9 +119,14 @@ FluidbookKeyboard.prototype = { } }); if (list.length === 0) { + console.log(selector, 'nothing here'); return false; } - return this._navigate(list, dir, ['focus'], loop); + let res = this._navigate(list, dir, ['focus'], loop); + if (!res) { + console.log(selector, 'end of list'); + } + return res; }, _navigate: function (list, dir, actions, loop) { diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index f83b1b1a..1ee8a1f4 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -753,11 +753,11 @@ FluidbookLinks.prototype = { setLinksInContainer: function (page, side) { var links = $("#links"); - links.append('
'); + links.append('
'); var container = links.find('.' + side + 'Container'); var llinks = this.fluidbook.loader.handleExtension(this.fluidbook.settings.links[page]); if (llinks !== '') { - container.html(llinks); + container.find('.linksHolder').html(llinks); } else if (page == 0) { container.addClass('empty'); } -- 2.39.5