diff --git a/blocks/navigation/renderer.php b/blocks/navigation/renderer.php index 3c99b3bc4a4..d39012cd4e2 100644 --- a/blocks/navigation/renderer.php +++ b/blocks/navigation/renderer.php @@ -74,18 +74,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) { diff --git a/blocks/navigation/yui/navigation/navigation.js b/blocks/navigation/yui/navigation/navigation.js index 180977d90ba..2189d51eed2 100644 --- a/blocks/navigation/yui/navigation/navigation.js +++ b/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'); } diff --git a/blocks/settings/renderer.php b/blocks/settings/renderer.php index 41cea8742c2..a19d41e03f9 100644 --- a/blocks/settings/renderer.php +++ b/blocks/settings/renderer.php @@ -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) {