PageSourceSearch

https://www.railsim-fr.com/wordpress/wp-content/themes/graphene/js/graphene.js?ver=2.9

js railsim-fr.com collected 2026-10-01 14:34:10 UTC 14,373 bytes, 381 lines download raw bytes

1jQuery(document).ready(function($) {
2	
3
4	/* Go to parent link of a dropdown menu if clicked when dropdown menu is open */
5	$('.dropdown-toggle[href], .dropdown-submenu > a[href]').click(function(){
6		if ( $(this).parent().hasClass('open') ) window.location = $(this).attr('href');
7	});
8
9	/* Multi-level dropdown menu on mobile */
10	$('.dropdown-submenu > a[href]').click(function(e){
11		if ( $(window).width() <= 991 ) {
12			e.preventDefault(); event.stopPropagation();
13			$('.dropdown-submenu', $(this).parents('.dropdown-menu') ).removeClass('open');
14			$(this).parent().toggleClass('open');
15
16			$('.dropdown-menu', $(this).parents('.dropdown-menu') ).hide();
17			$(this).siblings('.dropdown-menu').show();
18		}
19	});
20
21
22	/* Sticky navbar */
23	if ( grapheneJS.enableStickyMenu ) {
24		window.heightBreakpoint = $('.navbar').position().top;
25		if ( $('#wpadminbar').length > 0 && $(window).width() >= 768 ) window.heightBreakpoint -= 32;
26		
27		$(window).scroll(function() {
28			var height = $(window).scrollTop();
29			// if ( franzJS.hasTopBar ) {
30			// 	var topBarHeight = $('.top-bar').outerHeight();
31			// 	if ( height > topBarHeight ) { $('.navbar').addClass('navbar-fixed-top'); $('body').addClass('navbar-fixed'); }
32			// 	else { $('.navbar').removeClass('navbar-fixed-top'); $('body').removeClass('navbar-fixed'); }
33			// 	heightBreakpoint += topBarHeight;
34			// }
35			
36			if ( height > window.heightBreakpoint ) { 
37				$('body').addClass('navbar-pinned');
38				$('.navbar').addClass('navbar-fixed-top');
39			} else { 
40				if ( ! $('body').hasClass('navbar-persistent-pinned') ) {
41					$('body').removeClass('navbar-pinned'); 
42					$('.navbar').removeClass('navbar-fixed-top');
43				}
44			}
45		});
46
47
48		/* Adjust the width of the navbar to match the parent container */
49		adjustNavbarWidth();
50		$(window).resize(function(){adjustNavbarWidth();});
51		$('body > .container').resize(function(){adjustNavbarWidth();});
52	}
53
54	function adjustNavbarWidth(){
55		if ( $('.boxed-wrapper').length > 0 ) {
56			parentWidth = $('.boxed-wrapper').outerWidth();
57			$('.boxed-wrapper .navbar').width(parentWidth);
58		}
59	}
60
61
62	/* Live search */
63	if ( ! grapheneJS.disableLiveSearch ) {
64		$('.live-search-input input').autocomplete({
65		    serviceUrl				: grapheneJS.siteurl + '/?autocomplete=post',
66		    deferRequestBy			: 200,
67		    showNoSuggestionNotice	: true,
68		    noSuggestionNotice 		: grapheneJS.txtNoResult,
69		    onSearchStart: function (query) {
70		    	$(this).siblings('.live-search-icon').show();
71		    },
72		    onSearchComplete: function (query, suggestions) {
73		    	$(this).siblings('.live-search-icon').hide();
74		    },
75		    onSelect: function (suggestion) {
76		        window.location.href = suggestion.data;
77		    }
78		});
79
80		/* bbPress */
81		$('input[name="bbp_search"]').wrap('<div class="bbpress-live-search"></div>');
82		$('input[name="bbp_search"]').after('<i class="fa fa-spin fa-circle-o-notch live-search-icon" style="display:none"></i>');
83		$('.bbpress-live-search input').autocomplete({
84		    serviceUrl				: grapheneJS.siteurl + '/?autocomplete=bbpress',
85		    deferRequestBy			: 200,
86		    showNoSuggestionNotice	: true,
87		    noSuggestionNotice 		: grapheneJS.txtNoResult,
88		    onSearchStart: function (query) {
89		    	$(this).siblings('.live-search-icon').show();
90		    },
91		    onSearchComplete: function (query, suggestions) {
92		    	$(this).siblings('.live-search-icon').hide();
93		    },
94		    onSelect: function (suggestion) {
95		        window.location.href = suggestion.data;
96		    }
97		});
98	}
99	
100
101	/* Graphene Slider */
102	if ( ! grapheneJS.sliderDisable ) {
103		$('.carousel').each(function(){
104			$(this).carousel({
105				interval: grapheneJS.sliderInterval,
106				pause	: 'hover'
107			});
108			$(this).carousel('cycle');
109		});
110
111		// Preload slider background images
112		if ( grapheneJS.sliderDisplay == 'bgimage-excerpt' ) {
113			$('.carousel .item').each(function(){
114				var src = $(this).css('background-image').replace('url(', '').replace(')','');
115				if ( src.indexOf('http') == 0 ){
116					(new Image()).src = this;
117				}
118				src = null;
119			});
120		}
121
122		/* Fix Bootstrap Carousel not pausing on hover */
123		$(document).on( 'mouseenter', '.carousel', function() {
124			$(this).carousel( 'pause' );
125		});
126		$(document).on( 'mouseleave', '.carousel', function() {
127			$(this).carousel( 'cycle' );
128		});
129
130		/* Position the carousel caption when using full-width-boxed layout */
131		function graphenePositionCarouselCaption(){
132			if ( $(window).width() <= 991 || $('#header-menu-wrap').length == 0 ) return;
133			$('.layout-full-width-boxed .carousel-caption-content').css('left', $('#header-menu-wrap').position().left + 15 + 'px' );
134		}
135		$(window).resize(function(){graphenePositionCarouselCaption();});
136		graphenePositionCarouselCaption();
137	}
138
139
140	/* Comments */
141	if ( grapheneJS.shouldShowComments ) {
142		$('li.comment .comment-permalink').hide();
143		$('.comment-wrap').hover( function(){ $('.comment-permalink', this).fadeIn(200); }, function(){ $('.comment-permalink:eq(0)', this).fadeOut(200); });
144		$('.comment-form-jump a').click(function(){ $('html,body').animate({scrollTop: $("#respond").offset().top - 200},'slow'); return false;});
145		// Tabbed comments
146		$("div#comments h4.comments a").click(function(){
147			$("div#comments .comments").addClass( 'current' );
148			$("div#comments .pings").removeClass( 'current' );
149			$("div#comments #pings_list").hide();
150			$("div#comments .comments-list-wrapper").fadeIn(300);
151			return false;
152		});
153		$("div#comments h4.pings a").click(function(){
154			$("div#comments .pings").addClass( 'current' );
155			$("div#comments .comments").removeClass( 'current' );
156			$("div#comments .comments-list-wrapper").hide();
157			$("div#comments #pings_list").fadeIn(300);
158			return false;
159		});
160	}
161				
162	
163	/**
164	 * Infinite scroll
165	 */
166	$('.infinite-load .load').each(function(){
167		$(this).data( 'remaining-posts', $(this).data('totalPosts') - $(this).data('postsPerPage'));
168		var infScrollBtnObj = $(this);
169		var infScroll = $(this).data('container');
170		
171		var infScrollOptions = {
172			navSelector : $(this).data('navSelector'),
173			nextSelector: $(this).data('nextSelector'),
174			itemSelector: $(this).data('itemSelector'),
175			animate 	: false,
176			loading		: {
177				msgText		: grapheneGetInfScrollMessage('post', $(this).data('postsPerPage'), $(this).data('remainingPosts')),
178				finishedMsg	: grapheneJS.infScrollFinishedText,
179				img			: '',
180				msg			: null,
181				speed		: 400
182			},
183			// debug		: true
184		};
185
186		/* Manually parse the path so that Infinite Scroll will still work even on offset page */
187		currentPage = parseInt( $(infScrollOptions.navSelector+' .current').html() );
188		infScrollOptions.state = { currPage: currentPage };
189
190		nextURI = $(infScrollOptions.nextSelector).attr('href');
191		nextIndex = (currentPage+1).toString();
192		suffix = nextURI.slice(-(nextURI.length - nextURI.indexOf(nextIndex)-nextIndex.length));
193		pathURI = nextURI.replace(nextIndex+suffix,'');
194		infScrollOptions.pathParse = function(path,nextPage){
195			path = [pathURI,suffix];
196			return path;
197		};
198
199		/* Modify the path for reverse Infinite Scroll direction */
200		if (  $(this).data('direction') == 'reverse' ) {
201			infScrollOptions.direction = $(this).data('direction');
202			
203			currentPage = parseInt( $(infScrollOptions.navSelector+' .current').html() );
204			infScrollOptions.state = { currPage: currentPage };
205			
206			if ($(infScrollOptions.nextSelector).length > 0) {
207				nextURI = $(infScrollOptions.nextSelector).attr('href');
208				nextIndex = (currentPage-1).toString();
209				
210				suffix = nextURI.slice(-(nextURI.length - nextURI.indexOf(nextIndex)-nextIndex.length));
211				pathURI = nextURI.replace(nextIndex,'').replace(suffix,'');
212	
213				infScrollOptions.pathParse = function(path,nextPage){
214					path = [pathURI,suffix];
215					return path;
216				};
217			}
218		}
219		
220		$(infScroll).infinitescroll(infScrollOptions, function(newElems, response, path){
221			infScrollBtnObj.data('remaining-posts', infScrollBtnObj.data('remainingPosts') - parseInt(newElems.length));
222			
223			if ( infScrollBtnObj.data('method') == 'click' ) infScrollBtnObj.html(grapheneGetInfScrollBtnLbl(infScrollBtnObj.data('remainingPosts')));
224			else infScrollBtnObj.html(grapheneGetInfScrollMessage('post', infScrollBtnObj.data('postsPerPage'), infScrollBtnObj.data('remainingPosts')));
225
226			if ( $(infScroll).data('masonry') ) {
227				var $newElems = $( newElems ).css({ opacity: 0 }); 		// hide new items while they are loading
228				$('p.infinite-load').css('margin-top', '2000px');			// push the loading button down while the new items are loading
229				$(infScroll).imagesLoaded(function(){						// ensure that images load before adding to masonry layout
230					$newElems.animate({ opacity: 1 });
230					// show elems now they're ready
231					$(infScroll).masonry( 'appended', $newElems, true );
232					$('p.infinite-load').css('margin-top', '20px');
233				});
234			}
235			
236			if ( infScrollBtnObj.data('remainingPosts') <= 0 ) {
237				infScrollBtnObj.html(grapheneJS.infScrollFinishedText).addClass('disabled').removeAttr('href');
238				$(infScroll).infinitescroll('destroy');
239			}
240
241			$(infScroll).trigger( 'append.infinitescroll', [newElems, response, path] );
242		});
243		$($(this).data('navSelector')).hide();
244		
245		if ( $(this).data('method') == 'click' ){
246			$(infScroll).infinitescroll('pause');
247			$(this).click(function(e){
248				e.preventDefault();
249				if ($(this).data('remainingPosts') <= 0) return;
250				$($(this).data('container')).infinitescroll('retrieve');
251				$(this).html(grapheneGetInfScrollMessage('post', $(this).data('postsPerPage'), $(this).data('remainingPosts')));
252			});
253		} else {
254			$(this).html(grapheneGetInfScrollMessage('post', $(this).data('postsPerPage'), $(this).data('remainingPosts')));
255		}
256	});
257	
258
259	/**
260	 * Back to top button
261	 */
262	var backtotop = '#back-to-top';
263    if ( $(backtotop).length) {
264        var scrollTrigger = 100, // px
265            backToTop = function () {
266                var scrollTop = $(window).scrollTop();
267                var pageHeight = $(document).height() - $(window).height();
268
269                if ( $('.grecaptcha-badge').length > 0 ) {
270					if ( ! $('#back-to-top').hasClass('position-adjusted') ) {
271						recaptchaBadgePos = $('.grecaptcha-badge').position();
272						if ( ( $(window).height() - recaptchaBadgePos.top ) < 75 ) {
273							if ( ( $(window).width() - recaptchaBadgePos.left ) < 75 ) {
274								$('#back-to-top').css('bottom', ( $(window).height() - recaptchaBadgePos.top + 20 ) + 'px' );
275								$('#back-to-top').addClass('position-adjusted');
276							}
277						}
278					}
279				}
280
281               	if ( scrollTop == pageHeight ) {
282               		$(backtotop).removeClass('show');
283               	} else if (scrollTop > scrollTrigger) {
284                    $(backtotop).addClass('show');
285                } else {
286                    $(backtotop).removeClass('show');
287                }
288            };
289        backToTop();
290        $(window).on('scroll', function () {
291            backToTop();
292        });
293        $('#back-to-top').on('click', function (e) {
294            e.preventDefault();
295            $('html,body').animate({
296                scrollTop: 0
297            }, 700);
298        });
299    }
300
301
302    /* Layout Shortcodes */
303    if ( $.isFunction( 'tooltip' ) ) {
304    	// Stop "click triggered" tootips from acting as bookmarks to top of page
305    	$('[data-toggle="tooltip"]').tooltip().filter('[data-trigger*="click"]').on('click', function(e) {
306	        e.preventDefault();
307	    });
308	}
309
310
311	/* Masonry for posts layout */
312	if ( grapheneJS.isMasonry || $('.posts-list.loop-masonry').length > 0 ) {
313		$postsList = $('.loop-masonry .entries-wrapper');
314		$postsList.imagesLoaded(function(){
315			$postsList.masonry({
316				itemSelector: '.post-layout-grid',
317				columnWidth: 0.25
318			});
319		});
320	}
321
322
323	/**
324	 * Remember user preference to hide auto column switch notification
325	 */
326	$('#graphene-auto-column-switch-alert .close').click(function(){
327		data = { action: 'graphene-hide-auto-column-switch-alert' };
328		$.post(grapheneJS.ajaxurl, data);
329	});
330
331
332	/**
333	 * Ensure pricing table price heights are the same for all packages in the same row
334	 */
335	if ( $('.pricing-table .price-package').length > 1 && $(window).width() >= 768 ) {
336		$('.panel-row-style:has(.price-package)').each(function(){
337
338			var priceDetailsMaxHeight = 0;
339			$('.price-package .details', this).each(function(){
340				if ( $(this).outerHeight() > priceDetailsMaxHeight ) priceDetailsMaxHeight = $(this).outerHeight();
341			});
342			$('.price-package .details', this).css('height', priceDetailsMaxHeight + 'px');
343
344			var pricePackageMaxHeight = 0;
345			$('.price-package', this).each(function(){
346				if ( $(this).outerHeight() > pricePackageMaxHeight ) pricePackageMaxHeight = $(this).outerHeight();
347			});
348			$('.price-package', this).css('height', pricePackageMaxHeight + 'px');
349		});
350	}
351
352});
353
354
355function grapheneGetInfScrollMessage( type, itemsPerLoad, itemsLeft ){
356	type = typeof type !== 'undefined' ? type : 'post';
357	
358	if (itemsLeft < itemsPerLoad) itemsPerLoad = itemsLeft;
359	var message = '';
360	
361	if ( type == 'post' ) {
362		if (itemsLeft > 1) message = grapheneJS.infScrollMsgTextPlural.replace('window.grapheneInfScrollItemsPerPage',itemsPerLoad).replace('window.grapheneInfScrollItemsLeft',itemsLeft);
363		else message = grapheneJS.infScrollMsgText.replace('window.grapheneInfScrollItemsPerPage',itemsPerLoad).replace('window.grapheneInfScrollItemsLeft',itemsLeft);
364	}
365	
366	if ( type == 'comment' ) {
367		if (itemsLeft > 1) message = grapheneJS.infScrollCommentsMsgPlural.replace('window.grapheneInfScrollCommentsPerPage',itemsPerLoad).replace('window.grapheneInfScrollCommentsLeft',itemsLeft);
368		else message = grapheneJS.infScrollCommentsMsg.replace('window.grapheneInfScrollCommentsPerPage',itemsPerLoad).replace('window.grapheneInfScrollCommentsLeft',itemsLeft);
369	}
370	
371	message = '<i class="fa fa-spinner fa-spin"></i> ' + message;
372	return message;
373}
374
375
376function grapheneGetInfScrollBtnLbl(itemsLeft){
377	var message = '';
378	if ( itemsLeft == 0 ) message = grapheneJS.infScrollFinishedText;
379	else message = grapheneJS.infScrollBtnLbl;
380	return message;
381}

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.