PageSourceSearch

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

js saffre.fr collected 2026-10-02 21:32:17 UTC 8,435 bytes, 303 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 	$('.c-search-form_wrap input').blur(function () {
99 	var value_input = $(this).val();
100 		if(value_input == '' || value_input == $(this).attr("placeholder")){
101 		  $('.recherche-autocompletion form .ui-autocomplete').css('display','none');
102 		} else{
103 			$('.recherche-autocompletion form .ui-autocomplete').css('display','block');
104 		}
105 	});
106
107 	$('.c-search-form_wrap input').on('keyup', function(event) {
108 		var value_input = $(this).val();
109
110 		if(value_input == '' || value_input == $(this).attr("placeholder")){
111 		    $('.c-search-main_container').css('padding-top','15.625vw');
112 		    $('.recherche-autocompletion form .ui-autocomplete').css('display','none');
113 		}
114 	});
115
116 	$('.c-search-main').height(window.innerHeight + 'px');
117    
118    
119    // -------------------------------------------------------------------------
120    // Nom Mairie
121    // -------------------------------------------------------------------------
122    $('.container-header-bottom .nom-mairie h1').html(function(){	
123		var text = $(this).text().trim().split(" ");
124		var last = text.pop();
125		return text.join(" ") + (text.length > 0 ? ' <span class="last">'+last+'</span>' : last);   
126	});
127    
128
129	// -------------------------------------------------------------------------
130	// Modifs site
131	// -------------------------------------------------------------------------
132
133	function eventFire(el, etype){
134		if (el.fireEvent) {
135			el.fireEvent('on' + etype);
136		} else {
137			var evObj = document.createEvent('Events');
138			evObj.initEvent(etype, true, false);
139			el.dispatchEvent(evObj);
140		}
141	}
142
143	if($(window).width() > 960){
144		$( "header .menu__nav__list > li.menu-item-has-children").hover(
145		  function() {
146		    $('header').addClass( "fold" );
147		  }, function() {
148		    $('header').removeClass( "fold" );
149		  }
150		);
151	}else{
152		$('.menu__burger').click(function(){
153			$('header').toggleClass( "fold" );
154		});
155	}
156
157	$( ".accessibility" ).click(function() {
158	  eventFire(document.getElementById('uci_link'), 'click');
159	});
160
161
162	// Filtre de la navigation par profils
163	// ----------------------------------------------------------------
164
165
166	$('#submit-profil').click(function(){
167		if ($("#choix-du-profil").val() != "-1"){
168	    	window.location=document.getElementById("choix-du-profil").value;
169	 	}
170	});
171
172
173
174
175	// -------------------------------------------------------------------------
176
177	// Remontage formulaire
178	// -------------------------------------------------------------------------
179	$(document).ready(function(){
180		var error_form = $('.validation_error');
181		var position_msg ;
182			if(error_form.length > 0){
183				console.log('new-remontage');
184				position_msg = error_form.offset().top - 200;
185				$('html, body').animate({
186	                    scrollTop: position_msg
187	                }, 1000);
188			}
189	})
190
191	// Scripts slider
192	// ----------------------------------------------------------------
193
194	if($('body').hasClass('home')){
195		//Slider a la une
196		function highlight( items ) {
197		    items.addClass("active");
198		}
199		function unhighlight( items ) {
200		    items.removeClass("active");
201		}
202		$('#a-la-une .a-la-une-image').carouFredSel({
203			responsive: true,
204			width: '100%',
205			circular: true,
206			auto: 12000,
207			direction: "left",
208			items : 1,
209			auto: {
210				play : true,
211				duration: 2000,
212				easing: 'quadratic'
213				},
214			scroll: {
215				items: 1,
216				duration : 1500,
217				fx: "scroll",
218				easing : "quadratic",
219				onBefore: function( data ) {
220		          unhighlight( data.items.old );
221		        },
222		        onAfter : function( data ) {
223		          highlight( data.items.visible );
224		        }
225			},
226			 onCreate: function( data ){
227		        highlight( data.items );
228		    },
229			pagination: {
230				container : ".nav-a-la-une",
231			},
232		});
233
234		if ($("#a-la-une-medias").hasClass('a-la-une-video')){
235			$('.nav-une').css('display',"none");
236		}
237	}
238
239	// Responsive Iframe Videos
240
241	$(function() {
242
243	    var $allVideos = $("iframe[src^='//player.vimeo.com'], iframe[src^='//www.youtube.com'], object, embed"),
244	    $fluidEl = $("figure");
245
246		$allVideos.each(function() {
247
248		  $(this)
249		    // jQuery .data does not work on object/embed elements
250		    .attr('data-aspectRatio', this.height / this.width)
251		    .removeAttr('height')
252		    .removeAttr('width');
253
254		});
255	});
256
257	 // Modif html Home
258
259	// Bouton top (haut de page)
260	// ----------------------------------------------------------------
261
262	if($(window).width() > 480){
263		$('.scroll-top').click(function() {
264			$('html,body').animate({scrollTop: 0}, 'slow');
265		});
266
267		$(window).scroll(function(){
268			if($(window).scrollTop()<100){
269				$('.scroll-top').fadeOut();
270			}else{
271				$('.scroll-top').fadeIn();
272			}
273		});
274	}
275
276	// Variable global pour les propositions de publication
277	// ----------------------------------------------------------------
278	if($(window).width() >= 1260)	heightProp = 0;
279	else if($(window).width() >= 940 && $(window).width() < 1260)	heightProp = 0;
280	else if($(window).width() >= 580 && $(window).width() < 940)	heightProp = 0;
281	else if($(window).width() < 580)	heightProp = 414;
282    
283    
284    // ----------------------------------------------------------------
285    // SCRIPT ACCESSIBILITE
286    // ----------------------------------------------------------------  
287    $('#accessi-sitemap, #accessi-form input, #accessi-form button, #accessi-content').focus(function() {
288        $('#accessibilite').css({height : 'auto', padding : '10px'})
289    })
290
291
292    $('#accessi-sitemap, #accessi-form input, #accessi-form button, #accessi-content').focusout(function() {
293        $('#accessibilite').css({height : '0', padding : '0'})
294    }) 
295
296    $('#accessi-content').click(function(e) {
297        $("#breadcrumbs").focus(); 
298        $('html,body').animate({scrollTop: $('#breadcrumbs').offset().top - 100},'slow');
299    });
300});
301
302
303

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.