#521852 by brandonojc, Everett Zufelt, mgifford, and sun: Provide semantic markup to local tasks to indicate an active task.
parent
8b4ac207ca
commit
641306e95c
|
@ -1408,7 +1408,22 @@ function theme_menu_link(array $variables) {
|
|||
*/
|
||||
function theme_menu_local_task($variables) {
|
||||
$link = $variables['element']['#link'];
|
||||
return '<li' . (!empty($variables['element']['#active']) ? ' class="active"' : '') . '>' . l($link['title'], $link['href'], $link['localized_options']) . "</li>\n";
|
||||
$link_text = $link['title'];
|
||||
|
||||
if (!empty($variables['element']['#active'])) {
|
||||
// Add text to indicate active tab for non-visual users.
|
||||
$active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
|
||||
|
||||
// If the link does not contain HTML already, check_plain() it now.
|
||||
// After we set 'html'=TRUE the link will not be sanitized by l().
|
||||
if (empty($link['localized_options']['html'])) {
|
||||
$link['title'] = check_plain($link['title']);
|
||||
}
|
||||
$link['localized_options']['html'] = TRUE;
|
||||
$link_text = t('!local-task-title !active', array('!local-task-title' => $link['title'], '!active' => $active));
|
||||
}
|
||||
|
||||
return '<li' . (!empty($variables['element']['#active']) ? ' class="active"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . "</li>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -206,7 +206,9 @@ class PageEditTestCase extends DrupalWebTestCase {
|
|||
$this->assertEqual($edit_url, $actual_url, t('On edit page.'));
|
||||
|
||||
// Check that the title and body fields are displayed with the correct values.
|
||||
$this->assertLink(t('Edit'), 0, t('Edit tab found.'));
|
||||
$active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
|
||||
$link_text = t('!local-task-title !active', array('!local-task-title' => t('Edit'), '!active' => $active));
|
||||
$this->assertText(strip_tags($link_text), 0, t('Edit tab found and marked active.'));
|
||||
$this->assertFieldByName($title_key, $edit[$title_key], t('Title field displayed.'));
|
||||
$this->assertFieldByName($body_key, $edit[$body_key], t('Body field displayed.'));
|
||||
|
||||
|
|
Loading…
Reference in New Issue