You are here

function mixitup_views_get_settings in MixItUp Views 8

Same name and namespace in other branches
  1. 8.2 templates/mixitup_views.theme.inc \mixitup_views_get_settings()

Apply mixitup library to container.

Parameters

string $container: Container name.

array $options: Array of mixitup options.

Return value

array Returns MixitUp settings array.

1 call to mixitup_views_get_settings()
template_preprocess_mixitup_views_view_mixitup in templates/mixitup_views.theme.inc
Prepares variables for view templates.

File

templates/mixitup_views.theme.inc, line 90
Preprocessors and helper functions to make theming easier.

Code

function mixitup_views_get_settings($container, array $options = []) {
  $mixitup_func = \Drupal::service('mixitup_views.func_service');
  if (!empty($container)) {

    // For any options not specified, use default options.
    $options += $mixitup_func
      ->getDefaultOptions(TRUE);

    // Set of mixitup settings.
    $mixitup_settings = [
      'mixitup_settings_array' => [
        'selector_name' => $container,
        $container => [
          'selectors' => [
            'target' => $options['selectors_target'],
            'control' => '[data-mixitup-control]',
          ],
          'load' => [
            'filter' => $options['load_filter'],
            'sort' => $options['load_sort'],
          ],
          'animation' => [
            'enable' => (bool) $options['animation_enable'],
            'effects' => $options['animation_effects'],
            'duration' => (int) $options['animation_duration'],
            'easing' => $options['animation_easing'],
            'perspectiveDistance' => $options['animation_perspectiveDistance'],
            'perspectiveOrigin' => $options['animation_perspectiveOrigin'],
            'queue' => (bool) $options['animation_queue'],
            'queueLimit' => (int) $options['animation_queueLimit'],
          ],
        ],
      ],
      'filters_form_id' => '#mixitup-views-filters-form',
      'reset_id' => '#reset',
      'filtering_type' => isset($options['filter_type']) ? $options['filter_type'] : 'checkboxes',
      'agregation_type' => isset($options['agregation_type']) ? $options['agregation_type'] : 'and',
    ];
    return $mixitup_settings;
  }
}