/* global acumenScreenReaderText */ /** * Theme functions file. * * Contains handlers for navigation and widget area. */ (function($) { // Masonry if ( typeof $.fn.masonry === 'function' ) { //Masonry blocks $blocks = $('.infinite-grid'); $blocks.imagesLoaded(function() { $blocks.masonry({ itemSelector: '.grid-item', columnWidth: '.grid-item', // slow transitions transitionDuration: '1s' }); // Fade blocks in after images are ready (prevents jumping and re-rendering) $('.grid-item').fadeIn(); $blocks.find('.grid-item').animate({ 'opacity': 1 }); }); $(function() { setTimeout(function() { $blocks.masonry(); }, 2000); }); $(window).on( 'resize',function() { $blocks.masonry(); }); } // When Jetpack Infinite scroll posts have loaded $(document.body).on('post-load', function() { $blocks.masonry('reloadItems'); $blocks.imagesLoaded(function() { $blocks.masonry({ itemSelector: '.grid-item', columnWidth: '.grid-item', // slow transitions transitionDuration: '1s', }); // Fade blocks in after images are ready (prevents jumping and re-rendering) $('.grid-item').fadeIn(); $blocks.find('.grid-item').animate({ 'opacity': 1 }); }); $(document).ready(function() { setTimeout(function() { $blocks.masonry(); }, 2000); }); }); // Add header video class after the video is loaded. $(document).on('wp-custom-header-video-loaded', function() { $('body').addClass('has-header-video'); }); /** * Functionality for scroll to top button */ $(function() { $(window).on( 'scroll', function() { if ($(this).scrollTop() > 100) { $('#scrollup').fadeIn('slow'); $('#scrollup').show(); } else { $('#scrollup').fadeOut('slow'); $("#scrollup").hide(); } }); $('#scrollup').on('click', function() { $('body, html').animate({ scrollTop: 0 }, 500); return false; }); }); // Fixed header. $(window).on('scroll', function() { if ($('.sticky-enabled').length && $(window).scrollTop() > $('.sticky-enabled').offset().top && !($('.sticky-enabled').hasClass('sticky-header'))) { $('.sticky-enabled').addClass('sticky-header'); } else if (0 === $(window).scrollTop()) { $('.sticky-enabled').removeClass('sticky-header'); } }); var body, masthead, menuToggle, siteNavigation, searchNavigation, siteHeaderMenu, resizeTimer; function initMainNavigation(container) { // Add dropdown toggle that displays child menu items. var dropdownToggle = $('