PageSourceSearch

https://www.carmelholylanddco.org/wp-content/themes/adama/assets/js/theme.js?ver=1.0.1

js carmelholylanddco.org collected 2026-10-02 08:33:24 UTC 32,602 bytes, 1,212 lines download raw bytes

1/* global jQuery, adamaSettings, google */
2(function( $ ) {
3	"use strict";
4
5	var $window = $( window ),
6		$body = $( document.body ),
7		$wrapper = $body.find( '> .wrapper' ),
8		$wpadminbar,
9		$wcDemoStore,
10		$navbar,
11		windowLastWidth = $window.width(),
12		heightAdminBarLast = -1,
13		heightDemoStoreLast = -1,
14		heightStickyLast = -1;
15
16	/**
17	 * Helper function - restrict integer range and set default value in case number is not a number
18	 *
19	 * @param {int} value
20	 * @param {int|bool} min
21	 * @param {int|bool} max
22	 * @param {int} defaultValue
23	 * @returns {int}
24	 */
25	function intRangeDefault( value, min, max, defaultValue ) {
26		value = parseInt( value, 10 );
27
28		if ( isNaN( value ) ) {
29			value = defaultValue;
30		} else if ( min !== false && value < min ) {
31			value = min;
32		} else if ( max !== false && value > max ) {
33			value = max;
34		}
35
36		return value;
37	}
38
39	/**
40	 * Helper function - parse bool value and set default bool value in case one was not set
41	 *
42	 * @param {string} value
43	 * @param {bool} defaultValue
44	 * @returns {bool}
45	 */
46	function boolDefault( value, defaultValue ) {
47
48		if ( typeof value === 'boolean' ) {
49			return value;
50		} else if ( typeof value === 'string' ) {
51			value = value.toLowerCase();
52		}
53
54		if ( value === '1' || value === 'true' || value === 'yes' ) {
55			value = true;
56		} else if ( value === '0' || value === 'false' || value === 'no' ) {
57			value = false;
58		} else {
59			value = defaultValue;
60		}
61
62		return value;
63	}
64
65	/**
66	 * Helper function - Debounce events
67	 * http://stackoverflow.com/a/24004942/111433
68	 *
69	 * @param {Function} func
70	 * @param {int} wait
71	 * @param {bool} immediate
72	 * @returns {Function}
73	 */
74	function debounce( func, wait, immediate ) {
75		var timeout;
76		return function() {
77			var context = this,
78				args = arguments;
79
80			var callNow = immediate && !timeout;
81
82			clearTimeout( timeout );
83			timeout = setTimeout( function() {
84				timeout = null;
85
86				// Check if the function already ran with the immediate flag
87				if ( !immediate ) {
88					// Call the original function with apply apply lets you define the 'this' object as well as the arguments (both captured before setTimeout)
89					func.apply( context, args );
90				}
91			}, wait );
92
93			if ( callNow ) {
94				func.apply( context, args );
95			}
96		};
97	}
98
99	/**
100	 * Initialize Google map
101	 *
102	 * @param {object} geocoder
103	 * @param {object} infoWindow
104	 * @param {object} map
105	 * @param {bool} mapCentered
106	 * @param {string} address
107	 * @param {string} tooltip
108	 * @returns {void}
109	 */
110	function googleMapInit( geocoder, infoWindow, map, mapCentered, address, tooltip ) {
111		geocoder.geocode( { address: address }, function( results, status ) {
112			var marker;
113
114			if ( status === google.maps.GeocoderStatus.OK ) {
115
116				if ( !mapCentered ) {
117					map.setCenter( results[0].geometry.location );
118					mapCentered = true;
119				}
120
121				marker = new google.maps.Marker({
122					map: map,
123					position: results[0].geometry.location
124				});
125
126				google.maps.event.addListener( marker, 'click', function() {
127					infoWindow.setContent( tooltip );
128					infoWindow.open( map, marker );
129				} );
130
131			} else {
132				if ( window.console ) {
133					console.log( 'Adama', adamaSettings.tErrorGeocode + status );
134				}
135			}
136		});
137	}
138
139	/**
140	 * Set height of tallest block to each element in the same "row".
141	 *
142	 * @param {jQuery} $elements
143	 * @returns {void}
144	 */
145	function equalHeight( $elements ) {
146
147		// Do we have any elements to resize
148		if ( !$elements.length ) {
149			return;
150		}
151
152
153		var groups = {},
154			key;
155
156		// Group elements by current top position
157		$elements.each( function() {
158			var $this = $( this ),
159				height = $this.height( 'auto' ).outerHeight( false ),
160				top = Math.round( this.getBoundingClientRect().top ),
161				key = 't' + top;
162
163			if ( typeof groups[key] === 'undefined' ) {
164				groups[key] = {
165					maxHeight: height,
166					elements: [$this]
167				};
168			} else {
169				if ( height > groups[key].maxHeight ) {
170					groups[key].maxHeight = height;
171				}
172
173				groups[key].elements.push($this);
174			}
175		} );
176
177		// Set max heights for each elements in a "row"
178		for ( key in groups ) {
179			if ( groups.hasOwnProperty( key ) ) {
180
181				// Set height only if there are two or more elements in a row
182				if ( groups[key].elements.length > 1 ) {
183					for ( var i = 0; i < groups[key].elements.length; i++ ) {
184						groups[key].elements[i].css( 'height', groups[key].maxHeight + 'px' );
185					}
186				}
187
188			}
189		}
190	}
191
192	/**
193	 * Validate forms
194	 *
195	 * @param {object} e
196	 * @returns {void}
197	 */
198	function validateForm( e ) {
199		/*jshint validthis:true */
200
201		var $form = $( this ),
202			hasError = false;
203
204		// Remove old error messages
205		$form.find( '.alert' ).remove();
206
207		// Validate
208		$form.find( '[required]' ).each( function() {
209			var $ctrl = $( this ),
210				value = $.trim( $ctrl.val() ),
211				message;
212
213			if ( value === '' ) {
214				hasError = true;
215				message = adamaSettings.tErrorRequiredField;
216			} else if ( $ctrl.attr( 'id' ) === 'email' && !( /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/.test( value ) ) ) {
217				hasError = true;
218				message = adamaSettings.tErrorInvalidEmail;
219			}
220
221			if ( hasError ) {
222				$ctrl.parent().append( '<div class="alert alert-danger alert-form-message">' + message + '</div>' );
223			}
224		});
225
226		if ( hasError ) {
227			$form.prepend( '<div class="alert alert-danger">' + adamaSettings.tErrorGlobal + '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button></div>' );
228			e.preventDefault();
229		}
230	}
231
232	/**
233	 * Toggle shortcode content visibility.
234	 *
235	 * @returns {void}
236	 */
237	function shortcodeToggle() {
238		/*jshint validthis:true */
239
240		var $toggle = $( this ).next();
241
242		$toggle.slideToggle( 'fast', function() {
243			if ( $toggle.is( ':visible' ) ) {
244				$toggle.parent().addClass( 'active' );
245			} else {
246				$toggle.parent().removeClass( 'active' );
247			}
248		} );
249	}
250
251	/**
252	 * Add .animate-hover-slide-small to small elements.
253	 *
254	 * @returns {void}
255	 */
256	function animateHoverSmall() {
257		var $elements = $( '.animate-hover-slide' );
258
259		$elements.each( function() {
260			var $this = $( this ),
261				$item = $this.find( '.figure' ),
262				width = $item.width();
263
264				if ( !$this.hasClass( 'animate-hover-slide-small' ) && ( width <= 200 )  ) {
265					$this.addClass( 'animate-hover-slide-small' );
266				} else if ( $this.hasClass( 'animate-hover-slide-small' ) && ( width > 200 ) ) {
267					$this.removeClass( 'animate-hover-slide-small' );
268				}
269		} );
270	}
271
272	/**
273	 * Set positions for store demo notice and sticky header
274	 *
275	 * @returns {void}
276	 */
277	function setHeaderPositions() {
278		var heightAdminBar = 0,
279			heightDemoStore = 0,
280			heightSticky = 0;
281
282		// Calculate height - Admin bar
283		if ( $wpadminbar && $wpadminbar.length ) {
284			heightAdminBar = $wpadminbar.outerHeight( false );
285		}
286
287		// Calculate height - WooCommerce demo notice
288		if ( $wcDemoStore && $wcDemoStore.length ) {
289			heightDemoStore = $wcDemoStore.outerHeight( false );
290
291			if ( heightAdminBar !== heightAdminBarLast ) {
292				$wcDemoStore.css( 'top', heightAdminBar + 'px' );
293			}
294
295			if ( heightDemoStore !== heightDemoStoreLast ) {
296				$body.css( 'margin-top', heightDemoStore + 'px' );
297			}
298		}
299
300		// Sticky header
301		if ( $.fn.sticky && $navbar && $body.hasClass( 'sticky-header' ) ) {
302			heightSticky = $navbar.outerHeight( false );
303
304			if ( heightAdminBar !== heightAdminBarLast || heightDemoStore !== heightDemoStoreLast || heightSticky !== heightStickyLast ) {
305				$navbar.unstick();
306
307				if ( $window.width() >= 768 ) {
308					$navbar.sticky( {
309						topSpacing: heightAdminBar + heightDemoStore,
310						className : 'navbar-fixed'
311					} );
312				}
313			}
314
315			heightStickyLast = heightSticky;
316		}
317
318		heightAdminBarLast = heightAdminBar;
319		heightDemoStoreLast = heightDemoStore;
320	}
321
322	/**
323	 * Set positions for Mega menus
324	 *
325	 * @returns {void}
326	 */
327	function setMegaMenusPositions() {
328		if ( $window.width() > 740 ) {
329			var $megaMenuItems = $navbar.find( '.mega-menu' );
330
331			if ( $megaMenuItems.length > 0 ) {
332				$megaMenuItems.each( function() {
333					var $item = $( this ),
334						$megaMenu = $item.find( '> .sub-menu-container' ),
335						$itemPosition = $item.position(),
336						$megaMenuNewPosition = $itemPosition.top + $item.height();
337
338						if ( $megaMenu.length > 0 ) {
339							$megaMenu.css( { top: $megaMenuNewPosition } );
340						}
341				} );
342			}
343		}
344	}
345
346	/**
347	 * Show uncover footer
348	 *
349	 * @returns {void}
350	 */
351	function footerUncover() {
352		if ( adamaSettings.footerEnableUncover === '1' ) {
353			var $footerElement = $( '.main-footer' ),
354				$mainContent = $( '#main-content' ),
355				$wrapper = $( '.wrapper' ),
356				footerHeight = $footerElement.outerHeight( false ) - 1; // -1 to compensate for decimal places in certain situations
357
358			if ( $window.innerHeight() > footerHeight * 1.2 ) {
359				$mainContent.css( { 'margin-bottom': footerHeight + 'px' } );
360				$wrapper.css( { 'min-height': $window.innerHeight() - footerHeight - $wrapper.offset().top + 'px' } );
361
362				if ( !$footerElement.hasClass( 'footer-uncover' ) ) {
363					$footerElement.addClass( 'footer-uncover' );
364				}
365			} else {
366				$mainContent.css( { 'margin-bottom': 0 } );
367				$wrapper.css( { 'min-height': 0 } );
368
369				$footerElement.removeClass( 'footer-uncover' );
370			}
371		}
372	}
373
374	/**
375	 * Init LightBox
376	 *
377	 * @returns {void}
378	 */
379	function zoomLightBox() {
380		$( 'a.zoom' ).iLightBox( {
381			skin: adamaSettings.lightboxSkin || 'dark',
382			path: adamaSettings.lightboxDirection,
383			controls: {
384				arrows: boolDefault( adamaSettings.lightboxShowArrows, true ),
385				thumbnail: boolDefault( adamaSettings.lightboxShowThumnails, false )
386			}
387		} );
388	}
389
390	var isInfiniteScrollAjaxRunning = false,
391		infiniteLoaderErrorCount = 0;
392	/**
393	 * Infinite loader
394	 *
395	 * @param {object} e
396	 * @returns {void}
397	 */
398	$body.on( 'click', '.pagination-infinite a', function( e ) {
399		e.preventDefault();
400
401		var $this = $( this ),
402			$paginationContainer = $this.parent(),
403			$container = $( '.mixitup' ).first(),
404			$postPaged = parseInt( $container.data( 'current-page' ), 10 ),
405			$currentTerm = $( '.ajax-filter' ).first().find( '.filter-ajax.active' );
406
407		var data = {
408				security:   adamaSettings.nonceAjax,
409				action:     'galactica_infinite_loader',
410				type:       'portfolio',
411				pageID:     adamaSettings.pageID,
412				paged:      $postPaged,
413				targetPage: $postPaged + 1,
414				// postsCount: $container.children( '.mix' ).length,
415				categoryId: $currentTerm.data( 'category-id' ) || ''
416			};
417
418		$.ajax( {
419			type: "POST",
420			url:  adamaSettings.ajaxurl,
421			data: data,
422			beforeSend: function() {
423				isInfiniteScrollAjaxRunning = true;
424				$paginationContainer.show();
425			},
426			success: function( response ) {
427				var errorMessage = '';
428				if ( typeof response !== 'object' || !response.status ) {
429					errorMessage = adamaSettings.tErrorAjaxBadData;
430				} else if ( response.status === 'error' ) {
431					errorMessage = response.message;
432				}
433
434				if ( errorMessage ) {
435					infiniteLoaderErrorCount++;
436
437					if ( window.console ) {
438						console.log( 'Adama', errorMessage );
439					}
440					return;
441				}
442
443
444				var totalElements = $container[0].config.origOrder.length;
445
446				// Add new elements(s) after last target element (subtract 1 as .eq() is zero-based):
447				$container.find( '.mix' ).eq( totalElements - 1 ).after( response.html );
448
449				var selectedFilter = $currentTerm.data( 'filter' ) ? $currentTerm.data( 'filter' ) : 'all';
450
451				// Perform a remix and fade-in new elements
452				$container.mixitup( 'remix', selectedFilter );
453
454				// Update current page field
455				$container.data( 'current-page', response.currentPage );
456
457				if ( response.nextPage === 0 ) {
458					$paginationContainer.remove();
459				}
460
461				// Reset error counter
462				infiniteLoaderErrorCount = 0;
463			},
464			complete: function() {
465				$paginationContainer.hide();
466				isInfiniteScrollAjaxRunning = false;
467			}
468		} );
469	} );
470
471	/**
472	 * Infinite scroll load more
473	 *
474	 * @returns {void}
475	 */
476	function infiniteScrollLoadMore() {
477		if ( isInfiniteScrollAjaxRunning ) {
478			return;
479		} else if ( infiniteLoaderErrorCount >= 10 ) {
480			if ( window.console ) {
481				console.log( 'Adama', adamaSettings.tErrorAjaxAborting );
482			}
483			return;
484		}
485
486		var $button = $( '.pagination-infinite a' );
487		if ( $button.length ) {
488			var buttonOffset = $button.offset();
489			if ( buttonOffset && $window.scrollTop() > ( buttonOffset.top - $window.height() ) / 2 ) {
490				$button.trigger( 'click' );
491			}
492		}
493	}
494
495	/**
496	 * Filter portfolio items via ajax
497	 *
498	 * @param {object} e
499	 * @returns {void}
500	 */
501	$( '.ajax-filter' ).on( 'click', '.filter-ajax', function( e ) {
502		e.preventDefault();
503
504		var $thisFilter = $( this ),
505			$container = $( '.mixitup' ).first(),
506			$paginationContainer = $container.find( '.pagination-infinite' );
507
508
509		// Mark all inactive
510		$thisFilter.siblings( '.active' ).removeClass( 'active' );
511
512		// Remove current items
513		$container.children( '.mix' ).remove();
514
515
516		var data = {
517			security:   adamaSettings.nonceAjax,
518			action:     'galactica_infinite_loader',
519			type:       'portfolio',
520			pageID:     adamaSettings.pageID,
521			paged:      0,
522			targetPage: 1,
523			categoryId: $thisFilter.data( 'category-id' ) || ''
524		};
525
526		$.ajax( {
527			type: "POST",
528			url:  adamaSettings.ajaxurl,
529			data: data,
530			beforeSend: function() {
531				isInfiniteScrollAjaxRunning = true;
532
533				if ( $paginationContainer.length ) {
534					$paginationContainer.show();
535				} else {
536					$paginationContainer = $( '<div class="pagination-infinite"><div class="infinite-loader"></div><a href="#">
536' + adamaSettings.tInfiniteScrollLoading + '</a></div>' );
537					$container.append( $paginationContainer );
538				}
539			},
540			success: function( response ) {
541				var errorMessage = '';
542				if ( typeof response !== 'object' || !response.status ) {
543					errorMessage = adamaSettings.tErrorAjaxBadData;
544				} else if ( response.status === 'error' ) {
545					errorMessage = response.message;
546				}
547
548				if ( errorMessage ) {
549					infiniteLoaderErrorCount++;
550
551					if ( window.console ) {
552						console.log( 'Adama', errorMessage );
553					}
554					return;
555				}
556
557
558				// Add new elements
559				$container.prepend( response.html );
560
561				var selectedFilter = $thisFilter.data( 'filter' ) ? $thisFilter.data( 'filter' ) : 'all';
562
563				// Perform a remix and fade-in new elements
564				$container.mixitup( 'remix', selectedFilter );
565
566				// Update current page field
567				$container.data( 'current-page', response.currentPage );
568
569				if ( response.nextPage === 0 ) {
570					$paginationContainer.remove();
571				}
572
573				// Mark current filter button active
574				$thisFilter.addClass( 'active' );
575
576				// Reset error counter
577				infiniteLoaderErrorCount = 0;
578			},
579			complete: function() {
580				$paginationContainer.hide();
581				isInfiniteScrollAjaxRunning = false;
582			}
583		} );
584
585	} );
586
587	/**
588	 * Toggle mobile menu
589	 *
590	 * @param {object} e
591	 * @returns {void}
592	 */
593	$body.on( 'click', '.navbar-toggle-menu', function( e ) {
594		e.preventDefault();
595
596		var $menu = $( '.galactica-navbar-collapse' );
597
598		if ( $menu.length > 0 ) {
599			// Open current menu ancestors
600			$menu.find( '.current-menu-ancestor' ).addClass( 'active' ).children( '.sub-menu-container, .sub-menu-container-visible' ).show();
601
602			if ( !$menu.hasClass( 'open-nav' ) ) {
603				$menu.addClass( 'open-nav' ).slideDown( 'fast' );
604			} else {
605				$menu.removeClass( 'open-nav' ).slideUp( 'fast' );
606			}
607		}
608	} );
609
610	/**
611	 * Toggle mobile submenu
612	 *
613	 * @param {object} e
614	 * @returns {void}
615	 */
616	$body.on( 'click', '.toggle-submenu', function( e ) {
617		e.preventDefault();
618
619		var $toggleParent = $( this ).parent( 'li' ),
620			$activeChildren;
621
622		if ( !$toggleParent.hasClass( 'active' ) ) {
623			var $activeSiblings = $toggleParent.siblings( '.active' );
624
625			$activeSiblings
626				.removeClass( 'active' )
627				.find( '.sub-menu-container, .sub-menu-container-visible' )
628				.slideUp( 'fast' );
629
630			$activeChildren = $activeSiblings.find( '.active' );
631
632			$toggleParent.addClass( 'active' ).children( '.sub-menu-container, .sub-menu-container-visible' ).slideDown( 'fast' );
633		} else {
634			$activeChildren = $toggleParent.find( '.active' );
635
636			$toggleParent.removeClass( 'active' ).find( '.sub-menu-container, .sub-menu-container-visible' ).slideUp( 'fast' );
637		}
638
639		$activeChildren.removeClass( 'active' );
640	} );
641
642	/**
643	 * Calculate heights
644	 *
645	 * @returns {void}
646	 */
647	function calculateHeight() {
648		for ( var i = 0; i < adamaSettings.equalHeight.length; i++ ) {
649			equalHeight( $( adamaSettings.equalHeight[i].selector ) );
650		}
651	}
652
653	/**
654	 * Recalculate heights after carosuel resize
655	 *
656	 * @returns {void}
657	 */
658	function equalHeightSliderResized() {
659		/*jshint validthis:true */
660		var $this = $( this ),
661			dataSelectors = $this.data( 'equal' );
662
663		for ( var i = 0; i < dataSelectors.length; i++ ) {
664			equalHeight( $this.find( dataSelectors[i] ) );
665		}
666	}
667
668	/**
669	 * Reposition masonry after slider resize
670	 *
671	 * @returns {void}
672	 */
673	function masonrySliderResized() {
674		/*jshint validthis:true */
675		$( this ).closest( '.post-entries' ).masonry( 'layout' );
676	}
677
678	/**
679	 * Handle resize event
680	 *
681	 * @returns {void}
682	 */
683	function onResize() {
684
685		var width = $window.width();
686
687		// Only on width resize
688		if ( width !== windowLastWidth ) {
689
690			// Save new window width
691			windowLastWidth = width;
692
693			// Recalculate header positions
694			setHeaderPositions();
695
696			// Recalculate mega menus positions
697			setMegaMenusPositions();
698
699			// Recalculate heights
700			calculateHeight();
701
702			// Responsive animate hover
703			animateHoverSmall();
704
705		}
706
707		// Footer uncover
708		footerUncover();
709	}
710
711	/**
712	 * On DOM ready
713	 *
714	 * @returns {void}
715	 */
716	$( document ).ready( function() {
717
718		// Calculate positions for header elements
719		$wpadminbar = $( '#wpadminbar' );
720		$wcDemoStore = $( '.demo_store ');
721		$navbar = $( '.navbar-primary' );
722		setHeaderPositions();
723
724		// Detect if dropdown navigation would go off screen and reposition it
725		$body.on( 'mouseenter mouseleave', '.navbar-primary .menu-item-has-children', function( e ) {
726			if ( $window.width() > 740 ) {
727				var $subMenu = $( this ).find( '>
727 .sub-menu-container > .sub-menu' );
728
729				if ( $subMenu.length > 0 ) {
730					if ( ( $wrapper.width() - $subMenu.offset().left - $wrapper.offset().left - $subMenu.width() ) < 0 ) {
731						$subMenu.addClass( 'off-left' );
732					} else if ( $subMenu.hasClass( 'off-left' ) ) {
733						$subMenu.removeClass( 'off-left' );
734					}
735				}
736			}
737		} );
738
739		// Inview animations
740		if ( $.fn.waypoint ) {
741			$( '.pie-chart-in-view' ).waypoint( {
742				context    : window,
743				continuous : true,
744				enabled    : true,
745				horizontal : false,
746				//offset     : 'bottom-in-view',
747				//offset     : '90%',
748				offset     : function() {
749					var windowHeight = $window.height(),
750						positionMin = windowHeight - 100,
751						positionHalf = windowHeight - this.clientHeight / 2;
752
753					return positionMin < positionHalf ? positionMin : positionHalf;
754				},
755				triggerOnce: true,
756				handler    : function( direction ) {
757					$( '.pie-chart', this ).each( function() {
758						var $element = $( this ),
759							colorEmpty = $element.data( 'color_empty' ),
760							colorFill = $element.data( 'color_fill' );
761
762						$element.easyPieChart( {
763							barColor  : ( colorFill && colorFill !== '' ) ? colorFill : '#616161',
764							trackColor: ( colorEmpty && colorEmpty !== '' ) ? colorEmpty : '#dddddd',
765							scaleColor: false,
766							lineCap   : 'round',
767							lineWidth : intRangeDefault( $element.data( 'line_width' ), 1, 100, 10 ),
768							size      : intRangeDefault( $element.data( 'size' ), 10, false, 200 ),
769							easing    : 'easeOutCubic',
770							onStep    : function( from, to, percent ) {
771								$( this.el ).find( '.percent' ).text( Math.round( percent ) );
772							},
773							animate: {
774								duration: 2000,
775								enabled: true
776							}
777						} );
778					} );
779				}
780			} );
781
782			$( '.animate-in-view' ).waypoint( {
783				context    : window,
784				continuous : true,
785				enabled    : true,
786				horizontal : false,
787				//offset     : 'bottom-in-view',
788				//offset     : '90%',
789				offset     : function() {
790					var windowHeight = $window.height(),
791						positionMin = windowHeight - 100,
792						positionHalf = windowHeight - this.clientHeight / 2;
793
794					return positionMin < positionHalf ? positionMin : positionHalf;
795				},
796				triggerOnce: true,
797				handler    : function( direction ) {
798					var $element = $( this ),
799						animation = $element.data( 'animation' ),
800						animationSpeed = $element.data( 'animation-speed' );
801
802					if ( typeof animation !== 'undefined' && animation !== '' ) {
803
804						if ( typeof animationSpeed !== 'undefined' && animationSpeed !== '' ) {
805							animationSpeed += 's';
806							$element.css( {
807								'-moz-animation-duration': animationSpeed,
808								'-ms-animation-duration': animationSpeed,
809								'-o-animation-duration': animationSpeed,
810								'animation-duration': animationSpeed
811							} );
812						}
813
814						$element.one( 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
815							$element.removeClass( 'animated ' + animation );
816							if ( animation.indexOf( 'Out' ) !== -1 ) {
817								$element.css( { opacity: 0 } );
818							}
819						} );
820						$element
821							.addClass( 'animated ' + animation )
822							.removeClass( 'galactica-animate-hide' );
823
824					}
825				}
826			} );
827
828			$( '.shortcode-popup-trigger-in-view' ).waypoint( {
829				context    : window,
830				continuous : true,
831				enabled    : true,
832				horizontal : false,
833				//offset     : 'bottom-in-view',
834				//offset     : '90%',
835				offset     : function() {
836					var windowHeight = $window.height(),
837						positionMin = windowHeight - 100,
838						positionHalf = windowHeight - this.clientHeight / 2;
839
840					return positionMin < positionHalf ? positionMin : positionHalf;
841				},
842				triggerOnce: true,
843				handler    : function( direction ) {
844					var $this  = $( this ),
845						target = $this.data( 'target' );
846
847					if ( $.fn.modal && $this.data( 'popup-type' ) === 'bootstrap' ) {
848						// Bootstrap modal popup
849						$( target ).modal( 'show' );
850					} else if ( $.fn.iLightBox ) {
851						// iLightBox popup
852						$.iLightBox( [{
853							skin   : adamaSettings.lightboxSkin || 'dark',
854							type   : $this.data( 'type' ) || 'inline',
855							url    : target,
856							title  : $this.data( 'title' ),
857							options: {
858								width   : $this.data( 'width' ),
859								height  : $this.data( 'height' ),
860								onRender: function( iL ) {
861									iL.element[0].className += ' lightbox-popup-wrap';
862								}
863							}
864						}] );
865					}
866				}
867			} );
868		}
869
870		// Start Owl carousels
871		if ( $.fn.owlCarousel ) {
872			$( '.owl-carousel' ).each( function() {
873				var $element = $( this ),
874					items = intRangeDefault( $element.data( 'items' ), 1, false, 4 ),
875					settings = {
876						items             : items,
877						loop              : boolDefault( $element.data( 'loop' ), false ),
878						center            : boolDefault( $element.data( 'center' ), false ),
879						margin            : intRangeDefault( $element.data( 'margin' ), 0, false, 10 ),
880						startPosition     : intRangeDefault( $element.data( 'start' ), 0, false, 0 ),
881						nav               : boolDefault( $element.data( 'show_nav' ), true ),
882						dots              : boolDefault( $element.data( 'show_indicators' ), false ),
883						autoplay          : boolDefault( $element.data( 'autoplay' ), true ),
884						autoplayTimeout   : intRangeDefault( $element.data( 'interval' ), 100, false, 3000 ),
885						autoplayHoverPause: boolDefault( $element.data( 'pause' ), true ),
886						navText           : [ '', '' ],
887						responsive : {
888							// Breakpoint from 0 up
889							0 : {
890								items : 1
891							},
892							// Breakpoint from 768 up
893							768 : {
894								items : ( items > 1 ) ? 2 : 1
895							},
896							// Breakpoint from 992 up
897							992 : {
898								items : items
899							}
900						}
901					};
902
903				$element.owlCarousel( settings );
904			});
905		}
906
907		// Validate contact forms
908		$body.on( 'submit', '.comment-form', validateForm );
909
910		// Toggle shortcode
911		$body.on( 'click', '.shortcode-toggle-trigger', shortcodeToggle );
912
913		// Init Google Maps
914		if ( typeof google === 'object' && typeof google.maps === 'object' ) {
915			$( '.google-map' ).each( function() {
916				var $element = $( this ),
917					addresses = $element.data( 'address' ),
918					tooltips = $element.data( 'tooltip' ),
919					tooltip,
920					geocoder = new google.maps.Geocoder(),
921					infoWindow = new google.maps.InfoWindow(),
922					mapCentered = false,
923					map = new google.maps.Map( this, {
924						mapTypeId  : google.maps.MapTypeId[$element.data( 'type' ).toUpperCase()],
925						zoom       : intRangeDefault( $element.data( 'zoom' ), 1, 20, 15 ),
926						scrollwheel: boolDefault( $element.data( 'scrollwheel_enabled' ), false )
927					} );
928
929				if ( !addresses ) {
930					return;
931				}
932
933				addresses = addresses.split( '|' );
934
935				if ( tooltips ) {
936					tooltips = tooltips.split( '|' );
937				}
938
939				for ( var i = 0; i < addresses.length; i++ ) {
940					tooltip = ( tooltips && tooltips[i] ) ? tooltips[i] : addresses[i];
941					googleMapInit( geocoder, infoWindow, map, mapCentered, addresses[i], tooltip, i );
942				}
943			});
944		}
945
946		// Slideout Sidebar
947		var $sidebarSlideout = $( '#sidebar-slideout' );
948		if ( $sidebarSlideout.length ) {
949			$body.on( 'click', '.toggle-sidebar-slideout', function( e ) {
950				e.preventDefault();
951
952				if ( $sidebarSlideout.is( ':visible' ) ) {
953					if ( window.Modernizr && Modernizr.cssanimations ) {
954						$sidebarSlideout.one( 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
955							$sidebarSlideout
956								.hide()
957								.removeClass( 'animated bounceOutRight' );
958						} );
959
960						$sidebarSlideout.addClass( 'animated bounceOutRight' );
961					} else {
962						$sidebarSlideout.hide();
963					}
964				} else {
965					$sidebarSlideout.one( 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
966						$sidebarSlideout.removeClass( 'animated bounceInRight' );
967					} );
968
969					var top = $body.children( '.wrapper' ).position().top;
970					$sidebarSlideout
971						.css( { top: top } )
972						.show()
973						.addClass( 'animated bounceInRight' );
974				}
975			} );
976		}
977
978		// Scroll to top
979		if ( $.fn.UItoTop && adamaSettings.footerEnableToTop === '1' ) {
980			$().UItoTop( {
981				easingType: 'easeOutQuart'
982			});
983		}
984
985		// WooCommerce - Add to cart spinner
986		$body.on( 'adding_to_cart', function( e, $thisbutton, data ) {
987			var $product = $thisbutton.closest( '.product' );
988			$product.find( '.add-to-cart-spinner > .fa-check-circle-o' ).removeClass( 'fa-check-circle-o' ).addClass( 'fa-spinner fa-spin' );
989
990			// Show add to cart spinner
991			$product.find( '.add-to-cart-spinner' ).show();
992		});
993		$body.on( 'added_to_cart', function() {
994			// Hide add to cart spinner
995			var added = $( '.add-to-cart-hover .added' );
996			for ( var i = 0; i < added.length; i++ ) {
997				var $product = $( added[i] ).closest( '.product' );
998				$product.find( '.add-to-cart-spinner > .fa-spinner' ).removeClass( 'fa-spinner fa-spin' ).addClass( 'fa-check-circle-o' );
999
1000				// Hide add to cart spinner
1001				$product.find( '.add-to-cart-spinner' ).fadeOut( 2000 );
1002			}
1003		});
1004
1005		// Tooltips init
1006		if ( $.fn.tooltip ) {
1007			$( '[data-toggle="tooltip"]' ).tooltip();
1008		}
1009
1010		// MixItUp
1011		if ( $.fn.mixitup ) {
1012			$( '.mixitup' ).mixitup();
1013		}
1014
1015		// Lightbox
1016		if ( $.fn.iLightBox ) {
1017			$body
1018				// Archive zoom
1019				.on( 'click', '.zoom-archive', function( e ) {
1020					e.preventDefault();
1021
1022					var $this = $( this ),
1023						images = [{	url: $this.attr( 'href' ) }],
1024						imagesGallery = $this.data( 'images' ),
1025						controls = {};
1026
1027					if ( imagesGallery ) {
1028						images = images.concat( imagesGallery );
1029
1030						controls = {
1031							arrows: boolDefault( adamaSettings.lightboxShowArrows, true ),
1032							thumbnail: boolDefault( adamaSettings.lightboxShowThumnails, false )
1033						};
1034					}
1035
1036					$.iLightBox( images, {
1037						skin: adamaSettings.lightboxSkin || 'dark',
1038						path: adamaSettings.lightboxDirection,
1039						controls: controls
1040					} );
1041				} )
1042				// Shortcode popup
1043				.on( 'click', '.shortcode-popup-trigger-click', function() {
1044					var $this = $( this );
1045					$.iLightBox( [{
1046						skin   : adamaSettings.lightboxSkin || 'dark',
1047						type   : $this.data( 'type' ) || 'inline',
1048						url    : $this.data( 'target' ),
1049						title  : $this.data( 'title' ),
1050						options: {
1051							width   : $this.data( 'width' ),
1052							height  : $this.data( 'height' ),
1053							onRender: function( iL ) {
1054								iL.element[0].className += ' lightbox-popup-wrap';
1055							}
1056						}
1057					}] );
1058				} );
1059
1060			// Attach to all links that have img as direct child
1061			if ( boolDefault( adamaSettings.lightboxEnableForPosts, true ) ) {
1062				$( '.entry-content a:not(.zoom) > img' ).each( function() {
1063
1064					// Try to detect if a.href is link to image, we don't need lightbox for page links
1065					if ( this.src && this.parentElement.href && this.src.slice( -4 ) === this.parentElement.href.slice( -4 ) ) {
1066						$( this ).parent()
1067							.addClass( 'zoom' );
1068//							.attr( 'data-rel', 'prettyPhoto[gallery]' );
1069					}
1070
1071				} );
1072			}
1073			zoomLightBox();
1074		}
1075
1076		// Animations
1077		// NOTE: hover animations are done without JS
1078		$body.on( 'click', '.animate-click', function() {
1079			var $this = $( this ),
1080				$animatedElement = $this.siblings( '.animate-wr' ),
1081				animateIn = $this.data( 'animate-in' ),
1082				animateOut = $this.data( 'animate-out' ),
1083				animate = $animatedElement.is( ':hidden' ) ? animateIn : animateOut;
1084
1085			if ( typeof animate !== 'undefined' && animate !== '' ) {
1086				$animatedElement.one( 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
1087					$animatedElement.removeClass( animateIn + ' ' + animateOut );
1088				} );
1089
1090				$animatedElement
1091					.removeClass( animateIn + ' ' + animateOut )
1092					.addClass( animate );
1093			}
1094		} );
1095
1096
1097		// Placeholder support for old browsers
1098		if ( $.placeholder && !$.placeholder.browser_supported() ) {
1099			$.placeholder.shim();
1100
1101			$body.on( 'click', '.comment-reply-link, #cancel-comment-reply-link', function() {
1102				$.placeholder.shim();
1103			} );
1104		}
1105	} );
1106
1107	/**
1108	 * On window load - Runs after all media is loaded
1109	 *
1110	 * @returns {void}
1111	 */
1112	$window.load( function() {
1113		// Recalculate heights
1114		calculateHeight();
1115
1116		// Set positions for Mega menus
1117		setMegaMenusPositions();
1118
1119		// Footer uncover
1120		footerUncover();
1121
1122		// Responsive animate hover
1123		animateHoverSmall();
1124
1125		// Handle infinite scroll
1126		infiniteScrollLoadMore();
1127
1128		// Masonry
1129		if ( $.fn.masonry ) {
1130			// Reposition masonry after slider resize
1131			var debounceMasonrySliderResized = debounce( masonrySliderResized, 200, false );
1132
1133			// Init masonry
1134			$( '.masonry .post-entries' )
1135				.masonry( {
1136					itemSelector: '.post'
1137				} )
1138				.on( 'resized.owl.carousel', '.owl-carousel', debounceMasonrySliderResized );
1139		}
1140
1141		// Recalculate heights after carosuel resize
1142		for ( var i = 0; i < adamaSettings.equalHeight.length; i++ ) {
1143			if ( 'carousel' in adamaSettings.equalHeight[i] ) {
1144				var $carousel = $( adamaSettings.equalHeight[i].carousel ),
1145					dataSelectors = [];
1146
1147				if ( !$carousel.length ) {
1148					continue;
1149				}
1150
1151				if ( !$carousel.hasClass( 'carousel-equal' ) ) {
1152					$carousel.addClass( 'carousel-equal' );
1153
1154					// NOTE: Debounce will not work if multiple carousels on page
1155					$carousel.on( 'resized.owl.carousel', equalHeightSliderResized );
1156				} else {
1157					dataSelectors = $carousel.data( 'equal' );
1158				}
1159
1160				dataSelectors.push( adamaSettings.equalHeight[i].selector );
1161				$carousel.data( 'equal', dataSelectors );
1162			}
1163		}
1164
1165		// Popup init
1166		$( '.shortcode-popup-trigger-load' ).each( function() {
1167			var $this  = $( this ),
1168				target = $this.data( 'target' ),
1169				delay  = parseInt( $this.data( 'trigger-delay' ) ) * 1000;
1170
1171			window.setTimeout( function() {
1172				if ( $.fn.modal && $this.data( 'popup-type' ) === 'bootstrap' ) {
1173					// Bootstrap modal popup
1174					$( target ).modal( 'show' );
1175				} else if ( $.fn.iLightBox ) {
1176					// iLightBox popup
1177					$.iLightBox( [{
1178						skin   : adamaSettings.lightboxSkin || 'dark',
1179						type   : $this.data( 'type' ) || 'inline',
1180						url    : target,
1181						title  : $this.data( 'title' ),
1182						options: {
1183							width   : $this.data( 'width' ),
1184							height  : $this.data( 'height' ),
1185							onRender: function( iL ) {
1186								iL.element[0].className += ' lightbox-popup-wrap';
1187							}
1188						}
1189					}] );
1190				}
1191			}, delay );
1192
1193		} );
1194	} );
1195
1196	// On window resize (debounced)
1197	var debounceOnResize = debounce( onResize, 128, false );
1198	$window.resize( debounceOnResize );
1199
1200	/**
1201	 * On window scroll
1202	 *
1203	 * @returns {void}
1204	 */
1205	$window.on( 'scroll', function() {
1206
1207		// Handle infinite scroll
1208		infiniteScrollLoadMore();
1209
1210	} );
1211
1212})( jQuery );

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.