-
Notifications
You must be signed in to change notification settings - Fork 0
/
flickity_views.module
41 lines (33 loc) · 1.26 KB
/
flickity_views.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* @file
* A light-weight, customizable lightbox plugin for jQuery 1.3
*/
use Drupal\Core\Template\Attribute;
use Drupal\Component\Serialization\Json;
/**
* Prepares variables for Views Flickity templates.
*
* Default template: views-view-flickity.html.twig.
*
* @param array $variables
* An associative array containing:
* - view: A View object.
*/
function template_preprocess_views_view_flickity(&$variables) {
/** @var \Drupal\flickity_views\Plugin\views\style\Flickity $handler */
$handler = $variables['view']->style_plugin;
$variables['attributes'] = new Attribute(array('class' => ['js-flickity']));
// Flickity configuration.
$variables['settings'] = $handler->filterOptions();
$variables['attributes']['data-flickity-options'] = Json::encode($variables['settings']);
$variables['#attached']['library'][] = 'flickity_views/flickity';
$variables['#attached']['library'][] = 'flickity_views/flickity-addon';
if ($handler->options['flickity_imagesLoaded']) {
$variables['#attached']['library'][] = 'flickity_views/flickity-imagesloaded';
}
if ($handler->options['flickity_asNavFor']) {
$variables['#attached']['library'][] = 'flickity_views/flickity-as-nav-for';
}
template_preprocess_views_view_unformatted($variables);
}