PageSourceSearch

https://www.alies.fr/wp-content/themes/alies/assets/js/common.js?ver=1.0.0%20%28tc-4.1.0%29

js alies.fr collected 2026-09-28 06:59:46 UTC 10,717 bytes, 400 lines download raw bytes

1var anchors = [];
2var $body, $menu, admin_bar_height = 0;
3
4jQuery( function($) {
5
6	// Menu
7	var menuFix = function() {
8
9		var top          = $( window ).scrollTop();
10		var headerHeight = $header.outerHeight();
11
12		// Descente du scroll => Menu non fixé
13		if ( headerHeight > top && !$menu.hasClass('navbar-vertical') ) {
14			$body.removeClass('menu-fixed');
15		}
16		// Scroll au niveau du menu ou sous le menu => Menu fixé
17		else {
18			$body.addClass('menu-fixed');
19		}
20	};
21
22
23
24    var $sm_menu = $('.navbar-primary .navbar-nav')
25	
26	$sm_menu.smartmenus();
27	
28
29	var $body   = $('body');
30	var $header = $('.header-main');
31	var $menu   = $('.navbar-primary');
32	menuFix();
33	$(window).scroll( function() { menuFix(); } )
34		     .resize( function() { menuFix(); } );
35
36	$body.on( 'mouseenter mouseleave', '.dropdown', function( e ) {
37		var _d = $( e.target ).closest( '.dropdown' );
38		// _d.addClass( 'show' );
39		
40		setTimeout( function() {
41			// _d [ _d.is( ':hover' ) ? 'addClass' : 'removeClass' ]( 'show' );
42			$( '[data-toggle="dropdown"]', _d ).attr( 'aria-expanded', _d.is( ':hover' ) );
43		}, 150 );
44	});
45
46	// Lightbox
47	var lightbox_supported_ext = ['jpg', 'JPG', 'png', 'PNG', 'jpeg', 'JPEG'];
48	$('.body-container .content img').each(function(index, el) {
49
50
51		var $a = $(el).parent();
52
53		if ( $a.is('a') ) {
54
55			// if not already a lightbox
56			if ( '' == $a.attr('data-lightbox') || undefined == $a.attr('data-lightbox') ) {
57				
58				var aext = $a[0].href.split('/');
59				aext = aext[ aext.length - 1 ];
60				aext = aext.split('.');
61				aext = aext[1];
62
63				// Only image links
64				if ( -1 !== lightbox_supported_ext.indexOf( aext ) ) {
65
66					var lightname = '';
67					
68					if ( !$(el).hasClass('gallery-item') ) {
69						lightname = el.src.split('/');
70						lightname = lightname[ lightname.length - 1 ];
71						lightname = lightname.split('.');
72						lightname = lightname[0];
73					}
74
75					$a.attr('data-lightbox', lightname );
76					$a.attr('data-title', el.alt );
77				}
78			}
79		}
80	});
81
82	$('.multiple-front-item').hover(function() {
83		$(this).find('.etiquette').removeClass('bleu').addClass('orange');
84	}, function() {
85		$(this).find('.etiquette').removeClass('orange').addClass('bleu');
86	})
87
88	$('.sev-diaporama-front-links2-item').hover(function() {
89		var etiquette = $(this).find('.etiquette'); 
90		
91		if(etiquette.hasClass('orange')) {
92			$(etiquette).removeClass('orange').addClass('bleu');
93		} else {
94			$(etiquette).removeClass('bleu').addClass('orange');
95		}
96	}, function() {
97		var etiquette = $(this).find('.etiquette'); 
98		
99		if(etiquette.hasClass('orange')) {
100			$(etiquette).removeClass('orange').addClass('bleu');
101		} else {
102			$(etiquette).removeClass('bleu').addClass('orange');
103		}
104	})
105
106	// Form Resa
107	$( '.form-resa .input-daterange' ).datepicker({
108		language: $( '.form-resa' ).attr( 'data-lang' ),
109	});
110
111	var eltBottomFix = function( elt, className, init ) {
112		var windowScrollTop = window.scrollY;
113		var viewportHeight  = window.innerHeight;
114		var footerTopTop    = footerTop.offsetTop;
115		var footerTopHeight = footerTop.offsetHeight;
116
117		var eltAnchorBottom   = parseInt( footerTopTop + footerTopHeight );
118		var windowScrollBottom = parseInt( windowScrollTop + viewportHeight );
119
120		if ( body.classList.contains('admin-bar') ) {
121			eltAnchorBottom += adminBar.offsetHeight;
122		}
123
124		if ( body.classList.contains('has-cookielaw') ) {
125			eltAnchorBottom += cookielawBar.offsetHeight;
126		}
127
128		// console.log( 'eltAnchorBottom : ' + eltAnchorBottom + ' ; windowScrollBottom : ' + windowScrollBottom );
129
130		if ( eltAnchorBottom <= windowScrollBottom ) {
131			elt.classList.add( className );
132		} else {
133			elt.classList.remove( className );
134		}
135
136		init = init ? true : false;
137		if ( init ) {
138			$(window).scroll( function() { eltBottomFix( elt, className, false ); } )
139				     .resize( function() { eltBottomFix( elt, className, false ); } );
140		}
141	};
142	var body              = document.getElementsByTagName('body')[0];
143	var footerTop         = document.getElementsByClassName('footer-top')[0];
144	var formResaContainer = document.getElementsByClassName('form-resa-container')[0];
145	if ( body.classList.contains('admin-bar') ) {
146		var adminBar = document.getElementById('wpadminbar');
147	}
148	if ( body.classList.contains('has-cookielaw') ) {
149		var cookielawBar = document.getElementsByClassName('sevcookieslaw')[0];
150	}
151	eltBottomFix( formResaContainer, 'resa-fixed', true );
152
153	var toTopArrow = document.getElementsByClassName('totop-arrow')[0];
154	eltBottomFix( toTopArrow, 'totop-fixed', true );
155
156	/**
157	 * Google Analytics events
158	 *
159	 * Exemple d'attributs pour <a href="tel:0251203040"></a> 
160	 * 	data-gtag-action="téléphoner"
161	 *  data-gtag-category="contact"
162	 *  data-gtag-label="Clic lien header tel:"
163	 *  data-gtag-value="1"
164	 */
165	$( '.gtag-tracking' ).on( 'click', function( e ) {
166
167		var $this  = $( this ),
168			action = $this.attr('data-gtag-action'),
169			params = {
170				_category : $this.attr('data-gtag-category'),
171				_label    : $this.attr('data-gtag-label'),
172				_value    : $this.attr('data-gtag-value'),
173			};
174
175		params._category = params._category ? params._category : null;
176		params._label    = params._label ? params._label : null;
177		params._value    = params._value ? params._value : 1;
178
179		gtag_send_event( action, params );
180	} );
181
182	var gtag_send_event = function( action, params ) {
183
184		gtag( 'event', action, {
185			'event_category': params._category,
186			'event_label': params._label,
187			'value': params._value
188		} );
189
190		console.log( 'Event sent : ' + action + ' : ' + params._category + ' / ' + params._label + " = " + params._value );
191	};
192
193	// Menu
194	$body = $('body');
195	$menu = $( '.menu-primary' );
196	var headerHeight = parseInt( Math.floor( $( '.header-main' ).height() ) );
197	var scrolledWindow = function() {
198
199		if ( 0 == $( window ).scrollTop() ) {
200			$body.removeClass('scrolled');
201		} else {
202			$body.addClass('scrolled');
203			headerHeight = parseInt( Math.floor( $( '.header-main' ).height() ) );
204		}
205	};
206	scrolledWindow();
207	$(window).scroll( function() { scrolledWindow(); } );
208
209	var menuGoToAnchor = function( elt, e ) {
210
211
212
213		if (location.pathname.replace(/^\//,'') == elt.pathname.replace(/^\//,'') && location.hostname == elt.hostname && elt.hash.slice(1) != '') {
214		e.preventDefault();
215		console.log(elt.hash.slice(1));
216		    
217		    var target = $(elt.hash);
218		    target = target.length ? target : $('[name=' + elt.hash.slice(1) +']');
219		    
220		    if ( target.length ) {
221
222		    	var $menu_primary = $( '#menu_primary_navbar_collapse' );
223		        if ( $menu_primary.hasClass( 'show' ) ) {
224		        	$menu_primary.removeClass( 'show' );
225		        }
226
227				var scrollTop = calculateScrollTop( target );
228				var headerHeightBeforeAnimation = headerHeight;
229				var animationDuration = 500;
230
231				var properties = {
232					scrollTop: scrollTop,
233				};
234
235				var options = {
236		        	complete: function( now, fx ) {
237
238						if ( headerHeightBeforeAnimation != headerHeight ) {
239							scrollTop = calculateScrollTop( target );
240							$(this).stop().animate( { scrollTop: scrollTop }, ( animationDuration / 10 ) );
241						}
242					},
243					duration: animationDuration
244				};
245
246		        $( 'html, body' ).animate( properties, options );
247		    }
248		} else {
249			return true;
250		}
251	};
252
253	var calculateScrollTop = function( target ) {
254
255		var scrollTop = target.offset().top - headerHeight;
256
257		if ( $( 'body' ).hasClass( 'admin-bar' ) ) {
258			scrollTop -= admin_bar_height;
259		}
260
261		return scrollTop;
262	};
263
264	var updateCurrentMenu = function () {
265
266		var windowScroll = parseInt( Math.ceil( $( window ).scrollTop() ) + headerHeight );
267
268		// Init
269		$menu.find('ul li').removeClass( 'current-item' );
270
271		if ( $( 'body' ).hasClass('admin-bar')) {
272			windowScroll += admin_bar_height;
273		}
274
275		// First section
276		if ( windowScroll < anchors[0].offsetTop ) {
277			$menu.find( 'ul li:first-child' ).addClass( 'current-item' );
278		}
279		// Last section
280		else if ( windowScroll >= anchors[ (anchors.length - 1) ].offsetTop ) {
281			$menu.find( 'ul li:last-child' ).addClass( 'current-item' );
282		}
283		// Other secions
284		else { 
285			for ( var i = 0; i < (anchors.length - 1); i++ ) {
286				if ( windowScroll >= anchors[ i ].offsetTop && windowScroll < anchors[ (i + 1) ].offsetTop ) {
287					// console.log( anchors[ i ].element.id );
288					$menu.find( 'a[href="#' + anchors[ i ].element.id + '"]' ).parent().addClass( 'current-item' );
289				}
290			}
291		}
292	};
293
294	var initAnchorsData = function() {
295		anchors = [];
296		$( '.front-page-anchor' ).each( function( index, el ) {
297			anchors.push( {
298				element: el,
299				offsetTop: parseInt( Math.floor( $( el ).offset().top ) ),
300			} );
301		} );
302
303		admin_bar_height = 0;
304		if ( $( 'body' ).hasClass('admin-bar')) {
305
306			admin_bar_height = 32;
307
308			if ( 781 >= $(window).width() ) {
309				admin_bar_height = 46;
310			}
311
312			if ( 600 >= $(window).width() ) {
313				admin_bar_height = 0;
314			}
315		}
316	};
317
318	$('.totop-arrow').on( 'click', function( e ) {
319		menuGoToAnchor( this, e );
320	});
321 
322	if ( $('body').hasClass('home') ) {
323
324		$menu.on( 'click', '.menu-item > a', function( e ) {
325			menuGoToAnchor( this, e );
326		});
327
328		$( window ).on( 'load', function( e ) {
329			initAnchorsData();
330			updateCurrentMenu();
331		} );
332
333		$( window ).on( 'resize', function( e ) {
334			initAnchorsData();
335			updateCurrentMenu();
336		} );
337
338		$( window ).on( 'scroll', function( e ) {
339			if ( undefined == anchors[0] ) {
340				initAnchorsData();
341			}
342			updateCurrentMenu();
343		} );
344	}
345
346	// Elements load animation.
347	
348	/**
349	  * Copyright 2012, Digital Fusion
350	  * Licensed under the MIT license.
351	  * http://teamdf.com/jquery-plugins/license/
352	  *
353	  * @author Sam Sehnert
354	  * @desc A small plugin that checks whether elements are within
355	  *     the user visible viewport of a web browser.
356	  *     only accounts for vertical position, not horizontal.
357	  */
358	$.fn.visible = function( partial ) {
359		
360		var $t            = $( this ),
361		    $w            = $( window ),
362		    viewTop       = $w.scrollTop(),
363		    viewBottom    = viewTop + $w.height(),
364		    _top          = $t.offset().top,
365		    _bottom       = _top + $t.height(),
366		    compareTop    = partial === true ? _bottom : _top,
367		    compareBottom = partial === true ? _top : _bottom;
368		
369		return ( ( compareBottom <= viewBottom ) && ( compareTop >= viewTop ) );
370
371	};
372
373	var win     = $( window );
374	var allMods = $( 'article.content-front-page > *' );
375
376	// Already visible modules
377	allMods.each( function( i, el ) {
378		var $el = $(el);
379		if ( $el.visible( true ) ) {
380			$el.addClass( 'already-visible' );
381		} 
382	} );
383
384	win.scroll( function( event ) {
385
386		allMods.each( function( i, el ) {
387			var $el = $( el );
388			if ( $el.visible( true ) ) {
389				$el.addClass( 'come-in' );
390			} 
391		} );
392	} );
393
394
395	$('.header-lang').click(function() {
396		$('.bloc-lang').toggleClass('d-none');
397
398		return false;
399	});
400} );

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.