PageSourceSearch

https://www.labelledelabaie.fr/wp-content/plugins/ldb-native-pages/assets/js/home.js?ver=1.1.0.152

js labelledelabaie.fr collected 2026-10-04 01:24:38 UTC 4,330 bytes, 149 lines download raw bytes

1(function () {
2  function initCarousel(root) {
3    var track = root.querySelector(".jdgm-carousel__item-wrapper");
4    if (!track) return;
5
6    var items = track.querySelectorAll(".jdgm-carousel-item");
7    if (items.length < 2) return;
8
9    var index = 0;
10
11    function visibleCount() {
12      if (window.innerWidth <= 767) return 1;
13      if (window.innerWidth <= 991) return 2;
14      return 3;
15    }
16
17    function maxIndex() {
18      return Math.max(0, items.length - visibleCount());
19    }
20
21    function update() {
22      var itemWidth = items[0].getBoundingClientRect().width;
23      track.style.transform = "translate3d(" + -(index * itemWidth) + "px, 0, 0)";
24    }
25
26    var prev = root.querySelector(".jdgm-carousel__left-arrow");
27    var next = root.querySelector(".jdgm-carousel__right-arrow");
28
29    if (prev) {
30      prev.addEventListener("click", function () {
31        index = Math.max(0, index - 1);
32        update();
33      });
34    }
35    if (next) {
36      next.addEventListener("click", function () {
37        index = Math.min(maxIndex(), index + 1);
38        update();
39      });
40    }
41
42    window.addEventListener("resize", function () {
43      if (index > maxIndex()) index = maxIndex();
44      update();
45    });
46
47    update();
48  }
49
50  function initMaskSlider(root, slideSelector) {
51    var mask = root.querySelector(".w-slider-mask");
52    if (!mask) return;
53
54    var slides = mask.querySelectorAll(slideSelector);
55    if (!slides.length) return;
56
57    var index = 0;
58
59    function maxIndex() {
60      return Math.max(0, slides.length - 1);
61    }
62
63    function slideWidth() {
64      return mask.getBoundingClientRect().width || slides[0].getBoundingClientRect().width;
65    }
66
67    function update() {
68      var width = slideWidth();
69      mask.style.transform = "translate3d(" + -(index * width) + "px, 0, 0)";
70      mask.style.transition = "transform 0.5s ease";
71
72      var nav = root.querySelector(".w-slider-nav");
73      if (nav) {
74        var dots = nav.querySelectorAll("div");
75        dots.forEach(function (dot, dotIndex) {
76          dot.classList.toggle("w-active", dotIndex === index);
77        });
78      }
79    }
80
81    var prev = root.querySelector(".w-slider-arrow-left");
82    var next = root.querySelector(".w-slider-arrow-right");
83
84    if (prev) {
85      prev.style.cursor = slides.length > 1 ? "pointer" : "default";
86      prev.addEventListener("click", function (event) {
87        event.preventDefault();
88        if (slides.length < 2) return;
89        index = Math.max(0, index - 1);
90        update();
91      });
92    }
93
94    if (next) {
95      next.style.cursor = slides.length > 1 ? "pointer" : "default";
96      next.addEventListener("click", function (event) {
97        event.preventDefault();
98        if (slides.length < 2) return;
99        index = Math.min(maxIndex(), index + 1);
100        update();
101      });
102    }
103
104    var nav = root.querySelector(".w-slider-nav");
105    if (nav && !nav.children.length) {
106      for (var i = 0; i < slides.length; i++) {
107        (function (slideIndex) {
108          var dot = document.createElement("div");
109          dot.addEventListener("click", function () {
110            index = slideIndex;
111            update();
112          });
113          nav.appendChild(dot);
114        })(i);
115      }
116    } else if (nav) {
117      Array.prototype.forEach.call(nav.children, function (dot, dotIndex) {
118        dot.addEventListener("click", function () {
119          index = dotIndex;
120          update();
121        });
122      });
123    }
124
125    window.addEventListener("resize", function () {
126      if (index > maxIndex()) index = maxIndex();
127      update();
128    });
129
130    update();
131  }
132
133  function initRecettesSlider(root) {
134    initMaskSlider(root, ".slide-recette");
135  }
136
137  function initPatrimoineSlider(root) {
138    initMaskSlider(root, ".slide-patrimoine");
139  }
140
141  document.addEventListener("DOMContentLoaded", function () {
142    if (window.LDBJdgmStars) {
143      window.LDBJdgmStars.init();
144    }
145    document.querySelectorAll(".jdgm-carousel-wrapper").forEach(initCarousel);
146    document.querySelectorAll(".slider.recettes.w-slider").forEach(initRecettesSlider);
147    document.querySelectorAll(".slider.patrimoine.w-slider").forEach(initPatrimoineSlider);
148  });
149})();

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.