Commit 4daa01cb authored by tim.plunkett's avatar tim.plunkett

Issue #1716908 by aspilicious, tim.plunkett: Use the new attributes system in D8.

parent 86dc2687
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
/* @group Wrapper */ /* @group Wrapper */
#views-live-preview .contextual-links-region-active { #views-live-preview .contextual-region-active {
outline: medium none; outline: medium none;
} }
#views-live-preview div.contextual-links-wrapper { #views-live-preview div.contextual {
right: auto; right: auto;
top: auto; top: auto;
} }
html.js #views-live-preview div.contextual-links-wrapper { html.js #views-live-preview div.contextual {
display: inline; display: inline;
} }
...@@ -30,7 +30,7 @@ html.js #views-live-preview div.contextual-links-wrapper { ...@@ -30,7 +30,7 @@ html.js #views-live-preview div.contextual-links-wrapper {
/* @group List */ /* @group List */
div.contextual-links-wrapper ul.contextual-links { div.contextual ul.contextual-links {
-moz-border-radius: 0 4px 4px 4px; -moz-border-radius: 0 4px 4px 4px;
-webkit-border-radius: 0 4px 4px 4px; -webkit-border-radius: 0 4px 4px 4px;
border-radius: 0 4px 4px 4px; border-radius: 0 4px 4px 4px;
......
...@@ -45,7 +45,7 @@ function options_form(&$form, &$form_state) { ...@@ -45,7 +45,7 @@ function options_form(&$form, &$form_state) {
function pre_render(&$values) { function pre_render(&$values) {
// Add a row plugin css class for the contextual link. // Add a row plugin css class for the contextual link.
$class = 'contextual-links-region'; $class = 'contextual-region';
if (!empty($this->view->style_plugin->options['row_class'])) { if (!empty($this->view->style_plugin->options['row_class'])) {
$this->view->style_plugin->options['row_class'] .= " $class"; $this->view->style_plugin->options['row_class'] .= " $class";
} }
...@@ -85,7 +85,7 @@ function render($values) { ...@@ -85,7 +85,7 @@ function render($values) {
if (!empty($links)) { if (!empty($links)) {
$build = array( $build = array(
'#prefix' => '<div class="contextual-links-wrapper">', '#prefix' => '<div class="contextual">',
'#suffix' => '</div>', '#suffix' => '</div>',
'#theme' => 'links__contextual', '#theme' => 'links__contextual',
'#links' => $links, '#links' => $links,
......
...@@ -1801,14 +1801,11 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) { ...@@ -1801,14 +1801,11 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) {
array_unshift($variables['settings_links'], $variables['link']); array_unshift($variables['settings_links'], $variables['link']);
$variables['settings_links'] = implode('<span class="label">&nbsp;|&nbsp;</span>', $variables['settings_links']); $variables['settings_links'] = implode('<span class="label">&nbsp;|&nbsp;</span>', $variables['settings_links']);
// Add classes associated with this display tab to the overall list.
$variables['classes_array'] = array_merge($variables['classes_array'], $variables['class']);
if (!empty($variables['defaulted'])) { if (!empty($variables['defaulted'])) {
$variables['classes_array'][] = 'defaulted'; $variables['attributes']['class'][] = 'defaulted';
} }
if (!empty($variables['overridden'])) { if (!empty($variables['overridden'])) {
$variables['classes_array'][] = 'overridden'; $variables['attributes']['class'][] = 'overridden';
$variables['attributes_array']['title'][] = t('Overridden'); $variables['attributes_array']['title'][] = t('Overridden');
} }
...@@ -1826,10 +1823,10 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) { ...@@ -1826,10 +1823,10 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) {
$variables['item_help_icon'] = render($element['#item_help_icon']); $variables['item_help_icon'] = render($element['#item_help_icon']);
} }
if (!empty($element['#name'])) { if (!empty($element['#name'])) {
$variables['classes_array'][] = drupal_clean_css_identifier(strtolower($element['#name'])); $variables['attributes']['class'][] = drupal_html_class($element['#name']);
} }
if (!empty($element['#overridden'])) { if (!empty($element['#overridden'])) {
$variables['classes_array'][] = 'overridden'; $variables['attributes']['class'][] = 'overridden';
$variables['attributes_array']['title'][] = t('Overridden'); $variables['attributes_array']['title'][] = t('Overridden');
} }
......
...@@ -9,7 +9,7 @@ Drupal.behaviors.viewsContextualLinks = { ...@@ -9,7 +9,7 @@ Drupal.behaviors.viewsContextualLinks = {
// If there are views-related contextual links attached to the main page // If there are views-related contextual links attached to the main page
// content, find the smallest region that encloses both the links and the // content, find the smallest region that encloses both the links and the
// view, and display it as a contextual links region. // view, and display it as a contextual links region.
$('.views-contextual-links-page', context).closest(':has(.view)').addClass('contextual-links-region'); $('.views-contextual-links-page', context).closest(':has(.view)').addClass('contextual-region');
} }
}; };
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
* Main view template. * Main view template.
* *
* Variables available: * Variables available:
* - $classes_array: An array of classes determined in * - $attributes: An instance of Attributes class that can be manipulated as an
* template_preprocess_views_view(). Default classes are: * array and printed as a string.
* .view * It includes the 'class' information, which includes:
* .view-[css_name] * .view
* .view-id-[view_name] * .view-[css_name]
* .view-display-id-[display_name] * .view-id-[view_name]
* .view-dom-id-[dom_id] * .view-display-id-[display_name]
* - $classes: A string version of $classes_array for use in the class attribute * .view-dom-id-[dom_id]
* - $css_name: A css-safe version of the view name. * - $css_name: A css-safe version of the view name.
* - $css_class: The user-specified classes names, if any * - $css_class: The user-specified classes names, if any
* - $header: The view header * - $header: The view header
......
...@@ -55,16 +55,16 @@ function template_preprocess_views_view(&$vars) { ...@@ -55,16 +55,16 @@ function template_preprocess_views_view(&$vars) {
// Basic classes // Basic classes
$vars['css_class'] = ''; $vars['css_class'] = '';
$vars['classes_array'] = array(); $vars['attributes']['class'] = array();
$vars['classes_array'][] = 'view'; $vars['attributes']['class'][] = 'view';
$vars['classes_array'][] = 'view-' . drupal_clean_css_identifier($vars['name']); $vars['attributes']['class'][] = 'view-' . drupal_clean_css_identifier($vars['name']);
$vars['classes_array'][] = 'view-id-' . $vars['name']; $vars['attributes']['class'][] = 'view-id-' . $vars['name'];
$vars['classes_array'][] = 'view-display-id-' . $vars['display_id']; $vars['attributes']['class'][] = 'view-display-id-' . $vars['display_id'];
$css_class = $view->display_handler->get_option('css_class'); $css_class = $view->display_handler->get_option('css_class');
if (!empty($css_class)) { if (!empty($css_class)) {
$vars['css_class'] = preg_replace('/[^a-zA-Z0-9- ]/', '-', $css_class); $vars['css_class'] = preg_replace('/[^a-zA-Z0-9- ]/', '-', $css_class);
$vars['classes_array'][] = $vars['css_class']; $vars['attributes']['class'][] = $vars['css_class'];
} }
$empty = empty($vars['rows']); $empty = empty($vars['rows']);
...@@ -114,7 +114,7 @@ function template_preprocess_views_view(&$vars) { ...@@ -114,7 +114,7 @@ function template_preprocess_views_view(&$vars) {
// each view. This identifier is written to both Drupal.settings and the DIV // each view. This identifier is written to both Drupal.settings and the DIV
// wrapper. // wrapper.
$vars['dom_id'] = $view->dom_id; $vars['dom_id'] = $view->dom_id;
$vars['classes_array'][] = 'view-dom-id-' . $vars['dom_id']; $vars['attributes']['class'][] = 'view-dom-id-' . $vars['dom_id'];
} }
// If using AJAX, send identifying data about this view. // If using AJAX, send identifying data about this view.
...@@ -169,9 +169,6 @@ function template_process_views_view(&$vars) { ...@@ -169,9 +169,6 @@ function template_process_views_view(&$vars) {
if (is_array($vars['rows'])) { if (is_array($vars['rows'])) {
$vars['rows'] = drupal_render($vars['rows']); $vars['rows'] = drupal_render($vars['rows']);
} }
// Flatten the classes to a string for the template file.
$vars['classes'] = implode(' ', $vars['classes_array']);
} }
/** /**
...@@ -634,7 +631,7 @@ function template_preprocess_views_view_table(&$vars) { ...@@ -634,7 +631,7 @@ function template_preprocess_views_view_table(&$vars) {
$vars['row_classes'][count($vars['row_classes']) - 1][] = 'views-row-last'; $vars['row_classes'][count($vars['row_classes']) - 1][] = 'views-row-last';
} }
$vars['classes_array'] = array('views-table'); $vars['attributes']['class'] = array('views-table');
if (empty($vars['rows']) && !empty($options['empty_table'])) { if (empty($vars['rows']) && !empty($options['empty_table'])) {
$vars['rows'][0][0] = $view->display_handler->render_area('empty'); $vars['rows'][0][0] = $view->display_handler->render_area('empty');
// Calculate the amounts of rows with output. // Calculate the amounts of rows with output.
...@@ -645,9 +642,9 @@ function template_preprocess_views_view_table(&$vars) { ...@@ -645,9 +642,9 @@ function template_preprocess_views_view_table(&$vars) {
if (!empty($options['sticky'])) { if (!empty($options['sticky'])) {
drupal_add_js('misc/tableheader.js'); drupal_add_js('misc/tableheader.js');
$vars['classes_array'][] = "sticky-enabled"; $vars['attributes']['class'][] = "sticky-enabled";
} }
$vars['classes_array'][] = 'cols-'. count($vars['header']); $vars['attributes']['class'][] = 'cols-'. count($vars['header']);
if (!empty($handler->options['summary'])) { if (!empty($handler->options['summary'])) {
$vars['attributes_array'] = array('summary' => $handler->options['summary']); $vars['attributes_array'] = array('summary' => $handler->options['summary']);
...@@ -666,6 +663,7 @@ function template_preprocess_views_view_grid(&$vars) { ...@@ -666,6 +663,7 @@ function template_preprocess_views_view_grid(&$vars) {
$row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : TRUE; $row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : TRUE;
$columns = $options['columns']; $columns = $options['columns'];
$vars['attributes']['class'][] = 'views-view-grid cols-' . $columns;
$rows = array(); $rows = array();
$row_indexes = array(); $row_indexes = array();
...@@ -761,7 +759,6 @@ function template_preprocess_views_view_grid(&$vars) { ...@@ -761,7 +759,6 @@ function template_preprocess_views_view_grid(&$vars) {
} }
} }
$vars['rows'] = $rows; $vars['rows'] = $rows;
$vars['class'] = 'views-view-grid cols-' . $columns;
if (!empty($handler->options['summary'])) { if (!empty($handler->options['summary'])) {
$vars['attributes_array'] = array('summary' => $handler->options['summary']); $vars['attributes_array'] = array('summary' => $handler->options['summary']);
} }
...@@ -776,7 +773,7 @@ function template_preprocess_views_view_unformatted(&$vars) { ...@@ -776,7 +773,7 @@ function template_preprocess_views_view_unformatted(&$vars) {
$style = $view->style_plugin; $style = $view->style_plugin;
$options = $style->options; $options = $style->options;
$vars['classes_array'] = array(); $vars['row_classes'] = array();
$vars['classes'] = array(); $vars['classes'] = array();
$default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : FALSE; $default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : FALSE;
$row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : FALSE; $row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : FALSE;
...@@ -804,7 +801,7 @@ function template_preprocess_views_view_unformatted(&$vars) { ...@@ -804,7 +801,7 @@ function template_preprocess_views_view_unformatted(&$vars) {
} }
// Flatten the classes to a string for each row for the template file. // Flatten the classes to a string for each row for the template file.
$vars['classes_array'][$id] = isset($vars['classes'][$id]) ? implode(' ', $vars['classes'][$id]) : ''; $vars['row_classes'][$id] = isset($vars['classes'][$id]) ? implode(' ', $vars['classes'][$id]) : '';
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Template for each "box" on the display query edit screen. * Template for each "box" on the display query edit screen.
*/ */
?> ?>
<div class="<?php print $classes; ?>" <?php print $attributes; ?>> <div <?php print $attributes; ?>>
<?php print $item_help_icon; ?> <?php print $item_help_icon; ?>
<?php if(!empty($actions)) : ?> <?php if(!empty($actions)) : ?>
<?php print $actions; ?> <?php print $actions; ?>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Template for each row inside the "boxes" on the display query edit screen. * Template for each row inside the "boxes" on the display query edit screen.
*/ */
?> ?>
<div class="views-display-setting <?php print $classes; ?> <?php print $zebra; ?> clearfix" <?php print $attributes; ?>> <div class="views-display-setting <?php print $attributes['class']; ?> <?php print $zebra; ?> clearfix" <?php print $attributes; ?>>
<?php if ($description): ?> <?php if ($description): ?>
<span class="label"><?php print $description; ?></span> <span class="label"><?php print $description; ?></span>
<?php endif; ?> <?php endif; ?>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<?php if (!empty($title)) : ?> <?php if (!empty($title)) : ?>
<h3><?php print $title; ?></h3> <h3><?php print $title; ?></h3>
<?php endif; ?> <?php endif; ?>
<table class="<?php print $class; ?>"<?php print $attributes; ?>> <table <?php print $attributes; ?>>
<tbody> <tbody>
<?php foreach ($rows as $row_number => $columns): ?> <?php foreach ($rows as $row_number => $columns): ?>
<tr <?php if ($row_classes[$row_number]) { print 'class="' . $row_classes[$row_number] .'"'; } ?>> <tr <?php if ($row_classes[$row_number]) { print 'class="' . $row_classes[$row_number] .'"'; } ?>>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<?php endif; ?> <?php endif; ?>
<?php print $list_type_prefix; ?> <?php print $list_type_prefix; ?>
<?php foreach ($rows as $id => $row): ?> <?php foreach ($rows as $id => $row): ?>
<li class="<?php print $classes_array[$id]; ?>"><?php print $row; ?></li> <li <?php print $row_classes[$id]; ?>><?php print $row; ?></li>
<?php endforeach; ?> <?php endforeach; ?>
<?php print $list_type_suffix; ?> <?php print $list_type_suffix; ?>
<?php print $wrapper_suffix; ?> <?php print $wrapper_suffix; ?>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* @ingroup views_templates * @ingroup views_templates
*/ */
?> ?>
<table <?php if ($classes) { print 'class="'. $classes . '" '; } ?><?php print $attributes; ?>> <table <?php print $attributes; ?>>
<?php if (!empty($title)) : ?> <?php if (!empty($title)) : ?>
<caption><?php print $title; ?></caption> <caption><?php print $title; ?></caption>
<?php endif; ?> <?php endif; ?>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<h3><?php print $title; ?></h3> <h3><?php print $title; ?></h3>
<?php endif; ?> <?php endif; ?>
<?php foreach ($rows as $id => $row): ?> <?php foreach ($rows as $id => $row): ?>
<div <?php if ($classes_array[$id]) { print 'class="' . $classes_array[$id] .'"'; } ?>> <div <?php if ($row_classes[$id]) { print 'class="' . $row_classes[$id] .'"'; } ?>>
<?php print $row; ?> <?php print $row; ?>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
* Main view template. * Main view template.
* *
* Variables available: * Variables available:
* - $classes_array: An array of classes determined in * - $attributes: An instance of Attributes class that can be manipulated as an
* template_preprocess_views_view(). Default classes are: * array and printed as a string.
* .view * It includes the 'class' information, which includes:
* .view-[css_name] * .view
* .view-id-[view_name] * .view-[css_name]
* .view-display-id-[display_name] * .view-id-[view_name]
* .view-dom-id-[dom_id] * .view-display-id-[display_name]
* - $classes: A string version of $classes_array for use in the class attribute * .view-dom-id-[dom_id]
* - $css_name: A css-safe version of the view name. * - $css_name: A css-safe version of the view name.
* - $css_class: The user-specified classes names, if any * - $css_class: The user-specified classes names, if any
* - $header: The view header * - $header: The view header
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* @ingroup views_templates * @ingroup views_templates
*/ */
?> ?>
<div class="<?php print $classes; ?>"> <div <?php print $attributes; ?>">
<?php print render($title_prefix); ?> <?php print render($title_prefix); ?>
<?php if ($title): ?> <?php if ($title): ?>
<?php print $title; ?> <?php print $title; ?>
......
...@@ -594,12 +594,12 @@ function views_preprocess_html(&$variables) { ...@@ -594,12 +594,12 @@ function views_preprocess_html(&$variables) {
// prefer a smaller region to be chosen. The region we prefer differs from // prefer a smaller region to be chosen. The region we prefer differs from
// theme to theme and depends on the details of the theme's markup in // theme to theme and depends on the details of the theme's markup in
// page.tpl.php, so we can only find it using JavaScript. We therefore remove // page.tpl.php, so we can only find it using JavaScript. We therefore remove
// the "contextual-links-region" class from the <body> tag here and add // the "contextual-region" class from the <body> tag here and add
// JavaScript that will insert it back in the correct place. // JavaScript that will insert it back in the correct place.
if (!empty($variables['page']['#views_contextual_links_info'])) { if (!empty($variables['page']['#views_contextual_links_info'])) {
$key = array_search('contextual-links-region', $variables['classes_array']); $key = array_search('contextual-region', $variables['attributes']['class']->value());
if ($key !== FALSE) { if ($key !== FALSE) {
unset($variables['classes_array'][$key]); unset($variables['attributes']['class'][$key]);
// Add the JavaScript, with a group and weight such that it will run // Add the JavaScript, with a group and weight such that it will run
// before modules/contextual/contextual.js. // before modules/contextual/contextual.js.
drupal_add_js(drupal_get_path('module', 'views') . '/js/views-contextual.js', array('group' => JS_LIBRARY, 'weight' => -1)); drupal_add_js(drupal_get_path('module', 'views') . '/js/views-contextual.js', array('group' => JS_LIBRARY, 'weight' => -1));
......
...@@ -372,7 +372,7 @@ function views_ui_preprocess_views_view(&$vars) { ...@@ -372,7 +372,7 @@ function views_ui_preprocess_views_view(&$vars) {
'#section' => $section, '#section' => $section,
'#content' => is_array($vars[$section]) ? drupal_render($vars[$section]) : $vars[$section], '#content' => is_array($vars[$section]) ? drupal_render($vars[$section]) : $vars[$section],
'#theme_wrappers' => array('views_container'), '#theme_wrappers' => array('views_container'),
'#attributes' => array('class' => 'contextual-links-region'), '#attributes' => array('class' => 'contextual-region'),
); );
$vars[$section] = drupal_render($vars[$section]); $vars[$section] = drupal_render($vars[$section]);
} }
...@@ -434,7 +434,7 @@ function template_preprocess_views_ui_view_preview_section(&$vars) { ...@@ -434,7 +434,7 @@ function template_preprocess_views_ui_view_preview_section(&$vars) {
if (isset($links)) { if (isset($links)) {
$build = array( $build = array(
'#prefix' => '<div class="contextual-links-wrapper">', '#prefix' => '<div class="contextual">',
'#suffix' => '</div>', '#suffix' => '</div>',
'#theme' => 'links__contextual', '#theme' => 'links__contextual',
'#links' => $links, '#links' => $links,
......
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