PageSourceSearch

https://www.ipb.ac.id/wp-content/themes/mitech/assets/js/main.js

js ipb.ac.id collected 2026-09-24 08:42:26 UTC 49,000 bytes, 1,988 lines download raw bytes

1(
2	function( $ ) {
3		'use strict';
4
5		$.fn.insightSwiper = function() {
6			var $swiper;
7
8			this.each( function() {
9
10				var $slider = $( this );
11				var $sliderInner = $slider.children( '.swiper-inner' ).first();
12				var _settings = $slider.data();
13
14				if ( _settings.queueInit == '0' ) {
15					return;
16				}
17
18				var $sliderContainer = $sliderInner.children( '.swiper-container' ).first(),
19				    lgItems          = _settings.lgItems ? _settings.lgItems : 1,
20				    mdItems          = _settings.mdItems ? _settings.mdItems : lgItems,
21				    smItems          = _settings.smItems ? _settings.smItems : mdItems,
22				    xsItems          = _settings.xsItems ? _settings.xsItems : smItems,
23				    lgGutter         = _settings.lgGutter ? _settings.lgGutter : 0,
24				    mdGutter         = _settings.mdGutter ? _settings.mdGutter : lgGutter,
25				    smGutter         = _settings.smGutter ? _settings.smGutter : mdGutter,
26				    xsGutter         = _settings.xsGutter ? _settings.xsGutter : smGutter,
27				    speed            = _settings.speed ? _settings.speed : 1000;
28
29				if ( _settings.slideWrap ) {
30					$sliderInner.children( '.swiper-container' )
31					            .children( '.swiper-wrapper' )
32					            .children( 'div' )
33					            .wrap( "<div class='swiper-slide'><div class='swiper-slide-inner'></div></div>" );
34				}
35
36				if ( lgItems == 'auto' ) {
37					var _options = {
38						slidesPerView: 'auto',
39						spaceBetween: lgGutter,
40						breakpoints: {
41							// when window width is >=
42							767: {
43								spaceBetween: smGutter
44							},
45							990: {
46								spaceBetween: mdGutter
47							},
48							1199: {
49								spaceBetween: lgGutter
50							}
51						}
52					};
53				} else {
54					var _options = {
55						slidesPerView: xsItems, //slidesPerGroup: lgItems,
56						spaceBetween: xsGutter,
57						breakpoints: {
58							// when window width is <=
59							767: {
60								slidesPerView: smItems,
61								spaceBetween: smGutter
62							},
63							990: {
64								slidesPerView: mdItems,
65								spaceBetween: mdGutter
66							},
67							1199: {
68								slidesPerView: lgItems,
69								spaceBetween: lgGutter
70							}
71						}
72					};
73
74					if ( _settings.slidesPerGroup == 'inherit' ) {
75						_options.slidesPerGroup = xsItems;
76
77						_options.breakpoints[ 767 ].slidesPerGroup = smItems;
78						_options.breakpoints[ 990 ].slidesPerGroup = mdItems;
79						_options.breakpoints[ 1199 ].slidesPerGroup = lgItems;
80					}
81				}
82
83				_options.el = $sliderContainer;
84				_options.init = false;
85
86				_options.watchOverflow = true;
87
88				if ( _settings.slideColumns ) {
89					_options.slidesPerColumn = _settings.slideColumns;
90				}
91
92				if ( _settings.initialSlide ) {
93					_options.initialSlide = _settings.initialSlide;
94				}
95
96				if ( _settings.autoHeight ) {
97					_options.autoHeight = true;
98				}
99
100				if ( speed ) {
101					_options.speed = speed;
102				}
103
104				// Maybe: fade, flip
105				if ( _settings.effect ) {
106					_options.effect = _settings.effect;
107					/*_options.fadeEffect = {
108						crossFade: true
109					};*/
110				}
111
112				if ( _settings.loop ) {
113					_options.loop = true;
114				}
115
116				if ( _settings.centered ) {
117					_options.centeredSlides = true;
118				}
119
120				if ( _settings.autoplay ) {
121					_options.autoplay = {
122						delay: _settings.autoplay,
123						disableOnInteraction: false
124					};
125				}
126
127				if ( _settings.freemode ) {
128					_options.freeMode = true;
129				}
130
131				var $wrapTools;
132
133				if ( _settings.wrapTools ) {
134					$wrapTools = $( '<div class="swiper-tools"></div>' );
135
136					$slider.append( $wrapTools );
137				}
138
139				if ( _settings.nav ) {
140
141					if ( _settings.customNav && _settings.customNav !== '' ) {
142						var $customBtn = $( '#' + _settings.customNav );
143						var $swiperPrev = $customBtn.find( '.slider-prev-btn' );
144						var $swiperNext = $customBtn.find( '.slider-next-btn' );
145					} else {
146						var $swiperPrev = $( '<div class="swiper-nav-button swiper-button-prev"><i class="nav-button-icon"></i></div>' );
147						var $swiperNext = $( '<div class="swiper-nav-button swiper-button-next"><i class="nav-button-icon"></i></div>' );
148
149						var $swiperNavButtons = $( '<div class="swiper-nav-buttons"></div>' );
150						$swiperNavButtons.append( $swiperPrev ).append( $swiperNext );
151
152						if ( $wrapTools ) {
153							$wrapTools.append( $swiperNavButtons );
154						} else {
155							$sliderInner.append( $swiperNavButtons );
156						}
157					}
158
159					_options.navigation = {
160						nextEl: $swiperNext,
161						prevEl: $swiperPrev
162					};
163				}
164
165				if ( _settings.pagination ) {
166					var $swiperPagination = $( '<div class="swiper-pagination"></div>' );
167
168					if ( $wrapTools ) {
169						$wrapTools.append( $swiperPagination );
170					} else {
171						$slider.append( $swiperPagination );
172					}
173
174					_options.pagination = {
175						el: $swiperPagination,
176						clickable: true
177					};
178				}
179
180				if ( _settings.scrollbar ) {
181					var $scrollbar = $( '<div class="swiper-scrollbar"></div>' );
182					$sliderContainer.prepend( $scrollbar );
183
184					_options.scrollbar = {
185						el: $scrollbar,
186						draggable: true,
187					};
188
189					_options.loop = false;
190				}
191
192				if ( _settings.mousewheel ) {
193					_options.mousewheel = {
194						enabled: true
195					};
196				}
197
198				if ( _settings.vertical ) {
199					_options.direction = 'vertical'
200				}
201
202				$swiper = new Swiper( _options );
203
204				if ( _settings.reinitOnResize ) {
205					var _timer;
206					$( window ).resize( function() {
207						clearTimeout( _timer );
208
209						_timer = setTimeout( function() {
210							$swiper.destroy( true, true );
211
212							$swiper = new Swiper( $sliderContainer, _options );
213						}, 300 );
214					} );
215				}
216
217				// Disabled auto play when focus.
218				if ( _settings.autoplay ) {
219					$sliderContainer.hoverIntent( function() {
220						$swiper.autoplay.stop();
221					}, function() {
222						$swiper.autoplay.start();
223					} );
224				}
225
226				$swiper.init();
227
228				$( document ).trigger( 'insightSwiperInit', [ $swiper, $slider, _options ] );
229			} );
230
231			return $swiper;
232		};
233	}( jQuery )
234);
235
236(
237	function( $ ) {
238		'use strict';
239
240var $window            = $( window ),
241    $html              = $( 'html' ),
242    $body              = $( 'body' ),
243    $pageWrapper       = $( '#page' ),
244    $pageHeader        = $( '#page-header' ),
245    $headerInner       = $( '#page-header-inner' ),
246    $pageContent       = $( '#page-content' ),
247    headerStickyEnable = $insight.header_sticky_enable,
248    headerStickyHeight = parseInt( $insight.header_sticky_height ),
249    queueResetDelay,
250    animateQueueDelay  = 200,
251    wWidth             = window.innerWidth;
252/**
253 * Global ajaxBusy = false
254 * Desc: Status of ajax
255 */
256var ajaxBusy = false;
257$( document ).ajaxStart( function() {
258	ajaxBusy = true;
259} ).ajaxStop( function() {
260	ajaxBusy = false;
261} );
262
263$( window ).on( 'resize', function() {
264	$body.addClass( 'window-resized' );
265	wWidth = window.innerWidth;
266
267	calMobileMenuBreakpoint();
268	reCalculateVcRowFullHeight();
269	boxedFixVcRow();
270	calculateLeftHeaderSize();
271	initStickyHeader();
272	initFooterParallax();
273	initFooterFixed();
274} );
275
276$( window ).on( 'load', function() {
277	initPreLoader();
278	initStickyHeader();
279
280	window.dispatchEvent( new Event( 'resize' ) );
281} );
282
283$( document ).on( 'vc-full-width-row', calculateLeftHeaderSize );
284
285$( document ).ready( function() {
286	// Call functions in load event to make header sticky working properly.
287	initQueueAnimationForElements();
288	initAnimationForElements();
289
290	calMobileMenuBreakpoint();
291	reCalculateVcRowFullHeight();
292	boxedFixVcRow();
293
294	marqueBackground();
295	scrollToTop();
296
297	// Remove empty p tags form wpautop.
298	$( 'p:empty' ).each( function() {
299		if ( 0 >= this.attributes.length ) {
300			$( this ).remove();
301		}
302	} );
303
304	insightInitGrid();
305	initSliders();
306
307	setTimeout( function() {
308		navOnePage();
309	}, 100 );
310
311	initFooterParallax();
312	initFooterFixed();
313	initSmoothScrollLinks();
314	initLightGalleryPopups();
315	initVideoPopups();
316	initMapPopups();
317	initSearchPopup();
318	initHeaderRightMoreTools();
319	initOffSidebar();
320
321	insightInitSmartmenu();
322	initOffCanvasMenu();
323	initMobileMenu();
324	initCookieNotice();
325	initNewsletterPopup();
326	handlerEntryPostShare();
327} );
328
329function initSliders() {
330	$( '.mitech-swiper' ).each( function() {
331		if ( $( this ).hasClass( 'mitech-swiper-linked-yes' ) ) {
332			var mainSlider = $( this ).children( '.mitech-main-swiper' ).insightSwiper();
333			var thumbsSlider = $( this ).children( '.mitech-thumbs-swiper' ).insightSwiper();
334
335			mainSlider.controller.control = thumbsSlider;
336			thumbsSlider.controller.control = mainSlider;
337		} else {
338			$( this ).insightSwiper();
339		}
340	} );
341}
342
343function initPreLoader() {
344	setTimeout( function() {
345		$body.addClass( 'loaded' );
346	}, 200 );
347
348	var $loader = $( '#page-preloader' );
349
350	setTimeout( function() {
351		$loader.remove();
352	}, 2000 );
353}
354
355function initLightGalleryPopups() {
356	$( '.tm-light-gallery' ).each( function() {
357		insightInitLightGallery( $( this ) );
358	} );
359}
360
361function initVideoPopups() {
362	$( '.tm-popup-video' ).each( function() {
363		handlerPopupVideo( $( this ) );
364	} );
365}
366
367function handlerPopupVideo( $popup ) {
368	var options = {
369		selector: 'a',
370		fullScreen: false,
371		zoom: false
372	};
373	$popup.lightGallery( options );
374}
375
376function initMapPopups() {
377	$( '.tm-popup-map' ).each( function() {
378		handlerPopupMap( $( this ).children( 'a' ) );
379	} );
380}
381
382function handlerPopupMap( $popup ) {
383	var options = {
384		selector: 'this',
385		iframeMaxWidth: '80%',
386		autoplay: false,
387		fullScreen: false,
388		zoom: false,
389		hash: false,
390		share: false,
391		pager: false,
392		animateThumb: false,
393		showThumbByDefault: false,
394		getCaptionFromTitleOrAlt: false
395	};
396	$popup.lightGallery( options );
397}
398
399function marqueBackground() {
400	$( '.background-marque' ).each( function() {
401		var $el = $( this );
402		var x = 0;
403		var step = 1;
404		var speed = 10;
405
406		if ( $el.hasClass( 'to-left' ) ) {
407			step = - 1;
408		}
409
410		$el.css( 'background-repeat', 'repeat-x' );
411
412		var loop = setInterval( function() {
413			x += step;
414			$el.css( 'background-position-x', x + 'px' );
415		}, speed );
416
417		if ( $el.data( 'marque-pause-on-hover' ) == true ) {
418			$( this ).hoverIntent( function() {
419				clearInterval( loop );
420			}, function() {
421				loop = setInterval( function() {
422					x += step;
423					$el.css( 'background-position-x', x + 'px' );
424				}, speed );
425			} );
426		}
427	} );
428}
429
430function initSmoothScrollLinks() {
431	// Allows for easy implementation of smooth scrolling for buttons.
432	$( '.smooth-scroll-link' ).on( 'click', function( e ) {
433		var href = $( this ).attr( 'href' );
434
435		if ( ! href ) {
436			href = $( this ).data( 'href' );
437		}
438
439		var _wWidth = window.innerWidth;
440		if ( href.match( /^([.#])(.+)/ ) ) {
441			e.preventDefault();
442			var offset = 0;
443			if ( $insight.header_sticky_enable == 1 && $pageHeader.length > 0 && $headerInner.data( 'sticky' ) == '1' ) {
444
445				if ( $headerInner.data( 'header-position' ) === 'left' ) {
446					if ( _wWidth < $insight.mobile_menu_breakpoint ) {
447						offset += headerStickyHeight;
448					}
449				} else {
450					offset += headerStickyHeight;
451				}
452			}
453
454			// Add offset of admin bar when viewport min-width 600.
455			if ( _wWidth > 600 ) {
456				var $adminBar = $( '#wpadminbar' );
457
458				if ( $adminBar.length > 0 ) {
459					var adminBarHeight = $adminBar.height();
460					offset += adminBarHeight;
461				}
462			}
463
464			$.smoothScroll( {
465				offset: - offset,
466				scrollTarget: $( href ),
467				speed: 600,
468				easing: 'linear'
469			} );
470		}
471	} );
472}
473
474function initAnimationForElements() {
475	if ( ! $body.hasClass( 'page-has-animation' ) ) {
476		return;
477	}
478
479	var $animations = $pageContent.find( '.tm-animation' );
480
481	$animations.vcwaypoint( function() {
482		// Fix for different ver of waypoints plugin.
483		var _self = this.element ? this.element : $( this );
484		$( _self ).addClass( 'animate' );
485	}, {
486		offset: '100%' // triggerOnce: true
487	} );
488}
489
490function initQueueAnimationForElements() {
491	$( '.tm-animation-queue' ).each( function() {
492		var itemQueue  = [],
493		    queueTimer,
494		    queueDelay = $( this ).data( 'animation-delay' ) ? $( this ).data( 'animation-delay' ) : animateQueueDelay;
495
496		$( this ).children( '.item' ).vcwaypoint( function() {
497			// Fix for different ver of waypoints plugin.
498			var _self = this.element ? this.element : $( this );
499
500			queueResetDelay = setTimeout( function() {
501				queueDelay = animateQueueDelay;
502			}, animateQueueDelay );
503
504			itemQueue.push( _self );
505			processItemQueue( itemQueue, queueDelay, queueTimer );
506			queueDelay += animateQueueDelay;
507		}, {
508			offset: '90%',
509			triggerOnce: true
510		} );
511	} );
512}
513
514function processItemQueue( itemQueue, queueDelay, queueTimer, queueResetDelay ) {
515	clearTimeout( queueResetDelay );
516	queueTimer = window.setInterval( function() {
517		if ( itemQueue !== undefined && itemQueue.length ) {
518			$( itemQueue.shift() ).addClass( 'animate' );
519			processItemQueue();
520		} else {
521			window.clearInterval( queueTimer );
522		}
523	}, queueDelay );
524}
525
526function insightInitSmartmenu() {
527	var $primaryMenu = $pageHeader.find( '#page-navigation' ).find( 'ul' ).first();
528
529	if ( ! $primaryMenu.hasClass( 'sm' ) ) {
530		return;
531	}
532
533	$primaryMenu.smartmenus( {
534		subMenusSubOffsetX: 0,
535		subMenusSubOffsetY: - 17
536	} );
537
538	// Add animation for sub menu.
539	$primaryMenu.on( {
540		'show.smapi': function( e, menu ) {
541			$( menu ).removeClass( 'hide-animation' ).addClass( 'show-animation' );
542		},
543		'hide.smapi': function( e, menu ) {
544			$( menu ).removeClass( 'show-animation' ).addClass( 'hide-animation' );
545		}
546	} ).on( 'animationend webkitAnimationEnd oanimationend MSAnimationEnd', 'ul', function( e ) {
547		$( this ).removeClass( 'show-animation hide-animation' );
548		e.stopPropagation();
549	} );
550}
551
552function insightInitLightGallery( $gallery ) {
553	var _download   = (
554		    $insight.light_gallery_download === '1'
555	    ),
556	    _autoPlay   = (
557		    $insight.light_gallery_auto_play === '1'
558	    ),
559	    _zoom       = (
560		    $insight.light_gallery_zoom === '1'
561	    ),
562	    _fullScreen = (
563		    $insight.light_gallery_full_screen === '1'
564	    ),
565	    _share      = (
566		    $insight.light_gallery_share === '1'
567	    ),
568	    _thumbnail  = (
569		    $insight.light_gallery_thumbnail === '1'
570	    );
571
572	var options = {
573		selector: '.zoom',
574		thumbnail: _thumbnail,
575		download: _download,
576		autoplay: _autoPlay,
577		zoom: _zoom,
578		share: _share,
579		fullScreen: _fullScreen,
580		hash: false,
581		animateThumb: false,
582		showThumbByDefault: false,
583		getCaptionFromTitleOrAlt: false
584	};
585
586	$gallery.lightGallery( options );
587}
588
589function animateMagicLineOnScroll( $li, onScroll ) {
590	if ( onScroll == false ) {
591		$li.siblings( 'li' ).removeClass( 'current-menu-item' );
592		$li.addClass( 'current-menu-item' );
593	}
594}
595
596function navOnePage() {
597	if ( ! $body.hasClass( 'one-page' ) ) {
598		return;
599	}
600	var $header = $( '#page-header' );
601	var $headerInner = $header.children( '#page-header-inner' );
602	var $mainNav = $( '#page-navigation' ).find( '.menu__container' ).first();
603	var $li = $mainNav.children( '.menu-item' );
604	var $links = $li.children( 'a[href*="#"]:not([href="#"])' );
605	var onScroll = false;
606
607	var offset = 0;
608
609	if ( $body.hasClass( 'admin-bar' ) ) {
610		offset += 32;
611	}
612
613	if ( headerStickyEnable == 1 && $headerInner.data( 'sticky' ) == '1' ) {
614		offset += headerStickyHeight;
615		offset = - offset;
616	}
617
618	$li.each( function() {
619		if ( $( this ).hasClass( 'current-menu-item' ) ) {
620			var _link = $( this ).children( 'a' );
621
622			if ( _link[ 0 ].hash !== '' ) {
623				$( this ).removeClass( 'current-menu-item' );
624			}
625		}
626	} );
627
628	$links.each( function() {
629		var $this = $( this );
630		var id = this.hash;
631		var parent = $this.parent();
632
633		if ( $( id ).length > 0 ) {
634			$( id ).vcwaypoint( function( direction ) {
635				if ( direction === 'down' ) {
636					animateMagicLineOnScroll( parent, onScroll );
637				}
638			}, {
639				offset: '25%'
640			} );
641
642			$( id ).vcwaypoint( function( direction ) {
643				if ( direction === 'up' ) {
644					animateMagicLineOnScroll( parent, onScroll );
645				}
646			}, {
647				offset: '-25%'
648			} );
649		}
650	} );
651
652	// Allows for easy implementation of smooth scrolling for navigation links.
653	$links.on( 'click', function() {
654		var $this = $( this );
655		var href = this.hash;
656		var parent = $this.parent( 'li' );
657
658		parent.siblings( 'li' ).removeClass( 'current-menu-item' );
659		parent.addClass( 'current-menu-item' );
660
661		if ( $( href ).length > 0 ) {
662			$.smoothScroll( {
663				offset: offset,
664				scrollTarget: $( href ),
665				speed: 600,
666				easing: 'linear',
667				beforeScroll: function() {
668					onScroll = true;
669				},
670				afterScroll: function() {
671					onScroll = false;
672				}
673			} );
674		}
675
676		return false;
677	} );
678
679	// Smooth scroll to section if url has hash tag when page loaded.
680	var hashTag = window.location.hash;
681	if ( hashTag && $( hashTag ).length > 0 ) {
682		$.smoothScroll( {
683			offset: offset,
684			scrollTarget: $( hashTag ),
685			speed: 600,
686			easing: 'linear',
687			beforeScroll: function() {
688				onScroll = true;
689			},
690			afterScroll: function() {
691				onScroll = false;
692			}
693		} );
694	}
695}
696
697function initFooterParallax() {
698	var footerWrap = $( '#page-footer-wrapper' );
699
700	if ( ! footerWrap.hasClass( 'parallax' ) || $body.hasClass( 'page-template-one-page-scroll' ) ) {
701		return;
702	}
703
704	if ( footerWrap.length > 0 ) {
705		var contentWrap = $pageWrapper.children( '.content-wrapper' );
706		if ( wWidth >= 1024 ) {
707			var fwHeight = footerWrap.height();
708			$body.addClass( 'page-footer-parallax' );
709			contentWrap.css( {
710				marginBottom: fwHeight
711			} );
712		} else {
713			$body.removeClass( 'page-footer-parallax' );
714			contentWrap.css( {
715				marginBottom: 0
716			} );
717		}
718	}
719}
720
721function initFooterFixed() {
722	var footerWrap = $( '#page-footer-wrapper' );
723
724	if ( ! footerWrap.hasClass( 'fixed' ) || $body.hasClass( 'page-template-one-page-scroll' ) ) {
725		return;
726	}
727
728	if ( footerWrap.length > 0 ) {
729		var contentWrap = $pageWrapper.children( '.content-wrapper' );
730
731		var fwHeight = footerWrap.height();
732		$body.addClass( 'page-footer-fixed' );
733		contentWrap.css( {
734			marginBottom: fwHeight
735		} );
736	}
737}
738
739function scrollToTop() {
740	if ( $insight.scroll_top_enable != 1 ) {
741		return;
742	}
743	var $scrollUp = $( '#page-scroll-up' );
744	var lastScrollTop = 0;
745
746	$window.on( 'scroll', function() {
747		var st = $( this ).scrollTop();
748		if ( st > lastScrollTop ) {
749			$scrollUp.removeClass( 'show' );
750		} else {
751			if ( $window.scrollTop() > 200 ) {
752				$scrollUp.addClass( 'show' );
753			} else {
754				$scrollUp.removeClass( 'show' );
755			}
756		}
757		lastScrollTop = st;
758	} );
759
760	$scrollUp.on( 'click', function( evt ) {
761		$( 'html, body' ).animate( { scrollTop: 0 }, 600 );
762		evt.preventDefault();
763	} );
764}
765
766function openMobileMenu() {
767	$body.addClass( 'page-mobile-menu-opened' );
768
769	$( document ).trigger( 'mobileMenuOpen' );
770}
771
772function closeMobileMenu() {
773	$body.removeClass( 'page-mobile-menu-opened' );
774
775	$( document ).trigger( 'mobileMenuClose' );
776}
777
778function calMobileMenuBreakpoint() {
779	var _breakpoint = $insight.mobile_menu_breakpoint;
780	if ( wWidth <= _breakpoint ) {
781		$body.removeClass( 'desktop-menu' ).addClass( 'mobile-menu' );
782	} else {
783		$body.addClass( 'desktop-menu' ).removeClass( 'mobile-menu' );
784	}
785}
786
787function initMobileMenu() {
788	$( '#page-open-mobile-menu' ).on( 'click', function( e ) {
789		e.preventDefault();
790		e.stopPropagation();
791
792		openMobileMenu();
793	} );
794
795	$( '#page-close-mobile-menu' ).on( 'click', function( e ) {
796		e.preventDefault();
797		e.stopPropagation();
798
799		closeMobileMenu();
800	} );
801
802	$( '#page-mobile-main-menu' ).on( 'click', function( e ) {
803		if ( e.target !== this ) {
804			return;
805		}
806
807		closeMobileMenu();
808	} );
809
810	$( document ).on( 'mobileMenuOpen', function() {
811		$html.css( {
812			'overflow': 'hidden'
813		} );
814	} );
815
816	$( document ).on( 'mobileMenuClose', function() {
817		$html.css( {
818			'overflow': ''
819		} );
820	} );
821
822	var menu = $( '#mobile-menu-primary' );
823
824	menu.on( 'click', 'a', function( e ) {
825		var $this = $( this );
826		var _li = $( this ).parent( 'li' );
827		var href = $this.attr( 'href' );
828
829		if ( $body.hasClass( 'one-page' ) && href && href.match( /^([.#])(.+)/ ) ) {
830			closeMobileMenu();
831			var offset = 0;
832
833			if ( $body.hasClass( 'admin-bar' ) ) {
834				offset += 32;
835			}
836
837			if ( headerStickyEnable == 1 && $headerInner.data( 'sticky' ) == '1' ) {
838				offset += headerStickyHeight;
839			}
840
841			if ( offset > 0 ) {
842				offset = - offset;
843			}
844
845			_li.siblings( 'li' ).removeClass( 'current-menu-item' );
846			_li.addClass( 'current-menu-item' );
847
848			setTimeout( function() {
849				$.smoothScroll( {
850					offset: offset,
851					scrollTarget: $( href ),
852					speed: 600,
853					easing: 'linear'
854				} );
855			}, 300 );
856
857			return false;
858		}
859	} );
860
861	menu.on( 'click', '.toggle-sub-menu', function( e ) {
862		var _li = $( this ).parents( 'li' ).first();
863
864		e.preventDefault();
865		e.stopPropagation();
866
867		var _friends = _li.siblings( '.opened' );
868		_friends.removeClass( 'opened' );
869		_friends.find( '.opened' ).removeClass( 'opened' );
870		_friends.find( '.sub-menu' ).stop().slideUp();
871
872		if ( _li.hasClass( 'opened' ) ) {
873			_li.removeClass( 'opened' );
874			_li.find( '.opened' ).removeClass( 'opened' );
875			_li.find( '.sub-menu' ).stop().slideUp();
876		} else {
877			_li.addClass( 'opened' );
878			_li.children( '.sub-menu' ).stop().slideDown();
879		}
880	} );
881}
882
883function initOffCanvasMenu() {
884	var menu = $( '#off-canvas-menu-primary' );
885	var _lv1 = menu.children( 'li' );
886
887	$( '#page-open-main-menu' ).on( 'click', function( e ) {
888		e.preventDefault();
889		$body.addClass( 'page-off-canvas-menu-opened' );
890	} );
891
892	$( '#page-close-main-menu' ).on( 'click', function( e ) {
893		e.preventDefault();
894
895		menu.fadeOut( function() {
896			$body.removeClass( 'page-off-canvas-menu-opened' );
897			menu.fadeIn();
898			menu.find( '.sub-menu' ).slideUp();
899		} );
900	} );
901
902	var transDelay = 0.1;
903	_lv1.each( function() {
904		$( this )[ 0 ].setAttribute( 'style', '-webkit-transition-delay:' + transDelay + 's; -moz-transition-delay:' + transDelay + 's; -ms-transition-delay:' + transDelay + 's; -o-transition-delay:' + transDelay + 's; transition-delay:' + transDelay + 's' );
905		transDelay += 0.1;
906	} );
907
908	menu.on( 'click', '.menu-item-has-children > a, .page_item_has_children > a', function( e ) {
909		e.preventDefault();
910		e.stopPropagation();
911
912		var _li = $( this ).parent( 'li' );
913		var _friends = _li.siblings( '.opened' );
914		_friends.removeClass( 'opened' );
915		_friends.find( '.opened' ).removeClass( 'opened' );
916		_friends.find( '.sub-menu, .children' ).stop().slideUp();
917
918		if ( _li.hasClass( 'opened' ) ) {
919			_li.removeClass( 'opened' );
920			_li.find( '.opened' ).removeClass( 'opened' );
921			_li.find( '.sub-menu, .children' ).stop().slideUp();
922		} else {
923			_li.addClass( 'opened' );
924			_li.children( '.sub-menu, .children' ).stop().slideDown();
925		}
926	} );
927}
928
929function initStickyHeader() {
930	var $headerHolder = $pageHeader.children( '.page-header-place-holder' );
931	if ( $insight.header_sticky_enable == 1 && $pageHeader.length > 0 && $headerInner.data( 'sticky' ) == '1' ) {
932		if ( $headerInner.data( 'header-position' ) != 'left' ) {
933			var _hOffset = $headerInner.offset().top;
934
935			// Fix offset top return negative value on some devices.
936			if ( _hOffset < 0 ) {
937				_hOffset = 0;
938			}
939
940			var _hHeight = $headerInner.outerHeight();
941			var offset = _hOffset + _hHeight + 100;
942
943			if ( ! $pageHeader.hasClass( 'header-layout-fixed' ) ) {
944				var _hHeight = $headerInner.outerHeight();
945
946				$headerHolder.height( _hHeight );
947				$headerInner.addClass( 'held' );
948			}
949
950			$pageHeader.headroom( {
951				offset: offset,
952				onTop: function() {
953					if ( ! $pageHeader.hasClass( 'header-layout-fixed' ) ) {
954
955						setTimeout( function() {
956							var _hHeight = $headerInner.outerHeight();
957
958							$headerHolder.height( _hHeight );
959						}, 300 );
960					}
961				},
962			} );
963		} else {
964			if ( wWidth <= $insight.mobile_menu_breakpoint ) {
965				if ( ! $pageHeader.data( 'headroom' ) ) {
966					var _hOffset = $headerInner.offset().top;
967
968					// Fix offset top return negative value on some devices.
969					if ( _hOffset < 0 ) {
970						_hOffset = 0;
971					}
972
973					var _hHeight = $headerInner.outerHeight();
974					var offset = _hOffset + _hHeight + 100;
975
976					$pageHeader.headroom( {
977						offset: offset
978					} );
979				}
980			} else {
981				if ( $pageHeader.data( 'headroom' ) ) {
982					$pageHeader.data( 'headroom' ).destroy();
983					$pageHeader.removeData( 'headroom' );
984				}
985			}
986		}
987	}
988}
989
990function openSearchPopup() {
991	$body.addClass( 'page-search-popup-opened' );
992
993	$html.css( {
994		'overflow': 'hidden'
995	} );
996
997	/*var popupSearch = $( '#page-search-popup' );
998	var searchField = popupSearch.find( '.search-field' );
999
1000	setTimeout( function() {
1001		searchField.focus();
1002	}, 500 );*/
1003}
1004
1005function closeSearchPopup() {
1006	$body.removeClass( 'page-search-popup-opened' );
1007
1008	$html.css( {
1009		'overflow': ''
1010	} );
1011}
1012
1013function initSearchPopup() {
1014	$( '#btn-open-popup-search' ).on( 'click', function( e ) {
1015		e.preventDefault();
1016		openSearchPopup();
1017	} );
1018
1019	$( '#search-popup-close' ).on( 'click', function( e ) {
1020		e.preventDefault();
1021		closeSearchPopup();
1022	} );
1023}
1024
1025function openOffSidebar() {
1026	$body.addClass( 'page-off-sidebar-opened' );
1027}
1028
1029function closeOffSidebar() {
1030	$body.removeClass( 'page-off-sidebar-opened' );
1031}
1032
1033function initOffSidebar() {
1034	$( '#page-open-off-sidebar' ).on( 'click', function( e ) {
1035		e.preventDefault();
1036		openOffSidebar();
1037	} );
1038
1039	$( '#page-close-off-sidebar' ).on( 'click', function( e ) {
1040		e.preventDefault();
1041		closeOffSidebar();
1042	} );
1043
1044	var offSidebar = $( '#page-off-sidebar' );
1045
1046	offSidebar.on( 'click', function( e ) {
1047		if ( e.target !== this ) {
1048			return;
1049		}
1050
1051		closeOffSidebar();
1052	} );
1053}
1054
1055function initHeaderRightMoreTools() {
1056	$( '#header-right-more' ).on( 'click', function() {
1057		$body.toggleClass( 'header-more-tools-opened' );
1058	} );
1059
1060
1061	$( document ).on( 'click', function( evt ) {
1062		if ( evt.target.id === 'page-header-inner' ) {
1063			return;
1064		}
1065
1066		if ( $( evt.target ).closest( '#page-header-inner' ).length ) {
1067			return;
1068		}
1069
1070		$body.removeClass( 'header-more-tools-opened' );
1071	} );
1072}
1073
1074function calculateLeftHeaderSize() {
1075	if ( $headerInner.data( 'header-position' ) != 'left' ) {
1076		return;
1077	}
1078
1079	var _wWidth = window.innerWidth;
1080	var _containerWidth = parseInt( $body.data( 'site-width' ) );
1081	var $footer = $( '#page-footer-wrapper' );
1082
1083	if ( _wWidth <= $insight.mobile_menu_breakpoint ) {
1084		$html.css( {
1085			marginLeft: 0
1086		} );
1087
1088		if ( $footer.hasClass( 'parallax' ) || $footer.hasClass( 'fixed' ) || $footer.hasClass( 'overlay' ) ) {
1089			$footer.css( {
1090				left: 0
1091			} );
1092		}
1093	} else {
1094		var headerWidth = $headerInner.outerWidth();
1095
1096		if ( $insight.isRTL ) {
1097			$html.css( {
1098				marginRight: headerWidth + 'px'
1099			} );
1100		} else {
1101			$html.css( {
1102				marginLeft: headerWidth + 'px'
1103			} );
1104		}
1105
1106		if ( $footer.hasClass( 'parallax' ) || $footer.hasClass( 'fixed' ) || $footer.hasClass( 'overlay' ) ) {
1107			if ( $insight.isRTL ) {
1108				$footer.css( {
1109					right: headerWidth + 'px'
1110				} );
1111			} else {
1112				$footer.css( {
1113					left: headerWidth + 'px'
1114				} );
1115			}
1116		}
1117
1118		var rows = $( '#page-main-content' ).find( '.vc_row, .vc_section' );
1119		var footerRows = $footer.find( '.page-footer-inner' ).first().find( '.vc_row, .vc_section' );
1120		rows = rows.add( footerRows );
1121
1122		var $contentWidth = $( '#page' ).width();
1123		rows.each( function() {
1124			if ( $( this ).attr( 'data-vc-full-width' ) ) {
1125				var left = 0;
1126
1127				if ( $contentWidth > $insight.mobile_menu_breakpoint ) {
1128					left = - (
1129						(
1130							$contentWidth - _containerWidth
1131						) / 2
1132					) + 'px';
1133				}
1134
1135				var width = $contentWidth + 'px';
1136				$( this ).css( {
1137					width: width
1138				} );
1139
1140				if ( $insight.isRTL ) {
1141					$( this ).css( {
1142						right: left,
1143						left: 'auto'
1144					} );
1145				} else {
1146					$( this ).css( {
1147						left: left
1148					} );
1149				}
1150
1151				var stretch = $( this ).attr( 'data-vc-stretch-content' );
1152				if ( typeof stretch === typeof undefined || stretch === false ) {
1153					var _padding = 0;
1154					if ( $contentWidth > $insight.mobile_menu_breakpoint ) {
1155						_padding = (
1156							(
1157								$contentWidth - _containerWidth
1158							) / 2
1159						);
1160					}
1161					$( this ).css( {
1162						paddingLeft: _padding,
1163						paddingRight: _padding
1164					} );
1165				}
1166			}
1167		} );
1168	}
1169}
1170
1171function boxedFixVcRow() {
1172	if ( ! $body.hasClass( 'boxed' ) ) {
1173		return;
1174	}
1175
1176	if ( wWidth < 1200 ) {
1177		return;
1178	}
1179
1180	var siteWidth    = $pageWrapper.outerWidth(),
1181	    contentWidth = $body.data( 'content-width' ),
1182	    space        = (
1183		                   siteWidth - contentWidth
1184	                   ) / 2;
1185
1186	var breakpoint = Math.min( siteWidth, contentWidth );
1187
1188	$pageWrapper.find( '[data-vc-full-width=true]' ).each( function() {
1189		$( this ).css( {
1190			left: - space,
1191			width: siteWidth + 'px'
1192		} );
1193
1194		if ( $( this ).data( 'vc-stretch-content' ) != true ) {
1195			$( this ).css( {
1196				paddingLeft: space,
1197				paddingRight: space
1198			} );
1199		}
1200	} );
1201}
1202
1203function reCalculateVcRowFullHeight() {
1204	var fullHeight = window.innerHeight,
1205	    fullHeightCal,
1206	    offset     = 0,
1207	    $adminBar  = $( '#wpadminbar' ),
1208	    $vcRows    = $( '.vc_row-o-full-height' );
1209
1210	if ( $adminBar.length ) {
1211		offset += $adminBar.outerHeight();
1212	}
1213
1214	$headerInner = $pageHeader.children( '.page-header-inner' );
1215
1216	if ( ! $pageHeader.hasClass( 'header-layout-fixed' ) &&
1217	     (
1218		     $body.hasClass( 'handheld' ) || $headerInner.data( 'header-position' ) === undefined
1219	     ) ) {
1220		var hHeight = $headerInner.outerHeight();
1221
1222		offset += hHeight;
1223	}
1224
1225	fullHeightCal = fullHeight - offset;
1226
1227	$vcRows.each( function() {
1228		if ( $( this ).hasClass( 'calculated-height' ) ) {
1229			$vcRows.css( 'min-height', fullHeightCal + 'px' );
1230		} else {
1231			$vcRows.css( 'min-height', fullHeight + 'px' );
1232		}
1233	} );
1234
1235	$( document ).trigger( 'vc-full-height-row', $vcRows );
1236}
1237
1238function handlerEntryPostShare() {
1239	$( '.post-share' ).each( function() {
1240		var self = $( this );
1241		var $toggle = self.find( '.share-icon' );
1242
1243		$toggle.on( 'click', function() {
1244			self.toggleClass( 'opened' );
1245		} );
1246
1247		$( document ).on( 'click', function( e ) {
1248			if ( $( e.target ).closest( $toggle ).length == 0 ) {
1249				self.removeClass( 'opened' );
1250			}
1251		} );
1252	} );
1253
1254}
1255
1256function initCookieNotice() {
1257	if ( $insight.noticeCookieEnable == 1 && $insight.noticeCookieConfirm != 'yes' && $insight.noticeCookieMessages != '' ) {
1258
1259		$.growl( {
1260			location: 'br',
1261			fixed: true,
1262			duration: 3600000,
1263			size: 'large',
1264			title: '',
1265			message: $insight.noticeCookieMessages
1266		} );
1267
1268		$( '#tm-button-cookie-notice-ok' ).on( 'click', function() {
1269			$( this ).parents( '.growl-message' ).first().siblings( '.growl-close' ).trigger( 'click' );
1270
1271			var _data = {
1272				action: 'notice_cookie_confirm'
1273			};
1274
1275			_data = $.param( _data );
1276
1277			$.ajax( {
1278				url: $insight.ajaxurl,
1279				type: 'POST',
1280				data: _data,
1281				dataType: 'json',
1282				success: function( results ) {
1283
1284				},
1285				error: function( errorThrown ) {
1286					console.log( errorThrown );
1287				}
1288			} );
1289		} );
1290	}
1291}
1292
1293function initNewsletterPopup() {
1294	if ( $insight.isShowNewsletterPopup != '1' ) {
1295		return false;
1296	}
1297
1298	$( window ).on( 'load', function() {
1299		$body.addClass( 'newsletter-popup-opened' );
1300	} );
1301
1302	$( '#newsletter-popup-close' ).on( 'click', function() {
1303		$( document ).trigger( 'newsletterPopupClose' );
1304	} );
1305
1306	var newsletterPopup = $( '#newsletter-popup' );
1307
1308	newsletterPopup.on( 'click', function( e ) {
1309		if ( e.target !== this ) {
1310			return;
1311		}
1312
1313		$( document ).trigger( 'newsletterPopupClose' );
1314	} );
1315
1316	$( document ).on( 'newsletterPopupClose', function() {
1317		$body.removeClass( 'newsletter-popup-opened' );
1318
1319		var data = {
1320			action: 'newsletter_popup_confirm'
1321		};
1322
1323		data = $.param( data );
1324
1325		$.ajax( {
1326			url: $insight.ajaxurl,
1327			type: 'POST',
1328			data: data,
1329			dataType: 'json',
1330			success: function( results ) {
1331
1332			},
1333			error: function( errorThrown ) {
1334				console.log( errorThrown );
1335			}
1336		} );
1337	} );
1338}
1339
1340var resizeTimer;
1341
1342if ( typeof Isotope != 'undefined' ) {
1343	// Add isotope-hidden class for filtered items.
1344	var itemReveal = Isotope.Item.prototype.reveal,
1345	    itemHide   = Isotope.Item.prototype.hide;
1346
1347	Isotope.Item.prototype.reveal = function() {
1348		itemReveal.apply( this, arguments );
1349		$( this.element )
1350			.removeClass( 'isotope-hidden' );
1351	};
1352
1353	Isotope.Item.prototype.hide = function() {
1354		itemHide.apply( this, arguments );
1355		$( this.element )
1356			.addClass( 'isotope-hidden' );
1357	};
1358}
1359
1360function insightInitGrid() {
1361	$( '.tm-grid-wrapper' ).each( function() {
1362		var $el      = $( this ),
1363		    $grid    = $el.find( '.tm-grid' ),
1364		    $gridData,
1365		    gutter   = $el.data( 'gutter' ) ? $el.data( 'gutter' ) : 0,
1366		    itemWrap = $el.data( 'item-wrap' );
1367
1368		if ( itemWrap == '1' ) {
1369			$grid.children().not( '.grid-sizer' )
1370			     .wrap( '<div class="grid-item"></div>' );
1371		}
1372
1373		var $items = $grid.children( '.grid-item' );
1374
1375		$( document ).trigger( 'insightGridBeforeInit', [ $el, $grid ] );
1376
1377		if ( $el.data( 'type' ) == 'masonry' ) {
1378			var $isotopeOptions = {
1379				itemSelector: '.grid-item',
1380				percentPosition: true
1381			};
1382
1383			if( $insight.isRTL ) {
1384				$isotopeOptions.originLeft = false;
1385			}
1386
1387			if ( $el.data( 'grid-fitrows' ) ) {
1388				$isotopeOptions.layoutMode = 'fitRows';
1389			} else {
1390				$isotopeOptions.layoutMode = 'packery';
1391				$isotopeOptions.packery = {
1392					// Use outer width of grid-sizer for columnWidth.
1393					columnWidth: '.grid-sizer'
1394				}
1395			}
1396
1397			if ( $isotopeOptions.layoutMode === 'fitRows' ) {
1398				// Set gutter for fit rows layout.
1399				$isotopeOptions.fitRows = {};
1400				$isotopeOptions.fitRows.gutter = gutter;
1401			} else if ( $isotopeOptions.layoutMode === 'packery' ) {
1402				$isotopeOptions.packery.gutter = gutter;
1403			} else {
1404				// Set gutter for masonry layout.
1405				$isotopeOptions.masonry.gutter = gutter;
1406			}
1407
1408			// Remove default transition if grid has custom animation.
1409			if ( $grid.hasClass( 'has-animation' ) ) {
1410				$isotopeOptions.transitionDuration = 0;
1411			}
1412
1413			$( window ).resize( function() {
1414				insightGridMasonryCalculateSize( $el, $grid, $isotopeOptions );
1415				clearTimeout( resizeTimer );
1416				resizeTimer = setTimeout( function() {
1417					// Run code here, resizing has "stopped"
1418					insightGridMasonryCalculateSize( $el, $grid, $isotopeOptions );
1419				}, 300 );
1420			} );
1421
1422			insightGridMasonryCalculateSize( $el, $grid );
1423
1424			$gridData = $grid.imagesLoaded( function() {
1425				// init Isotope after all images have loaded
1426				$grid.isotope( $isotopeOptions );
1427
1428				if ( $el.data( 'match-height' ) ) {
1429					$items.matchHeight();
1430				}
1431
1432				$( document ).trigger( 'insightGridInit', [ $el, $grid, $isotopeOptions ] );
1433			} );
1434
1435			$gridData.one( 'arrangeComplete', function() {
1436				insightInitGridAnimation( $grid, $items );
1437				insightGridFilterCount( $el, $grid );
1438				initGridTiltEffect( $el, $items );
1439			} );
1440		} else if ( $el.data( 'type' ) == 'justified' ) {
1441			var jRowHeight        = $el.data( 'justified-height' ) ? $el.data( 'justified-height' ) : 300,
1442			    jMaxRowHeight     = $el.data( 'justified-max-height' ) ? $el.data( 'justified-max-height' ) : 0,
1443			    jLastRow          = $el.data( 'justified-last-row' ) ? $el.data( 'justified-last-row' ) : 'justify',
1444			    $justifiedOptions = {
1445				    rowHeight: jRowHeight,
1446				    selector: '.grid-item',
1447				    imgSelector: '.post-thumbnail img',
1448				    margins: gutter,
1449				    border: 0,
1450				    captions: false,
1451				    lastRow: jLastRow
1452			    };
1453
1454			if ( jMaxRowHeight && jMaxRowHeight > 0 ) {
1455				$justifiedOptions.maxRowHeight = jMaxRowHeight;
1456			}
1457
1458			$grid.justifiedGallery( $justifiedOptions );
1459			insightGridFilterCount( $el, $grid );
1460			insightInitGridAnimation( $grid, $items );
1461			initGridTiltEffect( $el, $items );
1462		} else {
1463			insightGridFilterCount( $el, $grid );
1464			insightInitGridAnimation( $grid, $items );
1465			initGridTiltEffect( $el, $items );
1466		}
1467
1468		insightGridFilterHandler( $el, $grid );
1469
1470		if ( $el.data( 'hover' ) == 'tilt' ) {
1471			var zIndex = 1;
1472
1473			$grid.on( 'mouseenter', '.grid-item', function() {
1474				zIndex ++;
1475
1476				$( this ).css( 'z-index', zIndex );
1477			} );
1478		}
1479
1480		if ( $el.data( 'pagination' ) == 'loadmore' ) {
1481			$el.children( '.tm-grid-pagination' )
1482			   .find( '.tm-grid-loadmore-btn' )
1483			   .on( 'click', function( e ) {
1484				   e.preventDefault();
1485				   if ( ! ajaxBusy ) {
1486					   $( this ).hide();
1487					   var $queryInput = $el.find( '.tm-grid-query' )
1488					                        .first();
1489					   var query = jQuery.parseJSON( $queryInput.val() );
1490
1491					   query.paged ++;
1492					   $queryInput.val( JSON.stringify( query ) );
1493					   insightInfiniteQuery( $el, $grid );
1494				   }
1495			   } );
1496		} else if ( $el.data( 'pagination' ) == 'loadmore_alt' ) {
1497			var loadMoreBtn = $( $el.data( 'pagination-custom-button-id' ) );
1498
1499			loadMoreBtn.on( 'click', function( e ) {
1500				e.preventDefault();
1501				if ( ! ajaxBusy ) {
1502					$( this ).hide();
1503					var $queryInput = $el.find( '.tm-grid-query' )
1504					                     .first();
1505					var query = jQuery.parseJSON( $queryInput.val() );
1506
1507					query.paged ++;
1508					$queryInput.val( JSON.stringify( query ) );
1509					insightInfiniteQuery( $el, $grid );
1510				}
1511			} );
1512		} else if ( $el.data( 'pagination' ) == 'infinite' ) {
1513			$( '.tm-grid-pagination', $el ).vcwaypoint( function( direction ) {
1514				if ( direction === 'down' && ! ajaxBusy ) {
1515					var $queryInput = $el.find( '.tm-grid-query' )
1516					                     .first();
1517					var query = jQuery.parseJSON( $queryInput.val() );
1518
1519					query.paged ++;
1520					$queryInput.val( JSON.stringify( query ) );
1521
1522					insightInfiniteQuery( $el, $grid );
1523				}
1524			}, {
1525				offset: '100%'
1526			} )
1527		}
1528	} );
1529
1530	$( document ).on( 'insightGridInfinityLoad', function( e, $wrapper ) {
1531		var $el = $( $wrapper );
1532		var $grid = $el.find( '.tm-grid' )
1533		var $queryInput = $el.find( '.tm-grid-query' )
1534		                     .first();
1535		var query = jQuery.parseJSON( $queryInput.val() );
1536
1537		query.paged = 1;
1538		$queryInput.val( JSON.stringify( query ) );
1539
1540		insightInfiniteQuery( $el, $grid, true );
1541	} );
1542}
1543
1544/**
1545 * Calculate size for grid items
1546 */
1547function insightGridMasonryCalculateSize( $el, $grid, $isotopeOptions ) {
1548	var windowWidth = window.innerWidth,
1549	    $gridWidth  = $grid[ 0 ].getBoundingClientRect().width,
1550	    $gutter     = $el.data( 'gutter' ) ? $el.data( 'gutter' ) : 0,
1551	    $column     = 1,
1552	    lgColumns   = $el.data( 'lg-columns' ) ? $el.data( 'lg-columns' ) : 1,
1553	    mdColumns   = $el.data( 'md-columns' ) ? $el.data( 'md-columns' ) : lgColumns,
1554	    smColumns   = $el.data( 'sm-columns' ) ? $el.data( 'sm-columns' ) : mdColumns,
1555	    xsColumns   = $el.data( 'xs-columns' ) ? $el.data( 'xs-columns' ) : smColumns;
1556
1557	if ( windowWidth >= 1200 ) {
1558		$column = lgColumns;
1559	} else if ( windowWidth >= 992 ) {
1560		$column = mdColumns;
1561	} else if ( windowWidth >= 641 ) {
1562		$column = smColumns;
1563	} else {
1564		$column = xsColumns;
1565	}
1566
1567	var $totalGutter = (
1568		                   $column - 1
1569	                   ) * $gutter;
1570
1571	var $columnWidth = (
1572		                   $gridWidth - $totalGutter
1573	                   ) / $column;
1574
1575	$columnWidth = Math.floor( $columnWidth );
1576
1577	var $columnWidth2 = $columnWidth;
1578	if ( $column > 1 ) {
1579		$columnWidth2 = $columnWidth * 2 + $gutter;
1580	}
1581
1582	$grid.children( '.grid-sizer' )
1583	     .css( {
1584		     'width': $columnWidth + 'px'
1585	     } );
1586
1587	var $columnHeight  = $columnWidth,
1588	    $columnHeight2 = $columnHeight,
1589	    ratio          = $el.data( 'grid-ratio' );
1590
1591	if ( ratio ) {
1592		var res    = ratio.split( ':' ),
1593		    ratioW = parseFloat( res[ 0 ] ),
1594		    ratioH = parseFloat( res[ 1 ] );
1595
1596		$columnHeight = (
1597			                $columnWidth * ratioH
1598		                ) / ratioW;
1599
1600		$columnHeight = Math.floor( $columnHeight );
1601
1602		if ( $column > 1 ) {
1603			$columnHeight2 = $columnHeight * 2 + $gutter;
1604		} else {
1605			$columnHeight2 = $columnHeight;
1606		}
1607	}
1608
1609	$grid.children( '.grid-item' ).each( function() {
1610		if ( $( this ).data( 'width' ) == '2' ) {
1611			$( this ).css( {
1612				'width': $columnWidth2 + 'px'
1613			} );
1614		} else {
1615			$( this ).css( {
1616				'width': $columnWidth + 'px'
1617			} );
1618		}
1619		if ( ratio ) {
1620			if ( $( this ).data( 'height' ) == '2' ) {
1621				$( this ).css( {
1622					'height': $columnHeight2 + 'px'
1623				} );
1624			} else {
1625				$( this ).css( {
1626					'height': $columnHeight + 'px'
1627				} );
1628			}
1629		}
1630	} );
1631
1632	if ( $isotopeOptions ) {
1633		$grid.isotope( 'layout', $isotopeOptions );
1634	}
1635}
1636
1637/**
1638 * Load post infinity from db.
1639 */
1640function insightInfiniteQuery( $wrapper, $grid, reset ) {
1641	var loader = $wrapper.children( '.tm-grid-pagination' )
1642	                     .find( '.tm-grid-loader' );
1643	loader.css( {
1644		'display': 'inline-block'
1645	} );
1646
1647	setTimeout( function() {
1648		var $queryInput = $wrapper.find( '.tm-grid-query' )
1649		                          .first(),
1650		    query       = jQuery.parseJSON( $queryInput.val() ),
1651		    _data       = $.param( query );
1652
1653		// Append nonce for CSRF protection.
1654		_data += '&nonce=' + encodeURIComponent( $insight.nonce );
1655
1656		$.ajax( {
1657			url: $insight.ajaxurl,
1658			type: 'POST',
1659			data: _data,
1660			dataType: 'json',
1661			success: function( response ) {
1662        if ( !response.success  ) {
1663          return;
1664        }
1665
1666        var results = response.data;
1667
1668				if ( results.max_num_pages ) {
1669					query.max_num_pages = results.max_num_pages;
1670				}
1671
1672				if ( results.count ) {
1673					query.count = results.count;
1674				}
1675
1676				$queryInput.val( JSON.stringify( query ) );
1677
1678				var html = results.template;
1679				var $tmp = $('<div></div>');
1680				$tmp.html( $.parseHTML( html ) );
1681				var $items = $tmp.find('.grid-item');
1682
1683				if ( reset == true ) {
1684					$grid.children( '.grid-item' ).remove();
1685				}
1686
1687				if ( $wrapper.data( 'type' ) == 'masonry' ) {
1688
1689					$grid.isotope()
1690					     .append( $items )
1691					     .isotope( 'appended', $items )
1692					     .imagesLoaded()
1693					     .always( function() {
1694						     $grid.isotope( 'layout' );
1695						     // Re run match height for all items.
1696						     if ( $wrapper.data( 'match-height' ) ) {
1697							     $grid.children( '.grid-item' ).matchHeight();
1698						     }
1699						     $( document ).trigger( 'insightGridUpdate', [ $wrapper, $grid, $items ] );
1700					     } );
1701
1702					insightGridFilterCount( $wrapper, $grid );
1703					insightGridMasonryCalculateSize( $wrapper, $grid );
1704				} else if ( $wrapper.data( 'type' ) == 'swiper' ) {
1705					var $slider = $wrapper.find( '.swiper-container' )[ 0 ].swiper;
1706					$slider.appendSlide( $items );
1707					$slider.update();
1708				} else if ( $wrapper.data( 'type' ) == 'justified' ) {
1709					$grid.append( html );
1710					$grid.justifiedGallery( 'norewind' );
1711				} else {
1712					$grid.append( $items );
1713					insightGridFilterCount( $wrapper, $grid );
1714				}
1715
1716				insightInitGridAnimation( $grid, $items );
1717				insightInitGalleryForNewItems( $grid, $items );
1718				insightInitPopupForNewItems( $grid, $items );
1719				insightHidePaginationIfEnd( $wrapper, query );
1720
1721				if ( $wrapper.hasClass( 'case-study-overlay-parallax' ) ) {
1722					initGridTiltEffect( $wrapper, $items );
1723				}
1724
1725				loader.hide();
1726			}
1727		} );
1728	}, 500 );
1729}
1730
1731/**
1732 * Init slider if grid item has post gallery format
1733 *
1734 * @param $grid
1735 * @param $items
1736 */
1737function insightInitGalleryForNewItems( $grid, $items ) {
1738	if ( $grid.data( 'grid-has-gallery' ) == true ) {
1739		$items.each( function() {
1740			if ( $( this )
1741				.hasClass( 'format-gallery' ) ) {
1742				var $slider = $( this )
1743					.children( '.post-gallery' );
1744				insightInitSwiper( $slider );
1745			}
1746		} );
1747	}
1748}
1749
1750/**
1751 * Init popup video if grid item has post video format
1752 *
1753 * @param $grid
1754 * @param $items
1755 */
1756function insightInitPopupForNewItems( $grid, $items ) {
1757	if ( $grid.data( 'grid-has-popup-video' ) == '1' ) {
1758		$items.each( function() {
1759			var $popup = $( this ).find( '.tm-popup-video' ).first();
1760			if ( $popup.length > 0 ) {
1761				handlerPopupVideo( $popup );
1762			}
1763		} );
1764	}
1765}
1766
1767/**
1768 * Remove pagination if has no posts anymore
1769 *
1770 * @param $el
1771 * @param query
1772 *
1773 */
1774function insightHidePaginationIfEnd( $el, query ) {
1775	if ( query.found_posts <= (
1776		query.paged * query.posts_per_page
1777	) ) {
1778
1779		if ( $el.data( 'pagination' ) === 'loadmore_alt' ) {
1780			var loadMoreBtn = $( $el.data( 'pagination-custom-button-id' ) );
1781
1782			loadMoreBtn.hide();
1783		} else {
1784			$el.children( '.tm-grid-pagination' ).hide();
1785		}
1786
1787		$el.children( '.tm-grid-messages' ).show( 1 );
1788		setTimeout( function() {
1789			$el.children( '.tm-grid-messages' ).remove();
1790		}, 5000 );
1791	} else {
1792		if ( $el.data( 'pagination' ) === 'loadmore_alt' ) {
1793			var loadMoreBtn = $( $el.data( 'pagination-custom-button-id' ) );
1794
1795			loadMoreBtn.show();
1796		} else {
1797			$el.children( '.tm-grid-pagination' ).show();
1798			$el.children( '.tm-grid-pagination' ).find( '.tm-grid-loadmore-btn' ).show();
1799		}
1800
1801	}
1802}
1803
1804/**
1805 * Update counter for grid filters
1806 *
1807 * @param $el
1808 * @param $grid
1809 */
1810function insightGridFilterCount( $el, $grid ) {
1811	if ( $el.children( '.tm-filter-button-group' ).data( 'filter-counter' ) != true ) {
1812		return;
1813	}
1814
1815	var $gridItems = $grid.children( '.grid-item' );
1816	var $gridTotal = $gridItems.length;
1817	var filterType = $el.data( 'filter-type' );
1818
1819	if ( filterType === 'ajax' ) {
1820		$el.find( '.btn-filter' ).each( function() {
1821			var count = $( this ).data( 'filter-count' );
1822
1823			if ( $( this ).children( '.filter-counter' ).length > 0 ) {
1824				$( this ).children( '.filter-counter' ).text( count );
1825			} else {
1826				$( this ).append( '<span class="filter-counter">' + count + '</span>' );
1827			}
1828		} );
1829	} else {
1830		$el.find( '.btn-filter' ).each( function() {
1831			var filter = $( this ).data( 'filter' );
1832			var count = 0;
1833			if ( filter == '*' ) {
1834				if ( $( this ).children( '.filter-counter' ).length > 0 ) {
1835					$( this ).children( '.filter-counter' ).text( $gridTotal );
1836				} else {
1837					$( this ).append( '<span class="filter-counter">' + $gridTotal + '</span>' );
1838				}
1839			} else {
1840				filter = filter.replace( '.', '' );
1841				$gridItems.each( function() {
1842					if ( $( this ).hasClass( filter ) ) {
1843						count ++;
1844					}
1845				} );
1846				if ( $( this ).children( '.filter-counter' ).length > 0 ) {
1847					$( this ).children( '.filter-counter' ).text( count );
1848				} else {
1849					$( this ).append( '<span class="filter-counter">' + count + '</span>' );
1850				}
1851			}
1852		} );
1853	}
1854}
1855
1856function insightGridFilterHandler( $el, $grid ) {
1857	$el.children( '.tm-filter-button-group' ).on( 'click', '.btn-filter', function() {
1858		if ( $( this ).hasClass( 'current' ) ) {
1859			return;
1860		}
1861
1862		if ( $el.data( 'filter-type' ) == 'ajax' ) {
1863			var filterValue = $( this ).attr( 'data-filter' );
1864
1865			var $queryInput = $el.find( '.tm-grid-query' ).first();
1866			var query = jQuery.parseJSON( $queryInput.val() );
1867			if ( filterValue === '*' ) {
1868				query.extra_taxonomy = '';
1869			} else {
1870				query.extra_taxonomy = $( this ).attr( 'data-ajax-filter' );
1871			}
1872
1873			$queryInput.val( JSON.stringify( query ) );
1874
1875			$( document ).trigger( 'insightGridInfinityLoad', $el );
1876
1877			$( this ).siblings().removeClass( 'current' );
1878			$( this ).addClass( 'current' );
1879		} else {
1880			var filterValue = $( this ).attr( 'data-filter' );
1881			if ( $el.data( 'type' ) == 'masonry' ) {
1882				$grid.children( '.grid-item' ).each( function() {
1883					$( this ).removeClass( 'animate' );
1884				} );
1885
1886				$grid.isotope( {
1887					filter: filterValue
1888				} );
1889
1890				if ( $grid.hasClass( 'has-animation' ) ) {
1891					$grid.children( '.grid-item:not(.isotope-hidden)' )
1892					     .each( function() {
1893						     $( this ).addClass( 'animate' );
1894					     } );
1895				}
1896			} else if ( $el.data( 'type' ) == 'swiper' ) {
1897				filterValue = filterValue.replace( '.', '' );
1898				$grid.children( '.grid-item' ).each( function() {
1899					if ( filterValue == '*' ) {
1900						$( this ).show();
1901						$( this ).addClass( 'animate' );
1902					} else {
1903						if ( ! $( this ).hasClass( filterValue ) ) {
1904							$( this ).hide();
1905						} else {
1906							$( this ).show();
1907							$( this ).addClass( 'animate' );
1908						}
1909					}
1910				} );
1911				var $slider = $el.children( '.mitech-swiper' )
1912				                 .children( '.swiper-container' )[ 0 ].swiper;
1913				$slider.update();
1914				$slider.slideTo( 0 );
1915			} else if ( $el.data( 'type' ) == 'justified' ) {
1916				if ( filterValue == '*' ) {
1917					$grid.justifiedGallery( { filter: false } );
1918				} else {
1919					$grid.justifiedGallery( { filter: filterValue } );
1920				}
1921			} else {
1922				$grid.children( '.grid-item' ).hide().removeClass( 'animate' );
1923
1924				var $filterItems;
1925
1926				if ( filterValue == '*' ) {
1927					$filterItems = $grid.children( '.grid-item' );
1928				} else {
1929					$filterItems = $grid.children( filterValue );
1930				}
1931
1932				$filterItems.show();
1933
1934				$filterItems.each( function( i, o ) {
1935					var self = $( this );
1936
1937					setTimeout( function() {
1938						self.addClass( 'animate' );
1939					}, i * 200 );
1940				} );
1941			}
1942
1943			$( this ).siblings().removeClass( 'current' );
1944			$( this ).addClass( 'current' );
1945		}
1946	} );
1947}
1948
1949function insightInitGridAnimation( $grid, $items ) {
1950	if ( ! $body.hasClass( 'page-has-animation' ) || ! $grid.hasClass( 'has-animation' ) ) {
1951		return;
1952	}
1953
1954	var itemQueue  = [],
1955	    queueDelay = 250,
1956	    queueTimer;
1957
1958	$items.vcwaypoint( function() {
1959		// Fix for different ver of waypoints plugin.
1960		var _self = this.element ? this.element : $( this );
1961
1962		itemQueue.push( _self );
1963		processItemQueue( itemQueue, queueDelay, queueTimer );
1964		queueDelay += 250;
1965
1966		queueResetDelay = setTimeout( function() {
1967			queueDelay = animateQueueDelay;
1968		}, animateQueueDelay );
1969	}, {
1970		offset: '90%',
1971		triggerOnce: true
1972	} );
1973}
1974
1975function initGridTiltEffect( $el, $items ) {
1976	if ( $el.data( 'hover' ) !== 'tilt' ) {
1977		return;
1978	}
1979
1980	$items.find( '.post-thumbnail' ).tilt( {
1981		perspective: 1440,
1982		scale: 1.06,
1983		easing: 'cubic-bezier(.03,.98,.52,.99)',
1984	} );
1985}
1986
1987}( jQuery )
1988);

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.