1/** 2 * Functionality specific to Twenty Thirteen. 3 * 4 * Provides helper functions to enhance the theme experience. 5 */ 6 7( function( $ ) { 8 var body = $( 'body' ), 9 _window = $( window ); 10 11 /** 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 14 * the sidebar. 15 */ 16 $( function() { 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; 21 22 if ( margin > 0 && _window.innerWidth() > 999 ) { 23 $( '#colophon' ).css( 'margin-top', margin + 'px' ); 24 } 25 } 26 } ); 27 28 /** 29 * Enables menu toggle for small screens. 30 */ 31 ( function() { 32 var nav = $( '#site-navigation' ), button, menu; 33 if ( ! nav ) { 34 return; 35 } 36 37 button = nav.find( '.menu-toggle' ); 38 if ( ! button ) { 39 return; 40 } 41 42 // Hide button if menu is missing or empty. 43 menu = nav.find( '.nav-menu' ); 44 if ( ! menu || ! menu.children().length ) { 45 button.hide(); 46 return; 47 } 48 49 button.on( 'click.twentythirteen', function() { 50 nav.toggleClass( 'toggled-on' ); 51 } ); 52 53 // Fix sub-menus for touch devices. 54 if ( 'ontouchstart' in window ) { 55 menu.find( '.menu-item-has-children > a' ).on( 'touchstart.twentythirteen', function( e ) { 56 var el = $( this ).parent( 'li' ); 57 58 if ( ! el.hasClass( 'focus' ) ) { 59 e.preventDefault(); 60 el.toggleClass( 'focus' ); 61 el.siblings( '.focus' ).removeClass( 'focus' ); 62 } 63 } ); 64 } 65 66 // Better focus for hidden submenu items for accessibility. 67 menu.find( 'a' ).on( 'focus.twentythirteen blur.twentythirteen', function() { 68 $( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' ); 69 } ); 70 } )(); 71 72 /** 73 * Makes "skip to content" link work correctly in IE9 and Chrome for better 74 * accessibility. 75 * 76 * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ 77 */ 78 _window.on( 'hashchange.twentythirteen', function() { 79 var element = document.getElementById( location.hash.substring( 1 ) ); 80 81 if ( element ) { 82 if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) { 83 element.tabIndex = -1; 84 } 85 86 element.focus(); 87 } 88 } ); 89 90 /** 91 * Arranges footer widgets vertically. 92 */ 93 if ( $.isFunction( $.fn.masonry ) ) { 94 var columnWidth = body.is( '.sidebar' ) ? 228 : 245; 95 96 $( '#secondary .widget-area' ).masonry( { 97 itemSelector: '.widget', 98 columnWidth: columnWidth, 99 gutterWidth: 20, 100 isRTL: body.is( '.rtl' ) 101 } ); 102 } 103} )( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.