Adds configuration for excluding MathJax elements from tab order.

This commit is contained in:
zorkow 2016-01-29 17:22:09 +00:00 committed by Davide P. Cervone
parent 0740dd4735
commit a1bfe0afcf
9 changed files with 25 additions and 11 deletions

View File

@ -1896,6 +1896,7 @@ MathJax.Hub = {
mpContext: false, // true means pass menu events to MathPlayer in IE mpContext: false, // true means pass menu events to MathPlayer in IE
mpMouse: false, // true means pass mouse events to MathPlayer in IE mpMouse: false, // true means pass mouse events to MathPlayer in IE
texHints: true, // include class names for TeXAtom elements texHints: true, // include class names for TeXAtom elements
inTabOrder: false, // set to false if math elements should be included in the tabindex
semantics: false // add semantics tag with original form in MathML output semantics: false // add semantics tag with original form in MathML output
}, },
@ -2367,14 +2368,14 @@ MathJax.Hub = {
error.oncontextmenu = EVENT.Menu; error.oncontextmenu = EVENT.Menu;
error.onmousedown = EVENT.Mousedown; error.onmousedown = EVENT.Mousedown;
error.onkeydown = EVENT.Keydown; error.onkeydown = EVENT.Keydown;
error.tabIndex = 0; error.tabIndex = this.getTabOrder();
} else { } else {
MathJax.Ajax.Require("[MathJax]/extensions/MathEvents.js",function () { MathJax.Ajax.Require("[MathJax]/extensions/MathEvents.js",function () {
var EVENT = MathJax.Extension.MathEvents.Event; var EVENT = MathJax.Extension.MathEvents.Event;
error.oncontextmenu = EVENT.Menu; error.oncontextmenu = EVENT.Menu;
error.onmousedown = EVENT.Mousedown; error.onmousedown = EVENT.Mousedown;
error.keydown = EVENT.Keydown; error.keydown = EVENT.Keydown;
error.tabIndex = 0; error.tabIndex = this.getTabOrder();
}); });
} }
// //
@ -2462,6 +2463,9 @@ MathJax.Hub = {
return dst; return dst;
}, },
getTabOrder: function() {
return this.config.menuSettings.inTabOrder ? 0 : -1},
// Old browsers (e.g. Internet Explorer <= 8) do not support trim(). // Old browsers (e.g. Internet Explorer <= 8) do not support trim().
SplitList: ("trim" in String.prototype ? SplitList: ("trim" in String.prototype ?
function (list) {return list.trim().split(/\s+/)} : function (list) {return list.trim().split(/\s+/)} :

View File

@ -246,6 +246,7 @@ MathJax.Hub.Config({
mpContext: false, // true means pass menu events to MathPlayer in IE mpContext: false, // true means pass menu events to MathPlayer in IE
mpMouse: false, // true means pass mouse events to MathPlayer in IE mpMouse: false, // true means pass mouse events to MathPlayer in IE
texHints: true, // include class names for TeXAtom elements texHints: true, // include class names for TeXAtom elements
inTabOrder: true, // set to true if math elements should be included in the tabindex
semantics: false // add semantics tag with original form in MathML output semantics: false // add semantics tag with original form in MathML output
}, },

View File

@ -546,6 +546,9 @@
Activate: function(event, menu) { Activate: function(event, menu) {
var jaxs = MENU.AllNodes(); var jaxs = MENU.AllNodes();
for (var j = 0, jax; jax = jaxs[j]; j++) { for (var j = 0, jax; jax = jaxs[j]; j++) {
if (jax.tabIndex > 0) {
jax.oldTabIndex = jax.tabIndex;
}
jax.tabIndex = -1; jax.tabIndex = -1;
} }
MENU.posted = true; MENU.posted = true;
@ -554,7 +557,12 @@
MENU.ActiveNode().tabIndex = -1; MENU.ActiveNode().tabIndex = -1;
var jaxs = MENU.AllNodes(); var jaxs = MENU.AllNodes();
for (var j = 0, jax; jax = jaxs[j]; j++) { for (var j = 0, jax; jax = jaxs[j]; j++) {
jax.tabIndex = 0; if (jax.oldTabIndex !== undefined) {
jax.tabIndex = jax.oldTabIndex
delete jax.oldTabIndex;
} else {
jax.tabIndex = HUB.getTabOrder();
}
} }
MENU.FocusNode(MENU.CurrentNode()); MENU.FocusNode(MENU.CurrentNode());
MENU.posted = false; MENU.posted = false;
@ -1534,7 +1542,8 @@
ITEM.RADIO("PlainSource","renderer", {action: MENU.Renderer, value:"PlainSource"}), ITEM.RADIO("PlainSource","renderer", {action: MENU.Renderer, value:"PlainSource"}),
ITEM.RULE(), ITEM.RULE(),
ITEM.CHECKBOX("Fast Preview", "FastPreview"), ITEM.CHECKBOX("Fast Preview", "FastPreview"),
ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {action:MENU.AssistiveMML}) ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {action:MENU.AssistiveMML}),
ITEM.CHECKBOX("Include in Tab Order", "inTabOrder", {action:CONFIG.inTabOrder})
), ),
ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer, ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer,
disabled:!HUB.Browser.hasMathPlayer}, disabled:!HUB.Browser.hasMathPlayer},

