// _Swank Scripts // @package eT3_Generic // @since Swank 1.0 //============================================ ( function( $ ) { // MENU SCRIPTS //============================================ // Menu Keyboard Accessibility //-------------------------------------------- function menuAccessibility() { var el = $( '#primary-menu' ); $("a", el).focus(function() { $(this).parents("li").addClass("focus"); }).blur(function() { $(this).parents("li").removeClass("focus"); }); } // Mobile Menu Toggle function menuControl() { $( '.menu-toggle' ).on( 'click', function( e ) { e.preventDefault(); $( this ).toggleClass( 'toggle-on' ); $( '#primary-menu' ).toggleClass( 'toggled' ); } ); } // Mobile Submenu Dropdown Button function menuDropdown() { var hasSubmenu = $( '', { 'class': 'dropdown-toggle', 'aria-expanded': false } ).append( $( '', { 'class': 'screen-reader-text', 'text': 'Dropdown Menu Toggle', } ) ); $( '.main-navigation' ).find( '.menu-item-has-children > a' ).after( hasSubmenu ); } // Mobile Submenu Toggle function submenuControl() { $( '.dropdown-toggle' ).on( 'click', function( e ) { e.preventDefault(); $( this ).toggleClass('toggled'); $( this ).next( '.sub-menu' ).toggleClass( 'toggled' ); if ( $( this ).attr( 'aria-expanded' ) === 'false' ) { $( this ).attr('aria-expanded', 'true'); } else { $( this ).attr('aria-expanded', 'false'); } } ); } // Wrap Tiled Gallery function galleryWrapper() { $( '.entry-content' ).find( '.tiled-gallery' ).wrap( '
' ).resize(); } // Add class to large images function outdentImages() { $( '.entry-content img' ).each( function() { var img = $( this ), caption = $( this ).closest( 'figure' ), new_img = new Image(); new_img.src = img.attr( 'src' ); $( new_img ).load( function() { var img_width = new_img.width; if ( img_width >= 1000 ) { $( img ).addClass( 'size-big' ); } if ( caption.hasClass( 'wp-caption' ) && img_width >= 1000 ) { caption.addClass( 'caption-big' ); } } ); } ); } $( document ).ready( function() { menuAccessibility(); menuControl(); menuDropdown(); submenuControl(); galleryWrapper(); outdentImages(); } ); } ) ( jQuery ); // Skip Link Focus Fix /** Helps with accessibility for keyboard only users. **/ ( function() { var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) { window.addEventListener( 'hashchange', function() { var id = location.hash.substring( 1 ), element; if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { return; } element = document.getElementById( id ); if ( element ) { if ( ! ( /^(?:a|select|input|button|textarea|li)$/i.test( element.tagName ) ) ) { element.tabIndex = -1; } element.focus(); } }, false ); } })();