From 3e190fc5f4f593d4344d932064b674231ebc2142 Mon Sep 17 00:00:00 2001 From: zorkow Date: Mon, 14 Sep 2015 01:28:13 +0100 Subject: [PATCH 1/4] Adds additional aria elements for the menu items. --- unpacked/extensions/MathMenu.js | 45 ++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js index 48d9c020f..8bcbd0163 100644 --- 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; From e3a62c0dfe165ed2b564be7c5646ded141af75d3 Mon Sep 17 00:00:00 2001 From: zorkow Date: Mon, 14 Sep 2015 01:43:57 +0100 Subject: [PATCH 2/4] Fixes the menu role. --- unpacked/extensions/MathMenu.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js index 8bcbd0163..1bb2834af 100644 --- 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)} @@ -897,9 +897,8 @@ role: "menuitemradio", Attributes: function(def) { - if (CONFIG.settings[this.variable] === this.value) { - def = HUB.Insert({"aria-checked": "true"}, 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; }, @@ -947,9 +946,8 @@ role: "menuitemcheckbox", Attributes: function(def) { - if (CONFIG.settings[this.variable]) { - def = HUB.Insert({"aria-checked": "true"}, 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; }, From 3b099e971aa80336009e73e08920df9798614f6e Mon Sep 17 00:00:00 2001 From: zorkow Date: Mon, 14 Sep 2015 02:03:21 +0100 Subject: [PATCH 3/4] Fixes labelling for close buttons. --- unpacked/extensions/HelpDialog.js | 4 ++-- unpacked/extensions/MathMenu.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unpacked/extensions/HelpDialog.js b/unpacked/extensions/HelpDialog.js index 2c16eb1ca..659408789 100644 --- 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 index 1bb2834af..a76a0122b 100644 --- a/unpacked/extensions/MathMenu.js +++ b/unpacked/extensions/MathMenu.js @@ -1048,8 +1048,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(); From 7c870b6d93c64b79287cc49337e9d2ae6ce0f20a Mon Sep 17 00:00:00 2001 From: zorkow Date: Mon, 14 Sep 2015 11:55:50 +0100 Subject: [PATCH 4/4] Cleaned code. --- unpacked/extensions/MathMenu.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js index a76a0122b..ab1e698bd 100644 --- a/unpacked/extensions/MathMenu.js +++ b/unpacked/extensions/MathMenu.js @@ -604,7 +604,6 @@ }, Create: function (menu) { - console.log('create'); if (!this.hidden) { var def = this.Attributes(); var label = this.Label(def,menu); @@ -915,7 +914,6 @@ 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++) { @@ -926,7 +924,6 @@ } 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]); }