MDL-63628 accessibility: Trigger file links with keyboard

This commit is contained in:
Damyon Wiese 2018-10-12 11:41:49 +08:00
parent 4c5b60a0f9
commit 2fbd00cb22
4 changed files with 28 additions and 4 deletions

View file

@ -24,7 +24,7 @@
M.block_private_files = {};
M.block_private_files.init_tree = function(Y, expand_all, htmlid) {
Y.use('yui2-treeview', function(Y) {
Y.use('yui2-treeview', 'node-event-simulate', function(Y) {
var tree = new Y.YUI2.widget.TreeView(htmlid);
tree.subscribe("clickEvent", function(node, event) {
@ -32,6 +32,12 @@ M.block_private_files.init_tree = function(Y, expand_all, htmlid) {
return false;
});
tree.subscribe("enterKeyPressed", function(node) {
// We want keyboard activation to trigger a click on the first link.
Y.one(node.getContentEl()).one('a').simulate('click');
return false;
});
if (expand_all) {
tree.expandAll();
}

View file

@ -3,7 +3,7 @@ M.mod_assign = {};
M.mod_assign.init_tree = function(Y, expand_all, htmlid) {
var treeElement = Y.one('#'+htmlid);
if (treeElement) {
Y.use('yui2-treeview', function(Y) {
Y.use('yui2-treeview', 'node-event-simulate', function(Y) {
var tree = new Y.YUI2.widget.TreeView(htmlid);
tree.subscribe("clickEvent", function(node, event) {
@ -11,6 +11,12 @@ M.mod_assign.init_tree = function(Y, expand_all, htmlid) {
return false;
});
tree.subscribe("enterKeyPressed", function(node) {
// We want keyboard activation to trigger a click on the first link.
Y.one(node.getContentEl()).one('a').simulate('click');
return false;
});
if (expand_all) {
tree.expandAll();
}

View file

@ -25,7 +25,7 @@
M.mod_folder = {};
M.mod_folder.init_tree = function(Y, id, expand_all) {
Y.use('yui2-treeview', function(Y) {
Y.use('yui2-treeview', 'node-event-simulate', function(Y) {
var tree = new Y.YUI2.widget.TreeView(id);
tree.subscribe("clickEvent", function(node, event) {
@ -33,6 +33,12 @@ M.mod_folder.init_tree = function(Y, id, expand_all) {
return false;
});
tree.subscribe("enterKeyPressed", function(node) {
// We want keyboard activation to trigger a click on the first link.
Y.one(node.getContentEl()).one('a').simulate('click');
return false;
});
if (expand_all) {
tree.expandAll();
} else {

View file

@ -118,7 +118,7 @@ M.mod_wiki.deleteversion = function(Y, args) {
}
M.mod_wiki.init_tree = function(Y, expand_all, htmlid) {
Y.use('yui2-treeview', function(Y) {
Y.use('yui2-treeview', 'node-event-simulate', function(Y) {
var tree = new Y.YUI2.widget.TreeView(htmlid);
tree.subscribe("clickEvent", function(node, event) {
@ -126,6 +126,12 @@ M.mod_wiki.init_tree = function(Y, expand_all, htmlid) {
return false;
});
tree.subscribe("enterKeyPressed", function(node) {
// We want keyboard activation to trigger a click on the first link.
Y.one(node.getContentEl()).one('a').simulate('click');
return false;
});
if (expand_all) {
tree.expandAll();
}