PageSourceSearch

https://www.guidedumaroc.fr/wp-content/themes/saxon/js/template.js?ver=1.3

js guidedumaroc.fr collected 2026-10-03 02:47:03 UTC 13,091 bytes, 447 lines download raw bytes

1/**
2*	Theme main theme Frontend JavaScript file
3*/
4(function($){
5$(document).ready(function() {
6
7	'use strict';
8
9	// iOS buttons style fix
10	var platform = navigator.platform;
11
12    if (platform === 'iPad' || platform === 'iPhone' || platform === 'iPod') {
13        $('input.button, input[type="text"], input[type="button"], input[type="password"], textarea, input.input-text').css('-webkit-appearance', 'none');
14    }
15
16	// Disable animations for touch devices
17	if(isTouchDevice()===true) {
18	    $("#animations-css").remove();
19	}
20
21	// Select restyling
22	$("select").select2({
23		allowClear: true,
24		minimumResultsForSearch: 10
25	});
26
27	// Init elements appear animations
28	AOS.init({
29		once: true
30	});
31
32	// Add body class for title header with background
33	if($("body.single-post .container-page-item-title.with-bg, body.page .container-page-item-title.with-bg").length > 0) {
34		$("body").addClass('blog-post-header-with-bg');
35	}
36
37	// Remove embed responsive container from Gutenberg elements, except Video
38	$('.wp-block-embed:not(.is-type-video) .embed-container').removeClass('embed-container');
39
40	// Add images backgrounds
41	$('.saxon-post-image').each(function( index ) {
42		$(this).attr('style', ($(this).attr('data-style')));
43	});
44	$('.saxon-next-post').each(function( index ) {
45		$(this).attr('style', ($(this).attr('data-style')));
46	});
47	$('.sidebar .widget.widget_saxon_text .saxon-textwidget').each(function( index ) {
48		$(this).attr('style', ($(this).attr('data-style')));
49	});
50	$('.container-page-item-title').each(function( index ) {
51		$(this).attr('style', ($(this).attr('data-style')));
52	});
53	$('.saxon-featured-categories-wrapper .saxon-featured-category').each(function( index ) {
54		$(this).attr('style', ($(this).attr('data-style')));
55	});
56	$('.saxon-featured-categories-wrapper .saxon-featured-category a').each(function( index ) {
57		$(this).attr('style', ($(this).attr('data-style')));
58	});
59	$('.sidebar .widget .post-categories a').each(function( index ) {
60		$(this).attr('style', ($(this).attr('data-style')));
61	});
62	$('.saxon-post .post-categories a').each(function( index ) {
63		$(this).attr('style', ($(this).attr('data-style')));
64	});
65	$('.footer-html-block').each(function( index ) {
66		$(this).attr('style', ($(this).attr('data-style')));
67	});
68	$('.post-review-block .post-review-criteria-value').each(function( index ) {
69		$(this).attr('style', ($(this).attr('data-style')));
70	});
71	$('.post-review-block .post-review-rating-total').each(function( index ) {
72		$(this).attr('style', ($(this).attr('data-style')));
73	});
74	$('.post-review-block .post-review-button-icon').each(function( index ) {
75		$(this).attr('style', ($(this).attr('data-style')));
76	});
77	$('.post-review-rating-badge').each(function( index ) {
78		$(this).attr('style', ($(this).attr('data-style')));
79	});
80	$('.post-review-criteria-rating').each(function( index ) {
81		$(this).attr('style', ($(this).attr('data-style')));
82	});
83
84	// Move WooCommerce sale badge
85	$('.woocommerce.single span.onsale').prependTo($('.woocommerce div.product div.images.woocommerce-product-gallery'));
86
87	// Mini search form behaviour
88	$('.search-toggle-wrapper.search-header .search-toggle-btn').on('click', function(e){
89
90		if($('.search-toggle-wrapper .searchform input[type="search"]').val() !== '') {
91			$('.search-toggle-wrapper .searchform .submit').click();
92		}
93	});
94
95	// Fullscreen search form behaviour
96	$('body').on('click', '.search-toggle-wrapper.search-fullscreen .search-toggle-btn', function(e){
97
98		$(document).keyup(function(e){
99		    if(e.keyCode === 27)
100		        $('.search-fullscreen-wrapper').fadeOut();
101		});
102
103		$('.search-fullscreen-wrapper').fadeIn();
104		$('.search-fullscreen-wrapper .search-fullscreen-form input[type="search"]').focus();
105		$('.search-fullscreen-wrapper .search-fullscreen-form input[type="search"]').val('');
106	});
107
108	$('.search-close-btn').on('click', function(e){
109		$('.search-fullscreen-wrapper').fadeOut();
110	});
111
112	// Main menu toggle button
113	$('header .mainmenu-mobile-toggle').on('click', function(e){
114		$('header .navbar-toggle').click();
115	});
116
117	// Top mobile menu
118	var topmenuopened = 0;
119	$( document ).on( "click", ".menu-top-menu-container-toggle", function(e) {
120		if(topmenuopened == 0) {
121			$(this).next().slideDown();
122			topmenuopened = 1;
123		} else {
124			topmenuopened = 0;
125			$(this).next().slideUp();
126		}
127	});
128
129	// Mobile menu clicks for top and main menus
130	$('.nav li > a, .header-menu li > a').on('click', function(e){
131
132		if($(window).width() < 991) {
133
134			// Open dropdown on click
135			if ( $(this).next(".sub-menu").length > 0 ) {
136				var sm = $(this).next(".sub-menu");
137
138				if(sm.data('open') !== 1) {
139					e.preventDefault();
140					e.stopPropagation();
141
142					sm.slideDown();
143
144					sm.data('open', 1);
145
146					$(this).parent().addClass('mobile-submenu-opened');
147
148				} else {
149					// Close dropdown if no href in link
150					if($(this).attr('href') == '#') {
151						e.preventDefault();
152						e.stopPropagation();
153
154						sm.slideUp();
155
156						sm.data('open', 0);
157
158						$(this).parent().removeClass('mobile-submenu-opened');
159					}
160				}
161
162			}
163		} else {
164			// Mobile menu clicks for touch devices
165			if(isTouchDevice()===true) {
166
167				if ( $(this).next(".sub-menu").length > 0 ) {
168					var sm = $(this).next(".sub-menu");
169
170					if(sm.data('open') !== 1) {
171						e.preventDefault();
172						e.stopPropagation();
173
174						sm.slideDown();
175
176						sm.data('open', 1);
177					}
178
179				}
180
181			}
182
183		}
184	});
185
186	// Sidebar menu widget clicks
187	$('.sidebar .widget.widget_nav_menu a').on('click', function(e){
188
189			if ( $(this).next(".sub-menu").length > 0 ) {
190				var sm = $(this).next(".sub-menu");
191
192				if(sm.data('open') !== 1)
193				{
194					e.preventDefault();
195					e.stopPropagation();
196					sm.slideDown();
197
198					sm.data('open', 1);
199
200					$(this).parent().addClass('mobile-submenu-opened');
201				}
202
203			}
204	});
205
206	// Cookie bar plugin restyle
207	if($('#catapult-cookie-bar').length > 0) {
208		$('#catapult-cookie-bar button').addClass('btn');
209	}
210
211	/**
212	*	Scroll related functions
213	*/
214
215	// Calculations in Single post page
216	if($('.single-post').length > 0) {
217		var post_container_height = $('.blog-post.blog-post-single').height();
218		var post_container_top = $('.blog-post.blog-post-single').offset().top;
219		var post_container_bottom = post_container_top + post_container_height;
220	}
221
222	// Post reading progress for single post page
223	if($('.single-post .blog-post-reading-progress').length > 0) {
224
225		var current_position_inside_post = 0;
226		var current_progress = 0;
227
228		$(window).scroll(function () {
229
230			current_position_inside_post = $(window).scrollTop() - post_container_top;
231			current_progress = current_position_inside_post * 100 / post_container_height;
232
233			if(current_progress > 100) {
234				current_progress = 100;
235			}
236
237			if(current_progress < 0) {
238				current_progress = 0;
239			}
240
241			$('.blog-post-reading-progress').width(current_progress + '%');
242
243		});
244	}
245
246	// Fixed social share for single post page
247	if($('.single-post .saxon-social-share-fixed').length > 0) {
248
249		var current_position_inside_post2 = 0;
250		var current_progress2 = -1;
251
252		saxon_fixedSocialWorker();
253
254		$(window).scroll(function () {
255
256			saxon_fixedSocialWorker();
257
258		});
259	}
260
261	function saxon_fixedSocialWorker() {
262
263		if(post_container_height > $('.single-post .saxon-social-share-fixed').height()) {
264			current_position_inside_post2 = $(window).scrollTop() - post_container_top;
265
266			current_progress2 = current_position_inside_post2 * 100 / (post_container_height - $('.single-post .saxon-social-share-fixed').height());
267
268
269			if(current_progress2 > 100) {
270
271
272				$('.single-post .saxon-social-share-fixed').css('position', 'absolute');
273				$('.single-post .saxon-social-share-fixed').css('bottom', 0);
274				$('.single-post .saxon-social-share-fixed').css('top', 'auto');
275				$('.single-post .saxon-social-share-fixed').css('opacity', 0);
276
277			} else if(current_progress2 > 90) {
278				$('.single-post .saxon-social-share-fixed').css('opacity', 0);
279			} else if(current_progress2 < 0) {
280
281				$('.single-post .saxon-social-share-fixed').css('position', 'absolute');
282				$('.single-post .saxon-social-share-fixed').css('bottom', 'auto');
283				$('.single-post .saxon-social-share-fixed').css('top', 0);
284				$('.single-post .saxon-social-share-fixed').css('margin-top', 0);
285				$('.single-post .saxon-social-share-fixed').css('opacity', 1);
286
287			} else {
288
289				$('.single-post .saxon-social-share-fixed').css('position', 'fixed');
290				$('.single-post .saxon-social-share-fixed').css('bottom', 'auto');
291				$('.single-post .saxon-social-share-fixed').css('top', 0);
292				$('.single-post .saxon-social-share-fixed').css('margin-top', '200px');
293				$('.single-post .saxon-social-share-fixed').css('opacity', 1);
294
295			}
296		}
297
298	}
299
300	// Scroll to top button
301	var scrollonscreen = 0;
302
303	$(window).scroll(function () {
304		scrollonscreen = $(window).scrollTop() + $(window).height();
305
306		if(scrollonscreen > $(window).height() + 350){
307			$('.scroll-to-top').css("bottom", "60px");
308		}
309		else {
310			$('.scroll-to-top').css("bottom", "-60px");
311		}
312
313	});
314
315	// Scroll to top animation
316	$('.scroll-to-top').on('click', function(e){
317		$('body,html').stop().animate({
318			scrollTop:0
319		},800,'easeOutCubic')
320		return false;
321	});
322
323	// Sticky header
324	if($(window).width() > 991 && !isTouchDevice()) {
325
326		var $stickyheader = $('header.main-header.sticky-header');
327		var STICKY_HEADER_OFFSET = 500; // Offest after header to show sticky version
328
329		if($stickyheader.length > 0) {
330			var $fixedheader = $stickyheader.clone();
331		   	$fixedheader.insertAfter($stickyheader);
332		   	$fixedheader.addClass('fixed');
333
334		   	if($("#wpadminbar").length > 0) {
335		   		$fixedheader.css('top', $("#wpadminbar").height());
336		   	}
337
338			$(window).scroll(function() {
339
340			    if ($(window).scrollTop() > $stickyheader.offset().top + STICKY_HEADER_OFFSET) {
341			        $fixedheader.fadeIn();
342			    } else {
343			        $fixedheader.fadeOut('fast');
344			    }
345			});
346		}
347	}
348
349	// Sticky sidebar position for touch devices without fixed header
350	if(isTouchDevice()) {
351		$('.blog-enable-sticky-sidebar.blog-enable-sticky-header .content-block .sidebar').css('top', '40px');
352	}
353
354	/**
355	*	Resize events
356	*/
357
358	$(window).resize(function () {
359
360	});
361
362	/**
363	* Social share for posts
364	*/
365
366	function saxon_socialshare(type, post_url, post_title, post_image) {
367
368		switch (type) {
369		  case 'facebook':
370		    window.open( 'https://www.facebook.com/sharer/sharer.php?u='+post_url, "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
371		    break;
372		  case 'google':
373		    window.open( 'https://plus.google.com/share?url='+post_url, "googleplusWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
374		    break;
375		  case 'twitter':
376		    window.open( 'http://twitter.com/intent/tweet?text='+post_title + ' ' + post_url, "twitterWindow", "height=370,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
377		    break;
378		  case 'pinterest':
379		    window.open( 'http://pinterest.com/pin/create/button/?url='+post_url+'&media='+post_image
379+'&description='+post_title, "pinterestWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
380		    break;
381		  case 'whatsapp':
382		    window.open( 'https://api.whatsapp.com/send?text='+post_title+' '+post_url, "whatsupWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
383			break;
384		  case 'vk':
385		    window.open( 'https://vk.com/share.php?url='+post_url+'&title='+post_title+'&description=&image='+post_image, "vkWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
386			break;
387		  case 'linkedin':
388		    window.open( 'https://www.linkedin.com/shareArticle?url='+post_url+'&title='+post_title, "linkedinWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
389			break;
390		  default:
391
392		}
393
394		return false;
395	}
396
397	$('.post-social a').on('click', function(e){
398
399		if($(this).data('type') !== 'link') {
400			e.preventDefault();
401			e.stopPropagation();
402
403			var share_type = $(this).data('type');
404			var post_image = $(this).data('image');
405			var post_title = encodeURIComponent($(this).data('title'));
406			var post_url = $(this).attr('href');
407
408			saxon_socialshare(share_type, post_url, post_title, post_image);
409		}
410
411	});
412
413	/**
414	*	Other scripts
415	*/
416
417	/**
418	*	Common functions
419	*/
420
421	// Check for touch device
422    function isTouchDevice(){
423	    return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
424	}
425
426});
427})(jQuery);
428
429// Global functions
430'use strict';
431
432/* Cookie functions */
433function setCookie(name,value,days) {
434    if (days) {
435        var date = new Date();
436        date.setTime(date.getTime()+(days*24*60*60*1000));
437        var expires = "; expires="+date.toGMTString();
438    }
439    else var expires = "";
440    document.cookie = name+"="+value+expires+"; path=/";
441}
442
443function getCookie(name) {
444  var value = "; " + document.cookie;
445  var parts = value.split("; " + name + "=");
446  if (parts.length == 2) return parts.pop().split(";").shift();
447}

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.