PageSourceSearch

https://www.lesbrulais.fr/wp-content/themes/les-brulais/js/scripts.js

js lesbrulais.fr collected 2026-10-02 21:21:57 UTC 8,776 bytes, 347 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
125	$(window).scroll(function (event) {
126		if($(window).width() > 940){
127		    var y = $(this).scrollTop();
128		    if (y >= 80){
129		    	$('body').addClass('sticky');
130		    }else{
131		    	$('body').removeClass('sticky');
132		    }
133		}
134	})
135
136	function eventFire(el, etype){
137		if (el.fireEvent) {
138			el.fireEvent('on' + etype);
139		} else {
140			var evObj = document.createEvent('Events');
141			evObj.initEvent(etype, true, false);
142			el.dispatchEvent(evObj);
143		}
144	}
145	$( ".toggle-access" ).click(function() {
146	  eventFire(document.getElementById('uci_link'), 'click');
147	});
148
149
150
151	// -------------------------------------------------------------------------
152
153	// Remontage formulaire
154	// -------------------------------------------------------------------------
155
156	$(document).ready(function(){
157		var error_form = $('.validation_error');
158		var position_msg ;
159			if(error_form.length > 0){
160				console.log('new-remontage');
161				position_msg = error_form.offset().top - 200;
162				$('html, body').animate({
163	                    scrollTop: position_msg
164	                }, 1000);
165			}
166	})
167
168	// Scripts slider
169	// ----------------------------------------------------------------
170
171	if($('body').hasClass('home')){
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 : 1,
179			auto: {
180				play : true,
181				duration: 2000,
182				easing: 'quadratic'
183				},
184			scroll: {
185				items: 1,
186				pauseOnHover: true,
187				fx: 'scroll',
188				easing : "quadratic"
189				},
190			pagination: {
191				container : ".nav-a-la-une",
192			},
193		});
194
195		if ($("#a-la-une-medias").hasClass('a-la-une-video')){
196			$('.nav-une').css('display',"none");
197		}
198
199		$('.news-diapo').carouFredSel({
200			responsive: true,
201			width: '100%',
202			circular: true,
203			auto: 8000,
204			direction: "left",
205			items : 1,
206			auto: {
207				play : true,
208				duration: 2000,
209				easing: 'quadratic'
210				},
211			scroll: {
212				items: 1,
213				pauseOnHover: true,
214				fx: 'scroll',
215				easing : "quadratic"
216				},
217			pagination: {
218				container : ".nav-news",
219			},
220		});
221
222		$('.events-diapo').carouFredSel({
223			responsive: true,
224			circular: true,
225			auto: false,
226			direction: "left",
227			items : {
228				visible : 2,
229				minimum : 3,
230				width : "270px",
231				height : "420px"
232			},
233			scroll: {
234				items: 1,
235				fx: 'scroll',
236				easing : "quadratic"
237				},
238			prev: {
239			    button: '.agenda-prev',
240			    key: 'left'
241			},
242			next: {
243				button: '.agenda-next',
244				key: 'right'
245			},
246		});
247
248		$('.agenda-prev').click(function() {
249			$('.events-diapo .event-wrapper').trigger('prev');
250		});
251
252		$('.agenda-next').click(function() {
253			$('.events-diapo .event-wrapper').trigger('next');
254		});
255
256	}
257
258	if($(window).width() < 1260){
259		$(document).scroll(function() {
260		var x = $(this).scrollTop();
261		$('.a-la-une-pic').css('background-position','0% '+parseInt(x/4)+'px');
262		});
263	}
264
265	$( document ).ready(function() {
266	    adaptColor('.bgColor');
267	});
268
269	function adaptColor(selector) {
270	  var rgb = $(selector).css("background-color");
271
272	  if (rgb.match(/^rgb/)) {
273	    var a = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/),
274	      r = a[1],
275	      g = a[2],
276	      b = a[3];
277	  }
278	  var hsp = Math.sqrt(
279	    0.299 * (r * r) +
280	    0.587 * (g * g) +
281	    0.114 * (b * b)
282	  );
283	  if (hsp > 200) {
284	    $('.news-events').addClass('dark-color');
285	    $('.header-page').addClass('dark-color');
286	    $('#a-la-une .a-la-une-media .a-la-une-item .diapo-info .titre').addClass('dark-color');
287	    $('header .sub-menu ul > li > a').addClass('dark-color');
288	    $('header .sub-menu ul > li > span').addClass('dark-color');
289	  } else {
290	    $('.title-part').addClass('light-color');
291	    $('.news-events').addClass('light-color');
292	    $('#a-la-une .a-la-une-media .a-la-une-item .diapo-info .titre').addClass('light-color');
293	    $('header .sub-menu ul > li > a').addClass('light-color');
294	    $('header .sub-menu ul > li > span').addClass('light-color');
295	  }
296	};
297
298
299	// Responsive Iframe Videos
300
301	$(function() {
302
303	    var $allVideos = $("iframe[src^='//player.vimeo.com'], iframe[src^='//www.youtube.com'], object, embed"),
304	    $fluidEl = $("figure");
305
306		$allVideos.each(function() {
307
308		  $(this)
309		    // jQuery .data does not work on object/embed elements
310		    .attr('data-aspectRatio', this.height / this.width)
311		    .removeAttr('height')
312		    .removeAttr('width');
313
314		});
315	});
316
317	 // Modif html Home
318
319	// Bouton top (haut de page)
320	// ----------------------------------------------------------------
321
322	if($(window).width() > 480){
323		$('.scroll-top').click(function() {
324			$('html,body').animate({scrollTop: 0}, 'slow');
325		});
326
327		$(window).scroll(function(){
328			if($(window).scrollTop()<100){
329				$('.scroll-top').fadeOut();
330			}else{
331				$('.scroll-top').fadeIn();
332			}
333		});
334	}
335
336	// Variable global pour les propositions de publication
337	// ----------------------------------------------------------------
338	if($(window).width() >= 1260)	heightProp = 0;
339	else if($(window).width() >= 940 && $(window).width() < 1260)	heightProp = 0;
340	else if($(window).width() >= 580 && $(window).width() < 940)	heightProp = 0;
341	else if($(window).width() < 580)	heightProp = 414;
342
343
344});
345
346
347

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.