View File

@ -403,7 +403,7 @@
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove, onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
onclick:EVENT.Click, ondblclick:EVENT.DblClick, onclick:EVENT.Click, ondblclick:EVENT.DblClick,
// Added for keyboard accessible menu. // Added for keyboard accessible menu.
onkeydown: EVENT.Keydown, tabIndex: "0" onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder()
}); });
if (jax.CHTML.display) { if (jax.CHTML.display) {
// //

View File

@ -578,7 +578,7 @@
onmousemove:EVENT.Mousemove, onclick:EVENT.Click, onmousemove:EVENT.Mousemove, onclick:EVENT.Click,
ondblclick:EVENT.DblClick, ondblclick:EVENT.DblClick,
// Added for keyboard accessible menu. // Added for keyboard accessible menu.
onkeydown: EVENT.Keydown, tabIndex: "0" onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder()
}); });
if (HUB.Browser.noContextMenu) { if (HUB.Browser.noContextMenu) {
span.ontouchstart = TOUCH.start; span.ontouchstart = TOUCH.start;

View File

@ -328,7 +328,7 @@
container.ondblclick = EVENT.DblClick; container.ondblclick = EVENT.DblClick;
// Added for keyboard accessible menu. // Added for keyboard accessible menu.
container.onkeydown = EVENT.Keydown; container.onkeydown = EVENT.Keydown;
container.tabIndex = "0"; container.tabIndex = HUB.getTabOrder();
if (HUB.Browser.noContextMenu) { if (HUB.Browser.noContextMenu) {
container.ontouchstart = TOUCH.start; container.ontouchstart = TOUCH.start;
container.ontouchend = TOUCH.end; container.ontouchend = TOUCH.end;

View File

@ -91,7 +91,7 @@
ondblclick: EVENT.DblClick, ondblclick: EVENT.DblClick,
// Added for keyboard accessible menu. // Added for keyboard accessible menu.
onkeydown: EVENT.Keydown, onkeydown: EVENT.Keydown,
tabIndex: "0" tabIndex: HUB.getTabOrder()
},[["span"]]); },[["span"]]);
if (HUB.Browser.noContextMenu) { if (HUB.Browser.noContextMenu) {
span.ontouchstart = TOUCH.start; span.ontouchstart = TOUCH.start;

View File

@ -199,7 +199,7 @@
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove, onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
onclick:EVENT.Click, ondblclick:EVENT.DblClick, onclick:EVENT.Click, ondblclick:EVENT.DblClick,
// Added for keyboard accessible menu. // Added for keyboard accessible menu.
onkeydown: EVENT.Keydown, tabIndex: "0" onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder()
}); });
if (HUB.Browser.noContextMenu) { if (HUB.Browser.noContextMenu) {
span.ontouchstart = TOUCH.start; span.ontouchstart = TOUCH.start;

View File

@ -222,7 +222,7 @@
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove, onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
onclick:EVENT.Click, ondblclick:EVENT.DblClick, onclick:EVENT.Click, ondblclick:EVENT.DblClick,
// Added for keyboard accessible menu. // Added for keyboard accessible menu.
onkeydown: EVENT.Keydown, tabIndex: "0" onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder()
}); });
if (HUB.Browser.noContextMenu) { if (HUB.Browser.noContextMenu) {
span.ontouchstart = TOUCH.start; span.ontouchstart = TOUCH.start;