commit 3e190fc5f4f593d4344d932064b674231ebc2142
parent 031dccee981ab707f8412660f623e0589659bb0f
Author: zorkow <volker.sorge@gmail.com>
Date: Mon, 14 Sep 2015 01:28:13 +0100
Adds additional aria elements for the menu items.
Diffstat:
1 file changed, 38 insertions(+), 7 deletions(-)
diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js
@@ -598,11 +598,13 @@
{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);
},
Create: function (menu) {
+ console.log('create');
if (!this.hidden) {
var def = this.Attributes();
var label = this.Label(def,menu);
@@ -679,14 +681,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 +798,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 +896,13 @@
marker: (isPC ? "\u25CF" : "\u2713"), // the checkmark
role: "menuitemradio",
+ Attributes: function(def) {
+ if (CONFIG.settings[this.variable] === this.value) {
+ def = HUB.Insert({"aria-checked": "true"}, 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,19 +910,24 @@
},
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) {
+ console.log(menu);
if (!this.disabled) {
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;
+ console.log('Changing');
MENU.cookie[this.variable] = CONFIG.settings[this.variable]; MENU.saveCookie();
SIGNAL.Post(["radio button",this]);
}
@@ -929,6 +946,13 @@
marker: "\u2713", // the checkmark
role: "menuitemcheckbox",
+ Attributes: function(def) {
+ if (CONFIG.settings[this.variable]) {
+ def = HUB.Insert({"aria-checked": "true"}, 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 +1002,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;