Commit 9c5aac97 authored by catch's avatar catch

Issue #1649780 by effulgentsia, jibran, Wim Leers, nod_, hefox, joelpittet,...

Issue #1649780 by effulgentsia, jibran, Wim Leers, nod_, hefox, joelpittet, kaare, BarisW, sun, rbayliss, Cottser, fubhy: Remove first/last/odd/even classes in favor of CSS3 pseudo selectors.
parent 6da8ebd0
......@@ -1108,14 +1108,8 @@ function menu_tree_output($tree) {
$router_item = menu_get_item();
$num_items = count($items);
foreach ($items as $i => $data) {
foreach ($items as $data) {
$class = array();
if ($i == 0) {
$class[] = 'first';
}
if ($i == $num_items - 1) {
$class[] = 'last';
}
// Set a class for the <li>-tag. Since $data['below'] may contain local
// tasks, only set 'expanded' class if the link also has children within
// the current menu.
......
......@@ -1234,14 +1234,10 @@ function theme_links($variables) {
$output .= '<ul' . new Attribute($attributes) . '>';
$num_links = count($links);
$i = 0;
$active = \Drupal::linkGenerator()->getActive();
$language_url = \Drupal::languageManager()->getLanguage(Language::TYPE_URL);
foreach ($links as $key => $link) {
$i++;
$link += array(
'href' => NULL,
'route_name' => NULL,
......@@ -1252,14 +1248,6 @@ function theme_links($variables) {
$class = array();
// Use the array key as class name.
$class[] = drupal_html_class($key);
// Add odd/even, first, and last classes.
$class[] = ($i % 2 ? 'odd' : 'even');
if ($i == 1) {
$class[] = 'first';
}
if ($i == $num_links) {
$class[] = 'last';
}
$link_element = array(
'#type' => 'link',
......@@ -1810,10 +1798,7 @@ function theme_item_list($variables) {
if ($items) {
$output .= '<' . $list_type . new Attribute($list_attributes) . '>';
$num_items = count($items);
$i = 0;
foreach ($items as &$item) {
$i++;
$attributes = array();
if (is_array($item)) {
if (isset($item['#wrapper_attributes'])) {
......@@ -1821,13 +1806,6 @@ function theme_item_list($variables) {
}
$item = drupal_render($item);
}
$attributes['class'][] = ($i % 2 ? 'odd' : 'even');
if ($i == 1) {
$attributes['class'][] = 'first';
}
if ($i == $num_items) {
$attributes['class'][] = 'last';
}
$output .= '<li' . new Attribute($attributes) . '>' . $item . '</li>';
}
$output .= "</$list_type>";
......
......@@ -213,7 +213,7 @@ public function buildForm(array $form, array &$form_state) {
$form['blocks'][$region] = array(
'#attributes' => array(
'class' => array('region-title', 'region-title-' . $region, 'odd'),
'class' => array('region-title', 'region-title-' . $region),
'no_striping' => TRUE,
),
);
......
......@@ -293,7 +293,7 @@ public function testBlockContextualLinks() {
$response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-page')));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure odd first"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '?destination=test-page">Configure block</a></li><li class="views-uiedit even last"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1?destination=test-page">Edit view</a></li></ul>');
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '?destination=test-page">Configure block</a></li><li class="views-uiedit"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1?destination=test-page">Edit view</a></li></ul>');
}
}
......@@ -78,9 +78,9 @@ function testDifferentPermissions() {
$response = $this->renderContextualLinks($ids, 'node');
$this->assertResponse(200);
$json = drupal_json_decode($response);
$this->assertIdentical($json[$ids[0]], '<ul class="contextual-links"><li class="nodepage-edit odd first last"><a href="' . base_path() . 'node/1/edit?destination=node">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[0]], '<ul class="contextual-links"><li class="nodepage-edit"><a href="' . base_path() . 'node/1/edit?destination=node">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[1]], '');
$this->assertIdentical($json[$ids[2]], '<ul class="contextual-links"><li class="nodepage-edit odd first last"><a href="' . base_path() . 'node/3/edit?destination=node">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[2]], '<ul class="contextual-links"><li class="nodepage-edit"><a href="' . base_path() . 'node/3/edit?destination=node">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[3]], '');
// Authenticated user: can access contextual links, cannot edit articles.
......
......@@ -677,8 +677,7 @@ function theme_field($variables) {
// Render the items.
$output .= '<div class="field-items"' . $variables['content_attributes'] . '>';
foreach ($variables['items'] as $delta => $item) {
$classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
$output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
$output .= '<div class="field-item"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
}
$output .= '</div>';
......
......@@ -42,7 +42,7 @@ HTML comment.
{% endif %}
<div class="field-items"{{ content_attributes }}>
{% for delta, item in items %}
<div class="field-item {{ cycle(["even", "odd"], delta) }}"{{ item_attributes[delta] }}>{{ item }}</div>
<div class="field-item"{{ item_attributes[delta] }}>{{ item }}</div>
{% endfor %}
</div>
</div>
......@@ -70,8 +70,7 @@
.image-anchor {
width: auto;
}
.image-anchor .even,
.image-anchor .odd {
.image-anchor tr {
background: none;
}
.image-anchor td {
......
......@@ -418,7 +418,7 @@ public function testBlockContextualLinks() {
$response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-page')));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure odd first"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '?destination=test-page">Configure block</a></li><li class="menu-edit even last"><a href="' . base_path() . 'admin/structure/menu/manage/tools?destination=test-page">Edit menu</a></li></ul>');
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '?destination=test-page">Configure block</a></li><li class="menu-edit"><a href="' . base_path() . 'admin/structure/menu/manage/tools?destination=test-page">Edit menu</a></li></ul>');
}
/**
......
......@@ -405,18 +405,18 @@ table.system-status-report .status-title {
border-left: 1px solid #cdcdcd;
border-right: none;
}
.theme-selector .operations li.last {
.theme-selector .operations li:last-child {
padding: 0 0 0 0.7em; /* LTR */
border-right: none; /* LTR */
}
[dir="rtl"] .theme-selector .operations li.last {
[dir="rtl"] .theme-selector .operations li:last-child {
padding: 0 0.7em 0 0;
border-left: none;
}
.theme-selector .operations li.first {
.theme-selector .operations li:first-child {
padding: 0 0.7em 0 0; /* LTR */
}
[dir="rtl"] .theme-selector .operations li.first {
[dir="rtl"] .theme-selector .operations li:first-child {
padding: 0 0 0 0.7em;
}
#system-themes-admin-form {
......
......@@ -116,30 +116,30 @@ function testItemList() {
);
$inner_b = '<div class="item-list"><ol id="blist">';
$inner_b .= '<li class="odd first">ba</li>';
$inner_b .= '<li class="item-class-bb even last">bb</li>';
$inner_b .= '<li>ba</li>';
$inner_b .= '<li class="item-class-bb">bb</li>';
$inner_b .= '</ol></div>';
$inner_cb = '<div class="item-list"><ul>';
$inner_cb .= '<li class="odd first">cba</li>';
$inner_cb .= '<li class="even last">cbb</li>';
$inner_cb .= '<li>cba</li>';
$inner_cb .= '<li>cbb</li>';
$inner_cb .= '</ul></div>';
$inner_c = '<div class="item-list"><ul id="clist">';
$inner_c .= '<li class="odd first">ca</li>';
$inner_c .= '<li class="item-class-cb even">cb' . $inner_cb . '</li>';
$inner_c .= '<li class="odd last">cc</li>';
$inner_c .= '<li>ca</li>';
$inner_c .= '<li class="item-class-cb">cb' . $inner_cb . '</li>';
$inner_c .= '<li>cc</li>';
$inner_c .= '</ul></div>';
$expected = '<div class="item-list">';
$expected .= '<h3>Some title</h3>';
$expected .= '<ul id="parentlist">';
$expected .= '<li class="odd first">a</li>';
$expected .= '<li id="item-id-b" class="even">b' . $inner_b . '</li>';
$expected .= '<li class="odd">c' . $inner_c . '</li>';
$expected .= '<li id="item-id-d" class="even">d</li>';
$expected .= '<li id="item-id-e" class="odd"></li>';
$expected .= '<li class="even last">f</li>';
$expected .= '<li>a</li>';
$expected .= '<li id="item-id-b">b' . $inner_b . '</li>';
$expected .= '<li>c' . $inner_c . '</li>';
$expected .= '<li id="item-id-d">d</li>';
$expected .= '<li id="item-id-e"></li>';
$expected .= '<li>f</li>';
$expected .= '</ul></div>';
$this->assertThemeOutput('item_list', $variables, $expected);
......@@ -189,10 +189,10 @@ function testLinks() {
$expected_links = '';
$expected_links .= '<ul id="somelinks">';
$expected_links .= '<li class="a-link odd first"><a href="' . url('a/link') . '">' . check_plain('A <link>') . '</a></li>';
$expected_links .= '<li class="plain-text even">' . check_plain('Plain "text"') . '</li>';
$expected_links .= '<li class="front-page odd active"><a href="' . url('<front>') . '" class="active">' . check_plain('Front page') . '</a></li>';
$expected_links .= '<li class="router-test even last"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . check_plain('Test route') . '</a></li>';
$expected_links .= '<li class="a-link"><a href="' . url('a/link') . '">' . check_plain('A <link>') . '</a></li>';
$expected_links .= '<li class="plain-text">' . check_plain('Plain "text"') . '</li>';
$expected_links .= '<li class="front-page active"><a href="' . url('<front>') . '" class="active">' . check_plain('Front page') . '</a></li>';
$expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . check_plain('Test route') . '</a></li>';
$expected_links .= '</ul>';
// Verify that passing a string as heading works.
......@@ -222,10 +222,10 @@ function testLinks() {
);
$expected_links = '';
$expected_links .= '<ul id="somelinks">';
$expected_links .= '<li class="a-link odd first"><a href="' . url('a/link') . '" class="a/class">' . check_plain('A <link>') . '</a></li>';
$expected_links .= '<li class="plain-text even"><span class="a/class">' . check_plain('Plain "text"') . '</span></li>';
$expected_links .= '<li class="front-page odd active"><a href="' . url('<front>') . '" class="active">' . check_plain('Front page') . '</a></li>';
$expected_links .= '<li class="router-test even last"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . check_plain('Test route') . '</a></li>';
$expected_links .= '<li class="a-link"><a href="' . url('a/link') . '" class="a/class">' . check_plain('A <link>') . '</a></li>';
$expected_links .= '<li class="plain-text"><span class="a/class">' . check_plain('Plain "text"') . '</span></li>';
$expected_links .= '<li class="front-page active"><a href="' . url('<front>') . '" class="active">' . check_plain('Front page') . '</a></li>';
$expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . check_plain('Test route') . '</a></li>';
$expected_links .= '</ul>';
$expected = $expected_heading . $expected_links;
$this->assertThemeOutput('links', $variables, $expected);
......
......@@ -55,7 +55,7 @@ public function testTourFunctionality() {
// Navigate to tour-test-1 and verify the tour_test_1 tip is found with appropriate classes.
$this->drupalGet('tour-test-1');
$elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', array(
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1 odd first',
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1',
':data_id' => 'tour-test-1',
':text' => 'The first tip',
));
......@@ -69,7 +69,7 @@ public function testTourFunctionality() {
$this->assertTourTips();
$elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p//a[@href=:href and contains(., :text)]]', array(
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1 odd first',
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1',
':data_id' => 'tour-test-1',
':href' => url('<front>', array('absolute' => TRUE)),
':text' => 'Drupal',
......
......@@ -514,7 +514,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{
border-width: 1px 1px 0;
}
.views-displays .secondary .action-list li.last {
.views-displays .secondary .action-list li:last-child {
border-width: 0 1px 1px;
}
......@@ -707,7 +707,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{
padding-bottom: 2px;
}
.views-ui-display-tab-bucket .even {
.views-ui-display-tab-bucket .views-display-setting:nth-of-type(even) {
background-color: #f3f5ee;
}
......@@ -784,7 +784,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{
border-top: 1px solid #ccc;
}
.views-filterable-options .even .form-type-checkbox {
.views-filterable-options .filterable-option:nth-of-type(even) .form-type-checkbox {
background-color: #f3f4ee;
}
......
......@@ -353,7 +353,7 @@ $.extend(Drupal.viewsUi.OptionsSearch.prototype, {
* Keyup handler for the search box that hides or shows the relevant options.
*/
handleKeyup: function (event) {
var found, i, j, option, search, words, wordsLength, zebraClass, zebraCounter;
var found, i, j, option, search, words, wordsLength;
// Determine the user's search query. The search text has been converted to
// lowercase.
......@@ -361,9 +361,6 @@ $.extend(Drupal.viewsUi.OptionsSearch.prototype, {
words = search.split(' ');
wordsLength = words.length;
// Start the counter for restriping rows.
zebraCounter = 0;
// Search through the search texts in the form for matching text.
var length = this.options.length;
for (i = 0; i < length; i++) {
......@@ -379,11 +376,8 @@ $.extend(Drupal.viewsUi.OptionsSearch.prototype, {
}
if (found) {
// Show the checkbox row, and restripe it.
zebraClass = (zebraCounter % 2) ? 'odd' : 'even';
option.$div.show();
option.$div.removeClass('even odd');
option.$div.addClass(zebraClass);
zebraCounter++;
}
else {
// The search string wasn't found; hide this item.
......
......@@ -132,15 +132,13 @@ public function buildForm(array $form, array &$form_state) {
}
foreach ($grouped_options as $group => $group_options) {
$zebra = 0;
foreach ($group_options as $key => $option) {
$zebra_class = ($zebra % 2) ? 'odd' : 'even';
$form['options']['name'][$key] = array(
'#type' => 'checkbox',
'#title' => $this->t('!group: !field', array('!group' => $option['group'], '!field' => $option['title'])),
'#description' => $option['help'],
'#return_value' => $key,
'#prefix' => "<div class='$zebra_class filterable-option'>",
'#prefix' => "<div class='filterable-option'>",
'#suffix' => '</div>',
'#states' => array(
'visible' => array(
......@@ -153,7 +151,6 @@ public function buildForm(array $form, array &$form_state) {
)
)
);
$zebra++;
}
}
......
......@@ -313,7 +313,7 @@ public function testPageContextualLinks() {
$response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-display')));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="views-uiedit odd first last"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1?destination=test-display">Edit view</a></li></ul>');
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="views-uiedit"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1?destination=test-display">Edit view</a></li></ul>');
}
/**
......
......@@ -24,15 +24,11 @@
* appended to the setting's description.
*/
function template_preprocess_views_ui_display_tab_setting(&$variables) {
static $zebra = 0;
// Add default class attributes.
$variables['attributes']['class'][] = 'views-display-setting';
$variables['attributes']['class'][] = ($zebra % 2 === 0 ? 'odd' : 'even');
$variables['attributes']['class'][] = 'clearfix';
$zebra++;
// Put the primary link to the left side.
array_unshift($variables['settings_links'], $variables['link']);
......
......@@ -446,7 +446,7 @@ h1#site-name {
text-decoration: none;
background: rgba(255, 255, 255, 0.15);
}
.region-header .block-menu li.last a {
.region-header .block-menu li:last-child a {
border-bottom: 0;
}
/* User Login block in the header region */
......@@ -481,10 +481,10 @@ h1#site-name {
float: left; /* LTR */
padding: 3px 0 1px;
}
.region-header #block-user-login .item-list li.last {
.region-header #block-user-login .item-list li:last-child {
padding-left: 0.5em; /* LTR */
}
[dir="rtl"] .region-header #block-user-login .item-list li.last {
[dir="rtl"] .region-header #block-user-login .item-list li:last-child {
padding-left: 0;
padding-right: 0.5em;
}
......@@ -916,7 +916,7 @@ ul.links {
border-bottom: 1px solid #dfdfdf;
line-height: 1.3;
}
#triptych .block.last {
#triptych .block:last-child {
border-bottom: none;
}
#triptych .block ul li,
......@@ -1072,18 +1072,18 @@ ul.links {
border-color: rgba(255, 255, 255, 0.15);
border-right: none;
}
#footer .menu li.first a {
#footer .menu li:first-child a {
padding-left: 0; /* LTR */
}
[dir="rtl"] #footer .menu li.first a {
[dir="rtl"] #footer .menu li:first-child a {
padding-right: 0;
padding-left: 12px;
}
#footer .menu li.last a {
#footer .menu li:last-child a {
padding-right: 0; /* LTR */
border-right: none; /* LTR */
}
[dir="rtl"] #footer .menu li.last a {
[dir="rtl"] #footer .menu li:last-child a {
padding-left: 0;
padding-right: 12px;
border-left: none;
......@@ -1948,7 +1948,7 @@ div.admin-panel .description {
* The contents of the popup dialog on the views edit form.
*/
.views-filterable-options .even .form-type-checkbox {
.views-filterable-options .filterable-option:nth-of-type(even) .form-type-checkbox {
background-color: #F9F9F9;
}
......
......@@ -50,7 +50,7 @@
text-shadow: 0 1px hsla(0, 0%, 100%, 0.6);
text-decoration: none;
}
.vertical-tab-button.last a {
.vertical-tab-button:last-child a {
border-bottom: 0;
}
.vertical-tab-button.selected a,
......
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