this.fluidbook = fluidbook;
this.shortcuts = [];
this.initKeyboardShortcuts();
+
+
+ /*
+ Next page icon
+ Previous page icon
+ Audio description icon ( listen to the page)
+ All clickable items in the page content (to be arranged in the correct order: Ticket 7467
+ Set / remove Bookmark;
+ Last page icon
+ First page icon
+ Fluidbook menu items Overview, Contents, etc…);
+ Client logo
+ Powered by fluidbook
+
+ Browser items / buttons
+ */
+ this.tabOrderSelectors = ['#next', '#previous', '.audio-description-wrapper.left', '.audio-description-wrapper.right', //.
+ '#links .leftContainer .linksHolder', '#links .rightContainer .linksHolder', //.
+ '#links .leftContainer .bookmark', '#links .rightContainer .bookmark',//.
+ '#last', '#first', //.
+ '#horizontalNav', '#menuOpener', //.
+ '#logo', //.
+ '#credits',];
+ this.ignoreFocus = false;
}
FluidbookKeyboard.prototype = {
initKeyboardShortcuts: function () {
- var $this = this;
+ let $this = this;
hotkeys.filter = function (event) {
var e = $(event.target || event.srcElement);
return !(e.is('input:not(#q),select,textarea'));
$this.escape();
});
this.keyShortcut('tab,shift+tab', function (e, handler) {
+ $this.ignoreFocus = true;
let dir = handler.shortcut === 'tab' ? 1 : -1;
- if ($this.fluidbook.search.isResultNavOpened()) {
- $this.tabNavigation('#searchResultsNav', dir);
- e.preventDefault();
- } else if ($this.fluidbook.nav.burger.isOpened) {
- $this.tabNavigation('#menu', dir);
- e.preventDefault();
- } else if ($this.fluidbook.menu.viewMode()) {
- $this.tabNavigation('.mview', dir);
+ if ($this.handleTab(dir)) {
e.preventDefault();
} else {
- if ($this.tabNavigationSections(['#next', '#previous', '.audio-description-wrapper.left', '.audio-description-wrapper.right', //.
- '#links .leftContainer .linksHolder', '#links .rightContainer .linksHolder', //.
- '#links .leftContainer .bookmark', '#links .rightContainer .bookmark', '#last', '#first', //.
- '#horizontalNav', '#menuOpener', //.
- '#logo', //.
- '#credits',], dir)) {
- e.preventDefault();
+ if (dir === -1) {
+ $("#firstFocus").get(0).focus();
}
}
+ setTimeout(function () {
+ $this.ignoreFocus = false;
+ }, 25);
}, false, false);
setInterval(function () {
$this.listenToIframeEscapeEvents();
}, 500);
+
+ $("#firstFocus").on('focus', function () {
+ if (!$this.ignoreFocus) {
+ $this.handleTab(1);
+ }
+ });
+ },
+
+ handleTab: function (dir) {
+ if (this.fluidbook.search.isResultNavOpened()) {
+ this.tabNavigation('#searchResultsNav', dir);
+ return true;
+ } else if (this.fluidbook.nav.burger.isOpened) {
+ this.tabNavigation('#menu', dir);
+ return true;
+ } else if (this.fluidbook.menu.viewMode()) {
+ this.tabNavigation('.mview', dir);
+ return true;
+ } else {
+ if (this.tabNavigationSections(this.tabOrderSelectors, dir)) {
+ return true;
+ }
+ }
+ return false;
},
listenToIframeEscapeEvents: function () {
elements = $(selector).find(focusableElementsString);
}
var list = [];
- console.log(selector,elements);
$(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);
- } else {
- console.log('skip', this);
}
});
if (list.length === 0) {
- console.log(selector, 'nothing here');
return false;
}
let res = this._navigate(list, dir, ['focus'], loop, switchList);
- if (!res) {
- console.log(selector, 'end of list');
- }
return res;
},
var items = $(list);
var nb = items.length;
if (!nb) {
- console.log('no item here', list);
return false;
}
var next;
}
var ne = $(items).eq(next);
- console.log(items, ne);
$.each(actions, function (k, action) {
if (action === 'focus') {
$(ne).focus();