jQuery( document ).ready( function( $ ) {
'use strict';
/*--------------------------------------------------------------
Screen size class
--------------------------------------------------------------*/
function gpScreenSizeClass() {
if ( $(window).innerWidth() <= 767 && $( 'body' ).hasClass( 'gp-responsive' ) ) {
$( 'body' ).addClass( 'gp-mobile' ).removeClass( 'gp-desktop' ).removeClass( 'gp-tablet-portrait' ).removeClass( 'gp-tablet-landscape' );
} else if ( $(window).innerWidth() <= 1023 && $( 'body' ).hasClass( 'gp-responsive' ) ) {
$( 'body' ).addClass( 'gp-tablet-portrait' ).removeClass( 'gp-desktop' ).removeClass( 'gp-tablet-landscape' ).removeClass( 'gp-mobile' );
} else if ( $(window).innerWidth() <= 1082 && $( 'body' ).hasClass( 'gp-responsive' ) ) {
$( 'body' ).addClass( 'gp-tablet-landscape' ).removeClass( 'gp-desktop' ).removeClass( 'gp-tablet-portrait' ).removeClass( 'gp-mobile' );
} else {
$( 'body' ).addClass( 'gp-desktop' ).removeClass( 'gp-tablet-landscape' ).removeClass( 'gp-tablet-portrait' ).removeClass( 'gp-mobile' );
}
}
gpScreenSizeClass();
$( window ).resize( gpScreenSizeClass );
/*--------------------------------------------------------------
Retina images
--------------------------------------------------------------*/
if ( $( 'body' ).hasClass( 'gp-retina' ) ) {
window.devicePixelRatio >= 2 && $( '.post-thumbnail img' ).each( function() {
$( this ).attr( { src: $( this ).attr( 'data-rel' ) } );
});
window.devicePixelRatio >= 2 && $( '.image-loop img' ).each(function() {
$( this ).attr( { 'data-original': $( this ).attr( 'data-rel' ) } );
});
window.devicePixelRatio >= 2 && $( '.gp-slider .slide-image' ).each(function(){
var bgImage = $(this).attr( 'data-rel' );
$( this ).css"dropdown-icon fa fa-caret-down" />' ).appendTo( $( this ).children( ':first' ) );
}
});
$( '#main-nav .menu > li:not(.megamenu) ul > li' ).each( function() {
if ( $( this ).find( 'ul' ).length > 0 ) {
$( '' ).appendTo( $( this ).children( ':first' ) );
}
});
/*--------------------------------------------------------------
Mega menus text/image support
--------------------------------------------------------------*/
if ( $( '.megamenu' ).length > 0 ) {
$( '.nav-text > a' ).contents().unwrap();
$( '.nav .megamenu .sub-menu .sub-menu li.nav-image' ).each( function() {
if ( $( this ).find( 'a' ).length > 0 ) {
var src = $( this ).find( 'a' ).attr( 'href' );
$( '' ).insertAfter( $( this ).children( ':first' ) );
$( this ).find( '.menu-image' ).attr( 'src', src );
$( this ).find( 'a' ).remove();
}
});
$( '#mobile-nav .nav-image' ).hide();
}
/*--------------------------------------------------------------
Slide up/down header mobile navigation
--------------------------------------------------------------*/
function gpHeaderMobileNav() {
$( '#header-mobile-nav-button' ).toggle( function() {
$( '#mobile-nav' ).stop().slideDown().removeClass( 'auto-height' );
$( '#header-mobile-nav-button' ).addClass( 'gp-active' );
}, function() {
$( '#mobile-nav' ).stop().slideUp().removeClass( 'auto-height' );
$( '#header-mobile-nav-button' ).removeClass( 'gp-active' );
});
}
gpHeaderMobileNav();
$( window ).resize( gpHeaderMobileNav );
/*--------------------------------------------------------------
Slide up/down header mobile dropdown menus
--------------------------------------------------------------*/
$( '#mobile-nav .menu li' ).each( function() {
if ( $( this ).find( 'ul' ).length > 0 ) {
$( '' ).insertAfter( $( this ).children( ':first' ) );
}
});
function gpHeaderMobileTopNav() {
$( '#mobile-nav ul > li' ).each( function() {
var navItem = $( this );
if ( $( navItem ).find( 'ul' ).length > 0 ) {
$( navItem ).children( '.mobile-dropdown-icon' ).toggle( function() {
$( navItem ).addClass( 'gp-active' );
$( navItem ).children( '.sub-menu' ).stop().slideDown()
$( '#mobile-nav' ).addClass( 'auto-height' );
}, function() {
$( navItem ).removeClass( 'gp-active' );
$( navItem ).children( '.sub-menu' ).stop().slideUp();
});
}
});
}
gpHeaderMobileTopNav();
$( window ).resize( gpHeaderMobileTopNav );
/*--------------------------------------------------------------
Slide up/down hub tabs mobile navigation
--------------------------------------------------------------*/
function gpTabsMobileNav() {
$( '#hub-tabs #hub-tabs-mobile-nav-button' ).toggle( function() {
$( '#hub-tabs ul' ).stop().slideDown();
$( '#hub-tabs-mobile-nav-button' ).addClass( 'gp-active' );
}, function() {
$( '#hub-tabs ul' ).stop().slideUp();
$( '#hub-tabs-mobile-nav-button' ).removeClass( 'gp-active' );
});
}
gpTabsMobileNav();
$( window ).resize( gpTabsMobileNav );
/*--------------------------------------------------------------
Smooth scroll
--------------------------------------------------------------*/
if ( $( 'body' ).hasClass( 'gp-smooth-scrolling' ) && $( window ).width() > 767 && $( 'body' ).outerHeight( true ) > $( window ).height() ) {
$( 'html' ).niceScroll({
cursorcolor: '#424242',
scrollspeed: 100,
mousescrollstep: 40,
cursorwidth: 10,
cursorborder: '0',
zindex: 10000,
cursoropacitymin: 0.3,
cursoropacitymax: 0.6
});
}
/*--------------------------------------------------------------
Parallax Effect
--------------------------------------------------------------*/
if( $( 'div' ).hasClass( 'gp-parallax' ) || $( 'header' ).hasClass( 'gp-parallax' ) ) {
$( window ).stellar( {
responsive: true,
horizontalScrolling: false
});
}
/*--------------------------------------------------------------
Masonry blog
--------------------------------------------------------------*/
if ( $( '.blog-wrapper' ).hasClass( 'blog-masonry' ) ) {
var container = $( '.blog-masonry .inner-loop' );
var element = container;
if ( container.find( 'img' ).length == 0 ) {
element = $( '
' );
}
imagesLoaded( element, function( instance ) {
container.isotope({
itemSelector: '.post-item',
masonry: {
columnWidth: container.find( '.post-item' )[0],
gutter: 20
}
});
container.animate( { 'opacity': 1 }, 1300 );
$( 'ul.page-numbers' ).animate( { 'opacity': 1 }, 1300 );
});
}
/*--------------------------------------------------------------
Lazyload Images
--------------------------------------------------------------*/
if ( $( 'div' ).hasClass( 'images-wrapper' ) ) {
$( '.image-loop img' ).lazyload({
effect: 'fadeIn'
});
$( '.images-wrapper').animate( { 'opacity': 1 }, 1300 );
}
/*--------------------------------------------------------------
Remove gallery shortcode when gallery slider active
--------------------------------------------------------------*/
$( '.gallery-slider-active .gallery' ).remove();
/*--------------------------------------------------------------
Back to top button
--------------------------------------------------------------*/
if ( $( 'body' ).hasClass( 'gp-back-to-top' ) ) {
$().UItoTop({
text: '',
scrollSpeed: 600
});
}
/*--------------------------------------------------------------
prettyPhoto lightbox
--------------------------------------------------------------*/
$(' a[class^="prettyPhoto"]' ).prettyPhoto({
theme: 'pp_default',
deeplinking: false,
social_tools: '',
default_width: '768'
});
/*--------------------------------------------------------------
Remove WooCommerce Comment Meta Dash
--------------------------------------------------------------*/
$( '.comment-text .meta' ).html( function( index, text ) {
return text.replace( '–', '' );
});
/*--------------------------------------------------------------
WooCommerce image overlay
--------------------------------------------------------------*/
$( '.product-image-container .image-overlay' ).css( 'opacity', 0 ).hover( function() {
$( this ).fadeTo( 'fast', 1 );
}, function() {
$( this ).fadeTo( 'fast', 0 );
});
/*--------------------------------------------------------------
Set slider height to auto
--------------------------------------------------------------*/
$( window ).load( function() {
if ( $( window ).innerWidth() > 1082 ) {
$( '#homepage-slider' ).css( 'height', 'auto' );
}
});
/*--------------------------------------------------------------
Featured wrapper caption
--------------------------------------------------------------*/
$( '.featured-post' ).css( 'opacity', 1 );
function gpCaptionPadding() {
var padding = ( $( '#featured-wrapper .gp-container' ).width() - $( '#main-header .gp-container' ).width() ) / 2;
$( '.large-post .featured-caption' ).css( 'padding-left', padding );
$( '.small-posts .featured-caption' ).css( 'padding-right', padding );
}
gpCaptionPadding();
$( window ).resize( gpCaptionPadding );
/*--------------------------------------------------------------
Follow Items
--------------------------------------------------------------*/
$( '.wpfp-span .unfollow-item' ).show();
$( '.wpfp-link' ).live( 'click', function() {
var dhis = $( this );
wpfp_do_js( dhis, 1 );
if ( dhis.hasClass( 'unfollow-item' ) ) {
dhis.parent( '.post-item' ).fadeOut();
}
return false;
});
function wpfp_do_js( dhis, doAjax ) {
dhis.addClass( 'follow-loading' );
var url = document.location.href.split( '#' )[0];
var params = dhis.attr('href').replace( '?', '' ) + '&ajax=1';
if ( doAjax ) {
jQuery.get( url, params, function( data ) {
dhis.parent().html( data );
if ( typeof wpfp_after_ajax == 'function' ) {
wpfp_after_ajax( dhis );
}
dhis.removeClass( 'follow-loading' );
}
);
}
}
/*--------------------------------------------------------------
Title header video
--------------------------------------------------------------*/
if ( $( '.entry-header' ).hasClass( 'video-header' ) ) {
headerVideo.init({
mainContainer: $( '.large-header.entry-header' ),
videoContainer: $( '.header-video' ),
header: $( '.header-video-media' ),
videoTrigger: $( '.play-video-button' ),
autoPlayVideo: false
});
}
/*--------------------------------------------------------------
Resize header
--------------------------------------------------------------*/
function gpResizeHeader() {
// Before Scrolling
if ( ( $( window ).innerWidth() <= 982 && $( 'body' ).hasClass( 'gp-responsive' ) ) || ( $( window ).scrollTop() > 0 && $( 'body' ).hasClass( 'gp-desktop' ) ) ) {
$( '.gp-header-standard #main-header' ).data( 'size', 'small' ).addClass( 'header-small' ).removeClass( 'header-large' ).stop().css({
height: parseInt( gp_script.smallHeaderHeight )
});
$( '.gp-header-centered #main-header' ).data( 'size', 'small' ).addClass( 'header-small' ).removeClass( 'header-large' ).stop().css({
height: parseInt( gp_script.smallHeaderHeight ) + parseInt( gp_script.logoMarginTop ) / gp_script.headerSizeReduction + parseInt( gp_script.logoMarginBottom ) / gp_script.headerSizeReduction
});
$( '#main-header #logo' ).stop().css({
marginTop: parseInt( gp_script.logoMarginTop ) / gp_script.headerSizeReduction,
marginBottom: parseInt( gp_script.logoMarginBottom ) / gp_script.headerSizeReduction
});
$( '#main-header #logo img' ).stop().css({
height: parseInt( gp_script.logoHeight ) / gp_script.headerSizeReduction
});
$( '#fixed-header-padding' ).stop().css({
paddingTop: parseInt( gp_script.smallHeaderHeight )
});
} else {
$( '.gp-header-standard #main-header' ).data( 'size', 'large' ).addClass( 'header-large' ).removeClass( 'header-small' ).stop().css({
height: gp_script.headerHeight
});
$( '.gp-header-centered #main-header' ).data( 'size', 'large' ).addClass( 'header-large' ).removeClass( 'header-small' ).stop().css({
height: parseInt( gp_script.headerHeaderHeight ) + parseInt( gp_script.logoMarginTop ) + parseInt( gp_script.logoMarginBottom )
});
$( '#main-header #logo' ).stop().css({
marginTop: parseInt( gp_script.logoMarginTop ),
marginBottom: parseInt( gp_script.logoMarginBottom )
});
$( '#main-header #logo img' ).stop().css({
height: parseInt( gp_script.logoHeight )
});
$( '#fixed-header-padding' ).stop().css({
paddingTop: parseInt( gp_script.headerHeight )
});
}
// Upon Scrolling
$( window ).scroll( function() {
if ( $( 'body' ).hasClass( 'gp-desktop' ) && $( 'body' ).hasClass( 'gp-fixed-header' ) && $( 'body' ).hasClass( 'gp-header-resize' ) ) {
if ( $( document ).scrollTop() > 50 ) {
if ( $( '#main-header' ).data( 'size' ) == 'large' ) {
$( '.gp-header-standard #main-header' ).data( 'size', 'small' ).addClass( 'header-small' ).removeClass( 'header-large' ).stop().animate({
height: parseInt( gp_script.smallHeaderHeight )
}, 300 );
$( '.gp-header-centered #main-header' ).data( 'size', 'small' ).addClass( 'header-small' ).removeClass( 'header-large' ).stop().animate({
height: parseInt( gp_script.smallHeaderHeight ) + ( parseInt( gp_script.logoMarginTop ) / gp_script.headerSizeReduction ) + ( parseInt( gp_script.logoMarginBottom ) / gp_script.headerSizeReduction )
}, 300 );
$( '#main-header #logo' ).stop().animate({
marginTop: parseInt( gp_script.logoMarginTop ) / gp_script.headerSizeReduction,
marginBottom: parseInt( gp_script.logoMarginBottom ) / gp_script.headerSizeReduction
}, 300 );
$( '#main-header #logo img' ).stop().animate({
height: parseInt( gp_script.logoHeight ) / gp_script.headerSizeReduction
}, 300 );
$( '#fixed-header-padding' ).stop().animate({
paddingTop: parseInt( gp_script.smallHeaderHeight )
}, 400 );
}
} else {
if ( $( '#main-header' ).data( 'size' ) == 'small' ) {
$( '.gp-header-standard #main-header' ).data( 'size', 'large' ).addClass( 'header-large' ).removeClass( 'header-small' ).stop().animate({
height: gp_script.headerHeight
}, 300 );
$( '.gp-header-centered #main-header' ).data( 'size', 'large' ).addClass( 'header-large' ).removeClass( 'header-small' ).stop().animate({
height: parseInt( gp_script.headerHeight ) + parseInt( gp_script.logoMarginTop ) + parseInt( gp_script.logoMarginBottom )
}, 300 );
$( '#main-header #logo' ).stop().animate({
marginTop: parseInt( gp_script.logoMarginTop ),
marginBottom: parseInt( gp_script.logoMarginBottom )
}, 300 );
$( '#main-header #logo img' ).stop().animate({
height: parseInt( gp_script.logoHeight )
}, 300 );
$( '#fixed-header-padding' ).stop().animate({
paddingTop: parseInt( gp_script.headerHeight )
}, 400 );
}
}
}
});
}
gpResizeHeader();
$( window ).resize( gpResizeHeader );
});
/*
playback timings (ms):
LoadShardBlock: 249.449 (3)
esindex: 0.008
captures_list: 267.653
CDXLines.iter: 12.567 (3)
PetaboxLoader3.datanode: 265.311 (4)
exclusion.robots: 0.375
exclusion.robots.policy: 0.359
RedisCDXSource: 0.593
PetaboxLoader3.resolve: 210.181
load_resource: 241.225
*/