PageSourceSearch

https://www.hdot.org/wp-content/themes/osmosis/js/main.js?ver=4.5.8

js hdot.org collected 2026-10-02 04:31:37 UTC 83,051 bytes, 2,424 lines download raw bytes

1var locationOnLoad = false;
2
3(function($) {
4
5	'use strict';
6
7	//////////////////////////////////////////////////////////////////////////////////////////////////////
8	// HEADER
9	//////////////////////////////////////////////////////////////////////////////////////////////////////
10	var headerSettings = {
11
12		selector   : '#grve-inner-header',
13		header     : '#grve-header',
14		container  : '#grve-inner-header .grve-container',
15
16		init: function(){
17			if(!$(this.header).length) {
18				return;
19			}
20			// Add Helper wrapper for sticky header.
21			var $selector = $(this.selector);
22			$selector.wrap('<div id="grve-header-wrapper"></div>');
23			$selector.css({ 'top' : 0 });
24			headerSettings.stickyHeader();
25
26			// Fixed Header integration with top bar
27			headerSettings.fixedHeader();
28			$(window).smartresize( function() {
29				headerSettings.fixedHeader();
30			});
31		},
32		stickyHeader: function(){
33			var $selector        = $(this.selector),
34				innerHeight      = $selector.height(),
35				stickyStyle      = $(this.header).attr('data-sticky-header'),
36				headerOffset     = $(this.header).hasClass('grve-logo-top') ? $('.grve-bottom-header').offset().top : $selector.offset().top,
37				logoOnTop        = $(this.header).hasClass('grve-logo-top') ? true : false,
38				safeButtonHeight = $selector.find('.grve-open-button').outerHeight();
39			// General Setting
40			if( stickyStyle != 'none' && !logoOnTop ) {
41				if( headerOffset === 0 ) {
42					$selector.css({ 'position' : 'fixed', 'top' : 0 });
43				}
44				$(window).on('scroll', function() {
45					headerSettings.stickySettings( headerOffset, stickyStyle );
46					if( stickyStyle == 'shrink' ) {
47						headerSettings.shrinkSettings( innerHeight, headerOffset, safeButtonHeight );
48					}
49				});
50			}
51			if( logoOnTop && stickyStyle == 'simply' ){
52				$(window).on('scroll', function() {
53					headerSettings.logoOnTopSticky( headerOffset );
54				});
55			}
56		},
57		stickySettings: function( headerOffset, stickyStyle ){
58			var scroll      = $(window).scrollTop(),
59				$selector   = $(this.selector),
60				$header     = $(this.header),
61				$container  = $(this.container),
62				windowWidth = $(window).width();
63
64			if( scroll > headerOffset ){
65				$header.addClass('grve-header-sticky');
66				$selector.css({ 'position' : 'fixed', 'top' : wpBarHeight });
67			} else {
68				$header.removeClass('grve-header-sticky');
69				if( headerOffset > 0 ) {
70					$selector.css({ 'position' : 'absolute', 'top' : 0 });
71				}
72			}
73		},
74		shrinkSettings: function( innerHeight, headerOffset, safeButtonHeight ){
75			var scroll     = $(window).scrollTop(),
76				$selector  = $(this.selector);
77			if( scroll > headerOffset + innerHeight *4 ) {
78				$selector.css({ 'height' : innerHeight/2, 'line-height' : innerHeight/2 + 'px' });
79				$selector.find('.grve-logo img').css({ 'max-height' : innerHeight/2});
80				if( safeButtonHeight > innerHeight/2 ) {
81					$selector.find('.grve-open-button').css({ 'height' : innerHeight/2, 'line-height' : innerHeight/2 + 'px' });
82				}
83			} else {
84				$selector.css({ 'height' : innerHeight, 'line-height' : innerHeight + 'px' });
85				$selector.find('.grve-logo img').css({ 'max-height' : innerHeight});
86				if( safeButtonHeight > innerHeight/2 ) {
87					$selector.find('.grve-open-button').css({ 'height' : safeButtonHeight, 'line-height' : safeButtonHeight + 'px' });
88				}
89			}
90		},
91		logoOnTopSticky: function( headerOffset ){
92			var scroll = $(window).scrollTop(),
93				$header     = $(this.header),
94				$headerTop = $('.grve-top-header'),
95				$headerBottom = $('.grve-bottom-header'),
96				$selector   = $(this.selector),
97				windowWidth = $(window).width(),
98				posTop = windowWidth + scrollBarWidth >= tabletPortrait ? - ( $headerTop.height() - wpBarHeight ) : 0.1;
99
100			if( scroll > headerOffset ){
101				$header.addClass('grve-header-sticky');
102				$selector.css({ 'position' : 'fixed', 'top' : posTop });
103			} else {
104				$header.removeClass('grve-header-sticky');
105				$selector.css({ 'position' : '', 'top' : '' });
106			}
107		},
108		fixedHeader: function(){
109			var $header        = $(this.header),
110				$topBar        = $('#grve-top-bar'),
111				integration    = $header.data('overlap'),
112				headerPosition = $header.data('header-position');
113
114			if( $topBar.length && integration == 'yes' && headerPosition == 'above-feature'  ){
115				var topBarHeight = $topBar.outerHeight(),
116					$headerWrapper = $('#grve-header-wrapper');
117
118				$headerWrapper.css('top',topBarHeight);
119			}
120		}
121	};
122	//////////////////////////////////////////////////////////////////////////////////////////////////////
123	// MAIN MENU
124	//////////////////////////////////////////////////////////////////////////////////////////////////////
125	var  mainMenu = {
126
127		menu      : '#grve-main-menu',
128		menuItem  : '#grve-main-menu li',
129
130		init: function() {
131			$(this.menuItem).on('mouseenter', function() {
132				var itemHover = $(this);
133				// Mega Menu Position
134				mainMenu.menuPosition(itemHover);
135
136				if( itemHover.hasClass('megamenu') ) {
137					itemHover.find( ' > ul ' ).addClass('active');
138				} else {
139					itemHover.find( ' > ul > li > a' ).addClass('active');
140				}
141			});
142			$(this.menuItem).on('mouseleave', function() {
143				var itemHover = $(this);
144				if( itemHover.hasClass('megamenu') ) {
145					itemHover.find( ' > ul ' ).removeClass('active');
146				} else {
147					itemHover.find( ' > ul > li > a' ).removeClass('active');
148				}
149			});
150			$(this.menuItem).find( ' > a[href="#"]').on('click',function(e){
151				e.preventDefault();
152			});
153			mainMenu.responsiveMenu();
154
155			// Respnsive Menu Style 2
156			mainMenu.responsiveMenuStyle2();
157
158			// Fix Double Click on devices without responsive menu
159			if( isMobile.any() ) {
160				mainMenu.deviceMenu();
161			}
162
163		},
164		menuPosition: function(item){
165			var containerWidth  = $(this.menu).parent().outerWidth(),
166				subMenu         = item.find(' > ul '),
167				subMenuWidth    = subMenu.width(),
168				windowWidth     = $(window).width(),
169				menuPositionX   = item.offset().left;
170			if( (menuPositionX + subMenuWidth) > ( windowWidth - containerWidth )/2 + containerWidth ) {
171				if( item.hasClass('megamenu')) {
172					subMenu.css('left', - ((menuPositionX + subMenuWidth) - (( windowWidth - containerWidth )/2 + containerWidth )) +'px' );
173				} else {
174					subMenu.addClass('grve-position-right');
175				}
176			}
177		},
178		deviceMenu: function(){
179			var $menuItem = $(this.menuItem);
180			$menuItem.on('touchstart touchend', function(e) {
181				var $item = $(this);
182				$item.siblings().removeClass('open-submenu');
183				if( $item.hasClass('menu-item-has-children') && $item.find('> a').attr('href') != '#' ) {
184					if( !$item.hasClass('open-submenu') ) {
185						if( $item.hasClass('megamenu') ) {
186							$item.find( ' > ul ' ).addClass('active');
187						} else {
188							$item.find( ' > ul > li > a' ).addClass('active');
189						}
190						e.preventDefault();
191						$item.addClass('open-submenu');
192					}
193				}
194			});
195		},
196		responsiveMenu: function(){
197			var menu          = $('#grve-main-menu-responsive'),
198				btnOpenMenu   = $('.grve-menu-button, .grve-responsive-menu-text'),
199				btnCloseMenu  = $('.grve-close-menu-button'),
200				themeWrapper  = $('#grve-theme-wrapper'),
201				menuLinks     = menu.find('a[href*="#"]:not( [href="#"] )');
202
203			btnOpenMenu.on('click',function(e){
204				e.preventDefault();
205				themeWrapper.toggleClass('grve-slide-left');
206				menu.toggleClass('grve-slide-left');
207			});
208			btnCloseMenu.on('click',function(e){
209				e.preventDefault();
210				themeWrapper.removeClass('grve-slide-left');
211				menu.removeClass('grve-slide-left');
212				// Close All
213				mainMenu.closeAllChilds();
214			});
215			themeWrapper.on('click',function(e){
216				if ( !menu.is(e.target) && menu.has(e.target).length === 0 && !btnOpenMenu.is(e.target) && btnOpenMenu.has(e.target).length === 0  ) {
217					themeWrapper.removeClass('grve-slide-left');
218					menu.removeClass('grve-slide-left');
219					// Close All
220					mainMenu.closeAllChilds();
221				}
222			});
223			menuLinks.on('click',function(e){
224				setTimeout(function(){
225					themeWrapper.removeClass('grve-slide-left');
226					menu.removeClass('grve-slide-left');
227					// Close All
228					mainMenu.closeAllChilds();
229				}, 1000);
230			});
231		},
232		responsiveMenuStyle2: function(){
233			var $menu = $('#grve-main-menu-responsive');
234			if( !$menu.hasClass('grve-style-2') ){
235				return;
236			}
237			$menu.find('.menu-item-has-children').append('<div class="grve-more-btn"></div>');
238
239			$('.grve-more-btn').on('click',function(){
240				$(this).toggleClass('close').parent().toggleClass('current-menu-item').children('.sub-menu').toggleClass('open');
241			});
242
243			$menu.find('a').on('click', function() {
244				if( ($(this).attr('href') === '#') || ($(this).attr('href') === '') ) {
245					$(this).parent().children('.grve-more-btn').trigger('click');
246				}
247			});
248
249		},
250		closeAllChilds: function(){
251			var $moreButton = $('.grve-more-btn');
252
253			$moreButton.removeClass('close').parent().removeClass('current-menu-item').children('.sub-menu').removeClass('open');
254		}
255	};
256	//////////////////////////////////////////////////////////////////////////////////////////////////////
257	// FEATURE SECTION SETTINGS
258	//////////////////////////////////////////////////////////////////////////////////////////////////////
259	var featureSection = {
260
261		container         : '#grve-feature-section .grve-feature-section-inner',
262		featureItem       : $( '#grve-feature-section .grve-feature-section-inner' ).attr('data-item'),
263		fullScreenMode    : $('#grve-header').attr('data-fullscreen'),
264
265		init: function(){
266			if( this.featureItem == 'image' || this.featureItem == 'slider' || this.featureItem == 'video' ) {
267				featureSection.featureImageLoad();
268			}
269			if( this.fullScreenMode == 'yes' ){
270				featureSection.fullScreen();
271				$(window).smartresize( function() {
272					featureSection.fullScreen();
273				});
274			} else {
275				featureSection.customSize();
276			}
277			$("#grve-feature-goto.grve-custom-color").css("color",$("#grve-feature-goto.grve-custom-color").attr("data-custom-color"));
278		},
279		fullScreen: function(){
280			var windowHeight    = $(window).height(),
281				headerHeight    = $('#grve-header').attr('data-overlap') == 'yes' ? 0 : $('#grve-inner-header').height(),
282				topBarHeight    = $('#grve-header').attr( 'data-topbar' ) == 'yes' ? $('#grve-top-bar').height() : 0,
283				$section        = $(this.container);
284			if( isMobile.any() &&  window.location !== window.parent.location ) {
285				windowHeight  = window.screen.height;
286			}
287			var sectionHeight = windowHeight - headerHeight - wpBarHeight - topBarHeight;
288			$section.css({ 'height' : sectionHeight });
289			$section.parent().css({ 'height' : sectionHeight });
290			if( this.featureItem == 'slider' ) {
291				$section.find('.grve-slider-item ').css({ 'height' : sectionHeight });
292			}
293			if( this.featureItem == 'map' ) {
294				$section.find('.grve-map ').css({ 'height' : sectionHeight });
295			}
296			if( this.featureItem == 'video' ) {
297				// Add Animation Class
298				$(featureSection.container).addClass('grve-animated');
299			}
300			if(this.featureItem == 'title') {
301				// Add Animation Class
302				$(featureSection.container).addClass('grve-animated');
303			}
304		},
305		customSize: function(){
306			var $section       = $(this.container),
307				customHeight   = $section.attr('data-height');
308			featureSection.resizeFeature( $section, customHeight );
309			$(window).smartresize( function() {
310				featureSection.resizeFeature( $section, customHeight );
311			});
312			if(this.featureItem == 'title') {
313				// Add Animation Class
314				$(featureSection.container).addClass('grve-animated');
315			}
316			if(this.featureItem == 'video') {
317				// Add Animation Class
318				$(featureSection.container).addClass('grve-animated');
319			}
320		},
321		resizeFeature: function( section, customHeight ){
322			if( $(window).width() >= 1200 ) {
323				section.css({ 'height' : customHeight });
324				section.parent().css({ 'height' : customHeight });
325				if( this.featureItem == 'slider' ) {
326					section.find('.grve-slider-item ').css({ 'height' : customHeight });
327				}
328				if( this.featureItem == 'map' ) {
329					section.find('.grve-map ').css({ 'height' : customHeight });
330				}
331			} else {
332				var ratio          = customHeight / 1200,
333					resizeHeight   = parseInt($(window).width() * ratio);
334				section.css({ 'height' : resizeHeight });
335				section.parent().css({ 'height' : resizeHeight });
336				if( this.featureItem == 'slider' ) {
337					section.find('.grve-slider-item ').css({ 'height' : resizeHeight });
338				}
339				if( this.featureItem == 'map' ) {
340					section.find('.grve-map ').css({ 'height' : resizeHeight });
341				}
342			}
343		},
344		featureImageLoad: function(){
345			var $bgImage       = $(this.container).find('.grve-bg-image'),
346				totalBgImage   = $bgImage.length;
347			if (!totalBgImage) {
348				return;
349			}
350			var waitImgDone = function() {
351				totalBgImage--;
352				if (!totalBgImage) {
353					if( $(featureSection.container).find( '.grve-slider').length ) {
354						featureSlider.init();
355					} else {
356						$bgImage.addClass('show');
357						// Add Animation Class
358						$(featureSection.container).addClass('grve-animated');
359
360						// Zoom Image Effect
361						if( $(featureSection.container).data('bg-effect') == 'zoom') {
362							sectionSettings.animatedBg( $(featureSection.container) );
363						}
364					}
365				}
366			};
367			$bgImage.each(function () {
368				function imageUrl(input) {
369					return input.replace(/"/g,"").replace(/url\(|\)$/ig, "");
370				}
371				var image = new Image(),
372					$that = $(this);
373				image.src = imageUrl($that.css('background-image'));
374				$(image).on('load',waitImgDone).on( "error", waitImgDone );
375			});
376		}
377	};
378	//////////////////////////////////////////////////////////////////////////////////////////////////////
379	// FEATURE SLIDER
380	//////////////////////////////////////////////////////////////////////////////////////////////////////
381	var featureSlider = {
382		init: function(){
383			var owl             = $('#grve-feature-slider'),
384				sliderItem      = owl.find('.grve-slider-item '),
385				sliderSpeed     = ( parseInt( owl.attr('data-slider-speed') ) ) ? parseInt( owl.attr('data-slider-speed') ) : 3500,
386				pauseHover      = owl.attr('data-slider-pause') == 'yes' ? true : '',
387				transition      = owl.attr('data-slider-transition') != 'slide' ? owl.attr('data-slider-transition') : false;
388			// Init Slider
389			owl.owlCarousel({
390				navigation      : false,
391				pagination      : false,
392				autoHeight      : false,
393				slideSpeed      : 400,
394				paginationSpeed : 400,
395				afterAction     : featureSlider.afterAction,
396				singleItem      : true,
397				autoPlay        : true,
398				stopOnHover     : pauseHover,
399				baseClass       : 'grve-slider',
400				theme           : 'grve-slider-style',
401				transitionStyle : transition
402			});
403			owl.trigger('owl.play',sliderSpeed);
404			// Slider Navigation
405			owl.parent().find('.grve-carousel-next').on('click',function(){
406				owl.trigger('owl.next');
407			});
408			owl.parent().find('.grve-carousel-prev').on('click',function(){
409				owl.trigger('owl.prev');
410			});
411			sliderItem.find('.grve-bg-image').addClass('show');
412			$(window).on('scroll', function() {
413				var $scroll = $(window).scrollTop();
414				if( $scroll > 10 ){
415					owl.trigger('owl.stop');//Stop Carousel
416				} else {
417					owl.trigger('owl.play',sliderSpeed);//Play Carousel
418				}
419			});
420
421			if ( !Modernizr.csstransforms3d ) {
422				sliderItem.find('.grve-bg-image').css({ 'width' : $(window).width() });
423				$(window).smartresize( function() {
424					sliderItem.find('.grve-bg-image').css({ 'width' : $(window).width() });
425				});
426			}
427		},
428		afterAction: function(){
429			var currentSlide     = this.$owlItems.eq(this.currentItem),
430				sliderColor      = currentSlide.find('.grve-slider-item').attr('data-style'),
431				color            = 'grve-' + sliderColor,
432				sliderTitleColor = currentSlide.find('.grve-slider-item').attr('data-title-color'),
433				titleColor       = 'grve-' + sliderTitleColor;
434
435			// Add Animation Class
436			if ( !Modernizr.csstransforms3d ) {
437				currentSlide.fadeIn('slow').addClass('grve-animated').siblings().hide().removeClass('grve-animated');
438			} else {
439				currentSlide.addClass('grve-animated').siblings().removeClass('grve-animated');
440			}
441			// Set Header Color
442			$('#grve-header').removeClass('grve-default grve-light grve-dark').addClass(color);
443			//Set GoTo Color
444			$('#grve-feature-goto').removeClass('grve-primary-1 grve-primary-2 grve-primary-3 grve-primary-4 grve-primary-5 grve-default grve-light grve-dark').addClass(titleColor);
445
446		}
447	};
448
449	//////////////////////////////////////////////////////////////////////////////////////////////////////
450	// SECTION SETTINGS
451	//////////////////////////////////////////////////////////////////////////////////////////////////////
452	var sectionSettings = {
453
454		config : {
455			section       : '#grve-main-content .grve-section',
456			parentSection : '#grve-content-area, #grve-post-area, #grve-portfolio-area'
457		},
458
459		init: function(){
460
461			$(sectionSettings.config.section).each(function(){
462				var $section      = $(this),
463					heightMode    = $section.attr('data-full-height'),
464					sectionType   = $section.attr('data-section-type'),
465					bgImageType   = $section.attr('data-image-type');
466
467				if( $section.parent().parent().is('.grve-blog-item') ) {
468					$section.css({ 'visibility': 'visible' });
469					return;
470				}
471				if( sectionType == 'fullwidth-background' ){
472					sectionSettings.fullBg($section);
473					$(window).smartresize( function() {
474						sectionSettings.fullBg($section);
475					});
476				}
477				if( sectionType == 'fullwidth-element' ){
478					sectionSettings.fullElement($section);
479					$(window).smartresize( function() {
480						sectionSettings.fullElement($section);
481					});
482				}
483				if( heightMode == 'yes' ) {
484					sectionSettings.fullHeight($section);
485					$(window).smartresize( function() {
486						sectionSettings.fullHeight($section);
487					});
488				}
489				if( bgImageType == 'animated' && !isMobile.any() ) {
490					sectionSettings.animatedBg($section);
491				}
492				$(window).smartresize( function() {
493					pageSettings.resizeVideoBgElement( $section.find('.grve-yt-bg-video') );
494				});
495
496			});
497
498		},
499		fullBg: function(section){
500			var windowWidth      = $(window).width(),
501				contentWidth     = $(sectionSettings.config.parentSection).outerWidth(),
502				sidebarWidth     = $('#grve-sidebar').length && ( windowWidth + scrollBarWidth >= 1024 ) ? $('#grve-sidebar').outerWidth() : 0,
503				conteinerWidth   = contentWidth + sidebarWidth,
504				space            = (windowWidth - conteinerWidth)/2,
505				sidebarSpace     = windowWidth - contentWidth;
506			if( $('.grve-right-sidebar').length && ( windowWidth + scrollBarWidth >= 1024 ) ) {
507				section.css({ 'visibility': 'visible', 'padding-left':space, 'padding-right': sidebarSpace, 'margin-left': -space, 'margin-right': -sidebarSpace});
508			}
509			else if( $('.grve-left-sidebar').length && ( windowWidth + scrollBarWidth >= 1024 ) ) {
510				section.css({ 'visibility': 'visible', 'padding-left':sidebarSpace, 'padding-right': space, 'margin-left': -sidebarSpace, 'margin-right': -space});
511			} else {
512				section.css({ 'visibility': 'visible', 'padding-left':space, 'padding-right': space, 'margin-left': -space, 'margin-right': -space});
513			}
514		},
515		fullElement: function(section){
516			var windowWidth      = $(window).width(),
517				contentWidth     = $(sectionSettings.config.parentSection).outerWidth(),
518				sidebarWidth     = $('#grve-sidebar').length && ( windowWidth + scrollBarWidth >= 1024 ) ? $('#grve-sidebar').outerWidth() : 0,
519				conteinerWidth   = contentWidth + sidebarWidth,
520				space            = (windowWidth - conteinerWidth)/2,
521				sidebarSpace     = windowWidth - contentWidth;
522			if( $('.grve-right-sidebar').length && ( windowWidth + scrollBarWidth >= 1024 ) ) {
523				section.css({ 'visibility': 'visible', 'padding-left':0, 'padding-right': sidebarSpace, 'margin-left': -space, 'margin-right': -sidebarSpace});
524			}
525			else if( $('.grve-left-sidebar').length && ( windowWidth + scrollBarWidth >= 1024 ) ) {
526				section.css({ 'visibility': 'visible', 'padding-left':sidebarSpace, 'padding-right': 0, 'margin-left': -sidebarSpace, 'margin-right': -space});
527			} else {
528				section.css({ 'visibility': 'visible', 'padding-left':0, 'padding-right': 0, 'margin-left': -space, 'margin-right': -space});
529			}
530		},
531		fullHeight: function(section){
532			var windowHeight    = $(window).height(),
533				headerHeight    = $('#grve-header').attr('data-sticky-header') != 'none' && $('#grve-header').length ? $('#grve-inner-header').outerHeight() : 0,
534				fieldBarHeight  = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0,
535				sectionHeight   = section.find('.grve-row').outerHeight(),
536				space           = (windowHeight - headerHeight - fieldBarHeight - sectionHeight)/2;
537			section.css({ 'visibility': 'visible',  'padding-top' : 0, 'padding-bottom' : 0});
538			if(sectionHeight > (windowHeight - headerHeight)){
539				section.css({ 'visibility': 'visible', 'padding-top':40, 'padding-bottom': 40});
540			} else {
541				section.css({ 'visibility': 'visible', 'padding-top':space, 'padding-bottom': space});
542			}
543		},
544		animatedBg: function(section){
545			section.on('mouseenter', function() {	
546				section.addClass('zoom');
547			});
548			section.on('mouseleave', function() {	
549				section.removeClass('zoom');
550			});
551		}
552	};
553	//////////////////////////////////////////////////////////////////////////////////////////////////////
554	// CONTENT SETTINGS
555	//////////////////////////////////////////////////////////////////////////////////////////////////////
556	var pageSettings = {
557		init: function() {
558
559			// HOVERS
560			pageSettings.hovers();
561
562			// BACKGROUND LOAD
563			pageSettings.bgLoader();
564
565			// LIGHT BOX
566			pageSettings.lightBox();
567
568			// Social Share
569			pageSettings.socialShareLinks();
570
571			// Animation Title
572			pageSettings.titleAnimation();
573
574			// Fit Video
575			pageSettings.fitVid();
576
577			// Resize Page, Post, Portfolio Title
578			pageSettings.resizeTitle();
579
580			// Anchor Bar
581			pageSettings.anchorBar();
582
583			// Back to top
584			pageSettings.backtoTop();
585
586			// Goto Section
587			pageSettings.gotoFirstSection();
588
589			// Sticky Sidebar
590			pageSettings.stickySidebar();
591
592			// Footer Settings
593			pageSettings.footerSettings();
594
595			// Grve Pop up
596			pageSettings.grvePopup();
597
598			// Image Load
599			pageSettings.imageLoader();
600
601			// Pie Chart
602			pageSettings.pieChart();
603
604		},
605		hovers: function(){
606			var hoverItem = $('.grve-image-hover');
607			if ( !isMobile.any() ) {
608				hoverItem.off('click');
609				hoverItem.off('mouseenter mouseleave').on('mouseenter mouseleave', function() {
610					$(this).toggleClass('hover');
611				});
612			} else {
613				hoverItem.off('mouseenter mouseleave');
614				hoverItem.off('click').on('click', function() {
615					hoverItem.removeClass('hover');
616					$(this).toggleClass('hover');
617				});
618			}
619		},
620		bgLoader: function() {
621			$('#grve-main-content .grve-bg-image, #grve-footer .grve-bg-image').each(function () {
622				function imageUrl(input) {
623					return input.replace(/"/g,"").replace(/url\(|\)$/ig, "");
624				}
625				var image = new Image(),
626					$that = $(this);
627				image.src = imageUrl($that.css('background-image'));
628				image.onload = function () {
629					$that.addClass('show');
630				};
631			});
632		},
633		lightBox: function(){
634			//IMAGE
635			$('.grve-image-popup').each(function() {
636				$(this).magnificPopup({
637					type: 'image',
638					preloader: false,
639					fixedBgPos: true,
640					fixedContentPos: true,
641					removalDelay: 200,
642					callbacks: {
643						beforeOpen: function() {
644							var mfpWrap = this.wrap;
645							this.bgOverlay.fadeIn(200);
646							pageSettings.addSpinner( mfpWrap );
647						},
648						imageLoadComplete: function() {
649							var $spinner = this.wrap.find('.grve-loader'),
650								$content = this.container;
651							pageSettings.removeSpinner( $spinner, $content );
652
653						},
654						beforeClose: function() {
655							this.wrap.fadeOut(100);
656							this.bgOverlay.fadeOut(100);
657						},
658					},
659					image: {
660						verticalFit: true,
661						titleSrc: function(item) {
662							var title   = item.el.data( 'title' ) ? item.el.data( 'title' ) : '',
663								caption = item.el.data('desc') ? '<br><small>' + item.el.data('desc') + '</small>' : '';
664							if ( '' === title ) {
665								title   = item.el.find('.grve-title').html() ? item.el.find('.grve-title').html() : '';
666							}
667							if ( '' === caption ) {
668								caption = item.el.find('.grve-caption').html() ? '<br><small>' + item.el.find('.grve-caption').html() + '</small>' : '';
669							}
670							return title + caption;
671						}
672					}
673				});
674			});
675			$('.grve-gallery-popup, .grve-post-gallery-popup').each(function() {
676				$(this).magnificPopup({
677					delegate: 'a',
678					type: 'image',
679					preloader: false,
680					fixedBgPos: true,
681					fixedContentPos: true,
682					removalDelay: 200,
683					callbacks: {
684						beforeOpen: function() {
685							var mfpWrap = this.wrap;
686							this.bgOverlay.fadeIn(200);
687							pageSettings.addSpinner( mfpWrap );
688						},
689						imageLoadComplete: function() {
690							var $spinner = this.wrap.find('.grve-loader'),
691								$content = this.container;
692							pageSettings.removeSpinner( $spinner, $content );
693
694						},
695						beforeClose: function() {
696							this.wrap.fadeOut(100);
697							this.bgOverlay.fadeOut(100);
698						},
699					},
700					gallery: {
701						enabled:true
702					},
703					image: {
704						tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
705						titleSrc: function(item) {
706							var title   = item.el.data( 'title' ) ? item.el.data( 'title' ) : '',
707								caption = item.el.data('desc') ? '<br><small>' + item.el.data('desc') + '</small>' : '';
708							if ( '' === title ) {
709								title   = item.el.find('.grve-title').html() ? item.el.find('.grve-title').html() : '';
710							}
711							if ( '' === caption ) {
712								caption = item.el.find('.grve-caption').html() ? '<br><small>' + item.el.find('.grve-caption').html() + '</small>' : '';
713							}
714							return title + caption;
715						}
716					}
717				});
718			});
719
720			if( 1 == grve_main_data.grve_wp_gallery_popup ) {
721				$('.gallery').each(function() {
722					$(this).magnificPopup({
723						delegate: 'a',
724						type: 'image',
725						preloader: false,
726						fixedBgPos: true,
727						fixedContentPos: true,
728						removalDelay: 200,
729						callbacks: {
730							beforeOpen: function() {
731								var mfpWrap = this.wrap;
732								this.bgOverlay.fadeIn(200);
733								pageSettings.addSpinner( mfpWrap );
734							},
735							imageLoadComplete: function() {
736								var $spinner = this.wrap.find('.grve-loader'),
737									$content = this.container;
738								pageSettings.removeSpinner( $spinner, $content );
739
740							},
741							beforeClose: function() {
742								this.wrap.fadeOut(100);
743								this.bgOverlay.fadeOut(100);
744							},
745						},
746						gallery: {
747							enabled:true
748						},
749						image: {
750							tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
751							titleSrc: function(item) {
752								var title   = item.el.closest('.gallery-item').find('.gallery-caption').html() ? item.el.closest('.gallery-item').find('.gallery-caption').html() : '';
753								return title;
754							}
755						}
756					});
757				});
758			}
759			//VIDEOS
760			if ( $('#grve-body').hasClass( 'grve-privacy-video-embeds-disabled' ) ) {
761				$('.grve-youtube-popup, .grve-vimeo-popup, .grve-video-popup').each(function() {
762					$(this).attr({"target" : "_blank"});
763				});
764			} else {
765				$('.grve-youtube-popup, .grve-vimeo-popup, .grve-video-popup').each(function() {
766					$(this).magnificPopup({
767						disableOn: 0,
768						type: 'iframe',
769						preloader: false,
770						fixedBgPos: true,
771						fixedContentPos: true,
772						removalDelay: 200,
773						callbacks: {
774							beforeOpen: function() {
775								var mfpWrap = this.wrap;
776								this.bgOverlay.fadeIn(200);
777								pageSettings.addSpinner( mfpWrap );
778							},
779							open: function() {
780								var $spinner = this.wrap.find('.grve-loader'),
781									$content = this.container;
782								pageSettings.removeSpinner( $spinner, $content );
783							},
784							beforeClose: function() {
785								this.wrap.fadeOut(100);
786								this.bgOverlay.fadeOut(100);
787							},
788						}
789					});
790				});
791			}
792
793			$('.grve-page-popup').each(function() {
794				$(this).magnificPopup({
795					disableOn: 0,
796					type: 'iframe',
797					preloader: false,
798					fixedBgPos: true,
799					fixedContentPos: true,
800					removalDelay: 200,
801					callbacks: {
802						beforeOpen: function() {
803							var mfpWrap = this.wrap;
804							this.bgOverlay.fadeIn(200);
805							pageSettings.addSpinner( mfpWrap );
806						},
807						open: function() {
808							var $spinner = this.wrap.find('.grve-loader'),
809								$content = this.container;
810							pageSettings.removeSpinner( $spinner, $content );
811						},
812						beforeClose: function() {
813							this.wrap.fadeOut(100);
814							this.bgOverlay.fadeOut(100);
815						},
816					}
817				});
818			});
819		},
820		addSpinner: function( mfpWrap ){
821			var spinner = '<div class="grve-loader"></div>';
822			$(spinner).appendTo( mfpWrap );
823		},
824		removeSpinner: function( spinner, content){
825			setTimeout(function(){
826				spinner.fadeOut(1000, function(){
827					content.animate({'opacity':1},600);
828				});
829			}, 700);
830		},
831		socialShareLinks: function(){
832			$('.grve-social-share-facebook').on('click',function(e){
833				e.preventDefault();
834				window.open( 'https://www.facebook.com/sharer/sharer.php?u=' + $(this).attr('href'), "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
835				return false;
836			});
837			$('.grve-social-share-twitter').on('click',function(e){
838				e.preventDefault();
839				window.open( 'http://twitter.com/intent/tweet?text=' + encodeURIComponent( $(this).attr('title') ) + ' ' + $(this).attr('href'), "twitterWindow", "height=450,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
840				return false;
841			});
842			$('.grve-social-share-linkedin').on('click',function(e){
843				e.preventDefault();
844				window.open( 'http://www.linkedin.com/shareArticle?mini=true&url=' + $(this).attr('href') + '&title=' + encodeURIComponent( $(this).attr('title') ), "linkedinWindow", "height=500,width=820,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
845				return false;
846			});
847			$('.grve-social-share-googleplus').on('click',function(e){
848				e.preventDefault();
849				window.open( 'https://plus.google.com/share?url=' + $(this).attr('href'), "googleplusWindow", "height=600,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
850				return false;
851			});
852			$('.grve-social-share-pinterest').on('click',function(e){
853				e.preventDefault();
854				window.open( 'http://pinterest.com/pin/create/button/?url=' + $(this).attr('href') + '&media=' + $(this).data('pin-img') + '&description=' + encodeURIComponent( $(this).attr('title') ), "pinterestWindow", "height=600,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
855				return false;
856			});
857			$('.grve-social-share-reddit').on('click',function(e){
858				e.preventDefault();
859				window.open( '//www.reddit.com/submit?url=' + $(this).attr('href'), "redditWindow", "height=600,width=820,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" );
860				return false;
861			});
862			$('.grve-like-counter-link').on('click',function(e){
863				e.preventDefault();
864				var link = $(this);
865				var id = link.data('post-id'),
866					counter = link.parent().find('.grve-like-counter');
867
868				var dataParams = {
869					action:'grve_likes_callback',
870					grve_likes_id: id,
871					_grve_nonce: grve_main_data.nonce_likes
872				};
873				
874				$.post( grve_main_data.ajaxurl, dataParams , function( response ) {
875					counter.html(response);
876				}).fail(function(xhr, status, error) {
877				});
878
879				return false;
880			});
881		},
882		postSocials: function(){
883			var $selector = $('#grve-post-title #grve-social-share');
884			if(!$selector.length || isMobile.any()) {
885				return;
886			}
887			stickyItems.init({ element : $selector, offset : 10 });
888			$(window).scroll(function(){
889				var socialTop     = $selector.offset().top,
890					fieldsBarTop  = $('.grve-fields-bar').offset().top;
891				if( socialTop ==  fieldsBarTop + 10 ) {
892					$selector.addClass('in-bar');
893				} else {
894					$selector.removeClass('in-bar');
895				}
896			});
897		},
898		titleAnimation: function(){
899			var titleContainer = $('#grve-page-title, #grve-post-title, #grve-portfolio-title, #grve-product-title');
900			titleContainer.find('.grve-container').addClass('grve-animated');
901		},
902		fitVid: function(){
903			$('.grve-video, .grve-media').fitVids();
904			$('iframe[src*="youtube"]').parent().fitVids();
905			$('iframe[src*="vimeo"]').parent().fitVids();
906		},
907		resizeTitle: function(){
908			var titleContainer =  $(' #grve-page-title-content');
909			if( $('#grve-post-title').length ) {
910				titleContainer =  $(' #grve-post-title-content');
911			}
912			if( $('#grve-portfolio-title').length ) {
913				titleContainer =  $(' #grve-portfolio-title-content');
914			}
915			if( $('#grve-product-title').length ) {
916				titleContainer =  $(' #grve-product-title-content');
917			}
918			if( titleContainer.length ) {
919				featureSection.resizeFeature( titleContainer, titleContainer.attr('data-height') );
920				$(window).smartresize( function() {
921					featureSection.resizeFeature( titleContainer, titleContainer.attr('data-height') );
922				});
923			}
924		},
925		anchorBar: function(){
926			var $selector   = $('#grve-anchor-menu'),
927				$section       = $('#grve-main-content .grve-section[id]'),
928				headerHeight   = 0,
929				fieldBarHeight = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0,
930				$menu       = $selector.find('ul'),
931				$menuIcon   = $selector.find('.grve-icon-menu');
932
933			if( $('#grve-header').data('sticky-header') != 'none' ){
934				if( $('#grve-header').hasClass('grve-logo-top') ) {
935					headerHeight = $('.grve-bottom-header').outerHeight();
936				} else {
937					headerHeight = $('#grve-inner-header').outerHeight();
938				}
939			}
940
941			var offsetTop = headerHeight + fieldBarHeight + wpBarHeight;
942
943			if(!$selector.length) {
944				return;
945			}
946			pageSettings.anchorBarUpdate( $selector, $menu );
947			$(window).smartresize( function() {
948				pageSettings.anchorBarUpdate( $selector, $menu );
949			});
950			$menuIcon.on('click',function(){
951				$menu.slideToggle(100);
952			});
953
954			$(window).on("scroll", function() {
955				if(!$selector.hasClass('grve-current-link')) {
956					return;
957				}
958
959				var scroll = $(window).scrollTop();
960
961				$section.each(function(){
962					var $that         = $(this),
963						currentId     = $that.attr('id'),
964						sectionOffset = $that.offset().top - offsetTop -1;
965
966					if (sectionOffset <= scroll && sectionOffset + $that.outerHeight() > scroll ) {
967						$('#grve-anchor-menu a[href*="#' + currentId + '"]').parent().addClass('current');
968					}
969					else{
970						$('#grve-anchor-menu a[href*="#' + currentId + '"]').parent().removeClass("current");
971					}
972
973				});
974			});
975		},
976		anchorBarUpdate: function( selector, menu ){
977			var $selector   = selector,
978				$menu       = menu,
979				menuWidth   = $menu.outerWidth(),
980				windowWidth = $(window).width();
981			if( menuWidth >= windowWidth ) {
982				$selector.addClass('grve-responsive-bar');
983				$menu.css('display', 'none');
984			}
985		},
986		backtoTop: function() {
987			var selectors  = {
988				topBtn     : '.grve-top-btn',
989				dividerBtn : '.grve-divider-backtotop',
990				topLink    : 'a[href="#grve-goto-header"]'
991			};
992			// Show backtoTop Button
993			if( $('#grve-header').attr('data-backtotop') != 'no' ) {
994				var btnUp = $('<div/>', {'class':'grve-top-btn grve-icon-nav-up'});
995					btnUp.appendTo('#grve-theme-wrapper');
996
997				$(window).on('scroll', function() {
998					if ($(this).scrollTop() > 600) {
999						$('.grve-top-btn').addClass('show');
1000					} else {
1001						$('.grve-top-btn').removeClass('show');
1002					}
1003				});
1004			}
1005			$.each(selectors, function(key, value){
1006				$(value).on('click', function(){
1007					$('html, body').animate({scrollTop: 0}, 900);
1008				});
1009			});
1010
1011		},
1012		gotoFirstSection: function(){
1013			var $selector    = $('#grve-feature-section .grve-goto-section'),
1014				$nextSection    = $('#grve-main-content .grve-section').first().length ? $('#grve-main-content .grve-section').first() : $('#grve-main-content'),
1015				topOffset       = 0,
1016				fieldBarHeight  = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0;
1017
1018			if( !isMobile.any() &&  $('#grve-header').data('sticky-header') != 'none' ){
1019				if( $('#grve-header').hasClass('grve-logo-top') ) {
1020					topOffset = $('.grve-bottom-header').outerHeight();
1021				} else {
1022					topOffset = $('#grve-inner-header').outerHeight();
1023				}
1024			}
1025
1026			if( $nextSection.length ) {
1027				$selector.on('click',function(){
1028					$('html,body').animate({
1029						scrollTop: $nextSection.offset().top - topOffset - fieldBarHeight
1030					}, 1000);
1031					return false;
1032				});
1033			}
1034		},
1035		stickySidebar: function(){
1036			var $item    = $('#grve-sidebar.grve-fixed-sidebar'),
1037				$content = $('#grve-content-area, #grve-post-area, #grve-portfolio-area');
1038			if( !$item.length ) {
1039				return;
1040			}
1041			var itemId          = $item.attr('id'),
1042				itemHeight      = $item.outerHeight(),
1043				itemWidth       = $item.outerWidth() - 1,
1044				itemFloat       = $item.css('float'),
1045				headerHeight    = $('#grve-inner-header').outerHeight(),
1046				titleHeight     = $('#grve-page-title').length ? $('#grve-page-title').outerHeight() : 0,
1047				fieldBarHeight  = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0,
1048				topBarHeight    = $('#grve-top-bar').length ? $('#grve-top-bar').outerHeight() : 0,
1049				offset          = headerHeight + fieldBarHeight + 30,
1050				windowHeight    = $(window).height();
1051			if( itemHeight > windowHeight || isMobile.any() ) {
1052				return false;
1053			}
1054			// Create A Helper Wrapper
1055			$item.wrap('<div id="' + itemId + '-wrapper"></div>' );
1056			$item.parent().css({
1057				'width'    : itemWidth,
1058				'height'   : itemHeight,
1059				'float'    : itemFloat,
1060				'position' : 'relative'
1061			});
1062			$item.css({
1063				'width'    : itemWidth,
1064				'position' : 'static'
1065			});
1066			$(window).on('scroll', function() {
1067				var contentHeight = $content.outerHeight(),
1068					contentTop    = $content.offset().top,
1069					contentBottom = contentTop + contentHeight;
1070				if( ( $(window).scrollTop() > contentTop - offset ) && ( $(window).scrollTop() < contentBottom - ( offset + itemHeight ) )){
1071					$item.css({'position':'fixed', 'width' : itemWidth, 'top': offset });
1072				}
1073				else if( $(window).scrollTop() > contentTop ){
1074					$item.css({'position':'absolute', 'top': contentHeight - itemHeight });
1075				}
1076				else if( $(window).scrollTop() < contentTop ){
1077					$item.css({'position':'static', 'top':'auto' });
1078				}
1079			});
1080		},
1081		footerSettings: function() {
1082			$('#grve-footer .grve-section').each(function(){
1083				var $that = $(this),
1084					sectionType = $that.attr('data-section-type');
1085				if( sectionType == 'fullwidth-background' ){
1086					pageSettings.footerFullBg($that);
1087					$(window).smartresize( function() {
1088						pageSettings.footerFullBg($that);
1089					});
1090				}
1091				if( sectionType == 'fullwidth-element' ){
1092					pageSettings.footerFullElement($that);
1093					$(window).smartresize( function() {
1094						pageSettings.footerFullElement($that);
1095					});
1096				}
1097			});
1098		},
1099		footerFullBg: function(element){
1100			var windowWidth    = $(window).width(),
1101				contentWidth   = element.parent().width(),
1102				space          = (windowWidth - contentWidth)/2;
1103			element.css({ 'visibility': 'visible', 'padding-left':space, 'padding-right': space, 'margin-left': -space, 'margin-right': -space});
1104		},
1105		footerFullElement: function(element){
1106			var windowWidth   = $(window).width(),
1107				contentWidth  = element.parent().width(),
1108				space         = (windowWidth - contentWidth)/2;
1109			element.css({ 'visibility': 'visible', 'padding-left':0, 'padding-right': 0, 'margin-left': -space, 'margin-right': -space});
1110		},
1111		grvePopup: function(){
1112			var $selector = $('.grve-open-popup-link'),
1113				delay = 0;
1114
1115			$selector.on( "click", function(e){
1116				e.preventDefault();
1117				var target = $(this).attr('href');
1118				if( !$(target).length ){
1119					return;
1120				} else {
1121					if( $(this).parents('#grve-main-menu-responsive').length ) {
1122						delay = 2000;
1123					}
1124					setTimeout(function(){
1125						$(target).addClass('grve-show-modal');
1126						if ( '#grve-search-modal' == target ) {
1127							setTimeout(function(){
1128								$("#grve-search-modal .grve-search-textfield").focus();
1129							},200);
1130						}
1131					},delay);
1132
1133					$('.grve-popup-overlay, .grve-close-modal').on( "click", function(e){
1134						if ( !$(target).is(e.target) ) {
1135							$(target).removeClass('grve-show-modal');
1136						}
1137					});
1138				}
1139			});
1140		},
1141		imageLoader: function(){
1142			var selectors  = {
1143				singleImage  : '.grve-image',
1144				media        : '.grve-media'
1145			};
1146			$.each(selectors, function(key, value){
1147				if( $(this).length ){
1148					var item     = $(this),
1149						imgLoad  = imagesLoaded( item );
1150					imgLoad.on( 'always', function() {
1151						if( $(value).parent().is('#grve-single-media') ){
1152							$(value).find('img').animate({ 'opacity': 1 },1000);
1153						} else {
1154							$(value).find('img').css('opacity', 1);
1155						}
1156					});
1157				}
1158			});
1159		},
1160		addVideoBg: function(){
1161			$('.grve-yt-bg-video').each(function() {
1162				var $element = $(this);
1163				var url = $element.data("video-bg-url");
1164				var videoID = url.match( /[\\?&]v=([^&#]*)/ )[ 1 ];
1165				if( '' !== videoID ) {
1166					insertYouTubeVideo($element, videoID );
1167				}
1168			});
1169			function insertYouTubeVideo($element, youtubeId, counter) {
1170				if ("undefined" === typeof YT || "undefined" === typeof YT.Player) {
1171					counter = "undefined" === typeof counter ? 0 : counter;
1172					if (100 < counter) {
1173						console.warn("Too many attempts to load YouTube api");
1174						return;
1175					}
1176					setTimeout(function() {
1177						insertYouTubeVideo($element, youtubeId, counter++);
1178					}, 100);
1179					return;
1180				}
1181				var startSeconds = $element.data('video-start') !== undefined ? parseInt( $element.data('video-start') ) : 0;
1182				var endSeconds = $element.data('video-end') !== undefined ? parseInt( $element.data('video-end') ) : 0;
1183				var $container = $element.prepend('<div class="grve-bg-youtube-video"><div class="inner"></div></div>').find(".inner");
1184				var ytPlayer = new YT.Player($container[0], {
1185					width: "100%",
1186					height: "100%",
1187					videoId: youtubeId,
1188					playerVars: {
1189						playlist: youtubeId,
1190						iv_load_policy: 3,
1191						enablejsapi: 1,
1192						disablekb: 1,
1193						autoplay: 1,
1194						controls: 0,
1195						showinfo: 0,
1196						rel: 0,
1197						loop: 1,
1198						start: startSeconds,
1199						end: endSeconds,
1200						wmode: "transparent"
1201					},
1202					events: {
1203						'onReady': onPlayerReady,
1204						'onStateChange': onPlayerStateChange
1205					}
1206				});
1207				function onPlayerReady(event) {
1208					event.target.mute().setLoop(true);
1209				}
1210				function onPlayerStateChange(event) {
1211					if ( 0 != startSeconds || 0 != endSeconds ) {
1212						if (event.data === YT.PlayerState.ENDED) {
1213							ytPlayer.loadVideoById({
1214								videoId: youtubeId,
1215								startSeconds: startSeconds,
1216								endSeconds: endSeconds
1217							});
1218						}
1219					}
1220				}
1221				// Resize Video
1222				pageSettings.resizeVideoBgElement( $element );
1223			}
1224		},
1225		resizeVideoAllYTBg: function(){
1226			$('.grve-yt-bg-video').each(function(){
1227				pageSettings.resizeVideoBgElement( $(this) );
1228			});
1229		},
1230		resizeVideoBgElement: function( $element ){
1231			var videoEl,
1232				videoW,
1233				videoH,
1234				marginLeft,
1235				marginTop,
1236				containerW = $element.innerWidth(),
1237				containerH = $element.innerHeight(),
1238				ratio1 = 16,
1239				ratio2 = 9;
1240
1241			if (containerW / containerH < ratio1 / ratio2) {
1242				videoW = containerH * (ratio1 / ratio2);
1243				videoH = containerH;
1244				videoW += 'px';
1245				videoH += 'px';
1246			} else {
1247				videoW = containerW;
1248				videoH = containerW * (ratio2 / ratio1);
1249				videoW += 'px';
1250				videoH += 'px';
1251			}
1252			if( $element.hasClass('grve-yt-bg-video') || $element.hasClass('grve-iframe-bg-video') ) {
1253				videoEl = 'iframe';
1254			} else {
1255				videoEl = 'video';
1256			}
1257
1258			$element.find( videoEl ).css({
1259				maxWidth: '1000%',
1260				width: videoEl == 'iframe' ? videoW : '',
1261				height: videoH
1262			});
1263		},
1264		removeVideoBg: function(){
1265			$('.grve-bg-video').each(function () {
1266				var $wrapper = $(this).parent(),
1267					$bgImage = $wrapper.find('.grve-bg-image'),
1268					$bgVideo = $wrapper.find('.grve-bg-video'),
1269					$bgHtml5Video = $wrapper.find('.grve-html5-bg-video'),
1270					$bgYtVideo = $wrapper.find('.grve-yt-bg-video'),
1271					$bgIFrameVideo = $wrapper.find('.grve-iframe-bg-video');
1272
1273				var bgVideoDevice = $bgVideo.data('videoDevice') !== undefined ? $bgVideo.data('videoDevice') : 'no';
1274				if( isMobile.any() && 'no' === bgVideoDevice) {
1275					$bgVideo.remove();
1276				} else {
1277
1278					if ( $bgHtml5Video.length ) {
1279						var $videoElement = $wrapper.find('.grve-bg-video video');
1280						var canPlayVideo = false;
1281						$wrapper.find('.grve-bg-video source').each(function(){
1282							if ( $videoElement.get(0).canPlayType( $(this).attr('type') ) ) {
1283								canPlayVideo = true;
1284							}
1285						});
1286						if(canPlayVideo) {
1287							$bgImage.remove();
1288						} else {
1289							$bgVideo.remove();
1290						}
1291					}
1292					if ( $bgYtVideo.length || $bgIFrameVideo.length ) {
1293						$bgImage.remove();
1294					}
1295				}
1296			});
1297		},
1298		gotoSection: function(){
1299			if( $('#grve-header').data('gotosection') == 'yes' ) {
1300				var $section     = $('#grve-main-content .grve-section[id]'),
1301					$anchorList  = $('<ul id="grve-anchor-list"></ul>'),
1302					$mainContent = $('#grve-main-content');
1303
1304				$anchorList.appendTo( $mainContent );
1305
1306				$section.each(function( i , n){
1307					var $that        = $(this),
1308						sectionId    = $that.attr('id'),
1309						sectionTitle = $that.data('section-title').length ? '<span>' + $that.data('section-title') + '</span>' : '',
1310						$anchorItem  = $('<li data-anclink="' + sectionId + '">' + sectionTitle + '</li>');
1311
1312					$anchorItem.appendTo('#grve-anchor-list');
1313				});
1314				// Show or Hide Go to Section
1315				pageSettings.showHideGoTo();
1316
1317				var $listItem = $('#grve-anchor-list li');
1318				$listItem.click(function(){
1319					var headerHeight = 0,
1320						fieldBarHeight  = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0;
1321
1322					if( $('#grve-header').data('sticky-header') != 'none' ){
1323						if( $('#grve-header').hasClass('grve-logo-top') ) {
1324							headerHeight = $('.grve-bottom-header').outerHeight();
1325						} else {
1326							headerHeight = $('#grve-inner-header').outerHeight();
1327						}
1328					}
1329					var offsetTop = headerHeight + fieldBarHeight + wpBarHeight;
1330
1331					var target = $(this).data('anclink');
1332					$('html, body').animate({scrollTop: $('#'+ target).offset().top - ( offsetTop - 1 )}, 600);
1333				});
1334			}
1335		},
1336		showHideGoTo: function(){
1337			var contentOffSet  = $('#grve-main-content').offset().top,
1338				$section       = $('#grve-main-content .grve-section'),
1339				$anchorList    = $('#grve-anchor-list'),
1340				$anchorItem    = $('#grve-anchor-list li'),
1341				headerHeight   = 0,
1342				fieldBarHeight = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0;
1343
1344			if( $('#grve-header').data('sticky-header') != 'none' ){
1345				if( $('#grve-header').hasClass('grve-logo-top') ) {
1346					headerHeight = $('.grve-bottom-header').outerHeight();
1347				} else {
1348					headerHeight = $('#grve-inner-header').outerHeight();
1349				}
1350			}
1351			var offsetTop = headerHeight + fieldBarHeight + wpBarHeight;
1352
1353
1354			$(window).on("scroll", function() {
1355				var scroll        = $(window).scrollTop(),
1356					sectionOffset = $section.offset().top,
1357					anchorOffset  = $anchorList.offset().top,
1358					anchorHeight  = $anchorList.height();
1359
1360				if( scroll > contentOffSet - offsetTop ){
1361					$anchorList.addClass( 'show ');
1362				} else {
1363					$anchorList.removeClass( 'show' );
1364				}
1365
1366				$anchorItem.each(function(){
1367					var currLink         = $(this).data('anclink'),
1368						refElement       = $('#' + currLink),
1369						refElementMargin = parseInt(refElement.css('margin-bottom')),
1370						refElementOffset =  refElement.offset().top - offsetTop;
1371
1372					if (refElementOffset <= anchorOffset - anchorHeight/2 && refElementOffset + refElement.outerHeight() + refElementMargin > anchorOffset - anchorHeight/2) {
1373						$(this).addClass("active");
1374					}
1375					else{
1376						$(this).removeClass("active");
1377					}
1378
1379				});
1380			});
1381
1382		},
1383		refMainMenu: function(){
1384
1385			var $section       = $('#grve-main-content .grve-section[id]'),
1386				headerHeight   = 0,
1387				fieldBarHeight = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0;
1388
1389
1390			if( $('#grve-header').data('sticky-header') != 'none' ){
1391				if( $('#grve-header').hasClass('grve-logo-top') ) {
1392					headerHeight = $('.grve-bottom-header').outerHeight();
1393				} else {
1394					headerHeight = $('#grve-inner-header').outerHeight();
1395				}
1396			}
1397
1398			var offsetTop = headerHeight + fieldBarHeight + wpBarHeight;
1399
1400			$(window).on("scroll", function() {
1401				var scroll = $(window).scrollTop();
1402
1403				$section.each(function(){
1404					var $that         = $(this),
1405						currentId     = $that.attr('id'),
1406						sectionOffset = $that.offset().top - offsetTop;
1407
1408					if (sectionOffset <= scroll && sectionOffset + $that.outerHeight() > scroll ) {
1409						$('#grve-main-menu a[href*="#' + currentId + '"]').parent().addClass('active');
1410					}
1411					else{
1412						$('#grve-main-menu a[href*="#' + currentId + '"]').parent().removeClass("active");
1413					}
1414
1415				});
1416			});
1417		},
1418		pieChart: function(){
1419
1420			$('.grve-chart-number').each(function() {
1421				var $element = $(this),
1422					delay       = $element.parent().attr('data-delay') !== '' ? parseInt( $element.parent().attr('data-delay') ) : 0,
1423					chartSize   = '170';
1424
1425				$element.css({ 'width' : chartSize, 'height' : chartSize, 'line-height' : chartSize + 'px' });
1426
1427				$element.appear(function() {
1428					setTimeout(function () {
1429						pageSettings.pieChartInit( $element );
1430					}, delay);
1431				});
1432			});
1433
1434		},
1435		pieChartInit: function( $element ){
1436
1437			var activeColor = $element.data('pie-active-color') !== '' ? $element.data('pie-active-color') : 'rgba(0,0,0,1)',
1438				pieColor    = $element.data('pie-color') !== '' ? $element.data('pie-color') : 'rgba(0,0,0,0.1)',
1439				pieLineCap  = $element.data('pie-line-cap') !== '' ? $element.data('pie-line-cap') : 'round',
1440				lineSize    = $element.data('pie-line-size') !== '' ? $element.data('pie-line-size') : '6',
1441				chartSize   = '170';
1442
1443
1444			$element.easyPieChart({
1445				barColor: activeColor,
1446				trackColor: pieColor,
1447				scaleColor: false,
1448				lineCap: pieLineCap,
1449				lineWidth: lineSize,
1450				animate: 1500,
1451				size: chartSize
1452			});
1453		},
1454		fixedFooter: function(){
1455			var $footer = $('#grve-footer'),
1456				sticky  = $footer.data('sticky-footer');
1457			if( sticky != 'yes' || isMobile.any() ) {
1458				return;
1459			} else {
1460				pageSettings.footerHeight();
1461				$(window).smartresize( function() {
1462					pageSettings.footerHeight();
1463				});
1464			}
1465		},
1466		footerHeight: function(){
1467			var $footer      = $('#grve-footer'),
1468				windowHeight = $(window).height(),
1469				footerHeight = $footer.outerHeight();
1470
1471			if( footerHeight > windowHeight ) {
1472				$('#grve-footer').removeClass('grve-sticky-footer').prev().css('margin-bottom',0);
1473			} else {
1474				$('#grve-footer').addClass('grve-sticky-footer').prev().css('margin-bottom',footerHeight);
1475			}
1476
1477		}
1478	};
1479
1480	// -------------------------------------------------------------------------------------------
1481	// SIDE MENU OPEN
1482	// -------------------------------------------------------------------------------------------
1483	var menuOpen = false;
1484
1485	var headerOptions = {
1486
1487		menuIcon     : $('#grve-header-options > li'),
1488		menuWrapper  : $('.grve-options-wrapper'),
1489
1490		init: function(){
1491			this.menuIcon.on('click',function(e){
1492				e.preventDefault();
1493				if(menuOpen) {
1494					headerOptions.closeMenu();
1495				} else {
1496					headerOptions.openMenu();
1497				}
1498			});
1499
1500			if( isMobile.any() ) {
1501				return;
1502			} else {
1503				this.menuIcon.on( 'mouseover', function() { headerOptions.openIconMenu(); } );
1504				this.menuWrapper.on( 'mouseover', function() { headerOptions.openMenu(); } );
1505				this.menuIcon.on( 'mouseout', function() { headerOptions.closeMenu(); });
1506			}
1507		},
1508		openIconMenu: function(){
1509			this.menuWrapper.addClass('grve-open-part');
1510			this.menuIcon.addClass('grve-open');
1511		},
1512		openMenu: function(){
1513			this.menuWrapper.addClass('grve-open-all');
1514			this.menuIcon.addClass('grve-open');
1515			menuOpen = true;
1516		},
1517		closeMenu: function(){
1518			this.menuWrapper.removeClass('grve-open-part grve-open-all');
1519			this.menuIcon.removeClass('grve-open');
1520			menuOpen = false;
1521		}
1522	};
1523
1524	//////////////////////////////////////////////////////////////////////////////////////////////////////
1525	// SET EQUAL COLUMNS HEIGHT
1526	//////////////////////////////////////////////////////////////////////////////////////////////////////
1527	var setColumnHeight = {
1528		init: function(){
1529			var section     = '.grve-section',
1530				windowWidth = $(window).width() + scrollBarWidth;
1531
1532			$(section).each(function(){
1533				var $that   = $(this),
1534					$column = $that.find('.grve-row').first().children();
1535
1536				if( $that.hasClass('grve-flex-row') ) {
1537					equalHeight( $that, $column );
1538				}
1539				if( $that.hasClass('grve-middle-content') ) {
1540					middleContent( $that, $column );
1541				}
1542			});
1543
1544			function equalHeight( section, $column ) {
1545				section.imagesLoaded('always',function(){
1546					$column.css({ 'min-height': '', 'padding-top': '', 'padding-bottom': '' });
1547					var maxHeight = setColumnHeight.getMaxHeight( section );
1548					if( ( windowWidth <= tabletLandscape && $column.hasClass('grve-tablet-column-1') ) || windowWidth <= tabletPortrait ) {
1549						$column.css({ 'min-height': '', 'visibility': 'visible'  });
1550					} else {
1551						$column.css({ 'min-height': maxHeight, 'visibility': 'visible'  });
1552					}
1553				});
1554			}
1555
1556			function middleContent( section, $column ) {
1557				section.imagesLoaded('always',function(){
1558					$column.css({ 'min-height': '', 'padding-top': '', 'padding-bottom': '' });
1559					var maxHeight = setColumnHeight.getMaxHeight( section );
1560					if( ( windowWidth <= tabletLandscape && $column.hasClass('grve-tablet-column-1') ) || windowWidth <= tabletPortrait ) {
1561						$column.css({ 'padding-top': '', 'padding-bottom': '', 'min-height': '', 'visibility': 'visible'  });
1562						section.find('.wpb_column').css({ 'visibility': 'visible'  });
1563					} else {
1564						$column.each(function(){
1565							var columnHeigth = $(this).outerHeight();
1566							if( columnHeigth <= maxHeight ) {
1567								var space = ( maxHeight - columnHeigth ) / 2;
1568								$(this).css({ 'padding-top' : space, 'padding-bottom' : space });
1569							}
1570						});
1571						section.find('.wpb_column').css({ 'visibility': 'visible'  });
1572					}
1573				});
1574			}
1575
1576		},
1577		getMaxHeight: function( section ){
1578			var $that         = section,
1579				sectionHeight = $that.height(),
1580				maxHeight     = sectionHeight;
1581
1582			return maxHeight;
1583		}
1584	};
1585	$(window).smartresize( function() {
1586		setColumnHeight.init();
1587	});
1588
1589	//////////////////////////////////////////////////////////////////////////////////////////////////////
1590	// CLASSIC ELEMENTS
1591	//////////////////////////////////////////////////////////////////////////////////////////////////////
1592	var classicElements = {
1593		init: function(){
1594			//Accordion Toggle
1595			classicElements.accordionToggle();
1596
1597			// Animation Appear
1598			classicElements.animAppear();
1599
1600			//Progress Bars
1601			classicElements.progressBars();
1602
1603			// Tabs
1604			classicElements.tabs();
1605
1606			// Vc Tabs
1607			classicElements.vcTab();
1608
1609			// Info Box
1610			classicElements.infoBox();
1611
1612			// Counters
1613			classicElements.counter();
1614
1615			// Countdown
1616			classicElements.countdown();
1617
1618			// Partner Advanced
1619			classicElements.partnerAdvanced();
1620
1621			// Portfolio Hover
1622			classicElements.portfolioHover();
1623
1624			// Woo Product
1625			classicElements.wooProduct();
1626
1627		},
1628
1629		accordionToggle: function(){
1630			$('.grve-toggle-wrapper.grve-first-open').each(function(){
1631				$(this).find('li').first().addClass('active');
1632			});
1633			$('.grve-toggle-wrapper li.active').find('.grve-title').addClass('active');
1634			$('.grve-toggle-wrapper li .grve-title').on('click',function(){
1635				$(this)
1636					.toggleClass('active')
1637					.next().slideToggle(350);
1638			});
1639			$('.grve-accordion-wrapper.grve-first-open').each(function(){
1640				$(this).find('li').first().addClass('active');
1641			});
1642			$('.grve-accordion-wrapper li.active').find('.grve-title').addClass('active');
1643			$('.grve-accordion-wrapper li .grve-title').on('click',function(){
1644				$(this)
1645					.toggleClass('active').next().slideToggle(350)
1646					.parent().siblings().find('.grve-title').removeClass('active')
1647					.next().slideUp(350);
1648			});
1649		},
1650		animAppear: function(){
1651			if(isMobile.any()) {
1652				$('.grve-animated-item').css('opacity',1);
1653			} else {
1654				$('.grve-animated-item').each(function() {
1655					var timeDelay = $(this).attr('data-delay');
1656					$(this).appear(function() {
1657					var $that = $(this);
1658						setTimeout(function () {
1659							$that.addClass('grve-animated');
1660						}, timeDelay);
1661					},{accX: 0, accY: -150});
1662				});
1663			}
1664		},
1665		progressBars: function(){
1666			var selector = '.grve-progress-bar';
1667			$(selector).each(function() {
1668				$(this).appear(function() {
1669
1670					var val         = $(this).attr('data-value'),
1671						percentage  = $('<div class="grve-percentage">'+ val + '%'+'</div>');
1672
1673					$(this).find('.grve-bar-line').animate({ width: val + '%' }, 1600);
1674
1675					percentage.appendTo($(this).find('.grve-bar'));
1676
1677					$(this).find('.grve-percentage').animate({ left: val + '%' }, 1600);
1678				});
1679			});
1680		},
1681		tabs: function(){
1682			$('.grve-tabs-title li').click(function () {
1683				$(this).addClass('active').siblings().removeClass('active');
1684				$(this).parent().parent().find('.grve-tabs-wrapper').find('.grve-tab-content').eq($(this).index()).addClass('active').siblings().removeClass('active');
1685			});
1686			$('.grve-tabs-title').each(function(){
1687				$(this).find('li').first().click();
1688			});
1689		},
1690		vcTab: function(){
1691
1692			var $tab = $('.vc_tta-tab a, .vc_tta-panel-title a');
1693
1694			$tab.on('click', function(){
1695				var $that = $(this),
1696					link  = $that.attr('href'),
1697					$panel = $(link),
1698					$iso = $panel.find('.grve-isotope');
1699				if( $iso.length > 0 ){
1700					setTimeout(function() {
1701						$iso.find('.grve-isotope-container').isotope('layout');
1702					},1000);
1703				}
1704			});
1705		},
1706		infoBox: function(){
1707			var infoMessage = $('.grve-message'),
1708			closeBtn = infoMessage.find($('.grve-close'));
1709			closeBtn.on('click',function(){
1710				$(this).parent().slideUp(150);
1711			});
1712		},
1713		counter: function(){
1714			var selector = '.grve-counter-item span';
1715			$(selector).each(function(i){
1716				var elements = $(selector)[i],
1717					thousandsSeparator = $(this).attr('data-thousands-separator') != '' ? $(this).attr('data-thousands-separator') : ',';
1718				$(elements).attr('id','grve-counter-' + i );
1719				var delay = $(this).parents('.grve-counter').attr('data-delay') !== '' ? parseInt( $(this).parents('.grve-counter').attr('data-delay') ) : 200,
1720					options = {
1721						useEasing    : true,
1722						useGrouping  : true,
1723						separator    : $(this).attr('data-thousands-separator-vis') != 'yes' ? thousandsSeparator : '',
1724						decimal      : $(this).attr('data-decimal-separator') != '' ? $(this).attr('data-decimal-separator') : '.',
1725						prefix       : $(this).attr('data-prefix') != '' ? $(this).attr('data-prefix') : '',
1726						suffix       : $(this).attr('data-suffix') != '' ? $(this).attr('data-suffix') : ''
1727					},
1728					counter = new countUp( $(this).attr('id') , $(this).attr('data-start-val'), $(this).attr('data-end-val'), $(this).attr('data-decimal-points'), 2.5, options);
1729				$(this).appear(function() {
1730					setTimeout(function () {
1731						counter.start();
1732					}, delay);
1733				});
1734			});
1735		},
1736		countdown: function(){
1737			$('.grve-countdown').each(function() {
1738				var $this        = $(this),
1739					finalDate    = $this.data('countdown'),
1740					numbersSize  = $this.data('numbers-size'),
1741					textSize     = $this.data('text-size'),
1742					numbersColor = $this.data('numbers-color'),
1743					textColor    = $this.data('text-color'),
1744					countdownItems = '',
1745					text = '',
1746					countdownFormat = $this.data('countdown-format').split('|');
1747
1748				$.each( countdownFormat, function( index, value ) {
1749					switch (value) {
1750						case 'w':
1751							text = grve_main_data.grve_string_weeks;
1752							break;
1753						case 'D':
1754						case 'd':
1755						case 'n':
1756							text = grve_main_data.grve_string_days;
1757							break;
1758						case 'H':
1759							text = grve_main_data.grve_string_hours;
1760							break;
1761						case 'M':
1762							text = grve_main_data.grve_string_minutes;
1763							break;
1764						case 'S':
1765							text = grve_main_data.grve_string_seconds;
1766							break;
1767						default:
1768							text = '';
1769					}
1770					countdownItems += '<div class="grve-countdown-item">';
1771					countdownItems += '<div class="grve-number grve-' + numbersSize + ' grve-color-' + numbersColor + '">%' + value + '</div>';
1772					countdownItems += '<span class="grve-' + textSize + ' grve-color-' + textColor + '">
1772' + text + '</span>';
1773					countdownItems += '</div>';
1774
1775				});
1776
1777				$this.countdown(finalDate, function(event) {
1778					$this = $(this).html(event.strftime( countdownItems ));
1779				});
1780			});
1781		},
1782		partnerAdvanced: function(){
1783			var partner = $('.grve-partner-advanced');
1784
1785			partner.parents('.grve-section').on('mouseenter mouseleave', function() {
1786				$(this).css('cursor','pointer');
1787			});
1788
1789			partner.parents('.grve-section').on('click',function(){
1790				var $that = $(this),
1791					$element = $that.find('.grve-partner-advanced'),
1792					offset = $that.offset().top,
1793					headerHeight    = 0,
1794					fieldBarHeight  = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0;
1795
1796				if( $('#grve-header').data('sticky-header') != 'none' ){
1797					if( $('#grve-header').hasClass('grve-logo-top') ) {
1798						headerHeight = $('.grve-bottom-header').outerHeight();
1799					} else {
1800						headerHeight = $('#grve-inner-header').outerHeight();
1801					}
1802				}
1803
1804				var distance = offset - ( headerHeight + fieldBarHeight - 1 );
1805
1806				if( distance > 0 && !$element.hasClass('active') ) {
1807					$('html,body').animate({
1808						scrollTop: distance
1809					}, 600,function(){
1810						$element.addClass('active').find('.grve-partner-content').slideDown(function(){
1811							$(this).addClass('grve-animated');
1812							return;
1813						});
1814					});
1815				} else {
1816					$element.toggleClass('active').find('.grve-partner-content').slideToggle(function(){
1817						$(this).toggleClass('grve-animated');
1818					});
1819				}
1820
1821			});
1822		},
1823		iconBox: function(){
1824			var $parent   = $('.grve-row');
1825
1826			$parent.each(function(){
1827				var $iconBox  = $(this).find('.grve-box-icon.grve-advanced-hover');
1828
1829				if( !$iconBox.length ) return;
1830
1831				classicElements.setIconBoxHeight( $iconBox );
1832			$(window).smartresize( function() {
1833					classicElements.setIconBoxHeight( $iconBox );
1834				});
1835
1836				$iconBox.off('mouseenter mouseleave').on('mouseenter mouseleave', function() {
1837					$(this).toggleClass('hover');
1838			});
1839
1840			});
1841		},
1842		setIconBoxHeight: function( element ){
1843			var arrHeight = [],
1844				$iconBox  = element;
1845
1846
1847			$iconBox.css({ 'height' : '', 'padding-top' : '' });
1848
1849			$iconBox.each(function(){
1850				var $that          = $(this),
1851					$iconBoxHeigth = $that.height();
1852
1853				arrHeight.push( $iconBoxHeigth );
1854			});
1855
1856			var maxHeight   = Math.max.apply(Math,arrHeight),
1857				iconHeight  = $iconBox.find('.grve-icon').height(),
1858				paddingTop  = ( maxHeight - iconHeight )/2;
1859
1860			$iconBox.css({ 'height' : maxHeight, 'padding-top' : paddingTop });
1861			setTimeout(function() {
1862				$iconBox.addClass('active');
1863			}, 800);
1864
1865		},
1866		portfolioHover: function(){
1867			$(' .grve-portfolio .grve-hover-style-2 ').each( function() { $(this).hoverdir(); } );
1868		},
1869		wooProduct: function(){
1870			var $product = $('.grve-product-item'),
1871				$productOptions = $('.grve-product-options');
1872			$product.off('mouseenter mouseleave').on('mouseenter mouseleave', function() {
1873				$(this).toggleClass('hover');
1874			});
1875			$productOptions.off('mouseenter mouseleave').on('mouseenter mouseleave', function() {
1876				var $addButton = $(this).find('.grve-add-cart');
1877				if( $addButton.length ){
1878					$(this).toggleClass('hover');
1879				}
1880			});
1881			$('.grve-product-options .grve-add-cart').on('click',function(){
1882				$(this).parents('.grve-product-media').addClass('grve-product-added-to-cart');
1883			});
1884		}
1885	};
1886
1887	//////////////////////////////////////////////////////////////////////////////////////////////////////
1888	// STICKY ELEMENTS
1889	//////////////////////////////////////////////////////////////////////////////////////////////////////
1890	var stickyItems = {
1891
1892		config : {
1893			element    : '.grve-fields-bar',
1894			offset     : 0
1895		},
1896
1897		init: function(settings){
1898			// allow overriding the default config
1899			$.extend(this.config, settings);
1900
1901			if( !$(this.config.element).length || isMobile.any() || $(this.config.element).hasClass('grve-responsive-bar') ) {
1902				return;
1903			}
1904			var $item       = $(this.config.element),
1905				itemOffset  = this.config.offset,
1906				positionX   = $item.offset().left,
1907				itemId      = $item.attr('id'),
1908				itemWidth   = $item.outerWidth() + 2,
1909				itemHeight  = $item.outerHeight();
1910			// Create A Helper Wrapper
1911			$item.wrap('<div id="' + itemId + '-wrapper"></div>' );
1912			$item.parent().css({
1913				'height' : itemHeight,
1914				'position' : 'relative'
1915			});
1916			$(window).scroll(function(){
1917				var scroll       = $(window).scrollTop(),
1918					elementTop   = $item.parent().offset().top,
1919					headerHeight =  0;
1920
1921				if( $('#grve-header').data('sticky-header') != 'none' ){
1922					if( $('#grve-header').hasClass('grve-logo-top') ) {
1923						headerHeight = $('.grve-bottom-header').outerHeight();
1924					} else {
1925						headerHeight = $('#grve-inner-header').outerHeight();
1926					}
1927				}
1928
1929				var offsetTop = headerHeight + itemOffset + wpBarHeight;
1930				if( scroll > elementTop - offsetTop ) {
1931					$item.css({
1932						'position' : 'fixed',
1933						'top'      : offsetTop,
1934						'left'     : positionX,
1935						'width'    : itemWidth
1936					}).addClass('sticky');
1937				}
1938				else {
1939					$item.css({
1940						'position' : '',
1941						'top'      : '',
1942						'left'     : '',
1943						'width'    : ''
1944					}).removeClass('sticky');
1945				}
1946			});
1947		}
1948	};
1949
1950	//////////////////////////////////////////////////////////////////////////////////////////////////////
1951	// TITLE PARALLAX
1952	//////////////////////////////////////////////////////////////////////////////////////////////////////
1953	var titleParallax = {
1954
1955		selector: '.grve-feature-content',
1956		container: '#grve-feature-section',
1957
1958		init: function(){
1959			if( isMobile.any() || $(this.container).data('effect') != 'parallax' ) {
1960				return;
1961			}
1962			$(window).scroll(function(){
1963				titleParallax.update();
1964			});
1965		},
1966		update: function(){
1967
1968			$(this.selector).transition({ y: $(window).scrollTop()*.5},0)
1969							.css( 'opacity', 1 - ( $(window).scrollTop()*.002 ) );
1970		}
1971	};
1972	//////////////////////////////////////////////////////////////////////////////////////////////////////
1973	// ONEPAGE SETTINGS
1974	//////////////////////////////////////////////////////////////////////////////////////////////////////
1975	var onePageSettings = {
1976		init: function(){
1977			var topOffset = 0;
1978			if( $('#grve-header').data('sticky-header') != 'none' ){
1979				if( $('#grve-header').hasClass('grve-logo-top') ) {
1980					topOffset = $('.grve-bottom-header').outerHeight();
1981				} else {
1982					topOffset = $('#grve-inner-header').outerHeight();
1983				}
1984			}
1985			var fieldBarHeight  = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0;
1986
1987			$('a[href*="#"]:not( [href="#"] )').on('click',function(e){
1988				if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname ) {
1989					var target = $(this.hash);
1990					target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
1991					if ( target.length && ( target.hasClass('grve-section') || target.hasClass('grve-bookmark') ) ) {
1992						$('html,body').animate({
1993							scrollTop: target.offset().top - topOffset - fieldBarHeight + 1
1994						}, 1000);
1995						return false;
1996					}
1997				}
1998			});
1999
2000			if (window.location.hash) {
2001				setTimeout(function() {
2002					$('html, body').scrollTop(0);
2003					$('#grve-main-content').css('opacity',1);
2004					var target = window.location.hash;
2005
2006					if ($(target).length) {
2007						$('html, body').delay(600).animate({
2008							scrollTop: $(target).offset().top - topOffset - fieldBarHeight
2009						}, 600);
2010					}
2011					window.location.hash = "";
2012				}, 0);
2013			}
2014			else {
2015				$('#grve-main-content').css('opacity',1);
2016			}
2017		}
2018	};
2019
2020	//////////////////////////////////////////////////////////////////////////////////////////////////////
2021	// CAROUSEL
2022	//////////////////////////////////////////////////////////////////////////////////////////////////////
2023	var  carousels = {
2024
2025		init: function() {
2026			var $elements = $('.grve-carousel-element');
2027
2028			$elements.each(function(){
2029				var	carousel = $(this);
2030
2031				var carouselSettings = {
2032					sliderSpeed : ( parseInt( carousel.attr('data-slider-speed') ) ) ? parseInt( carousel.attr('data-slider-speed') ) : 3000,
2033					paginationSpeed : ( parseInt( carousel.attr('data-pagination-speed') ) ) ? parseInt( carousel.attr('data-pagination-speed') ) : 400,
2034					autoHeight  : carousel.attr('data-slider-autoheight') == 'yes' ? true : '',
2035					sliderPause : carousel.attr('data-slider-pause') == 'yes' ? true : false,
2036					autoPlay    : carousel.attr('data-slider-autoplay') != 'no' ? true : false,
2037					itemNum     : carousel.hasClass('grve-carousel') ? parseInt( carousel.attr('data-items')) : 1,
2038					itemsTablet : carousel.hasClass('grve-carousel') ? [768,2] : [768,1],
2039					baseClass   : 'grve-carousel',
2040					pagination  : false
2041				};
2042				if ( carousel.hasClass('grve-testimonial') ) {
2043					// Testimonial Navigation
2044					carouselSettings.pagination = true;
2045				}
2046				else if ( carousel.hasClass('grve-carousel') ) {
2047					// Custom Navigation
2048					carousels.customNav(carousel);
2049				}
2050				else if ( carousel.hasClass('grve-slider') ) {
2051					// Custom Navigation
2052					carousels.customNav(carousel);
2053					carousels.customPause(carousel, carouselSettings);
2054				}
2055				// Carousel Settings
2056				carousels.carouselInit(carousel, carouselSettings);
2057			});
2058
2059		},
2060		carouselInit: function(carousel, settings){
2061			carousel.owlCarousel({
2062
2063				navigation        : false,
2064				pagination        : settings.pagination,
2065				autoHeight        : settings.autoHeight,
2066				slideSpeed        : 400,
2067				paginationSpeed   : settings.paginationSpeed,
2068				singleItem        : false,
2069				items             : settings.itemNum,
2070				autoPlay          : settings.autoPlay,
2071				stopOnHover       : settings.sliderPause,
2072				baseClass         : 'grve-carousel-element',
2073				theme             : '',
2074				itemsDesktop      : false,
2075				itemsDesktopSmall : false,
2076			 	itemsTablet       : settings.itemsTablet
2077
2078			});
2079			// Carousel Element Speed
2080			if( settings.autoPlay == true ){
2081			carousel.trigger('owl.play',settings.sliderSpeed);
2082			}
2083			carousel.css('visibility','visible');
2084
2085			var $parentSection = $(carousel.parents('.grve-section')),
2086				heightMode     = $parentSection.attr('data-full-height');
2087
2088			if( heightMode == 'yes' ) {
2089				sectionSettings.fullHeight($parentSection);
2090			}
2091		},
2092		customNav: function(carousel){
2093			// Carousel Navigation
2094			carousel.parent().find('.grve-carousel-next').on('click',function(){
2095				carousel.trigger('owl.next');
2096			});
2097			carousel.parent().find('.grve-carousel-prev').on('click',function(){
2098				carousel.trigger('owl.prev');
2099			});
2100		},
2101		// Fixed Pause on Hover ( Slider with Custom Title )
2102		customPause: function(carousel, settings){
2103			var customTitle = carousel.parent().find('.grve-custom-title-wrapper');
2104			if(settings.sliderPause){
2105				customTitle.hover(function(){
2106					carousel.trigger('owl.stop');
2107					carousel.find('.grve-image-hover').addClass('hover');
2108				},function(){
2109					carousel.trigger('owl.play',settings.sliderSpeed);
2110					carousel.find('.grve-image-hover').removeClass('hover');
2111				});
2112			}
2113			if(customTitle.length){
2114				customTitle.hover(function(){
2115					carousel.find('.grve-image-hover').addClass('hover');
2116				},function(){
2117					carousel.find('.grve-image-hover').removeClass('hover');
2118				});
2119			}
2120		}
2121	};
2122	//////////////////////////////////////////////////////////////////////////////////////////////////////
2123	// ISOTOPE SPINNER
2124	//////////////////////////////////////////////////////////////////////////////////////////////////////
2125	var isoSpinner = {
2126		init: function(){
2127			var $selector = $('.grve-isotope');
2128			$selector.each(function(){
2129				var $that = $(this),
2130					dataSpinner = $that.data('spinner');
2131				if( dataSpinner == 'yes' ){
2132					isoSpinner.addSpinner( $that );
2133				}
2134
2135			});
2136		},
2137		addSpinner: function( $that ){
2138			var $spinner = $('<div class="grve-iso-spinner" title="2"><svg version="1.1" id="spinner" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="60px" height="60px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve"><path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/></path></svg></div>');
2139			$spinner.appendTo( $that );
2140		},
2141		removeSpinner: function( $container ){
2142			$container.parent().find('.grve-iso-spinner').animate({'opacity':0},600,function(){
2143				$container.animate({'opacity': 1},600);
2144			});
2145		}
2146	};
2147	//////////////////////////////////////////////////////////////////////////////////////////////////////
2148	// ISOTOPE
2149	//////////////////////////////////////////////////////////////////////////////////////////////////////
2150	var iso = {
2151
2152		init: function() {
2153			var $selector = $('.grve-isotope');
2154			$selector.each(function(){
2155				var $that        = $(this),
2156					$container   = $that.find('.grve-isotope-container'),
2157					$isotopItem  = $container.find('.grve-isotope-item'),
2158					layout       = $that.data('layout') !== '' ? $that.data('layout') : 'fitRows',
2159					dataSpinner  = $that.data('spinner');
2160
2161				iso.isotopeSetup( $container, layout, dataSpinner );
2162				$(window).smartresize( function() {
2163					if(layout == 'packery') {
2164						iso.packeryStyleFix( $container );
2165					}
2166				});
2167				$that.find('.grve-filter li').on('click',function(){
2168					var selector = $(this).attr('data-filter');
2169					$container.isotope({
2170						filter: selector
2171					});
2172					$(this).addClass('selected').siblings().removeClass('selected');
2173				});
2174			});
2175		},
2176		isotopeSetup: function( $container, layout, dataSpinner ){
2177			$container.isotope({
2178				resizable: true,
2179				itemSelector: '.grve-isotope-item',
2180				layoutMode: layout
2181			});
2182			if(layout == 'packery') {
2183				iso.packeryStyleFix( $container );
2184			}
2185			$container.isotope('layout');
2186			if( dataSpinner == 'yes' ) {
2187				setTimeout(function() {
2188					isoSpinner.removeSpinner( $container );
2189				},2000);
2190			} else {
2191				$container.animate({'opacity': 1},600);
2192			}
2193
2194			$(window).smartresize( function() {
2195				setTimeout(function() {
2196					$container.isotope('layout');
2197				},1000);
2198			});
2199		},
2200		packeryStyleFix: function( $container ) {
2201			var smallItem = $container.find('.grve-isotope-item.grve-packery-image').first(),
2202				standardHeight = smallItem.width(),
2203				wideTallHeight = (standardHeight * 2)  + parseInt(smallItem.css('margin-bottom'), 10);
2204			if (standardHeight > 0) {
2205				$container.find('.grve-isotope-item.grve-packery-image .grve-media').css('height', standardHeight);
2206				$container.find('.grve-isotope-item.grve-packery-w2 .grve-media').css('height', standardHeight);
2207				$container.find('.grve-isotope-item.grve-packery-h2 .grve-media').css('height', wideTallHeight);
2208				$container.find('.grve-isotope-item.grve-packery-h2-w2 .grve-media').css('height', wideTallHeight);
2209			}
2210			$container.isotope('layout');
2211		}
2212	};
2213
2214	//////////////////////////////////////////////////////////////////////////////////////////////////////
2215	// NON ISOTOPE FILTER
2216	//////////////////////////////////////////////////////////////////////////////////////////////////////
2217	var noniso = {
2218
2219		init: function() {
2220			var $selector = $('.grve-non-isotope');
2221			$selector.each(function(){
2222				var $that = $(this);
2223				$that.find('.grve-filter li').on('click',function(){
2224					var selector = $(this).attr('data-filter');
2225					if ( '*' == selector ) {
2226						$that.find('.grve-non-isotope-item').fadeIn('1000');
2227					} else {
2228						$that.find('.grve-non-isotope-item').hide();
2229						$that.find(selector).fadeIn('1000');
2230					}
2231					$(this).addClass('selected').siblings().removeClass('selected');
2232				});
2233			});
2234		}
2235	};
2236	//////////////////////////////////////////////////////////////////////////////////////////////////////
2237	// PARALLAX
2238	//////////////////////////////////////////////////////////////////////////////////////////////////////
2239	var parallax = {
2240
2241		selector : 'div[data-stellar-ratio]',
2242
2243		init: function(){
2244
2245			if( isMobile.any() || !$(this.selector).length ) {
2246				return;
2247			}
2248
2249			$(window).stellar({
2250				horizontalScrolling: false,
2251				verticalOffset: 0,
2252				horizontalOffset: 0,
2253				responsive: true,
2254				scrollProperty: 'scroll',
2255				positionProperty: 'transform',
2256				parallaxBackgrounds: false,
2257				parallaxElements: true,
2258				hideDistantElements: false,
2259			});
2260			parallax.settings();
2261			$(window).smartresize( function() {
2262				parallax.settings();
2263			});
2264		},
2265		settings: function(){
2266
2267			$(parallax.selector).each(function (){
2268				var $parallax           = $(this),
2269					$container          = $parallax.parent(),
2270					containerHeight     = $container.outerHeight(),
2271					windowHeight        = $(window).height();
2272
2273				if( 1 == grve_main_data.grve_row_stellar_auto ) {
2274					$parallax.css({
2275						'height': containerHeight + windowHeight,
2276						'top': -1 * windowHeight * 0.5 / 2
2277					});
2278				}
2279			});
2280		}
2281	};
2282	
2283	//////////////////////////////////////////////////////////////////////////////////////////////////////
2284	// PRODUCT
2285	//////////////////////////////////////////////////////////////////////////////////////////////////////
2286	var wooProductRating = {
2287		init : function(){
2288			if ( typeof wc_single_product_params !== 'undefined' ) {
2289				var $rating = $( '.woocommerce-Reviews #respond' ).find( '#rating' );
2290				if ( $rating.length > 0 && wc_single_product_params.review_rating_required === 'no' ) {
2291					$('.woocommerce-Reviews #respond #rating').removeAttr('required');
2292				}
2293			}
2294		}
2295	};	
2296	//////////////////////////////////////////////////////////////////////////////////////////////////////
2297	// GLOBAL VARIABLES
2298	//////////////////////////////////////////////////////////////////////////////////////////////////////
2299	var wpBarHeight = $('#grve-body').hasClass('admin-bar') ? 32 : 0;
2300	var largeScreen = 2048;
2301	var tabletLandscape = 1200;
2302	var tabletPortrait = 1023;
2303	var mobileScreen = 767;
2304	var isMobile = {
2305		Android: function() {
2306			return navigator.userAgent.match(/Android/i);
2307		},
2308		BlackBerry: function() {
2309			return navigator.userAgent.match(/BlackBerry/i);
2310		},
2311		iOS: function() {
2312			return navigator.userAgent.match(/iPhone|iPad|iPod/i);
2313		},
2314		Opera: function() {
2315			return navigator.userAgent.match(/Opera Mini/i);
2316		},
2317		Windows: function() {
2318			return navigator.userAgent.match(/IEMobile/i);
2319		},
2320		any: function() {
2321			return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
2322		}
2323	};
2324
2325	// Scrollbar Width
2326	var parent, child, scrollBarWidth;
2327
2328	if( scrollBarWidth === undefined ) {
2329		parent          = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body');
2330		child           = parent.children();
2331		scrollBarWidth  = child.innerWidth()-child.height(99).innerWidth();
2332		parent.remove();
2333	}
2334
2335
2336
2337	$(document).ready( function() {
2338
2339		// Remove Video Bg
2340		pageSettings.removeVideoBg();
2341
2342		// Add Video Bg
2343		pageSettings.addVideoBg();
2344
2345		// FEATURE SECTION SETTINGS
2346		featureSection.init();
2347
2348		// HEADER
2349		headerSettings.init();
2350
2351		// MAIN MENU
2352		mainMenu.init();
2353
2354		// SIDE MENU
2355		headerOptions.init();
2356
2357		// CLASSIC ELEMENTS
2358		classicElements.init();
2359
2360		// PAGE SETTINGS
2361		pageSettings.init();
2362
2363		// STICKY ELEMENTS
2364		stickyItems.init();
2365
2366		// POST SOCIALS
2367		pageSettings.postSocials();
2368
2369		// TITLE PARALLAX
2370		titleParallax.init();
2371
2372		// SECTIONS
2373		sectionSettings.init();
2374
2375		// ONEPAGE SETTINGS
2376		if(!locationOnLoad) {
2377			onePageSettings.init();
2378		}
2379
2380		// ISOTOPE
2381		iso.init();
2382		// ISOTOPE SPINNER
2383		isoSpinner.init();
2384		
2385		// PRODUCT
2386		wooProductRating.init();
2387
2388	});
2389
2390	$(window).on('load',function () {	
2391
2392		// Icon Box
2393		classicElements.iconBox();
2394
2395		// Column Height
2396		setColumnHeight.init();
2397
2398		// CAROUSELS
2399		carousels.init();
2400
2401		// ISOTOPE
2402		iso.init();
2403
2404		//NON ISOTOPE FILTER
2405		noniso.init();
2406
2407		// PARALLAX
2408		parallax.init();
2409
2410		pageSettings.gotoSection();
2411
2412		pageSettings.refMainMenu();
2413
2414		// FIXED FOOTER
2415		pageSettings.fixedFooter();
2416
2417		// ONEPAGE SETTINGS
2418		if(locationOnLoad) {
2419			onePageSettings.init();
2420		}
2421
2422	});
2423
2424})(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.