2 * Functionality specific to Twenty Thirteen.
4 * Provides helper functions to enhance the theme experience.
8 var body = $( 'body' ),
12 * Adds a top margin to the footer if the sidebar widget area is higher
13 * than the rest of the page, to help the footer always visually clear
17 if ( body.is( '.sidebar' ) ) {
18 var sidebar = $( '#secondary .widget-area' ),
19 secondary = ( 0 === sidebar.length ) ? -40 : sidebar.height(),
20 margin = $( '#tertiary .widget-area' ).height() - $( '#content' ).height() - secondary;
22 if ( margin > 0 && _window.innerWidth() > 999 ) {
23 $( '#colophon' ).css( 'margin-top', margin + 'px' );
29 * Enables menu toggle for small screens.
32 var nav = $( '#site-navigation' ), button, menu;
37 button = nav.find( '.menu-toggle' );
42 // Hide button if menu is missing or empty.
43 menu = nav.find( '.nav-menu' );
44 if ( ! menu || ! menu.children().length ) {
49 button.on( 'click.twentythirteen', function() {
50 nav.toggleClass( 'toggled-on' );
53 // Better focus for hidden submenu items for accessibility.
54 menu.find( 'a' ).on( 'focus.twentythirteen blur.twentythirteen', function() {
55 $( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' );
60 * Makes "skip to content" link work correctly in IE9 and Chrome for better
63 * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
65 _window.on( 'hashchange.twentythirteen', function() {
66 var element = document.getElementById( location.hash.substring( 1 ) );
69 if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {
70 element.tabIndex = -1;
78 * Arranges footer widgets vertically.
80 if ( $.isFunction( $.fn.masonry ) ) {
81 var columnWidth = body.is( '.sidebar' ) ? 228 : 245;
83 $( '#secondary .widget-area' ).masonry( {
84 itemSelector: '.widget',
85 columnWidth: columnWidth,
87 isRTL: body.is( '.rtl' )