You are here

function views_isotope_get_config_json in Brainstorm profile 7

Convert the name of a config into a JSON representation.

Style as per http://isotope.metafizzy.co/#initialize-in-html.

1 call to views_isotope_get_config_json()
theme_isotope_grid in modules/custom/views_isotope/views_isotope.module
Default theme implementation for the grid.

File

modules/custom/views_isotope/views_isotope.module, line 127
Load the isotope library and provide configuration and theme options.

Code

function views_isotope_get_config_json($config, array $additional_attributes) {
  ctools_include('export');
  $plugin = ctools_export_crud_load('isotope_configurations', $config);

  // Properties that should be passed directly to isotope.
  $allowed_attributes = [
    'layoutMode',
    'transitionDuration',
    'urlFilters',
    'isFitWidth',
    'isHorizontal',
    'stamp',
    'horizontalAlignment',
    'verticalAlignment',
    'isOriginLeft',
  ];

  // Default attributes.
  $attributes = [
    'columnWidth' => '.isotope-grid-sizer',
    'itemSelector' => '.isotope-element',
    'gutter' => '.isotope-gutter-sizer',
  ] + $additional_attributes;
  foreach ($plugin as $key => $value) {
    if (in_array($key, $allowed_attributes)) {
      $attributes[$key] = $value;
    }
  }
  return drupal_json_encode($attributes);
}