MDL-30833 Accessibility: Added aria-expanded attribute on navigation nodes

This commit is contained in:
Rajesh Taneja 2012-09-11 13:04:09 +08:00
parent c8ac480979
commit e5c46b5435
3 changed files with 12 additions and 2 deletions

View File

@ -121,18 +121,20 @@ class block_navigation_renderer extends plugin_renderer_base {
// this applies to the li item which contains all child lists too
$liclasses = array($item->get_css_type(), 'depth_'.$depth);
$liexpandable = array();
if ($item->has_children() && (!$item->forceopen || $item->collapse)) {
$liclasses[] = 'collapsed';
}
if ($isbranch) {
$liclasses[] = 'contains_branch';
$liexpandable = array('aria-expanded' => in_array('collapsed', $liclasses) ? "false" : "true");
} else if ($hasicon) {
$liclasses[] = 'item_with_icon';
}
if ($item->isactive === true) {
$liclasses[] = 'current_branch';
}
$liattr = array('class'=>join(' ',$liclasses));
$liattr = array('class' => join(' ',$liclasses)) + $liexpandable;
// class attribute on the div item which only contains the item content
$divclasses = array('tree_item');
if ($isbranch) {

View File

@ -162,16 +162,20 @@ TREE.prototype = {
switch (e.action) {
case 'expand' :
target.removeClass('collapsed');
target.set('aria-expanded', true);
break;
case 'collapse' :
target.addClass('collapsed');
target.set('aria-expanded', false);
break;
default :
target.toggleClass('collapsed');
target.set('aria-expanded', !target.hasClass('collapsed'));
}
e.halt();
} else {
target.toggleClass('collapsed');
target.set('aria-expanded', !target.hasClass('collapsed'));
}
}
@ -180,6 +184,7 @@ TREE.prototype = {
target.siblings('li').each(function(){
if (this.get('id') !== target.get('id') && !this.hasClass('collapsed')) {
this.addClass('collapsed');
this.set('aria-expanded', false);
}
});
}
@ -287,6 +292,7 @@ BRANCH.prototype = {
}
if (isbranch) {
branchli.addClass('collapsed').addClass('contains_branch');
branchli.set('aria-expanded', false);
branchp.addClass('branch');
}

View File

@ -40,18 +40,20 @@ class block_settings_renderer extends plugin_renderer_base {
// this applies to the li item which contains all child lists too
$liclasses = array($item->get_css_type());
$liexpandable = array();
if (!$item->forceopen || (!$item->forceopen && $item->collapse) || ($item->children->count()==0 && $item->nodetype==navigation_node::NODETYPE_BRANCH)) {
$liclasses[] = 'collapsed';
}
if ($isbranch) {
$liclasses[] = 'contains_branch';
$liexpandable = array('aria-expanded' => in_array('collapsed', $liclasses) ? "false" : "true");
} else if ($hasicon) {
$liclasses[] = 'item_with_icon';
}
if ($item->isactive === true) {
$liclasses[] = 'current_branch';
}
$liattr = array('class'=>join(' ',$liclasses));
$liattr = array('class' => join(' ',$liclasses)) + $liexpandable;
// class attribute on the div item which only contains the item content
$divclasses = array('tree_item');
if ($isbranch) {