Skip to content

Commit a1bfe0a

Browse files
zorkowdpvc
authored andcommitted
Adds configuration for excluding MathJax elements from tab order.
1 parent 0740dd4 commit a1bfe0a

File tree

9 files changed

+25
-11
lines changed

9 files changed

+25
-11
lines changed

unpacked/MathJax.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ MathJax.Hub = {
18801880
showMathMenu: true, // attach math context menu to typeset math?
18811881
showMathMenuMSIE: true, // separtely determine if MSIE should have math menu
18821882
// (since the code for that is a bit delicate)
1883-
1883+
18841884
menuSettings: {
18851885
zoom: "None", // when to do MathZoom
18861886
CTRL: false, // require CTRL for MathZoom?
@@ -1896,6 +1896,7 @@ MathJax.Hub = {
18961896
mpContext: false, // true means pass menu events to MathPlayer in IE
18971897
mpMouse: false, // true means pass mouse events to MathPlayer in IE
18981898
texHints: true, // include class names for TeXAtom elements
1899+
inTabOrder: false, // set to false if math elements should be included in the tabindex
18991900
semantics: false // add semantics tag with original form in MathML output
19001901
},
19011902

@@ -2367,14 +2368,14 @@ MathJax.Hub = {
23672368
error.oncontextmenu = EVENT.Menu;
23682369
error.onmousedown = EVENT.Mousedown;
23692370
error.onkeydown = EVENT.Keydown;
2370-
error.tabIndex = 0;
2371+
error.tabIndex = this.getTabOrder();
23712372
} else {
23722373
MathJax.Ajax.Require("[MathJax]/extensions/MathEvents.js",function () {
23732374
var EVENT = MathJax.Extension.MathEvents.Event;
23742375
error.oncontextmenu = EVENT.Menu;
23752376
error.onmousedown = EVENT.Mousedown;
23762377
error.keydown = EVENT.Keydown;
2377-
error.tabIndex = 0;
2378+
error.tabIndex = this.getTabOrder();
23782379
});
23792380
}
23802381
//
@@ -2462,6 +2463,9 @@ MathJax.Hub = {
24622463
return dst;
24632464
},
24642465

2466+
getTabOrder: function() {
2467+
return this.config.menuSettings.inTabOrder ? 0 : -1},
2468+
24652469
// Old browsers (e.g. Internet Explorer <= 8) do not support trim().
24662470
SplitList: ("trim" in String.prototype ?
24672471
function (list) {return list.trim().split(/\s+/)} :

unpacked/config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ MathJax.Hub.Config({
246246
mpContext: false, // true means pass menu events to MathPlayer in IE
247247
mpMouse: false, // true means pass mouse events to MathPlayer in IE
248248
texHints: true, // include class names for TeXAtom elements
249+
inTabOrder: true, // set to true if math elements should be included in the tabindex
249250
semantics: false // add semantics tag with original form in MathML output
250251
},
251252

unpacked/extensions/MathMenu.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,9 @@
546546
Activate: function(event, menu) {
547547
var jaxs = MENU.AllNodes();
548548
for (var j = 0, jax; jax = jaxs[j]; j++) {
549+
if (jax.tabIndex > 0) {
550+
jax.oldTabIndex = jax.tabIndex;
551+
}
549552
jax.tabIndex = -1;
550553
}
551554
MENU.posted = true;
@@ -554,7 +557,12 @@
554557
MENU.ActiveNode().tabIndex = -1;
555558
var jaxs = MENU.AllNodes();
556559
for (var j = 0, jax; jax = jaxs[j]; j++) {
557-
jax.tabIndex = 0;
560+
if (jax.oldTabIndex !== undefined) {
561+
jax.tabIndex = jax.oldTabIndex
562+
delete jax.oldTabIndex;
563+
} else {
564+
jax.tabIndex = HUB.getTabOrder();
565+
}
558566
}
559567
MENU.FocusNode(MENU.CurrentNode());
560568
MENU.posted = false;
@@ -1534,7 +1542,8 @@
15341542
ITEM.RADIO("PlainSource","renderer", {action: MENU.Renderer, value:"PlainSource"}),
15351543
ITEM.RULE(),
15361544
ITEM.CHECKBOX("Fast Preview", "FastPreview"),
1537-
ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {action:MENU.AssistiveMML})
1545+
ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {action:MENU.AssistiveMML}),
1546+
ITEM.CHECKBOX("Include in Tab Order", "inTabOrder", {action:CONFIG.inTabOrder})
15381547
),
15391548
ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer,
15401549
disabled:!HUB.Browser.hasMathPlayer},

unpacked/jax/output/CommonHTML/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
404404
onclick:EVENT.Click, ondblclick:EVENT.DblClick,
405405
// Added for keyboard accessible menu.
406-
onkeydown: EVENT.Keydown, tabIndex: "0"
406+
onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder()
407407
});
408408
if (jax.CHTML.display) {
409409
//

unpacked/jax/output/HTML-CSS/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@
578578
onmousemove:EVENT.Mousemove, onclick:EVENT.Click,
579579
ondblclick:EVENT.DblClick,
580580
// Added for keyboard accessible menu.
581-
onkeydown: EVENT.Keydown, tabIndex: "0"
581+
onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder()
582582
});
583583
if (HUB.Browser.noContextMenu) {
584584
span.ontouchstart = TOUCH.start;

unpacked/jax/output/NativeMML/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
container.ondblclick = EVENT.DblClick;
329329
// Added for keyboard accessible menu.
330330
container.onkeydown = EVENT.Keydown;
331-
container.tabIndex = "0";
331+
container.tabIndex = HUB.getTabOrder();
332332
if (HUB.Browser.noContextMenu) {
333333
container.ontouchstart = TOUCH.start;
334334
container.ontouchend = TOUCH.end;

unpacked/jax/output/PlainSource/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
ondblclick: EVENT.DblClick,
9292
// Added for keyboard accessible menu.
9393
onkeydown: EVENT.Keydown,
94-
tabIndex: "0"
94+
tabIndex: HUB.getTabOrder()
9595
},[["span"]]);
9696
if (HUB.Browser.noContextMenu) {
9797
span.ontouchstart = TOUCH.start;

unpacked/jax/output/PreviewHTML/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
200200
onclick:EVENT.Click, ondblclick:EVENT.DblClick,
201201
// Added for keyboard accessible menu.
202-
onkeydown: EVENT.Keydown, tabIndex: "0"
202+
onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder()
203203
});
204204
if (HUB.Browser.noContextMenu) {
205205
span.ontouchstart = TOUCH.start;

unpacked/jax/output/SVG/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
223223
onclick:EVENT.Click, ondblclick:EVENT.DblClick,
224224
// Added for keyboard accessible menu.
225-
onkeydown: EVENT.Keydown, tabIndex: "0"
225+
onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder()
226226
});
227227
if (HUB.Browser.noContextMenu) {
228228
span.ontouchstart = TOUCH.start;

0 commit comments

Comments
 (0)