function claro_views_ui_display_top_alter
Same name in other branches
- 9 core/themes/claro/claro.theme \claro_views_ui_display_top_alter()
- 8.9.x core/themes/claro/claro.theme \claro_views_ui_display_top_alter()
- 10 core/themes/claro/claro.theme \claro_views_ui_display_top_alter()
Implements hook_views_ui_display_top_alter().
File
-
core/
themes/ claro/ claro.theme, line 764
Code
function claro_views_ui_display_top_alter(&$element) {
// @todo Remove this after https://www.drupal.org/node/3051605 has been
// solved.
$element['tabs']['#prefix'] = preg_replace('/(class="(.+\\s)?)tabs(\\s.+"|")/', '$1views-tabs$3', $element['tabs']['#prefix']);
$element['tabs']['#prefix'] = preg_replace('/(class="(.+\\s)?)secondary(\\s.+"|")/', '$1views-tabs--secondary$3', $element['tabs']['#prefix']);
foreach (Element::children($element['tabs']) as $tab) {
$element['tabs'][$tab]['#theme'] = 'menu_local_task__views_ui';
}
// Change top extra actions to use the small dropbutton variant.
// @todo Revisit after https://www.drupal.org/node/3057581 is added.
if (!empty($element['extra_actions'])) {
$element['extra_actions']['#dropbutton_type'] = 'small';
}
// Add a class to each item in the add display dropdown so they can be styled
// with a single selector.
if (isset($element['add_display'])) {
foreach ($element['add_display'] as &$display_item) {
if (isset($display_item['#type']) && in_array($display_item['#type'], [
'submit',
'button',
], TRUE)) {
$display_item['#attributes']['class'][] = 'views-tabs__action-list-button';
}
}
}
// Rearrange top bar contents so floats aren't necessary for positioning.
if (isset($element['extra_actions'], $element['tabs'], $element['add_display'])) {
$element['extra_actions']['#weight'] = 10;
$element['extra_actions']['#theme_wrappers'] = [
'container' => [
'#attributes' => [
'class' => [
'views-display-top__extra-actions-wrapper',
],
],
],
];
$element['#attributes']['class'] = array_diff($element['#attributes']['class'], [
'clearfix',
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.