]> _ Git - fluidbook-html5.git/commitdiff
fix #3779 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jul 2020 17:55:35 +0000 (19:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jul 2020 17:55:35 +0000 (19:55 +0200)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.keyboard.js
js/libs/fluidbook/fluidbook.menu.js
js/libs/fluidbook/fluidbook.search.js

index e0bcb7380d44db17a22c975a1dd18d9d832882ad..481484f9fa7ae5204532f2027d8e92531471b103 100644 (file)
@@ -521,12 +521,12 @@ Fluidbook.prototype = {
 
     hideArrows: function (id) {
         $(id).addClass('hidden').attr('aria-hidden', 'true');
-        $(id).find('a').attr('tabindex', '-1');
+        $(id).find('a').prop('tabindex', -1);
     },
 
     showArrows: function (id) {
         $(id).removeClass('hidden').attr('aria-hidden', 'false');
-        $(id).find('a').attr('tabindex', null);
+        $(id).find('a').prop('tabindex', 0);
     },
 
     updateShadows: function (page, animationDuration) {
index 3fdecb8ed989b71673f35182a4390a52925db2be..ebb451a4d85949a388a8ccef7fc2bf688519555e 100644 (file)
@@ -28,6 +28,14 @@ FluidbookKeyboard.prototype = {
                 screenfull.exit();
             }
         });
+        this.keyShortcut('tab,shift+tab', function (e, handler) {
+            if ($this.fluidbook.menu.viewMode()) {
+                $this.tabNavigation('.mview', handler.shortcut === 'tab' ? 1 : -1);
+                e.preventDefault();
+            }
+        }, false, false);
+
+
         if (this.fluidbook.settings.fullscreen) {
             this.keyShortcut('f11', function () {
                 screenfull.toggle();
@@ -40,6 +48,35 @@ FluidbookKeyboard.prototype = {
         }
     },
 
+    _navigate: function (list, dir) {
+        if (dir === undefined) {
+            dir = 1;
+        }
+        var items = $(list);
+        console.log(list);
+        var nb = items.length;
+        var next;
+        if ($(items).has(document.activeElement)) {
+            var index = $(items).index(document.activeElement);
+            next = (nb + index + dir) % nb;
+            console.log('n', nb);
+        } else {
+            if (dir === 1) {
+                next = 0;
+            } else {
+                next = nb - 1;
+            }
+        }
+        console.log(next);
+        var ne = $(items).eq(next);
+        $(ne).focus();
+    },
+
+    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]';
+        this._navigate($(selector).find(focusableElementsString), dir);
+    },
+
     initBookmarksShortcuts: function () {
         var $this = this;
         this.keyShortcut('ctrl+alt+d', function () {
@@ -71,7 +108,7 @@ FluidbookKeyboard.prototype = {
             if ($this.fluidbook.search.isHintsNavOpened()) {
                 $this.fluidbook.search.navigateHint(handler.key === 'down' ? 1 : -1);
                 e.preventDefault();
-            }else if($this.fluidbook.search.isResultsOverviewOpened()) {
+            } else if ($this.fluidbook.search.isResultsOverviewOpened()) {
                 $this.fluidbook.search.navigateResults(handler.key === 'down' ? 1 : -1);
             }
         }, false, false);
index a53eacc53fcc49c8e229275efb8c39fa8509b4cd..41b587045b35ebf9de8339582d22b428e640428d 100644 (file)
@@ -168,7 +168,7 @@ FluidbookMenu.prototype = {
         $("#view").append(res);
     },
 
-    getCaption:function(caption, close, cls) {
+    getCaption: function (caption, close, cls) {
         if (cls === undefined) {
             cls = '';
         }
index 596c41533ffc8db75f23fae0e81093a6dc92f4b6..7c3c94fcd0b2cc19b7da8d0f0427f4e11472678f 100644 (file)
@@ -165,35 +165,13 @@ FluidbookSearch.prototype = {
     },
 
     navigateHint: function (dir) {
-        this._navigate("#menuSearchHints .hint", '.hint', dir);
+        this.fluidbook.keyboard._navigate("#menuSearchHints .hint", dir);
     },
 
     navigateResults: function (dir) {
-        this._navigate('#menuSearchResults .doubleThumb', '.doubleThumb', dir);
+        this.fluidbook.keyboard._navigate('#menuSearchResults .doubleThumb', dir);
     },
 
-    _navigate: function (listSelector, elementSelector, dir) {
-        if (dir === undefined) {
-            dir = 1;
-        }
-        var hints = $(listSelector);
-        var nbhints = hints.length;
-        var next;
-        if ($(document.activeElement).is(elementSelector)) {
-            var index = $(hints).index(document.activeElement);
-            next = (nbhints + index + dir) % nbhints;
-        } else {
-            if (dir === 1) {
-                next = 0;
-            } else {
-                next = nbhints - 1;
-            }
-        }
-        var ne = $(hints).eq(next);
-        $(ne).focus();
-    },
-
-
     closeResultsNav: function (keepSearch) {
         keepSearch = keepSearch !== 'undefined' ? keepSearch : false;