PageSourceSearch

https://www.sustainablegambling.com/fr/wp-content/themes/sgc_awp/src/js/main.js?ver=1789023553

js sustainablegambling.com collected 2026-10-04 00:30:23 UTC 14,216 bytes, 417 lines download raw bytes

1window.onload = () => {
2  insertExpansions();
3  setupParallax();
4};
5
6function toggleClass(element, className) {
7  element.classList.toggle(className);
8}
9
10function addClassIfNotPresent(element, className) {
11  if (element && !element.classList.contains(className)) {
12      element.classList.add(className);
13  }
14}
15
16function insertExpansions() {
17  document.querySelectorAll('.page_item_has_children').forEach(parent => {
18      const span = document.createElement('span');
19      span.classList.add('exp');
20      parent.insertBefore(span, parent.firstChild);
21  });
22}
23
24document.addEventListener("DOMContentLoaded", function () {
25  // Agenda Timeline Functionality
26  initializeAgendaTimelines();
27
28  const lightbox = GLightbox({
29    selector: 'a[href$=".jpg"]:not(.noPop), a[href$=".jpeg"]:not(.noPop), a[href$=".png"]:not(.noPop), a[href$=".gif"]:not(.noPop), a[href$=".svg"]:not(.noPop), .iframePop',
30    openEffect: 'zoom',
31    closeEffect: 'fade',
32    svg: {
33      close: `
34        <svg class="w-[2rem] rotate-45 min-w-[2rem] h-[2rem]" width="31" height="31" viewBox="0 0 31 31" fill="none" xmlns="http://www.w3.org/2000/svg">
35        <circle class="group-hover:fill-unitedBlue" cx="15.5" cy="15.5" r="15.5" fill="white"/>
36        <line class="group-hover:stroke-white" x1="15.5" y1="6" x2="15.5" y2="25" stroke="#000066"/>
37        <line class="group-hover:stroke-white" x1="25" y1="15.5" x2="6" y2="15.5" stroke="#000066"/>
38        </svg>
39      `,
40      play: `
41        <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg" style="min-width: 6.25rem; width: 6.25rem; height: 6.25rem;">
42          <path d="M50 0C77.6142 0 100 22.3858 100 50C100 77.6142 77.6142 100 50 100C22.3858 100 0 77.6142 0 50C0 22.3858 22.3858 0 50 0ZM36.667 70L70 50.833L36.667 31.667V70Z" fill="white" />
43        </svg>
44      `,
45      next: `
46      <svg class="group-hover:cursor-pointer group-hover:scale-125 transition duration-500 ease w-full h-full" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg">
47        <circle class="group-hover:fill-unitedBlue" cx="20.5" cy="20.5" r="20.5" fill="white"></circle>
48        <line class="group-hover:stroke-white" x1="24.3536" y1="11.6464" x2="33.3536" y2="20.6464" stroke="#000066"></line>
49        <line class="group-hover:stroke-white" x1="24.3464" y1="28.9465" x2="33.3464" y2="19.9465" stroke="#000066"></line>
50        <line class="group-hover:stroke-white" x1="33.0691" y1="20.3" x2="7.94006" y2="20.3" stroke="#000066"></line>
51      </svg>
52    `,
53    prev: `
54      <svg class="group-hover:cursor-pointer group-hover:scale-125 transition duration-500 ease w-full h-full rotate-180" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg">
55        <circle class="group-hover:fill-unitedBlue" cx="20.5" cy="20.5" r="20.5" fill="white"></circle>
56        <line class="group-hover:stroke-white" x1="24.3536" y1="11.6464" x2="33.3536" y2="20.6464" stroke="#000066"></line>
57        <line class="group-hover:stroke-white" x1="24.3464" y1="28.9465" x2="33.3464" y2="19.9465" stroke="#000066"></line>
58        <line class="group-hover:stroke-white" x1="33.0691" y1="20.3" x2="7.94006" y2="20.3" stroke="#000066"></line>
59      </svg>
60    `
61    }
62  });
63
64  if(document.querySelectorAll('.showOnScroll').length > 0){
65    gsap.utils.toArray('.showOnScroll').forEach(element => {
66      gsap.to(element, {
67        opacity: 1,
68        duration: 1.4,
69        ease: 'power2.out',
70        scrollTrigger: {
71          trigger: element,
72          start: 'top 85%', // start animation when the top of the element hits the 80% viewport height
73          toggleActions: 'play none none none' // defines what happens when the scrollTrigger is triggered and reversed
74        }
75      });
76    });
77  }
78});
79
80document.addEventListener('DOMContentLoaded', function() {
81  const tabs = document.querySelectorAll('.tab-button');
82  const mediaItems = document.querySelectorAll('.iframePop');
83  
84  tabs.forEach(tab => {
85      tab.addEventListener('click', function() {
86          // Remove active class from all tabs
87          tabs.forEach(t => t.classList.remove('active'));
88          
89          // Add active class to clicked tab
90          this.classList.add('active');
91          
92          // Get filter value
93          const filter = this.getAttribute('data-filter');
94          
95          // Show/hide media items
96          mediaItems.forEach(item => {
97              if (filter === 'all' || item.getAttribute('data-group') === filter) {
98                  item.style.display = '';
99              } else {
100                  item.style.display = 'none';
101              }
102          });
103          
104          setTimeout(() => {
105              ScrollTrigger.refresh();
106          }, 50);
107      });
108  });
109});
110
111document.addEventListener("click", function(event) {
112  // Use closest to find the clicked element or its parent with the class 'archive_filter'
113  var filterEl = event.target.closest('.archive_filter');
114
115  // Proceed only 
115if 'archive_filter' class was found
116  if (filterEl) {
117    // If it's already 'open', remove the class
118    if (filterEl.classList.contains('open')) {
119      filterEl.classList.remove('open');
120    } else {
121      // Otherwise, remove 'open' from all elements with class 'archive_filter'
122      document.querySelectorAll('.archive_filter').forEach(function(el) {
123        el.classList.remove('open');
124      });
125      // Then add 'open' to the clicked element
126      filterEl.classList.add('open');
127    }
128  }
129});
130
131
132//Scrolled header animation + .scrolled class added to body when scrolled header
133gsap.registerPlugin(ScrollTrigger);
134
135let logo = ".navbar-brand:not(.footer .navbar-brand)";
136let langSwitch = ".lang-switcher:not(.navigation .lang-switcher)";
137let search = ".header_search:not(.navigation .header_search)";
138let search_input = ".header_search .blurry-input";
139let header = ".header_background";
140
141let tl = gsap.timeline({
142  scrollTrigger: {
143    trigger: ".header",
144    start: "+=128",
145    toggleActions: "play none none reverse",
146    scrub: 1,
147    duration: 0.5,
148    onLeave: () => {
149      document.body.classList.add('scrolled');
150    },
151    onEnterBack: () => {
152      document.body.classList.remove('scrolled');
153    },
154  }
155});
156
157
158
159//Tables
160if (document.querySelector("table") != null) {
161  const tables = document.querySelectorAll('table');
162  tables.forEach(table => {
163    const theadExists = table.querySelector('thead');
164    const tableWrapper = document.createElement('div');
165    tableWrapper.classList.add('table-wrapper', 'overflow-auto');
166    table.parentNode.insertBefore(tableWrapper, table);
167    tableWrapper.appendChild(table);
168  });
169}
170
171function setupParallax() {
172  const parallaxWrappers = document.querySelectorAll('.parallax-wrapper');
173
174  parallaxWrappers.forEach(wrapper => {
175    const circles = wrapper.querySelectorAll('.circle');
176
177    // Define a variable to store the animation frame ID
178    let animationFrameID;
179
180    // Calculate the parallax effect
181    function updateParallax() {
182      const scrollY = window.scrollY || window.pageYOffset;
183
184      // Apply the parallax effect to each circle to follow the scroll position
185      circles.forEach(circle => {
186        const translateY = scrollY * 0.3; // Adjust the multiplier for desired effect
187        gsap.to(circle, { y: translateY, duration: 0.6, ease: "power1.out" });
188      });
189
190      // Request the next animation frame
191      animationFrameID = requestAnimationFrame(updateParallax);
192    }
193
194    // Attach the scroll event listener to start the animation
195    window.addEventListener('scroll', () => {
196      // If an animation frame is not already requested, start the animation
197      if (!animationFrameID) {
198        updateParallax();
199      }
200    });
201
202    // Initial call to set the initial position
203    updateParallax();
204  });
205}
206
207  document.addEventListener("DOMContentLoaded", function () {
208    const toggleButtons = document.querySelectorAll(".open-additional-info");
209
210    toggleButtons.forEach(button => {
211      button.addEventListener("click", function () {
212        const timeline = this.closest(".timeline");
213
214        if (timeline) {
215          const isExpanded = timeline.classList.contains("timeline-expand");
216
217          if (isExpanded) {
218            timeline.classList.remove("timeline-expand");
219          } else {
220            timeline.classList.add("timeline-expand");
221          }
222        }
223      });
224    });
225  });
226  function equalizeH4Heights() {
227    const container = document.querySelector('.wp-block-sgc-agenda .type-columns.layout-2');
228    if (!container) return;
229  
230    const headings = container.querySelectorAll('h4');
231    if (headings.length === 0) return;
232  
233    headings.forEach(h => h.style.height = 'auto');
234  
235    if (window.innerWidth >= 992) {
236      let maxHeight = 0;
237  
238      headings.forEach(h => {
239        const hgt = h.offsetHeight;
240        if (hgt > maxHeight) maxHeight = hgt;
241      });
242  
243      headings.forEach(h => h.style.height = maxHeight + 'px');
244    }
245  }
246  
247  window.addEventListener('load', equalizeH4Heights);
248  window.addEventListener('resize', equalizeH4Heights);
249
250/**
251 * Initialize Agenda Timeline Functionality
252 */
253function initializeAgendaTimelines() {
254  // Timeline expand/collapse functionality
255  const timelines = document.querySelectorAll('.timeline');
256  
257  document.querySelectorAll('.agenda-speaker').forEach(speaker => {
258    speaker.addEventListener('click', () => {
259      const speakerId = speaker.getAttribute('data-speaker-id');
260      console.log('data-speaker-id:', speakerId);
261      const modal = document.getElementById('speaker-modal-' + speakerId);
262      if (modal) {
263        modal.classList.remove('hidden');
264        // Add overflow-hidden to body
265        document.body.classList.add('overflow-hidden');
266      }
267    });
268 });
269 
270 // Close by button 'Close'
271 document.querySelectorAll('.close-additional-info').forEach(closeBtn => {
272    closeBtn.addEventListener('click', () => {
273      const modal = closeBtn.closest('.agenda-speaker-overlay');
274      if (modal) {
275        modal.classList.add('hidden');
276        // Remove overflow-hidden class from body
277        document.body.classList.remove('overflow-hidden');
278      }
279    });
280 });
281 
282 document.querySelectorAll('.agenda-speaker-overlay').forEach(overlay => {
283    overlay.addEventListener('click', (event) => {
284      if (event.target === overlay) {
285        overlay.classList.add('hidden');
286        // Remove overflow-hidden class from body
287        document.body.classList.remove('overflow-hidden');
288      }
289    });
290 });
291 
292 // Close by Tab ESC
293 document.addEventListener('keydown', (event) => {
294    if (event.key === 'Escape') {
295      const openModal = document.querySelector('.agenda-speaker-overlay:not(.hidden)');
296      if (openModal) {
297        openModal.classList.add('hidden');
298        // Remove overflow-hidden class from body
299        document.body.classList.remove('overflow-hidden');
300      }
301    }
302 });
303
304}
305  function pxToRem(px) {
306    const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
307    return px / rootFontSize;
308  }
309
310 function setTimelineHeight(timeline) {
311  const totalPx = getCollapsedTimelineHeight(timeline);
312  const totalRem = pxToRem(totalPx);
313  timeline.style.height = `${totalRem}rem`;
314}
315  function getCollapsedTimelineHeight(timeline) {
316    const title = timeline.querySelector('h3');
317    const titleHeightPx = title ? title.offsetHeight : 0;
318    const extraPx = 26;
319    return titleHeightPx + extraPx;
320  }
321
322  function adjustAllTimelines() {
323    const timelines = document.querySelectorAll('.timeline');
324
325    timelines.forEach(timeline => {
326      if (timeline.classList.contains('timeline-expand')) {
327        clearTimelineHeight(timeline);
328      } else {
329        setTimelineHeight(timeline);
330      }
331    });
332  }
333
334  window.addEventListener('load', adjustAllTimelines);
335  window.addEventListener('resize', () => {
336    setTimeout(adjustAllTimelines, 100);
337  });
338
339const timelines = document.querySelectorAll('.timeline');
340
341timelines.forEach(timeline => {
342  const observer = new MutationObserver(mutations => {
343    mutations.forEach(mutation => {
344      if (mutation.attributeName === 'class') {
345        const isExpanding = timeline.classList.contains('timeline-expand');
346
347        const fullHeight = timeline.scrollHeight;
348        const collapsedHeight = getCollapsedTimelineHeight(timeline);
349        timeline.style.height = fullHeight + 'px';
350
351        requestAnimationFrame(() => {
352          if (isExpanding) {
353            timeline.style.height = fullHeight + 'px';
354          } else {
355            timeline.style.height = collapsedHeight + 'px';
356          }
357        });
358      }
359    });
360  });
361
362  observer.observe(timeline, { attributes: true });
363
364if (!timeline.classList.contains('timeline-expand')) {
365  const collapsedHeight = getCollapsedTimelineHeight(timeline);
366  timeline.style.height = collapsedHeight + 'px';
367}
368});
369
370function removeUselessExpandButtons() {
371  const timelines = document.querySelectorAll('.timeline');
372
373  timelines.forEach(timeline => {
374    const toggleButton = timeline.querySelector('.open-additional-info');
375    if (!toggleButton) return;
376
377    const collapsedHeight = getCollapsedTimelineHeight(timeline);
378    const fullHeight = timeline.scrollHeight;
379
380    if (Math.abs(fullHeight - collapsedHeight) <= 2) {
381      toggleButton.style.display = 'none';
382    } else {
383      toggleButton.style.display = '';
384    }
385  });
386}
387
388window.addEventListener('load', () => {
389  adjustAllTimelines();
390  removeUselessExpandButtons();
391});
392
393window.addEventListener('resize', () => {
394  setTimeout(() => {
395    adjustAllTimelines();
396    removeUselessExpandButtons();
397  }, 100);
398});
399
400  //Modules with white background have no padding top when previous is also white
401
402  document.addEventListener('DOMContentLoaded', () => {
403  const whiteModules = document.querySelectorAll('.module.is-style-white');
404
405  whiteModules.forEach((module, i) => {
406    const prev = module.previousElementSibling;
407
408    let prevModule = prev;
409    while (prevModule && !prevModule.classList.contains('module')) {
410      prevModule = prevModule.previousElementSibling;
411    }
412
413    if (prevModule && prevModule.classList.contains('is-style-white')) {
414      module.style.paddingTop = '0';
415    }
416  });
417});

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.