PageSourceSearch

https://www.h-fr.ch/themes/custom/hfr/components/slider-mobile/slider-mobile.js?tlecxb

js h-fr.ch collected 2026-09-25 04:59:54 UTC 1,452 bytes, 58 lines download raw bytes

1(function ($, Drupal, once) {
2
3  "use strict";
4
5  Drupal.behaviors.sliderMobile = {
6    attach: function (context) {
7      once('slider-mobile', '.hfr-slider-mobile', context)
8        .forEach((slider) => {
9          if ($(window).width() < 768) {
10            this.buildSlider(slider);
11          }
12
13          window.addEventListener("resize", () => {
14            const initialized = slider.classList.contains('slick-initialized');
15            if ($(window).width() >= 768) {
16              if (initialized) {
17                this.destroySlider(slider);
18              }
19            }
20            else {
21              if (initialized) {
22                this.rebuild(slider);
23              }
24              else {
25                this.buildSlider(slider);
26              }
27            }
28          });
29
30        });
31    },
32    buildSlider(slider) {
33      const config = slider.getAttribute('data-config') ? JSON.parse(slider.getAttribute('data-config')) : {};
34      const windowWidth = $(window).width();
35
36      if (config.slidesToShow && windowWidth >= 768) {
37        config.slidesToShow = 2;
38      }
39      else {
40        config.slidesToShow = 1;
41      }
42
43      $(slider).slick({
44        infinite: false,
45        arrows: false,
46        ...config,
47      });
48    },
49    destroySlider(slider) {
50      $(slider).slick('unslick');
51    },
52    rebuild(slider) {
53      this.destroySlider(slider);
54      this.buildSlider(slider);
55    }
56  };
57
58})(jQuery, Drupal, once);

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.