Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…nodes
  • Loading branch information...
commit 07b3331b59f80d023a1b0b2bc8211919e60e49e2 1 parent 4db3699
@rajeshtaneja rajeshtaneja authored
View
4 blocks/navigation/renderer.php
@@ -74,18 +74,20 @@ protected function navigation_node($items, $attrs=array(), $expansionlimit=null,
// 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
6 blocks/navigation/yui/navigation/navigation.js
@@ -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
4 blocks/settings/renderer.php
@@ -40,18 +40,20 @@ protected function navigation_node(navigation_node $node, $attrs=array()) {
// 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) {
Please sign in to comment.
Something went wrong with that request. Please try again.