Commit ffdfe048 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#103391 by m3avrck, RobRoy and dvessel: cleanup active list item classes

parent 118e91cc
...@@ -1096,27 +1096,19 @@ function theme_links($links, $attributes = array('class' => 'links')) { ...@@ -1096,27 +1096,19 @@ function theme_links($links, $attributes = array('class' => 'links')) {
$i = 1; $i = 1;
foreach ($links as $key => $link) { foreach ($links as $key => $link) {
$class = ''; $class = $key;
// Automatically add a class to each link and also to each LI // Add first, last and active classes to the list of links to help out themers.
if (isset($link['attributes']) && isset($link['attributes']['class'])) {
$link['attributes']['class'] .= ' '. $key;
$class = $key;
}
else {
$link['attributes']['class'] = $key;
$class = $key;
}
// Add first and last classes to the list of links to help out themers.
$extra_class = '';
if ($i == 1) { if ($i == 1) {
$extra_class .= 'first '; $class .= ' first';
} }
if ($i == $num_links) { if ($i == $num_links) {
$extra_class .= 'last '; $class .= ' last';
}
if ($link['href'] == $_GET['q']) {
$class .= ' active';
} }
$output .= '<li class="'. $extra_class . $class .'">'; $output .= '<li class="'. $class .'">';
if (isset($link['href'])) { if (isset($link['href'])) {
// Pass in $link as $options, they share the same keys. // Pass in $link as $options, they share the same keys.
...@@ -1127,7 +1119,11 @@ function theme_links($links, $attributes = array('class' => 'links')) { ...@@ -1127,7 +1119,11 @@ function theme_links($links, $attributes = array('class' => 'links')) {
if (empty($link['html'])) { if (empty($link['html'])) {
$link['title'] = check_plain($link['title']); $link['title'] = check_plain($link['title']);
} }
$output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>'; $span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
} }
$i++; $i++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment