diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index 689ef5a17..353c00ed9 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -1880,7 +1880,7 @@ MathJax.Hub = { showMathMenu: true, // attach math context menu to typeset math? showMathMenuMSIE: true, // separtely determine if MSIE should have math menu // (since the code for that is a bit delicate) - + menuSettings: { zoom: "None", // when to do MathZoom CTRL: false, // require CTRL for MathZoom? @@ -1896,6 +1896,7 @@ MathJax.Hub = { mpContext: false, // true means pass menu events to MathPlayer in IE mpMouse: false, // true means pass mouse events to MathPlayer in IE texHints: true, // include class names for TeXAtom elements + inTabOrder: true, // set to false if math elements should be included in the tabindex semantics: false // add semantics tag with original form in MathML output }, @@ -2367,14 +2368,14 @@ MathJax.Hub = { error.oncontextmenu = EVENT.Menu; error.onmousedown = EVENT.Mousedown; error.onkeydown = EVENT.Keydown; - error.tabIndex = 0; + error.tabIndex = this.getTabOrder(this.getJaxFor(script)); } else { MathJax.Ajax.Require("[MathJax]/extensions/MathEvents.js",function () { var EVENT = MathJax.Extension.MathEvents.Event; error.oncontextmenu = EVENT.Menu; error.onmousedown = EVENT.Mousedown; error.keydown = EVENT.Keydown; - error.tabIndex = 0; + error.tabIndex = this.getTabOrder(this.getJaxFor(script)); }); } // @@ -2462,6 +2463,10 @@ MathJax.Hub = { return dst; }, + getTabOrder: function(script) { + return this.config.menuSettings.inTabOrder ? 0 : -1; + }, + // Old browsers (e.g. Internet Explorer <= 8) do not support trim(). SplitList: ("trim" in String.prototype ? function (list) {return list.trim().split(/\s+/)} : diff --git a/unpacked/config/default.js b/unpacked/config/default.js index a6aee2f4f..6f92045d2 100644 --- a/unpacked/config/default.js +++ b/unpacked/config/default.js @@ -246,6 +246,7 @@ MathJax.Hub.Config({ mpContext: false, // true means pass menu events to MathPlayer in IE mpMouse: false, // true means pass mouse events to MathPlayer in IE 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 }, diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js index caa69de33..360231487 100644 --- a/unpacked/extensions/MathMenu.js +++ b/unpacked/extensions/MathMenu.js @@ -544,18 +544,12 @@ MENU.FocusNode(menu); }, Activate: function(event, menu) { - var jaxs = MENU.AllNodes(); - for (var j = 0, jax; jax = jaxs[j]; j++) { - jax.tabIndex = -1; - } + MENU.UnsetTabIndex(); MENU.posted = true; }, Unfocus: function() { MENU.ActiveNode().tabIndex = -1; - var jaxs = MENU.AllNodes(); - for (var j = 0, jax; jax = jaxs[j]; j++) { - jax.tabIndex = 0; - } + MENU.SetTabIndex(); MENU.FocusNode(MENU.CurrentNode()); MENU.posted = false; }, @@ -577,6 +571,26 @@ Left: function(event, menu) { MENU.MoveHorizontal(event, menu, function(x) {return x - 1;}); }, + UnsetTabIndex: function () { + var jaxs = MENU.AllNodes(); + for (var j = 0, jax; jax = jaxs[j]; j++) { + if (jax.tabIndex > 0) { + jax.oldTabIndex = jax.tabIndex; + } + jax.tabIndex = -1; + } + }, + SetTabIndex: function () { + var jaxs = MENU.AllNodes(); + for (var j = 0, jax; jax = jaxs[j]; j++) { + if (jax.oldTabIndex !== undefined) { + jax.tabIndex = jax.oldTabIndex + delete jax.oldTabIndex; + } else { + jax.tabIndex = HUB.getTabOrder(jax); + } + } + }, //TODO: Move to utility class. // Computes a mod n. @@ -1328,6 +1342,9 @@ } }; + /* + * Toggle assistive MML settings + */ MENU.AssistiveMML = function (item,restart) { var AMML = MathJax.Extension.AssistiveMML; if (!AMML) { @@ -1534,7 +1551,8 @@ ITEM.RADIO("PlainSource","renderer", {action: MENU.Renderer, value:"PlainSource"}), ITEM.RULE(), 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") ), ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer, disabled:!HUB.Browser.hasMathPlayer}, diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 54b0f75c3..bed4fe2bb 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -403,7 +403,7 @@ onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove, onclick:EVENT.Click, ondblclick:EVENT.DblClick, // Added for keyboard accessible menu. - onkeydown: EVENT.Keydown, tabIndex: "0" + onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder(jax) }); if (jax.CHTML.display) { // diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index a2ee58dd1..f00dfe6d1 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -578,7 +578,7 @@ onmousemove:EVENT.Mousemove, onclick:EVENT.Click, ondblclick:EVENT.DblClick, // Added for keyboard accessible menu. - onkeydown: EVENT.Keydown, tabIndex: "0" + onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder(jax) }); if (HUB.Browser.noContextMenu) { span.ontouchstart = TOUCH.start; diff --git a/unpacked/jax/output/NativeMML/jax.js b/unpacked/jax/output/NativeMML/jax.js index f830881d6..c7c436587 100644 --- a/unpacked/jax/output/NativeMML/jax.js +++ b/unpacked/jax/output/NativeMML/jax.js @@ -328,7 +328,7 @@ container.ondblclick = EVENT.DblClick; // Added for keyboard accessible menu. container.onkeydown = EVENT.Keydown; - container.tabIndex = "0"; + container.tabIndex = HUB.getTabOrder(jax); if (HUB.Browser.noContextMenu) { container.ontouchstart = TOUCH.start; container.ontouchend = TOUCH.end; diff --git a/unpacked/jax/output/PlainSource/jax.js b/unpacked/jax/output/PlainSource/jax.js index 69f8fe2b4..a34ca39d4 100644 --- a/unpacked/jax/output/PlainSource/jax.js +++ b/unpacked/jax/output/PlainSource/jax.js @@ -91,7 +91,7 @@ ondblclick: EVENT.DblClick, // Added for keyboard accessible menu. onkeydown: EVENT.Keydown, - tabIndex: "0" + tabIndex: HUB.getTabOrder(jax) },[["span"]]); if (HUB.Browser.noContextMenu) { span.ontouchstart = TOUCH.start; diff --git a/unpacked/jax/output/PreviewHTML/jax.js b/unpacked/jax/output/PreviewHTML/jax.js index 52125e84b..1ff2c6c2e 100644 --- a/unpacked/jax/output/PreviewHTML/jax.js +++ b/unpacked/jax/output/PreviewHTML/jax.js @@ -199,7 +199,7 @@ onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove, onclick:EVENT.Click, ondblclick:EVENT.DblClick, // Added for keyboard accessible menu. - onkeydown: EVENT.Keydown, tabIndex: "0" + onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder(jax) }); if (HUB.Browser.noContextMenu) { span.ontouchstart = TOUCH.start; diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 05e72453b..ea221f1d7 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -222,7 +222,7 @@ onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove, onclick:EVENT.Click, ondblclick:EVENT.DblClick, // Added for keyboard accessible menu. - onkeydown: EVENT.Keydown, tabIndex: "0" + onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder(jax) }); if (HUB.Browser.noContextMenu) { span.ontouchstart = TOUCH.start;