You are here

function template_preprocess_sooperthemes_gridstack_gridstack_plugin_style in Sooperthemes GridStack 7

Implementation of template preprocess for the view.

File

templates/sooperthemes_gridstack/theme.inc, line 6

Code

function template_preprocess_sooperthemes_gridstack_gridstack_plugin_style(&$vars) {
  $view = $vars['view'];
  $options = $view->style_plugin->options;
  $layout_data = $options['gridstack_layout_data'];
  $vars['layout_data'] = drupal_json_decode($layout_data);
  if ($options['gridstack_overlay']) {
    $vars['classes_array'][] = 'sooperthemes-gridstack--' . $options['gridstack_overlay'];
  }
  if ($options['gridstack_zoom']) {
    $vars['classes_array'][] = 'sooperthemes-gridstack--zoom';
  }
  if (!empty($options['gridstack_gap'])) {
    $vars['gridstack_margin'] = 'style="margin: ' . round($options['gridstack_gap'] / 2, 2) . 'px"';
  }
  if (!empty($options['gridstack_items_mobile'])) {
    $vars['gridstack_items_mobile'] = $options['gridstack_items_mobile'] - 1;

    // -1 because $key counts from 0
  }
  else {
    $vars['gridstack_items_mobile'] = 2;
  }
  drupal_add_library('sooperthemes_gridstack', 'sooperthemes_gridstack_lib');
}