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 * Enables menu toggle for small screens. 13 */ 14 ( function() { 15 var nav = $( '#site-navigation' ), button, menu; 16 if ( ! nav ) { 17 return; 18 } 19 20 button = nav.find( '.menu-toggle' ); 21 if ( ! button ) { 22 return; 23 } 24 25 // Hide button if menu is missing or empty. 26 menu = nav.find( '.nav-menu' ); 27 if ( ! menu || ! menu.children().length ) { 28 button.hide(); 29 return; 30 } 31 32 button.on( 'click.twentythirteen', function() { 33 nav.toggleClass( 'toggled-on' ); 34 } ); 35 36 // Fix sub-menus for touch devices. 37 if ( 'ontouchstart' in window ) { 38 menu.find( '.menu-item-has-children > a' ).on( 'touchstart.twentythirteen', function( e ) { 39 var el = $( this ).parent( 'li' ); 40 41 if ( ! el.hasClass( 'focus' ) ) { 42 e.preventDefault(); 43 el.toggleClass( 'focus' ); 44 el.siblings( '.focus' ).removeClass( 'focus' ); 45 } 46 } ); 47 } 48 49 // Better focus for hidden submenu items for accessibility. 50 menu.find( 'a' ).on( 'focus.twentythirteen blur.twentythirteen', function() { 51 $( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' ); 52 } ); 53 } )(); 54 55 /** 56 * Makes "skip to content" link work correctly in IE9 and Chrome for better 57 * accessibility. 58 * 59 * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ 60 */ 61 _window.on( 'hashchange.twentythirteen', function() { 62 var element = document.getElementById( location.hash.substring( 1 ) ); 63 64 if ( element ) { 65 if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) { 66 element.tabIndex = -1; 67 } 68 69 element.focus(); 70 } 71 } ); 72 73 /** 74 * Arranges footer widgets vertically. 75 */ 76 if ( $.isFunction( $.fn.masonry ) ) { 77 var columnWidth = body.is( '.sidebar' ) ? 228 : 245; 78 79 $( '#secondary .widget-area' ).masonry( { 80 itemSelector: '.widget', 81 columnWidth: columnWidth, 82 gutterWidth: 20, 83 isRTL: body.is( '.rtl' ) 84 } ); 85 } 86} )( 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.