commit 980091128a265de1d0ce152108ca42f5e491b296
parent 1c0597b921118c6ffb3f91fe9b55fcfb4fb2d1e3
Author: Davide P. Cervone <dpvc@union.edu>
Date: Mon, 14 Sep 2015 07:20:48 -0400
Merge pull request #1265 from mathjax/add_more_aria
Add some more ARIA
Diffstat:
2 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/unpacked/extensions/HelpDialog.js b/unpacked/extensions/HelpDialog.js
@@ -155,8 +155,8 @@
]],
["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]],
["span",{id: "MathJax_HelpClose", onclick: HELP.Remove,
- onkeydown: HELP.Keydown, tabIndex: 0,
- "aria-label": "Close", "aria-describedby": "Close window"},
+ onkeydown: HELP.Keydown, tabIndex: 0, role: "button",
+ "aria-label": "Close window"},
[["span",{},["\u00D7"]]]
]
]));
diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js
@@ -280,7 +280,7 @@
onmouseup: MENU.Mouseup, ondblclick: FALSE,
ondragstart: FALSE, onselectstart: FALSE, oncontextmenu: FALSE,
menuItem: this, className: "MathJax_Menu", onkeydown: MENU.Keydown,
- role: "navigation"
+ role: "menu"
});
if (!forceLTR) {MathJax.Localization.setCSS(menu)}
@@ -598,7 +598,8 @@
{onmouseup: MENU.Mouseup,
ondragstart: FALSE, onselectstart: FALSE, onselectend: FALSE,
ontouchstart: MENU.Touchstart, ontouchend: MENU.Touchend,
- className: "MathJax_MenuItem", menuItem: this},
+ className: "MathJax_MenuItem", role: this.role,
+ menuItem: this},
def);
},
@@ -679,14 +680,12 @@
* Abstract class of menu items that are focusable and perform some action
*/
MENU.ENTRY = MENU.ITEM.Subclass({
-
role: "menuitem", // Aria role.
Attributes: function(def) {
def = HUB.Insert(
{onmouseover: MENU.Mouseover, onmouseout: MENU.Mouseout,
- onmousedown: MENU.Mousedown, role: this.role,
- onkeydown: MENU.Keydown,
+ onmousedown: MENU.Mousedown, onkeydown: MENU.Keydown,
"aria-disabled": !!this.disabled},
def);
def = this.SUPER(arguments).Attributes.call(this, def);
@@ -798,6 +797,11 @@
marker: "\u25BA", // the submenu arrow
markerRTL: "\u25C4", // the submenu arrow for RTL
+ Attributes: function(def) {
+ def = HUB.Insert({"aria-haspopup": "true"}, def);
+ def = this.SUPER(arguments).Attributes.call(this, def);
+ return def;
+ },
Init: function (name,def) {
if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair
this.name = name; var i = 1;
@@ -891,6 +895,12 @@
marker: (isPC ? "\u25CF" : "\u2713"), // the checkmark
role: "menuitemradio",
+ Attributes: function(def) {
+ var checked = CONFIG.settings[this.variable] === this.value ? "true" : "false";
+ def = HUB.Insert({"aria-checked": checked}, def);
+ def = this.SUPER(arguments).Attributes.call(this, def);
+ return def;
+ },
Init: function (name,variable,def) {
if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair
this.name = name; this.variable = variable; this.With(def);
@@ -898,7 +908,9 @@
},
Label: function (def,menu) {
var span = {className:"MathJax_MenuRadioCheck" + this.rtlClass()};
- if (CONFIG.settings[this.variable] !== this.value) {span = {style:{display:"none"}}}
+ if (CONFIG.settings[this.variable] !== this.value) {
+ span = {style:{display:"none"}};
+ }
return [["span",span,[this.marker]]," "+this.Name()];
},
Mouseup: function (event,menu) {
@@ -906,8 +918,9 @@
var child = menu.parentNode.childNodes;
for (var i = 0, m = child.length; i < m; i++) {
var item = child[i].menuItem;
- if (item && item.variable === this.variable)
- {child[i].firstChild.style.display = "none"}
+ if (item && item.variable === this.variable) {
+ child[i].firstChild.style.display = "none";
+ }
}
menu.firstChild.display = "";
CONFIG.settings[this.variable] = this.value;
@@ -929,6 +942,12 @@
marker: "\u2713", // the checkmark
role: "menuitemcheckbox",
+ Attributes: function(def) {
+ var checked = CONFIG.settings[this.variable] ? "true" : "false";
+ def = HUB.Insert({"aria-checked": checked}, def);
+ def = this.SUPER(arguments).Attributes.call(this, def);
+ return def;
+ },
Init: function (name,variable,def) {
if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair
this.name = name; this.variable = variable; this.With(def);
@@ -978,6 +997,13 @@
* A rule in a menu
*/
MENU.ITEM.RULE = MENU.ITEM.Subclass({
+ role: "separator",
+
+ Attributes: function(def) {
+ def = HUB.Insert({"aria-orientation": "vertical"}, def);
+ def = this.SUPER(arguments).Attributes.call(this, def);
+ return def;
+ },
Label: function (def,menu) {
def.className += " MathJax_MenuRule";
return null;
@@ -1019,8 +1045,8 @@
["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]],
["span",{className:"MathJax_MenuClose",id:"MathJax_AboutClose",
onclick:MENU.About.Remove,
- onkeydown: MENU.About.Keydown, tabIndex: 0,
- "aria-label": "Close", "aria-describedby": "Close window"},
+ onkeydown: MENU.About.Keydown, tabIndex: 0, role: "button",
+ "aria-label": "Close window"},
[["span",{},"\u00D7"]]]
]);
about.focus();