]> _ Git - fluidbook-html5.git/commitdiff
wip #7547 @5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 24 Jun 2025 16:23:54 +0000 (18:23 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 24 Jun 2025 16:23:54 +0000 (18:23 +0200)
_index.html
js/libs/fluidbook/fluidbook.audiodescription.js
js/libs/fluidbook/fluidbook.keyboard.js

index c060fc29a5cc62dd1193ae9312dd78e0c2dfdd0d..05e0f54c993f39d95a7f64a2358e2f9b32a2d94c 100644 (file)
@@ -57,7 +57,7 @@
         <nav id="horizontalNav" role="navigation"></nav>
         <nav id="menu" aria-hidden="true"></nav>
         <div id="search"></div>
-        <a id="logo" aria-hidden="true" tabindex="-1"></a>
+        <a id="logo" aria-hidden="true"></a>
     </header>
     <nav role="navigation" id="interface"></nav>
     <div id="helpView"></div>
index 4403a47e6988be3d4a9a03f6d262cc498c218089..817aeca95f29a2ee57dbd58ce8625c2d6e04518f 100644 (file)
@@ -33,11 +33,13 @@ FluidbookAudioDescription.prototype = {
     init: function () {
 
         // Add button elements
-        this.container.append(this.buttonLeft);
-        this.container.append(this.buttonRight);
+        this.container.append('<div class="audio-description-wrapper left" />');
+        this.container.find('.audio-description-wrapper.left').append(this.buttonLeft);
+        this.container.append('<div class="audio-description-wrapper right" />');
+        this.container.find('.audio-description-wrapper.right').append(this.buttonRight);
 
-        var $this = this,
-            buttons = $('.' + this.buttonClass)
+        var $this = this;
+        var buttons = $('.' + this.buttonClass)
 
         // Add tooltips
         buttons.attr('data-tooltip', this.fluidbook.l10n.__('listen to the page'));
@@ -103,6 +105,7 @@ FluidbookAudioDescription.prototype = {
             $(this.buttonLeft).hide();
         }
 
+
         // Right hand page
         if (this.hasAudio(pageNumRight) && !this.fluidbook.displayOnePage) {
             $(this.buttonRight).show();
@@ -143,8 +146,7 @@ FluidbookAudioDescription.prototype = {
 
     playSide: function (side) {
 
-        var targetSelector = '.' + this.buttonClass + '.' + side,
-            pageNum = this.fluidbook.getPageNumberOfSide(side);
+        var targetSelector = '.' + this.buttonClass + '.' + side, pageNum = this.fluidbook.getPageNumberOfSide(side);
 
         // Only try to play audio if available (button will be visible)
         if (this.hasAudio(pageNum)) {
index f47bdf024da9a20c1ad3b13a163f5898fe5a384c..07d5baa24dd2942081336cc8193ce49eb6026556 100644 (file)
@@ -39,6 +39,9 @@ FluidbookKeyboard.prototype = {
             } else if ($this.fluidbook.menu.viewMode()) {
                 $this.tabNavigation('.mview', dir);
                 e.preventDefault();
+            } else {
+                $this.tabNavigationSections(['.audio-description-wrapper.left', '.audio-description-wrapper.right'], dir);
+                e.preventDefault();
             }
         }, false, false);
 
@@ -59,7 +62,48 @@ FluidbookKeyboard.prototype = {
         })
     },
 
-    _navigate: function (list, dir, actions) {
+
+    tabNavigationSections: function (selectors, dir) {
+        let currentSection = -1;
+        let active = $(document.activeElement);
+        $.each(selectors, function (k, s) {
+            if ($(s).has(active) || $(s).is(active)) {
+                currentSection = k;
+                return false;
+            }
+        });
+
+        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);
+        }
+    },
+
+    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);
+        var list = [];
+        $(elements).each(function () {
+            if (parseInt($(this).attr('tabindex')) < 0) {
+                return;
+            }
+            if ($(this).parents('[tabindex="-1"],.ignore-tab-children').length === 0 && $(this).is(':visible')) {
+                list.push(this);
+            }
+        });
+        return this._navigate(list, dir, ['focus'], loop);
+    },
+
+    _navigate: function (list, dir, actions, loop) {
+        if (loop === undefined) {
+            loop = true;
+        }
         if (actions === undefined) {
             actions = ['focus'];
         }
@@ -71,7 +115,14 @@ FluidbookKeyboard.prototype = {
         var next;
         if ($(items).has(document.activeElement)) {
             var index = $(items).index(document.activeElement);
-            next = (nb + index + dir) % nb;
+            if (loop) {
+                next = (nb + index + dir) % nb;
+            } else {
+                next = index + dir;
+                if (next >= nb || next < 0) {
+                    return false;
+                }
+            }
         } else {
             if (dir === 1) {
                 next = 0;
@@ -80,7 +131,6 @@ FluidbookKeyboard.prototype = {
             }
         }
         var ne = $(items).eq(next);
-        console.log(items, ne);
         $.each(actions, function (k, action) {
             if (action === 'focus') {
                 $(ne).focus();
@@ -88,21 +138,7 @@ FluidbookKeyboard.prototype = {
                 $(ne).click();
             }
         });
-    },
-
-    tabNavigation: function (selector, dir) {
-        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);
-        var list = [];
-        $(elements).each(function () {
-            if ($(this).attr('tabindex') == '-1') {
-                return;
-            }
-            if ($(this).parents('[tabindex="-1"],.ignore-tab-children').length === 0 && $(this).is(':visible')) {
-                list.push(this);
-            }
-        });
-        this._navigate(list, dir);
+        return true;
     },
 
     initBookmarksShortcuts: function () {