You are here

function mixitup_views_apply in MixItUp Views 7

Apply mixitup library to container.

Parameters

string $container: Container name.

array $options: Array of mixitup options.

1 call to mixitup_views_apply()
template_preprocess_views_view_mixitup in ./mixitup_views.module
Preprocess function for views_view_mixitup.tpl.php.

File

./mixitup_views.module, line 197
Provides a Views style plugin for displaying content with Mixitup filtering.

Code

function mixitup_views_apply($container, $options = array()) {
  if (mixitup_views_loaded() && !empty($container)) {

    // For any options not specified, use default options.
    $options += mixitup_views_default_options(TRUE);

    // Set of mixitup settings.
    $mixitup_settings = array(
      'mixitup' => array(
        $container => array(
          'selectors' => array(
            'target' => $options['selectors_target'],
            'filter' => $options['selectors_filter'],
            'sort' => $options['selectors_sort'],
          ),
          'load' => array(
            'filter' => $options['load_filter'],
            'sort' => $options['load_sort'],
          ),
          'animation' => array(
            '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',
    );
    drupal_add_css(drupal_get_path('module', 'mixitup_views') . '/css/mixitup_views.css');
    $script_file = drupal_get_path('module', 'mixitup_views') . '/js/mixitup_views.js';

    // Apply the script.
    drupal_add_js($mixitup_settings, 'setting');
    drupal_add_js($script_file);
  }
}