PageSourceSearch

https://int.diasorin.com/themes/custom/diasorin_theme/js/sliders.js?v=10.6.17

js diasorin.com collected 2026-09-24 19:20:56 UTC 4,831 bytes, 181 lines download raw bytes

1/**
2 * @file
3 * Responsive Slick sliders for Diasorin theme components.
4 */
5(function ($, Drupal) {
6  'use strict';
7
8  var MOBILE_MAX_WIDTH = 991.98;
9  var GLOBAL_EVENTS_SLIDER_MAX_WIDTH = 1199.98;
10  var GLOBAL_EVENTS_MIN_SLIDES = 1;
11
12  function isMobileViewport() {
13    return window.innerWidth <= MOBILE_MAX_WIDTH;
14  }
15
16  function isGlobalEventsSliderViewport() {
17    return window.innerWidth <= GLOBAL_EVENTS_SLIDER_MAX_WIDTH;
18  }
19
20  function hasEnoughGlobalEventsCards($viewContent) {
21    return $viewContent.find('.single-card-gevent').length > GLOBAL_EVENTS_MIN_SLIDES;
22  }
23
24  /**
25   * Numbered w/ layout: horizontal slider below 992px.
26   */
27  function initNumberedWLayoutSlider($wrapper) {
28    if (!$wrapper.length || $wrapper.hasClass('slick-initialized')) {
29      return;
30    }
31
32    $wrapper.slick({
33      centerMode: true,
34      centerPadding: '40px',
35      slidesToShow: 1,
36      slidesToScroll: 1,
37      dots: true,
38      arrows: false,
39      infinite: false,
40      adaptiveHeight: true,
41      focusOnSelect: false,
42      touchThreshold: 10,
43      draggable: true,
44      swipe: true,
45      touchMove: true,
46    });
47
48    $wrapper.slick('setPosition');
49  }
50
51  function destroyNumberedWLayoutSlider($wrapper) {
52    if ($wrapper.hasClass('slick-initialized')) {
53      $wrapper.slick('unslick');
54    }
55  }
56
57  function toggleNumberedWLayoutSlider($wrapper) {
58    if (isMobileViewport()) {
59      initNumberedWLayoutSlider($wrapper);
60    }
61    else {
62      destroyNumberedWLayoutSlider($wrapper);
63    }
64  }
65
66  function toggleAllNumberedWLayoutSliders(context) {
67    var $wrappers = $(context).find('.numbered-w-layout-wrapper');
68    if ($(context).hasClass('numbered-w-layout-wrapper')) {
69      $wrappers = $wrappers.add(context);
70    }
71
72    $wrappers.each(function () {
73      toggleNumberedWLayoutSlider($(this));
74    });
75  }
76
77  /**
78   * Global events section: slider below 1200px when more than 3 cards.
79   */
80  function initGlobalEventsSlider($viewContent) {
81    if (!$viewContent.length || $viewContent.hasClass('slick-initialized')) {
82      return;
83    }
84
85    $viewContent.slick({
86      slidesToShow: 2,
87      slidesToScroll: 1,
88      dots: true,
89      arrows: true,
90      infinite: false,
91      adaptiveHeight: true,
92      responsive: [{
93        breakpoint: 768,
94        settings: {
95          slidesToShow: 1,
96          slidesToScroll: 1,
97        },
98      }],
99    });
100
101    $viewContent.slick('setPosition');
102  }
103
104  function destroyGlobalEventsSlider($viewContent) {
105    if ($viewContent.hasClass('slick-initialized')) {
106      $viewContent.slick('unslick');
107    }
108  }
109
110  function toggleGlobalEventsSlider($viewContent) {
111    if (isGlobalEventsSliderViewport() && hasEnoughGlobalEventsCards($viewContent)) {
112      initGlobalEventsSlider($viewContent);
113    }
114    else {
115      destroyGlobalEventsSlider($viewContent);
116    }
117  }
118
119  function getGlobalEventsViewContents(context) {
120    var $sections = $(context).find('.section-global-events');
121    if ($(context).hasClass('section-global-events')) {
122      $sections = $sections.add(context);
123    }
124
125    var $viewContents = $();
126    $sections.each(function () {
127      $viewContents = $viewContents.add($(this).children('.view-content'));
128    });
129
130    return $viewContents;
131  }
132
133  function toggleAllGlobalEventsSliders(context) {
134    getGlobalEventsViewContents(context).each(function () {
135      toggleGlobalEventsSlider($(this));
136    });
137  }
138
139  Drupal.behaviors.numberedWLayoutSlider = {
140    attach: function (context) {
141      var wrappers = typeof once === 'function'
142        ? once('numbered-w-layout-slider', '.numbered-w-layout-wrapper', context)
143        : context.querySelectorAll('.numbered-w-layout-wrapper');
144
145      $(wrappers).each(function () {
146        toggleNumberedWLayoutSlider($(this));
147      });
148    },
149  };
150
151  Drupal.behaviors.globalEventsSlider = {
152    attach: function (context) {
153      var sections = typeof once === 'function'
154        ? once('global-events-slider', '.section-global-events', context)
155        : context.querySelectorAll('.section-global-events');
156
157      $(sections).each(function () {
158        toggleGlobalEventsSlider($(this).children('.view-content'));
159      });
160    },
161  };
162
163  var resizeTimer;
164  $(window).on('resize.numberedWLayoutSlider', function () {
165    clearTimeout(resizeTimer);
166    resizeTimer = setTimeout(function () {
167      toggleAllNumberedWLayoutSliders(document);
168      $('.numbered-w-layout-wrapper.slick-initialized').slick('setPosition');
169    }, 150);
170  });
171
172  var globalEventsResizeTimer;
173  $(window).on('resize.globalEventsSlider', function () {
174    clearTimeout(globalEventsResizeTimer);
175    globalEventsResizeTimer = setTimeout(function () {
176      toggleAllGlobalEventsSliders(document);
177      $('.section-global-events > .view-content.slick-initialized').slick('setPosition');
178    }, 150);
179  });
180
181})(jQuery, Drupal);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.