You are here

function template_preprocess_sooperthemes_gridstack_gridstack_style in Sooperthemes GridStack 8

Implementation of template preprocess for the view style.

File

./theme.inc, line 35
Preprocess functions for SooperThemes GridStack module.

Code

function template_preprocess_sooperthemes_gridstack_gridstack_style(&$vars) {
  template_preprocess_views_view_unformatted($vars);
  $options = $vars['view']->style_plugin->options;
  $layout_data = $options['gridstack_layout_data'];
  $vars['layout_data'] = Json::decode($layout_data);
  if ($options['gridstack_overlay']) {
    $vars['classes'][] = 'sooperthemes-gridstack--' . $options['gridstack_overlay'];
  }
  if ($options['gridstack_zoom']) {
    $vars['classes'][] = 'sooperthemes-gridstack--zoom';
  }
  if ($options['gridstack_gap']) {
    $vars['gridstack_margin'] = 'style="margin: ' . round($options['gridstack_gap'] / 2, 2) . 'px"';
  }
  if ($options['gridstack_items_mobile']) {

    // -1 because $key counts from 0.
    $vars['gridstack_items_mobile'] = $options['gridstack_items_mobile'] - 1;
  }
  else {
    $vars['gridstack_items_mobile'] = 2;
  }
}