PageSourceSearch

https://www.viadanse.com/wp-content/themes/viadanse2015/js/scripts.js

js viadanse.com collected 2026-10-02 12:27:59 UTC 6,518 bytes, 226 lines download raw bytes

1;(function ($, root) {
2	'use strict';
3
4
5
6    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ACCORDEONS
7    document.addEventListener('DOMContentLoaded', function() {
8        // Récupérer tous les accordéons sur la page
9        var acc = document.getElementsByClassName("accordion");
10
11        for (var i = 0; i < acc.length; i++) {
12            acc[i].addEventListener("click", function() {
13                // Activer/désactiver le panel cliqué
14                this.classList.toggle("active");
15                var panel = this.nextElementSibling;
16                if (panel.style.maxHeight) {
17                    panel.style.maxHeight = null; // Ferme le panel
18                } else {
19                    panel.style.maxHeight = panel.scrollHeight + "px"; // Ouvre le panel
20                }
21            });
22        }
23    });
24	
25	/*	
26	document.addEventListener('DOMContentLoaded', function() {
27		var filterContainer = document.querySelector('.wcs-filters__container');
28
29		window.addEventListener('scroll', function() {
30			var rect = filterContainer.getBoundingClientRect();
31			if (rect.top <= 0) {
32				filterContainer.classList.add('fixed');
33			} else {
34				filterContainer.classList.remove('fixed');
35			}
36		});
37	});
38	*/
39
40
41	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EVENTS — DOCUMENT.
42	$(document).ready(function() {
43		
44		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SLIDE PARTENAIRES
45		jQuery(function() {
46			$('.slide-home').slick({
47			  dots: true,
48			  arrows: false,
49			  infinite: false,
50			  adaptiveHeight: true,
51			  /*fade: true,*/
52			  /*pauseOnHover: false,*/
53			  speed: 500,
54				autoplay: true,
55				autoplaySpeed: 3000,
56			  slidesToShow: 1,
57			  slidesToScroll: 1
58			});
59		});		
60		
61		/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GESTION DES FADE IN */
62		document.body.classList.add('js-on');
63		const fadeDivs = document.querySelectorAll('.fade, .fade-land, .fade-l, .fade-r');
64		if(fadeDivs){
65			fadeDivs.forEach(div => {
66				let checkScrollForFade = new IntersectionObserver(function(entries, checkScroll){
67					entries.forEach(entry => {
68						if (entry.isIntersecting) {
69							div.classList.add('in');
70							checkScrollForFade.unobserve(div);
71						}
72					});
73				}, {rootMargin: "0px", threshold: 0.1});
74				checkScrollForFade.observe(div);
75			});
76		}
77		
78
79		// Fonction qui vérifie la position du scroll et applique ou enlève la classe
80		function checkScroll() {
81			if ($(window).scrollTop() >= 50) {
82				$('.header').addClass('bg-header');
83			} else {
84				$('.header').removeClass('bg-header');
85			}
86		}
87
88		checkScroll();
89
90		$(window).scroll(function () {
91			checkScroll();
92		});
93
94		
95		// Variables.
96		let
97			$body = $('body'),
98			$header = $('.header'),
99			$nav = $('.nav'),
100			relayouting = false,
101			device,
102			deviceMedia = function(e) {
103				relayouting = true;
104				// Size.
105				if (typeof($('.device').css('content')) !== 'undefined')
106					device = $('.device').css('content').replace(/['"]+/g,'');
107				else
108					device = ($(window).width() <= 737) ? 'phone' : 'monitor';
109				// Touch.
110				$body.removeClass('touchevents no-touchevents');
111				$body.addClass((!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) ? 'no-' : '') + 'touchevents');
112				//
113				setTimeout(function() { relayouting = false; }, 100);
114			};
115		// Device.
116		deviceMedia();
117
118		/*~~~~~~~~~~~~~~~~~~ NAVIGATION — MOBILE */
119		$('.burger').on('click.toggle', function(e) {
120			$body.addClass('nav-animate');
121			$body.toggleClass('nav-open');
122			$("li.current-menu-item").parent().addClass("collapsed");
123		});
124		$nav.on('transitionend', function(e) {
125			$body.removeClass('nav-animate');
126		});
127		
128		/*~~~~~~~~~~~~~~~~~ NAVIGATION — DESKTOP */
129		$('.sub-menu').prev('a').each(function(i) {
130			let $this = $(this);
131			$this.addClass('inactive');
132			$this.on({
133				'click': function(e) { 
134					$this.next('.sub-menu').toggleClass('collapsed');
135					$this.next('.menu-item ul').parent().toggleClass('active-parent');
136				},
137				'mouseover': function(e) { 
138					if (!$(".burger").is(':visible')) {
139					$this.next('.sub-menu').addClass('collapsed');
140					$this.addClass('active');
141					$this.next('.menu-item ul').parent().addClass('active-parent');
142					} 
143				},
144				'mouseenter': function(e) { 
145					$body.addClass('nav-open');
146				}
147				//'mouseleave': function(e) { $body.removeClass('nav-open'); }
148			});
149			$(this).parent('.menu-item').on('mouseleave', function(e) {
150				if (!$(".burger").is(':visible')) {
151					$body.removeClass('nav-open');
152					$('.sub-menu').removeClass('collapsed');
153					$('.menu-item-has-children a').removeClass('active');
154				}
155			});
156			
157			$(this).closest('.sub-menu').find('.current_page_item').addClass("collapsed");
158			
159		});
160		let navClose = function(e) {
161			!$header[0].contains(e.target) && /monitor/.test(device) && $body.hasClass('nav-open') && $body.removeClass('nav-open');
162		};
163		document.addEventListener('click', navClose, true);
164		//document.addEventListener('scroll', navClose, true);
165		
166		
167		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EVENTS — WINDOW.
168		$(window).on({
169			resize: window.throttle(
170				function(e) {
171					if (!relayouting) {
172						deviceMedia(e);
173					}
174				}, 50, {leading: false, trailing:true}
175			),
176			orientationchange: function(e) {
177				if (!relayouting && typeof device!=='undefined' && !/monitor/.test(device)) {
178					setTimeout(function() {
179						deviceMedia(e);
180					}, 5);
181				}
182			}
183		});
184
185	});
186
187	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WINDOW — THROTTLE.
188	window.throttle = function(func, wait, options) {
189		let context, args, result;
190		let timeout = null;
191		let previous = 0;
192		if (!options) options = {};
193		let later = function() {
194			previous = options.leading === false ? 0 : window.now();
195			timeout = null;
196			result = func.apply(context, args);
197			if (!timeout) context = args = null;
198		};
199		return function() {
200			let now = window.now();
201			if (!previous && options.leading === false) previous = now;
202			let remaining = wait - (now - previous);
203			context = this;
204			args = arguments;
205			if (remaining <= 0 || remaining > wait) {
206				if (timeout) {
207					clearTimeout(timeout);
208					timeout = null;
209				}
210				previous = now;
211				result = func.apply(context, args);
212				if (!timeout) context = args = null;
213			} else if (!timeout && options.trailing !== false) {
214				timeout = setTimeout(later, remaining);
215			}
216			return result;
217		};
218	};
219
220	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WINDOW — DATE NOW.
221	window.now = Date.now || function() {
222		return new Date().getTime();
223	};
224
225	
226})(jQuery, this);

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.