Skip to content

Commit 0e07941

Browse files
committed
Merge pull request #1376 from dpvc/tabindex
Add configuration for tabIndex attribute.
2 parents 0740dd4 + d1a569c commit 0e07941

File tree

9 files changed

+42
-18
lines changed

9 files changed

+42
-18
lines changed

unpacked/MathJax.js

Lines changed: 8 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: true, // 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(this.getJaxFor(script));
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(this.getJaxFor(script));
23782379
});
23792380
}
23802381
//
@@ -2462,6 +2463,10 @@ MathJax.Hub = {
24622463
return dst;
24632464
},
24642465

2466+
getTabOrder: function(script) {
2467+
return this.config.menuSettings.inTabOrder ? 0 : -1;
2468+
},
2469+
24652470
// Old browsers (e.g. Internet Explorer <= 8) do not support trim().
24662471
SplitList: ("trim" in String.prototype ?
24672472
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: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -544,18 +544,12 @@
544544
MENU.FocusNode(menu);
545545
},
546546
Activate: function(event, menu) {
547-
var jaxs = MENU.AllNodes();
548-
for (var j = 0, jax; jax = jaxs[j]; j++) {
549-
jax.tabIndex = -1;
550-
}
547+
MENU.UnsetTabIndex();
551548
MENU.posted = true;
552549
},
553550
Unfocus: function() {
554551
MENU.ActiveNode().tabIndex = -1;
555-
var jaxs = MENU.AllNodes();
556-
for (var j = 0, jax; jax = jaxs[j]; j++) {
557-
jax.tabIndex = 0;
558-
}
552+
MENU.SetTabIndex();
559553
MENU.FocusNode(MENU.CurrentNode());
560554
MENU.posted = false;
561555
},
@@ -577,6 +571,26 @@
577571
Left: function(event, menu) {
578572
MENU.MoveHorizontal(event, menu, function(x) {return x - 1;});
579573
},
574+
UnsetTabIndex: function () {
575+
var jaxs = MENU.AllNodes();
576+
for (var j = 0, jax; jax = jaxs[j]; j++) {
577+
if (jax.tabIndex > 0) {
578+
jax.oldTabIndex = jax.tabIndex;
579+
}
580+
jax.tabIndex = -1;
581+
}
582+
},
583+
SetTabIndex: function () {
584+
var jaxs = MENU.AllNodes();
585+
for (var j = 0, jax; jax = jaxs[j]; j++) {
586+
if (jax.oldTabIndex !== undefined) {
587+
jax.tabIndex = jax.oldTabIndex
588+
delete jax.oldTabIndex;
589+
} else {
590+
jax.tabIndex = HUB.getTabOrder(jax);
591+
}
592+
}
593+
},
580594

581595
//TODO: Move to utility class.
582596
// Computes a mod n.
@@ -1328,6 +1342,9 @@
13281342
}
13291343
};
13301344

1345+
/*
1346+
* Toggle assistive MML settings
1347+
*/
13311348
MENU.AssistiveMML = function (item,restart) {
13321349
var AMML = MathJax.Extension.AssistiveMML;
13331350
if (!AMML) {
@@ -1534,7 +1551,8 @@
15341551
ITEM.RADIO("PlainSource","renderer", {action: MENU.Renderer, value:"PlainSource"}),
15351552
ITEM.RULE(),
15361553
ITEM.CHECKBOX("Fast Preview", "FastPreview"),
1537-
ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {action:MENU.AssistiveMML})
1554+
ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {action:MENU.AssistiveMML}),
1555+
ITEM.CHECKBOX("Include in Tab Order", "inTabOrder")
15381556
),
15391557
ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer,
15401558
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(jax)
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(jax)
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(jax);
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(jax)
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(jax)
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(jax)
226226
});
227227
if (HUB.Browser.noContextMenu) {
228228
span.ontouchstart = TOUCH.start;

0 commit comments

Comments
 (0)