$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);
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;
}
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) {
}
});
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) {