/*
Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net
*/
(function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k));
if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("
"))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q,
u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),eb&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}),
a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize",
y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n 600 ? 200 : 50,
elemBottom = elemTop + elemBuffer;
return ( elemBottom <= docViewBottom );
}
//Masonry blocks
//Masonry blocks
$container = $( '.posts' );
function masonryInitClassic(){
$container.masonry({
itemSelector: '.masonry-preview',
percentPosition: true,
transitionDuration: 0,
} );
}
$container.imagesLoaded().done( function(){
if ($('.masonry-preview').length)
masonryInitClassic();
});
$( document ).ready( function() {
setTimeout( function() {
if ($('.masonry-preview').length)
masonryInitClassic();
}, 500 );
} );
$( window ).resize( function () {
if ($('.masonry-preview').length)
masonryInitClassic();
} );
// Parallax effect on the fade blocks
var scroll = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame ||
// IE Fallback, you can even fallback to onscroll
function(callback){ window.setTimeout(callback, 1000/60) };
function loop(){
var windowOffset = window.pageYOffset;
if ( windowOffset < $( window ).outerHeight() ) {
$( '.fade-block' ).css({
'transform': 'translateY( ' + Math.ceil ( windowOffset * 0.25 ) + 'px)',
'opacity': 1 - ( windowOffset * 0.002 )
});
}
scroll( loop )
}
if (!$('body').hasClass('vertical-featured-image')) loop();
// Toggle navigation
$( '.nav-toggle' ).on( 'click', function(){
$( this ).add( '.site-nav' ).toggleClass( 'active' );
$( 'body' ).toggleClass( 'lock-screen' );
} );
// Resize videos after their container
var vidSelector = ".post iframe, .post object, .post video, .widget-content iframe, .widget-content object, .widget-content iframe";
var resizeVideo = function(sSel) {
$( sSel ).each(function() {
var $video = $(this),
$container = $video.parent(),
iTargetWidth = $container.width();
if ( !$video.attr("data-origwidth") ) {
$video.attr("data-origwidth", $video.attr("width"));
$video.attr("data-origheight", $video.attr("height"));
}
var ratio = iTargetWidth / $video.attr("data-origwidth");
$video.css("width", iTargetWidth + "px");
$video.css("height", ( $video.attr("data-origheight") * ratio ) + "px");
});
};
resizeVideo( vidSelector );
$( window ).resize( function() {
resizeVideo( vidSelector );
} );
// Smooth scroll to anchor links
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event) {
// On-page links
if ( location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname ) {
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length) {
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
}, 1000 );
}
}
})
// If the website has a custom logo, adjust the site-nav top
// padding to make sure it is consistent with image dimensions
if ( $( 'body').hasClass( 'wp-custom-logo' )) {
var headerHeight = $( '.site-header' ).outerHeight(),
altNavigationHegiht = $( '.alt-nav' ).height();
$( '.site-nav' ).css( 'padding-top', (headerHeight + 40) + 'px' );
if (!$('.site-header').hasClass('header-wide'))
$( '.alt-nav' ).css( 'top', ((headerHeight / 2) - Math.round(altNavigationHegiht / 2)) + 'px' );
$( window ).resize( function() {
var headerHeight = $( '.site-header' ).outerHeight(),
altNavigationHegiht = $( '.alt-nav' ).height();
$( '.site-nav' ).css( 'padding-top', (headerHeight + 40) + 'px' );
if (!$('.site-header').hasClass('header-wide'))
$( '.alt-nav' ).css( 'top', ((headerHeight / 2) - Math.round(altNavigationHegiht / 2)) + 'px' );
} );
}
if ( $( 'body').hasClass( 'sticky-menu' )) {
var position = $( "#site-header" ).offset(),
height = $('#site-header').outerHeight(),
width = $( window ).width();
//$('body').css('padding-top', height + 'px');
function joy_sticky_menu() {
if ($('.sticky-navigation').length) {
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('.sticky-navigation').outerHeight();
$(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
function hasScrolled() {
var st = $(this).scrollTop();
// avoid hide close on open menu
if ($( 'body' ).hasClass( 'lock-screen' )) return;
// Make sure they scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If they scrolled down and are past the navbar, add class .nav-up.
// This is necessary so you never see what is "behind" the navbar.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
// We want to hide both the red and black bars on scroll down every time
$('.sticky-navigation').removeClass('sticky-effect').addClass('nav-up');
} else {
// Scroll Up
if(st <= (navbarHeight * 2)) {
// If we are 50px from the top of the screen then show the red and black bars.
$('.sticky-navigation').removeClass('nav-up').removeClass('sticky-effect');
} else {
// If we are more than 50px from the top then we want to show only
// the red bar at the top of the screen
$('.sticky-navigation').removeClass('nav-up').addClass('sticky-effect');
}
}
lastScrollTop = st;
}
}
}
joy_sticky_menu();
}
function single_sticky_bottom() {
if ($('#joy-single-sticky').length) {
var top_offset = $('.entry-content').offset().top;
if (top_offset > 600) top_offset = 600;
var height = $(document).height() - $(window).height();
var sticky_meta_offset = top_offset;
var footer_offset = $('.site-footer').offset().top - $('.site-footer').height() - $(window).height();
$(window).scroll(function() {
if ($(window).scrollTop() > sticky_meta_offset && $(window).scrollTop() < (height - 200)) {
$('.joy-sticky-content.meta').parent().addClass('joy-single-sticky-show joy-show-meta');
} else {
$('.joy-sticky-content.meta').parent().removeClass('joy-single-sticky-show');
}
});
}
}
function scroll_to_top() {
if ($('.joy-sticky-to-top').length) {
$('body').on('click', '.joy-sticky-to-top', function(e) {
e.preventDefault();
$('body,html').animate({
scrollTop: 0
}, 800);
return false;
});
}
}
if ($( window ).width() > 960) {
single_sticky_bottom();
scroll_to_top();
}
// Intercept the Jetpack Load More button when it's reinserted
$( document ).bind( 'DOMNodeInserted', function( e ) {
var $target = $( e.target );
if ( $target.is( '#infinite-handle' ) ) {
$target.hide();
}
} );
if ($('.slider-type-slider').length) {
$('.slider-type-slider').css('height', $(window).height() - 200);
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
spaceBetween: 10,
slidesPerView: 4,
autoplay: 4000,
loop: true,
effect: 'fade'
});
}
$('.recipe .recipe-ingredients li').each(function() {
$(this).click(function(e){
e.preventDefault();
$(this).toggleClass('completed');
});
});
// Triggers re-layout on Jetpack infinite scroll
infinite_count = 0;
$( document.body ).on( 'post-load', function() {
infinite_count = infinite_count + 1;
// Target the new items and hide them
var $selector = $( '#infinite-view-' + infinite_count ),
$elements = $selector.find( '.post-preview' );
$elements.hide();
// When images are loaded, show them again
$elements.imagesLoaded().done( function(){
$container.append( $elements );
$elements.show();
$container.masonry( 'appended', $elements );
// Prepare for fade-in animation on scroll
$elements.each( function( index ) {
if ( $( this ).offset().top < ( $( window ).height() + $( window ).scrollTop() ) ) {
$( this ).addClass( 'jetpack-fade-in' );
} else {
$( this ).addClass( 'will-spot' ).removeClass( 'spotted' );
}
} );
// Show the load more button again
$( '#infinite-handle' ).fadeIn();
});
});
});