PageSourceSearch

https://www.urbanisme.fr/wp-content/themes/bold-news/framework/js/misc.js?ver=6.9.9

js urbanisme.fr collected 2026-09-24 21:26:20 UTC 20,519 bytes, 578 lines download raw bytes

1'use strict';
2
3window.addEventListener("pageshow", function(evt){
4        if(evt.persisted){
5        setTimeout(function(){
6            window.location.reload();
7        },10);
8    }
9}, false);
10
11window.boldthemes_loaded = false;
12
13(function( $ ) {
14	
15	function initRefreshCart() {
16		$( '.cart-contents' ).each(function() {
17			bt_refresh_cart();
18		});
19		var cart_node = jQuery( '.widget_shopping_cart' )[0];
20		if ( cart_node !== undefined ) {
21			var config = { attributes: true, childList: true, subtree: true };
22			var callback = function( mutationsList, observer ) {
23				// for ( var mutation of mutationsList ) {
24				for (var index = 0; index < mutationsList.length; index) {
25					var mutation = mutationsList[index];
26					if ( mutation.type == 'childList' ) {
27						jQuery( '.btCartWidgetIcon' ).off( 'click' ).on( 'click', function ( e ) { jQuery( this ).parent().parent().toggleClass( 'on' ); jQuery('body').toggleClass( 'btCartDropdownOn' ); });
28						jQuery( '.verticalMenuCartToggler' ).off( 'click' ).on( 'click', function ( e ) { jQuery( this ).closest( '.widget_shopping_cart_content' ).removeClass( 'on' ); jQuery('body').removeClass('.btCartDropdownOn'); });
29					}
30					index++;
31				}
32			};
33			var observer = new MutationObserver( callback );
34			observer.observe( cart_node, config );
35		}
36	}
37
38	function boldthemes_video_resize() {
39		$( 'iframe' ).not( '.twitter-tweet' ).not( "[title*='recaptcha']" ).not( ".bt_banner iframe" ).not( ".bt_skip_resize" ).not( ".rs-skin-widget-frame" ).not( ".sb-widget-iframe" ).each(function() {
40			if ( ! $( this ).parent().hasClass( 'boldPhotoBox' ) && ! ($( this ).parents('.adsbygoogle').length > 0)) {
41				$( this ).css( 'width', '100%' );
42				$( this ).css( 'height', $( this ).width() * 9 / 16 );
43			}
44		});
45		
46		$( 'embed' ).each(function() {
47			if ( ! $( this ).parent().hasClass( 'boldPhotoBox' ) ) {
48				$( this ).css( 'width', '100%' );
49				$( this ).css( 'height', $( this ).width() * 9 / 16 );
50			}
51		});	
52	}
53	
54	jQuery.fn.isOnScreen = function( delta ) {
55		var element = this.get( 0 );
56		if ( element == undefined ) return false;
57		if( delta == undefined ) delta = 50;
58		var bounds = element.getBoundingClientRect();
59		return bounds.top + delta < window.innerHeight && bounds.bottom > 0;
60	}
61
62	
63	// lazy image load
64	window.bt_bb_lazy_load_images = function() {
65		var $elems = $( 'img.btLazyLoadImage:not(.btLazyLoaded)' );
66		//console.log($elems);
67		$elems.each(function() {
68			var $elm = $(this);
69			//console.log($elm);
70			if ( $elm.isOnScreen( -200 ) ) {
71				$elm.addClass( 'btLazyLoaded' );
72				//console.log($elm.data( 'image_src' ));
73				$elm.attr( 'src', $elm.data( 'image_src' ));
74			}
75		});
76		var $elems = $( '.btLazyLoadBackground:not(.btLazyLoaded)' );
77		$elems.each(function() {
78			var $elm = $(this);
79			if ( $elm.isOnScreen( -200 ) ) {
80				$elm.addClass( 'btLazyLoaded' );
81				$elm.css( 'background-image', 'url(' + $elm.data( 'background_image_src' ) + ')' );
82			}
83		});
84	}
85	
86	$( document ).ready(function() {
87		
88		initRefreshCart();
89			
90		boldthemes_video_resize();
91		
92		$( '.widget_archive select option' ).each(function() {
93			$( this ).html( $( this ).html().replace( /([\d]+)$/, '($1)' ) );
94			$( this ).html( $( this ).html().replace( /^\s/, '' ) );
95		});
96		
97		$( '.widget_categories select option' ).each(function() {
98			$( this ).html( $( this ).html().replace( /\&nbsp;\&nbsp;(\()/, ' $1' ) );
99		});		
100		
101		/* position on screen */
102
103		$( '.no-touch .btSidebar select, .no-touch select.orderby, .no-touch #btSettingsPanelContent select, .no-touch .wpcf7-form select:not([multiple])' ).fancySelect().on( 'change.fs', function() {
104			$( this ).trigger( 'change.$' );
105		});
106		
107		if ( $( '.btGhost' ).length > 0 ) {
108			$( 'body' ).append( $( '.btGhost' ) );
109			$( 'body' ).addClass( 'btHasGhost' );
110		}
111		
112		$( '.btQuoteSlider' ).wrap( '<div class="btQuoteWrapper"></div>' );
113
114		$( '.btHasGhost .btMediaBox .btGhostSliderThumb a' ).on( 'click', function( e ) {
115			e.preventDefault();
116			$( '.single-portfolio .btGhost' ).removeClass( 'btRemoveGhost' );
117			$( '.btHasGhost .btGhostSliderThumb' ).removeClass( 'btMarkedImage' );
118			boldthemes_disable_scroll();
119			$( '.btGhost .slick-slider' ).slick( 'slickGoTo', $( this ).closest( '.btGhostSliderThumb' ).data( 'order-num' ) );
120		});
121		
122		if ( $( window ).scrollTop() > 0 || $( 'html' ).hasClass( 'no-csstransforms3d' ) ) {
123			$( '.btGhost' ).addClass( 'btRemoveGhost' );
124		}
125		
126		window.boldthemes_theme_loaded = false;
127		
128		window.boldthemes_disable_scroll = function() {
129			window.onmousewheel = document.onmousewheel = function() {
130				if ( window.boldthemes_theme_loaded ) {
131					$( '.btCloseGhost' ).trigger('click');
132				}
133				if ( ! window.boldthemes_theme_loaded || ! window.boldthemes_theme_allow_scroll ) {
134					return false;
135				}
136			};
137			$( window ).on( 'DOMMouseScroll', function( e ) {
138				if ( window.boldthemes_theme_loaded ) {
139					$( '.btCloseGhost' ).trigger('click');
140				}			
141				if ( ! window.boldthemes_theme_loaded || ! window.boldthemes_theme_allow_scroll ) {
142					e.preventDefault();
143				}
144			});		
145		}
146		
147		window.boldthemes_enable_scroll = function() {
148			window.onmousewheel = document.onmousewheel = null;
149		}
150		
151		var articleWithGhost = $( '.btPostOverlay' ).length > 0;
152		
153		if ( $( '.btRemoveGhost' ).length == 0 && $( '.btGhost' ).length > 0  ) {
154			window.boldthemes_theme_allow_scroll = false;
155			boldthemes_disable_scroll();
156		}
157
158		$('.btPriceTable').each(function(){
159			$(this).closest('.rowItem').addClass('rowItemPriceTable');
160		});
161		
162		$('.btIconHexagonShape .btIcoHolder').append('<svg viewBox="0 0 110 125" preserveAspectRatio="xMaxYMax meet"><polygon class="hex" points="55,5 105,30 105,95 55,120 5,95 5,30"></polygon></svg>');
163		
164    	if(/MSIE \d|Trident.*rv:/.test(navigator.userAgent)) {
165    		$('body').addClass('ieEleven');	
166    		$('.fixedSliderHeight .slick-track').each(function(){
167    			var goalHeight = $(this).height();
168    			$(this).find('.btSliderCell').css('height',goalHeight);
169    		});
170    	}
171
172		$( '.wpcf7-date' ).on( 'change', function() {
173			$( this ).addClass( 'placeholderclass' );
174		});
175        
176	});
177
178	$( window ).on('load', function() {
179		window.boldthemes_theme_loaded = true;
180		
181		// remove preloader
182		$( 'body' ).addClass( 'btRemovePreloader' );
183		
184		// trigger custom load event
185		setTimeout( function() { $( window ).trigger( 'btload' ); window.boldthemes_loaded = true; }, 1000 );
186		
187		// gmaps with img overlay
188		$( window ).trigger( 'resize' );
189		
190	});
191
192	$( window ).resize(function() {
193		boldthemes_video_resize();
194	});
195
196	/* Animate classic elements */
197
198	function btAnimateRows() {
199		var $elems = $( 'body:not(.btPageTransitions) .rowItem.animate:not(.animated), .headline .animate, article.animate' ).not( '.slided .animate' );
200		$elems.each(function() {
201			var $elm = $( this );
202			if ( 
203			( $elm.isOnScreen() && ! $( 'body' ).hasClass( 'impress-enabled' ) ) ||
204			( $elm.isOnScreen() && $( 'body' ).hasClass( 'impress-enabled' ) && $elm.closest( '.boldSection' ).hasClass( 'active' ) )
205			) {
206				$elm.addClass( 'animated' );
207			}
208		});
209		bt_bb_lazy_load_images();
210	}
211
212	if ( ! $( 'body' ).hasClass( 'impress-enabled' ) ) {
213		$( window ).scroll(function() {
214			btAnimateRows();
215		});
216	}	
217
218	$( window ).on( 'load', function() {
219		btAnimateRows();
220		
221		// autoplay
222		if ( $( 'li.btAnimNavNext' ).length && $( 'body' ).data( 'autoplay' ) > 0 ) {
223			window.boldthemes_autoplay_interval = setInterval( function(){ $( 'li.btAnimNavNext' ).trigger( 'click' ); }, $( 'body' ).data( 'autoplay' ) );
224		}		
225	});
226	
227	$( window ).on( 'boldthemes_section_animation_out', function( e, el ) {
228		$( el ).find( '.rowItem.animated' ).removeClass( 'animated' );
229	});
230	
231	$( window ).on( 'boldthemes_section_animation_end', function( e, el ) {
232		$( el ).find( '.rowItem.animate' ).addClass( 'animated' );
233	});		
234
235	$( document ).ready(function() {
236
237		var doc = document.documentElement;
238		doc.setAttribute('data-useragent', navigator.userAgent);
239
240		// basic functions
241
242		if ( ! String.prototype.startsWith ) {
243			String.prototype.startsWith = function(searchString, position) {
244				position = position || 0;
245				return this.lastIndexOf(searchString, position) === position;
246			};
247		}
248
249		if ( ! String.prototype.endsWith ) {
250			String.prototype.endsWith = function(searchString, position) {
251				var subjectString = this.toString();
252				if (position === undefined || position > subjectString.length) {
253					position = subjectString.length;
254				}
255				position -= searchString.length;
256				var lastIndex = subjectString.indexOf(searchString, position);
257				return lastIndex !== -1 && lastIndex === position;
258			};
259		}
260
261		/* scroll handlers */
262
263		function scrollPage() {
264			var fromTop = $( this ).scrollTop();
265			$( '.btCloseGhost' ).trigger('click');
266		}
267
268		function scrollPageTo( val ) {
269			val = parseInt( val );
270			$( 'body, html' ).animate({ scrollTop: val + 'px' }, 500 );
271		}
272
273		function scrollPageToId(id) {
274			if ( $( id ).length == 0 ) return false;
275			var topOffset = $( id ).offset().top;
276			if ( window.btStickyEnabled && topOffset > window.btStickyOffset ) {
277				topOffset -= $( '.mainHeader' ).height();
278				
279			}
280			$( 'html, body' ).animate({ scrollTop: topOffset }, 500);
281		}
282
283		/* init scroll listener */
284
285		window.addEventListener( 'scroll', scrollPage );
286	 	
287		// delay click to allow on page leave screen
288		$( 'body.bodyPreloader .mainHeader .menu' ).off('click').on( 'click', 'a', function() {
289			if ( ! $( this ).hasClass( 'lightbox' ) && ! $( this ).hasClass( 'add_to_cart_button' ) ) {
290				var href = $( this ).attr( 'href' );
291				if ( href !== undefined ) {
292					if ( location.href == href || ( location.href.split( '#' )[0] != href.split( '#' )[0] && ! href.startsWith( '#' ) && ! href.startsWith( 'mailto' ) 
293						&& ! href.startsWith( 'callto' ) && ! $( this ).hasClass( 'lightbox' ) && ! $( this ).hasClass( 'add_to_cart_button' ) ) ) {
294						if ( $( this ).attr( 'target' ) != '_blank' && ! href.endsWith( '#respond' ) ) {
295							if ( $( '#btPreloader' ).length ) {
296								$( 'body' ).removeClass( 'btRemovePreloader' );
297								setTimeout( function() { window.location = href }, 1500 );
298								return false;
299							}
300						}
301					} else if ( href != "#" && ! href.startsWith( 'mailto' ) ) {
302						if ( $( this ).parent().parent().attr('class') != 'tabsHeader' ) scrollPageToId( href );
303						return false;
304					}
305				}
306			}
307		});
308
309		// Vertical alignment fix
310
311		$( '.rowItem.btMiddleVertical, .rowItem.btBottomVertical, .rowItem.btTopVertical' ).parent().parent().addClass( 'btTableRow' );
312
313		/* Footer widgets count and column set */
314
315		$( '#boldSiteFooterWidgetsRow' ).children().addClass( 'rowItem col-md-' + 12 / $( '#boldSiteFooterWidgetsRow' ).children().length + ' col-sm-12' );
316
317		// Gallery slider info bar toggler
318
319		$( '.btGetInfo' ).on( 'click', function () {
320			$(this).toggleClass( 'on' ).next().toggleClass( 'open' );
321			return false;
322		});	
323
324		// Close gallery slider
325
326		$( '.btCloseGhost' ).on( 'click', function () {
327			if ( ! $( '.btGhost' ).hasClass( 'btRemoveGhost' ) ) {
328				$( '.btGhost' ).addClass( 'btRemoveGhost' );
329				$( window ).trigger( 'resize' );
330				var pos = $( this ).parent().find( '.slick-slider' ).first().slick( 'slickCurrentSlide' );
331				var num_slides = $( this ).parent().find( '.slick-slider' ).find( '.slick-slide' ).length;
332				var thumbs = $( '.btGridGallery' ).first().find( '.btGhostSliderThumb' );
333				if ( thumbs.length > 0 ) {
334					var num_thumbs = thumbs.length;
335					if ( num_slides > num_thumbs && pos > 0 ) {
336						$( thumbs[ pos - 1 ] ).addClass( 'btMarkedImage' );
337						$( 'html, body' ).animate({
338							scrollTop: $( thumbs[ pos - 1 ] ).offset().top + $( thumbs[ pos - 1 ] ).height() * .5 - window.innerHeight * 0.5
339						}, 0 );
340					} else if ( num_slides == num_thumbs ) {
341						$( thumbs[ pos ] ).addClass( 'btMarkedImage' );
342						$( 'html, body' ).animate({
343							scrollTop: $( thumbs[ pos ] ).offset().top + $( thumbs[ pos ] ).height() * .5 - window.innerHeight * 0.5
344						}, 0 );
345					}
346				}
347				setTimeout( function() { window.boldthemes_theme_allow_scroll = true; $( '.btMarkedImage' ).removeClass( 'btMarkedImage' ) }, 800 );
348				return false;
349			}
350		});
351		
352		// magnific-popup grid gallery
353		
354		$( '.tilesWall.lightbox' ).each(function() {
355			$( this ).find( 'a' ).magnificPopup({
356				type: 'image',
357				// other options
358				gallery:{
359					enabled:true
360				},
361				closeMarkup:'<button class="mfp-close" type="button"><i class="mfp-close-icn">&times;</i></button>',
362				image: {
363					titleSrc: 'data-title'
364				},
365				closeBtnInside:false		
366			});
367		});
368		
369		// magnific-popup product gallery
370		$( 'body.single-product .product .images' ).each(function() {
371			$( this ).find( 'a' ).magnificPopup({
372				type: 'image',
373				// other options
374				callbacks: {
375					beforeClose: function() {
376						var photo = $( this.st.el ).closest( '.bpgPhoto' );
377						photo.removeClass( 'out-top' );
378						photo.removeClass( 'out-right' );
379						photo.removeClass( 'out-bottom' );
380						photo.removeClass( 'out-left' );						
381					}
382				},
383				gallery:{
384					enabled:true
385				},
386				closeMarkup:'<button class="mfp-close" type="button"><i class="mfp-close-icn">&times;</i></button>',
387				image: {
388					titleSrc: 'data-title'
389				},
390				closeBtnInside:false		
391			});
392		});
393		
394		if ( window.boldthemes_anim_selector ) {
395		
396			$( window ).on( 'btload', function() {
397				$( '.btPageWrap' ).append( '<div id="btAnimSelector" class="btDarkSkin"><select id="btFwdAnim"></select><select id="btBckAnim"></select></div>' );
398				
399				var anim = [];
400				
401				anim[1] = 'Move to left | from right';
402				anim[2] = 'Move to right | from left';
403				anim[3] = 'Move to top | from bottom';
404				anim[4] = 'Move to bottom | from top';
405				anim[5] = 'Fade | from right';
406				anim[6] = 'Fade | from left';
407				anim[7] = 'Fade | from bottom';
408				anim[8] = 'Fade | from top';
409				anim[9] = 'Fade left | Fade right';
410				anim[10] = 'Fade right | Fade left';
411				anim[11] = 'Fade top | Fade bottom';
412				anim[12] = 'Fade bottom | Fade top';
413				anim[13] = 'Different easing | from right';
414				anim[14] = 'Different easing | from left';
415				anim[15] = 'Different easing | from bottom';
416				anim[16] = 'Different easing | from top';
417				anim[17] = 'Scale down | from right';
418				anim[18] = 'Scale down | from left';
419				anim[19] = 'Scale down | from bottom';
420				anim[20] = 'Scale down | from top';
421				anim[21] = 'Scale down | scale down';
422				anim[22] = 'Scale up | scale up';
423				anim[23] = 'Move to left | scale up';
424				anim[24] = 'Move to right | scale up';
425				anim[25] = 'Move to top | scale up';
426				anim[26] = 'Move to bottom | scale up';
427				anim[27] = 'Scale down | scale up';
428				anim[28] = 'Glue left | from right';
429				anim[29] = 'Glue right | from left';
430				anim[30] = 'Glue bottom | from top';
431				anim[31] = 'Glue top | from bottom';
432				anim[32] = 'Flip right';
433				anim[33] = 'Flip left';
434				anim[34] = 'Flip top';
435				anim[35] = 'Flip bottom';
436				anim[36] = 'Rotate fall';
437				anim[37] = 'Rotate newspaper';
438				anim[38] = 'Push left | from right';
439				anim[39] = 'Push right | from left';
440				anim[40] = 'Push top | from bottom';
441				anim[41] = 'Push bottom | from top';
442				anim[42] = 'Push left | pull right';
443				anim[43] = 'Push right | pull left';
444				anim[44] = 'Push top | pull bottom';
445				anim[45] = 'Push bottom | pull top';
446				anim[46] = 'Fold left | from right';
447				anim[47] = 'Fold right | from left';
448				anim[48] = 'Fold top | from bottom';
449				anim[49] = 'Fold bottom | from top';
450				anim[50] = 'Move to right | unfold left';
451				anim[51] = 'Move to left | unfold right';
452				anim[52] = 'Move to bottom | unfold top';
453				anim[53] = 'Move to top | unfold bottom';
454				anim[54] = 'Room to left';
455				anim[55] = 'Room to right';
456				anim[56] = 'Room to top';
457				anim[57] = 'Room to bottom';
458				anim[58] = 'Cube to left';
459				anim[59] = 'Cube to right';
460				anim[60] = 'Cube to top';
461				anim[61] = 'Cube to bottom';
462				anim[62] = 'Carousel to left';
463				anim[63] = 'Carousel to right';
464				anim[64] = 'Carousel to top';
465				anim[65] = 'Carousel to bottom';
466				anim[66] = 'Sides';
467				
468				if ( $('body.btHalfPage').length ) {
469					var titleLeft = 'Select left animation';
470					var titleRight = 'Select right animation';
471				} else {
472					var titleLeft = 'Select forward animation';
473					var titleRight = 'Select backward animation';				
474				}
475				
476				$( '#btAnimSelector #btFwdAnim' ).append( '<option value="">' + titleLeft + '</option>' );
477				$( '#btAnimSelector #btBckAnim' ).append( '<option value="">' + titleRight + '</option>' );
478				
479				for ( var i = 1; i < anim.length; i++ ) {
480					$( '#btAnimSelector #btFwdAnim' ).append( '<option value="' + i + '">' + anim[ i ] + '</option>' );
481					$( '#btAnimSelector #btBckAnim' ).append( '<option value="' + i + '">' + anim[ i ] + '</option>' );
482				}
483				
484				$( '#btAnimSelector #btFwdAnim' ).on( 'change', function( e ) {
485					var val = $( this ).val();
486					var $pages = $( 'section.btSectionTransitions' );
487					$pages.each( function() {
488						$( this ).data( 'animation', val );
489					});
490					$( '.btAnimNavNext' ).trigger( 'click' );
491				});
492				
493				$( '#btAnimSelector #btBckAnim' ).on( 'change', function( e ) {
494					var val = $( this ).val();
495					var $pages = $( 'section.btSectionTransitions' );
496					$pages.each( function() {
497						$( this ).data( 'animation-back', val );
498					});
499					$( '.btAnimNavPrev' ).trigger( 'click' );
500				});
501
502				$( '.no-touch #btAnimSelector select' ).fancySelect().on('change.fs', function() {
503					$(this).trigger('change.$');
504				});
505
506				setTimeout( function() { $( 'body' ).addClass( 'btShowAnimSelector' ); }, 10 );
507			});
508		
509		}
510
511	});
512	
513	
514	
515})( jQuery );
516
517function boldthemes_swipedetect( el, callback ) {
518
519	var touchsurface = el,
520	swipedir,
521	startX,
522	startY,
523	distX,
524	distY,
525	threshold = 150, //required min distance traveled to be considered swipe
526	restraint = 100, // maximum distance allowed at the same time in perpendicular direction
527	allowedTime = 300, // maximum time allowed to travel that distance
528	elapsedTime,
529	startTime,
530	handleswipe = callback || function( swipedir ) {}
531
532	touchsurface.addEventListener( 'touchstart', function( e ) {
533		var touchobj = e.changedTouches[0];
534		swipedir = 'none';
535		startX = touchobj.pageX;
536		startY = touchobj.pageY;
537		startTime = new Date().getTime(); // record time when finger first makes contact with surface
538	}, false );
539
540	touchsurface.addEventListener( 'touchmove', function( e ) {
541
542	}, false );
543
544	touchsurface.addEventListener( 'touchend', function( e ) {
545		var touchobj = e.changedTouches[0];
546		distX = touchobj.pageX - startX;// get horizontal dist traveled by finger while in contact with surface
547		distY = touchobj.pageY - startY; // get vertical dist traveled by finger while in contact with surface
548
549		elapsedTime = new Date().getTime() - startTime; // get time elapsed
550		if ( elapsedTime <= allowedTime ) { // first condition for awipe met
551			if ( Math.abs( distX ) >= threshold && Math.abs( distY ) <= restraint ) { // 2nd condition for horizontal swipe met
552				swipedir = ( distX < 0 ) ? 'left' : 'right'; // if dist traveled is negative, it indicates left swipe
553			} else if ( Math.abs( distY ) >= threshold && Math.abs( distX ) <= restraint ) { // 2nd condition for vertical swipe met
554				swipedir = ( distY < 0 ) ? 'up' : 'down'; // if dist traveled is negative, it indicates up swipe
555			}
556		}
557
558		handleswipe( swipedir );
559
560	}, false );
561}
562
563function bt_refresh_cart() {
564	jQuery( '.btCartWidgetIcon' ).off('click').on( 'click', function ( e ) { 
565		jQuery(this).parent().parent().toggleClass( 'on' ); 
566		jQuery('body').toggleClass( 'btCartDropdownOn' ); 
567	});
568	jQuery('.verticalMenuCartToggler').off('click').on( 'click', function(){
569		jQuery(this).closest('.widget_shopping_cart_content').removeClass('on');
570		jQuery('body').removeClass('.btCartDropdownOn');
571	});
572}
573
574jQuery( document ).ready(function() {
575	jQuery( '.cart-contents' ).each(function() {
576		bt_refresh_cart();
577	});
578});

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.