( function( $ ) { var arcticBlack = arcticBlack || {}; arcticBlack.init = function() { arcticBlack.$body = $( document.body ); arcticBlack.$window = $( window ); arcticBlack.$html = $( 'html' ); this.inlineSVG(); this.fitVids(); this.smoothScroll(); this.thumbFocus(); this.featuredSlider(); this.footerSlider(); }; arcticBlack.supportsInlineSVG = function() { var div = document.createElement( 'div' ); div.innerHTML = ''; return 'http://www.w3.org/2000/svg' === ( 'undefined' !== typeof SVGRect && div.firstChild && div.firstChild.namespaceURI ); }; arcticBlack.inlineSVG = function() { if ( true === arcticBlack.supportsInlineSVG() ) { document.documentElement.className = document.documentElement.className.replace( /(\s*)no-svg(\s*)/, '$1svg$2' ); } }; arcticBlack.fitVids = function() { $( '#page' ).fitVids({ customSelector: 'iframe[src^="https://videopress.com"]' }); }; arcticBlack.smoothScroll = function() { var $smoothScroll = $( 'a[href*="#site-navigation"], a[href*="#content"], a[href*="#tertiary"]' ); $smoothScroll.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 }, 500, function() { // Callback after animation // Must change focus! var $target = $(target); $target.focus(); if ($target.is(':focus')) { // Checking if the target was focused return false; } else { $target.attr( 'tabindex', '-1' ); // Adding tabindex for elements not focusable $target.focus(); // Set focus again } }); } } }); }; arcticBlack.thumbFocus = function() { $( '.entry' ).find( 'a' ).on( 'hover focus blur', function( e ) { e.preventDefault(); $( this ).parent().prev('.post-thumbnail').toggleClass( 'focus' ); } ); }; arcticBlack.featuredSlider = function() { var prev__btn = '', next__btn = ''; $('.featured-content').not('.slick-initialized').slick({ infinite: true, adaptiveHeight: true, slidesToScroll: 1, fade: true, slidesToShow: 1, autoplay: true, autoplaySpeed: 5000, arrows: true, dots: true, pauseOnHover: false, dotsClass: 'arctic-slick-dots', prevArrow: prev__btn, nextArrow: next__btn, responsive: [ { breakpoint: 788, settings: { fade: true, slidesToShow: 1 } } ] }); }; arcticBlack.footerSlider = function() { $( '#quaternary .instagram-pics' ).not('.slick-initialized').slick({ infinite: true, dots: false, adaptiveHeight: false, slidesToShow: 8, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, arrows: false, responsive: [ { breakpoint: 960, settings: { slidesToShow: 6 } }, { breakpoint: 768, settings: { slidesToShow: 4 } }, { breakpoint: 480, settings: { slidesToShow: 2 } } ] }); }; /** Initialize arcticBlack.init() */ $( function() { arcticBlack.init(); }); $( document.body ).on( 'post-load', function () { arcticBlack.thumbFocus(); }); } )( jQuery );