MDL-71603 editor_atto: set aria-pressed when a button status is changed

This commit is contained in:
Shamim Rezaie 2021-06-28 02:29:59 +10:00
parent 1eeb7ce395
commit d93fb10f88
8 changed files with 14 additions and 2 deletions

View File

@ -129,6 +129,8 @@ Y.namespace('M.atto_collapse').Button = Y.Base.create('button', Y.M.editor_atto.
button.setAttribute('aria-expanded', 'false');
}
// We don't want to have both aria-pressed and aria-expanded set. So we remove aria-pressed here.
button.removeAttribute('aria-pressed');
}
}, {
ATTRS: {

View File

@ -1 +1 @@
YUI.add("moodle-atto_collapse-button",function(s,t){var o="atto_collapse",a="showgroups",e="collapse",l="collapsed",n=".atto_group",r=".atto_toolbar_row";s.namespace("M.atto_collapse").Button=s.Base.create("button",s.M.editor_atto.EditorPlugin,[],{initializer:function(){var t,i=s.Object.size(this.get("host").get("plugins"));i<=1+parseInt(this.get(a),10)||this.toolbar.all(n).size()>this.get(a)||(t=this.addButton({icon:"icon",iconComponent:o,callback:this._toggle}),this.get("host").on("pluginsloaded",function(t,i){var e,o=[s.Node.create('<div class="atto_toolbar_row"></div>'),s.Node.create('<div class="atto_toolbar_row" tabindex="-1"></div>')];this.toolbar.appendChild(o[0]).insert(o[1],"after"),(e=this.toolbar.all(n)).slice(0,this.get(a)).each(function(t){o[0].appendChild(t)}),e.slice(this.get(a)).each(function(t){o[1].appendChild(t)}),this._setVisibility(i),i.setAttribute("aria-expanded","false")},this,t))},_toggle:function(t){t.preventDefault();var i=this.buttons[e];i.getData(l)?(this.highlightButtons(e),this._setVisibility(i,!0),this.toolbar.all(r).item(1).focus()):(this.unHighlightButtons(e),this._setVisibility(i),this.buttons[this.name].focus())},_setVisibility:function(t,i){var e=this.toolbar.all(r).item(1);i?(t.set("title",M.util.get_string("showfewer",o)),e.show(),t.setData(l,!1),t.setAttribute("aria-expanded","true")):(t.set("title",M.util.get_string("showmore",o)),e.hide(),t.setData(l,!0),t.setAttribute("aria-expanded","false"))}},{ATTRS:{showgroups:{value:3}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
YUI.add("moodle-atto_collapse-button",function(s,t){var o="atto_collapse",a="showgroups",e="collapse",l="collapsed",n=".atto_group",r=".atto_toolbar_row";s.namespace("M.atto_collapse").Button=s.Base.create("button",s.M.editor_atto.EditorPlugin,[],{initializer:function(){var t,i=s.Object.size(this.get("host").get("plugins"));i<=1+parseInt(this.get(a),10)||this.toolbar.all(n).size()>this.get(a)||(t=this.addButton({icon:"icon",iconComponent:o,callback:this._toggle}),this.get("host").on("pluginsloaded",function(t,i){var e,o=[s.Node.create('<div class="atto_toolbar_row"></div>'),s.Node.create('<div class="atto_toolbar_row" tabindex="-1"></div>')];this.toolbar.appendChild(o[0]).insert(o[1],"after"),(e=this.toolbar.all(n)).slice(0,this.get(a)).each(function(t){o[0].appendChild(t)}),e.slice(this.get(a)).each(function(t){o[1].appendChild(t)}),this._setVisibility(i),i.setAttribute("aria-expanded","false")},this,t))},_toggle:function(t){t.preventDefault();var i=this.buttons[e];i.getData(l)?(this.highlightButtons(e),this._setVisibility(i,!0),this.toolbar.all(r).item(1).focus()):(this.unHighlightButtons(e),this._setVisibility(i),this.buttons[this.name].focus())},_setVisibility:function(t,i){var e=this.toolbar.all(r).item(1);i?(t.set("title",M.util.get_string("showfewer",o)),e.show(),t.setData(l,!1),t.setAttribute("aria-expanded","true")):(t.set("title",M.util.get_string("showmore",o)),e.hide(),t.setData(l,!0),t.setAttribute("aria-expanded","false")),t.removeAttribute("aria-pressed")}},{ATTRS:{showgroups:{value:3}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});

View File

@ -125,6 +125,8 @@ Y.namespace('M.atto_collapse').Button = Y.Base.create('button', Y.M.editor_atto.
button.setAttribute('aria-expanded', 'false');
}
// We don't want to have both aria-pressed and aria-expanded set. So we remove aria-pressed here.
button.removeAttribute('aria-pressed');
}
}, {
ATTRS: {

View File

@ -127,6 +127,8 @@ Y.namespace('M.atto_collapse').Button = Y.Base.create('button', Y.M.editor_atto.
button.setAttribute('aria-expanded', 'false');
}
// We don't want to have both aria-pressed and aria-expanded set. So we remove aria-pressed here.
button.removeAttribute('aria-pressed');
}
}, {
ATTRS: {

View File

@ -1041,11 +1041,13 @@ EditorPluginButtons.prototype = {
if (button) {
if (this.buttons[button]) {
this.buttons[button][method](HIGHLIGHT);
this.buttons[button].setAttribute('aria-pressed', highlight ? 'true' : 'false');
this._buttonHighlightToggled(button, highlight);
}
} else {
Y.Object.each(this.buttons, function(button) {
button[method](HIGHLIGHT);
button.setAttribute('aria-pressed', highlight ? 'true' : 'false');
this._buttonHighlightToggled(button, highlight);
}, this);
}

File diff suppressed because one or more lines are too long

View File

@ -1037,11 +1037,13 @@ EditorPluginButtons.prototype = {
if (button) {
if (this.buttons[button]) {
this.buttons[button][method](HIGHLIGHT);
this.buttons[button].setAttribute('aria-pressed', highlight ? 'true' : 'false');
this._buttonHighlightToggled(button, highlight);
}
} else {
Y.Object.each(this.buttons, function(button) {
button[method](HIGHLIGHT);
button.setAttribute('aria-pressed', highlight ? 'true' : 'false');
this._buttonHighlightToggled(button, highlight);
}, this);
}

View File

@ -891,11 +891,13 @@ EditorPluginButtons.prototype = {
if (button) {
if (this.buttons[button]) {
this.buttons[button][method](HIGHLIGHT);
this.buttons[button].setAttribute('aria-pressed', highlight ? 'true' : 'false');
this._buttonHighlightToggled(button, highlight);
}
} else {
Y.Object.each(this.buttons, function(button) {
button[method](HIGHLIGHT);
button.setAttribute('aria-pressed', highlight ? 'true' : 'false');
this._buttonHighlightToggled(button, highlight);
}, this);
}