You are here

function template_preprocess_gridstack_admin in GridStack 8

Prepares variables for gridstack-admin.html.twig templates.

File

templates/gridstack.theme.inc, line 145
Hooks and preprocess functions for the GridStack module.

Code

function template_preprocess_gridstack_admin(&$variables) {
  template_preprocess_gridstack($variables);
  $element = $variables['element'];
  foreach ([
    'content',
    'preview',
    'wrapper',
  ] as $key) {
    $variables[$key . '_attributes'] = isset($element["#{$key}" . '_attributes']) ? $element["#{$key}" . '_attributes'] : [];
  }
  $settings =& $variables['settings'];
  $content_attributes =& $variables['content_attributes'];
  $preview_attributes =& $variables['preview_attributes'];
  $wrapper_attributes =& $variables['wrapper_attributes'];
  $settings['id'] = 'gridstack-' . $settings['breakpoint'];
  $content_attributes['id'] = $settings['id'];
  $variables['wrapper_attributes']['id'] = 'gridstack-wrapper-' . $settings['breakpoint'];
  $variables['wrapper_attributes']['data-breakpoint'] = $settings['breakpoint'];
  $variables['content_attributes'] = new Attribute($content_attributes);
  $variables['preview_attributes'] = new Attribute($preview_attributes);
  $variables['wrapper_attributes'] = new Attribute($wrapper_attributes);
  $variables['main_button_texts'] = [];
  $settings['is_main_preview'] = FALSE;
  if ($settings['breakpoint'] == $settings['icon_breakpoint']) {
    $settings['is_main_preview'] = TRUE;
    $variables['main_button_texts'] = [
      'save' => t('Update icon'),
      'add' => t('Add grid'),
    ];
  }
}