You are here

function views_isotope_get_config_json in Views Isotope (Deprecated) 7.2

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 ./views_isotope.module
Default theme implementation for the grid.

File

./views_isotope.module, line 126
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 = array(
    'layoutMode',
    'transitionDuration',
    'urlFilters',
    'isFitWidth',
    'isHorizontal',
    'stamp',
    'horizontalAlignment',
    'verticalAlignment',
    'isOriginLeft',
  );

  // Default attributes.
  $attributes = array(
    '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);
}