( function( $ ) { /* * A function to help debouncing. */ var debounce = function( func, wait ) { var timeout, args, context, timestamp; return function() { context = this; args = [].slice.call( arguments, 0 ); timestamp = new Date(); var later = function() { var last = ( new Date() ) - timestamp; if ( last < wait ) { timeout = setTimeout( later, wait - last ); } else { timeout = null; func.apply( context, args ); } }; if ( ! timeout ) { timeout = setTimeout( later, wait ); } }; }; /* * Remove body "blog" class when a user is logged in and doesn't have a post yet. */ if ( $( '.site-main' ).children().hasClass( 'not-found' ) && $( 'body' ).hasClass( 'blog' ) ) { $( 'body' ).removeClass( 'blog' ).addClass( 'search-no-results' ); } /* * Move the Page Links before Sharedaddy. */ $( '.single .hentry' ).each( function() { $( this ).find( '.page-links' ).insertBefore( $( this ).find( '.sharedaddy' ).first() ); } ); /* * Add a class of "pace-done" to body when Sharedaddy official sharing buttons are being displayed. */ if ( $('.sd-social-official').length > 0 ) { $( 'body' ).addClass( 'pace-done' ); } /* * Format Video: Move videos above the Entry Header. */ $( '.single .format-video' ).find( 'embed, iframe, object, video' ).parent().each( function() { if ( ! $( this ).hasClass( 'entry-content' ) ) { $( this ).addClass( 'entry-media' ) .insertBefore( $( '.entry-header' ) ); } } ); $( '.single .format-video' ).find( 'iframe[src*="videopress.com"]' ).each( function() { $( this ).wrap( '
' ); $( this ).parent( '.entry-media' ).insertBefore( $( '.entry-header' ) ); } ); /* * Make sure tables don't overflow in Entry Content. */ $( '.entry-content' ).find( 'table' ).each( function() { if ( $( this ).width() > $( this ).parent().width() ) { $( this ).css( 'table-layout', 'fixed' ); } } ); /* * Remove border from linked images. */ $( '.entry-content a' ).each( function() { $( this ).has( 'img' ).addClass( 'no-border' ); } ); /* * Add hover class to Search Submit. */ function search_add_class() { $( this ).closest( '.search-form' ).addClass( 'hover' ); } function search_remove_class() { $( this ).closest( '.search-form' ).removeClass( 'hover' ); } var search_submit = $( '.search-submit' ); search_submit.hover( search_add_class, search_remove_class ); search_submit.focusin( search_add_class ); search_submit.focusout( search_remove_class ); /* * Remove Comment Reply if empty. */ $( '.comment .reply' ).each( function() { if ( $.trim( $( this ).text() ) === '' ) { $( this ).remove(); } } ); /* * Remove Byline if hidden and Entry Footer if empty. */ if ( $( '.byline' ).is( ':hidden') ) { $( '.byline' ).remove(); } $( '.entry-footer' ).filter( function() { return $.trim( $( this ).text() ) === '' } ).addClass( 'empty' ); /* * Add dropdown toggle that display child menu items. */ $( '.main-navigation .page_item_has_children > a, .main-navigation .menu-item-has-children > a, .widget_nav_menu .page_item_has_children > a, .widget_nav_menu .menu-item-has-children > a' ).append( '