Skip to content

Commit

Permalink
MDL-63628 accessibility: Trigger file links with keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Jan 22, 2019
1 parent 68b59f3 commit bad1713
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
8 changes: 7 additions & 1 deletion blocks/private_files/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@
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) {
// we want normal clicking which redirects to url
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();
}
Expand Down
8 changes: 7 additions & 1 deletion mod/assign/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ 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) {
// We want normal clicking which redirects to url.
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();
}
Expand Down
8 changes: 7 additions & 1 deletion mod/folder/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@
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) {
// we want normal clicking which redirects to url
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 {
Expand Down
8 changes: 7 additions & 1 deletion mod/wiki/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,20 @@ 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) {
// we want normal clicking which redirects to url
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();
}
Expand Down

0 comments on commit bad1713

Please sign in to comment.