PageSourceSearch

https://www.latranchesurmer.fr/wp-content/themes/latranche/js/scripts.js

js latranchesurmer.fr collected 2026-10-02 17:56:41 UTC 8,394 bytes, 340 lines download raw bytes

1jQuery(function($) {
2
3	// Menu Site
4	// -------------------------------------------------------------------
5
6
7	// Séparer les li en 3 ul de chaque sub-menwidth:158pxu
8	$('.sub-menu').each(function(){
9		var count_li = $(this).children('ul.bloc-menu-left').children('li').length;
10		var trois_count_li = count_li/3;
11
12		for (i = count_li-1; i > (Math.ceil(trois_count_li)-1); i--) {
13			$(this).children('ul.bloc-menu-middle').prepend($(this).children('ul.bloc-menu-left').children('li').eq(i));
14		};
15
16		var count_li_first = $(this).children('ul.bloc-menu-left').children('li').length;
17		var count_li_deux = $(this).children('ul.bloc-menu-middle').children('li').length;
18		if(count_li_deux == 2){
19			count_li_deux = 2;
20			count_li_first = 1;
21		}
22		for (i = count_li_deux-1; i > count_li_first-1; i--) {
23			$(this).children('ul.bloc-menu-right').prepend($(this).children('ul.bloc-menu-middle').children('li').eq(i));
24		}
25	});
26
27	// Menu responsive
28
29	( function() {
30		var container, button, menu;
31
32		container = document.getElementById( 'header' );
33		if ( ! container ) {
34			return;
35		}
36
37		button = container.getElementsByTagName( 'button' )[0];
38		if ( 'undefined' === typeof button ) {
39			return;
40		}
41
42		menu = container.getElementsByClassName( 'menu__nav__list' )[0];
43
44		// Hide menu toggle button if menu is empty and return early.
45		if ( 'undefined' === typeof menu ) {
46			button.style.display = 'none';
47			return;
48		}
49
50		menu.setAttribute( 'aria-expanded', 'false' );
51
52		if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
53			menu.className += ' nav-menu';
54		}
55
56		button.onclick = function() {
57			if ( -1 !== menu.className.indexOf( 'toggled' ) )
58				menu.className = menu.className.replace( ' toggled', '' );
59			else
60				menu.className += ' toggled';
61		};
62	} )();
63
64
65
66	$('header .menu__nav__list li.menu-item-has-children').click(function () {
67		if ( $( "#menu-menu-principal" ).hasClass( "toggled" ) ) {
68	        /*$('header .main-menu li ul').addClass('sub-menu');*/
69
70	            var sameLi = false;
71	            if ($(this).hasClass('active')) sameLi = true;
72	            $(this).parent().find('> li').removeClass('active');
73	            if (!sameLi) $(this).toggleClass('active');
74
75		}
76	});
77
78	// Recherche
79
80
81 	$(window).bind('keydown', function(event) {
82 		if(event.keyCode == 27) {
83 			$('.search').css('display', 'none');
84 			$('.search').removeClass('ouvert');
85 		}
86 	});
87
88 	$('.c-search-form_open').click(function(){
89 	    $('body').addClass('has-search-main-open');
90 	    if($(window).width() > 1240) {
91 	    	$( ".c-search-form input" ).focus();
92 		}
93 	});
94 	$('.c-search-form_close').click(function(){
95 	    $('body').removeClass('has-search-main-open');
96 	});
97
98
99
100 	$('.c-search-form_wrap input').blur(function () {
101 	var value_input = $(this).val();
102 		if(value_input == '' || value_input == $(this).attr("placeholder")){
103 		  $('.recherche-autocompletion form .ui-autocomplete').css('display','none');
104 		} else{
105 			$('.recherche-autocompletion form .ui-autocomplete').css('display','block');
106 		}
107 	});
108
109 	$('.c-search-form_wrap input').on('keyup', function(event) {
110 		var value_input = $(this).val();
111
112 		if(value_input == '' || value_input == $(this).attr("placeholder")){
113 		    $('.c-search-main_container').css('padding-top','15.625vw');
114 		    $('.recherche-autocompletion form .ui-autocomplete').css('display','none');
115 		}
116 	});
117
118 	$('.c-search-main').height(window.innerHeight + 'px');
119
120	// -------------------------------------------------------------------------
121	// Modifs site
122	// -------------------------------------------------------------------------
123
124	//Bouton d'accessibilité
125	function eventFire(el, etype){
126		if (el.fireEvent) {
127			el.fireEvent('on' + etype);
128		} else {
129			var evObj = document.createEvent('Events');
130			evObj.initEvent(etype, true, false);
131			el.dispatchEvent(evObj);
132		}
133	}
134
135	$( ".accessibility" ).click(function() {
136	  eventFire(document.getElementById('uci_link'), 'click');
137	});
138
139	//Iframe google translate
140	$('header a.translate').click(function(){
141		$("#google_translate_element .skiptranslate .goog-te-gadget-simple").trigger('click');
142		return false;
143	})
144
145	// Menu sticky
146	$(window).scroll(function (event) {
147		if($(window).width() > 940){
148		    var y = $(this).scrollTop();
149		    if (y > 0){
150		    	$('body').addClass('sticky');
151		    }else{
152		    	$('body').removeClass('sticky');
153		    }
154		}
155	})
156
157	//Donner à la sidebar une largeur negative égale à la hauteur du fil d'ariane
158	bcHeight = $('#breadcrumbs').outerHeight();
159	sMargin = bcHeight + 40;
160	if($(window).width() > 940){
161		$('#secondary').css('margin-top', -sMargin + 'px');
162		$('.wrapper-panel').css('margin-top', -sMargin + 'px');
163	}
164
165
166	// Scripts slider
167	// ----------------------------------------------------------------
168
169	if($('body').hasClass('home')){
170		//Slider a la une
171		if($('#a-la-une .a-la-une-image').length > 0){
172			$('#a-la-une .a-la-une-image').carouFredSel({
173				responsive: true,
174				width: '100%',
175				circular: true,
176				auto: 12000,
177				direction: "left",
178				items : {
179					visible : 1,
180					minimum : 2
181				},
182				auto: {
183					play : true,
184					duration: 2000,
185					easing: 'quadratic'
186					},
187				scroll: {
188					items: 1,
189					pauseOnHover: true,
190					fx: 'scroll',
191					easing : "quadratic"
192					},
193				prev: {
194				    button: '.nav-une__arrow--prev',
195				    key: 'left'
196				},
197				next: {
198					button: '.nav-une__arrow--next',
199					key: 'right'
200				},
201			});
202		}
203
204		$('.nav-une__arrow--prev').click(function() {
205			$('#a-la-une .a-la-une-image .a-la-une-item').trigger('prev');
206		});
207
208		$('.nav-une__arrow--next').click(function() {
209			$('#a-la-une .a-la-une-image .a-la-une-item').trigger('next');
210		});
211
212		//Slider des actualités
213		$('.home-actus ul').carouFredSel({
214			responsive: true,
215			circular: true,
216			direction: "left",
217			items : {
218				visible : 2,
219				minimum : 3,
220				width : "470px",
221				height : "480px"
222			},
223			auto: {
224				play : false,
225				duration: 2000,
226				easing: 'quadratic'
227				},
228			scroll: {
229				items: 1,
230				fx: 'scroll',
231				easing : "quadratic"
232				},
233			prev: {
234			    button: '.home-actus .nav-home--left',
235			    key: 'left'
236			},
237			next: {
238				button: '.home-actus .nav-home--right',
239				key: 'right'
240			},
241		});
242
243		$('.home-actus .nav-home--left').click(function() {
244			$('.home-actus ul li').trigger('prev');
245		});
246
247		$('.home-actus .nav-home--right').click(function() {
248			$('.home-actus ul li').trigger('next');
249		});
250
251		//Slider des évènements
252		
253		$('.home-agenda ul').carouFredSel({
254			responsive: true,
255			circular: true,
256			auto: 10000,
257			direction: "left",
258			items : {
259				visible : 3,
260				minimum : 4,
261				width : "300px",
262				height : "260px"
263			},
264			auto: {
265				duration: 2000,
266				easing: 'quadratic'
267				},
268			scroll: {
269				items: 1,
270				fx: 'scroll',
271				easing : "quadratic"
272				},
273			prev: {
274			    button: '.home-agenda .nav-home--left',
275			    key: 'left'
276			},
277			next: {
278				button: '.home-agenda .nav-home--right',
279				key: 'right'
280			},
281		});
282
283		$('.home-agenda .nav-home--left').click(function() {
284			$('.home-agenda ul li').trigger('prev');
285		});
286
287		$('.home-agenda .nav-home--right').click(function() {
288			$('.home-agenda ul li').trigger('next');
289		});
290	}
291
292	// Responsive Iframe Videos
293
294	$(function() {
295
296	    var $allVideos = $("iframe[src^='//player.vimeo.com'], iframe[src^='//www.youtube.com'], object, embed"),
297	    $fluidEl = $("figure");
298
299		$allVideos.each(function() {
300
301		  $(this)
302		    // jQuery .data does not work on object/embed elements
303		    .attr('data-aspectRatio', this.height / this.width)
304		    .removeAttr('height')
305		    .removeAttr('width');
306
307		});
308	});
309
310	 // Modif html Home
311
312	// Bouton top (haut de page)
313	// ----------------------------------------------------------------
314
315	if($(window).width() > 480){
316		$('.scroll-top').click(function() {
317			$('html,body').animate({scrollTop: 0}, 'slow');
318		});
319
320		$(window).scroll(function(){
321			if($(window).scrollTop()<100){
322				$('.scroll-top').fadeOut();
323			}else{
324				$('.scroll-top').fadeIn();
325			}
326		});
327	}
328
329	// Variable global pour les propositions de publication
330	// ----------------------------------------------------------------
331	if($(window).width() >= 1260)	heightProp = 0;
332	else if($(window).width() >= 940 && $(window).width() < 1260)	heightProp = 0;
333	else if($(window).width() >= 580 && $(window).width() < 940)	heightProp = 0;
334	else if($(window).width() < 580)	heightProp = 414;
335
336
337});
338
339
340

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.