Ticket #24839: 24839-twentytwelve.diff
File 24839-twentytwelve.diff, 1.4 KB (added by , 11 years ago) |
---|
-
functions.php
142 142 */ 143 143 wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '1.0', true ); 144 144 145 /* 146 * Adds JavaScript for toggling the sub-menu when :focus an anchor in a wp_nav_menu 147 */ 148 wp_enqueue_script( 'twentytwelve-nav-menus', get_template_directory_uri() . '/js/nav-menus.js', array( 'jquery' ), '1.0', true ); 149 145 150 $font_url = twentytwelve_get_font_url(); 146 151 if ( ! empty( $font_url ) ) 147 152 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), null ); -
js/nav-menus.js
1 /** 2 * nav-menus.js 3 * 4 * Handles toggling the sub-menu on the anchor focus (Accessibility) 5 */ 6 ( function( $ ) { 7 $( 'li.menu-item a' ).on({ 8 focus : function( e ) { 9 if( $( this ).parents( 'li' ).find( '> ul' ) ) { 10 $( this ).parents( 'li' ).find( '> ul' ).each( function() { 11 $( this ).show(); 12 }); 13 } 14 }, 15 focusout : function( e ) { 16 if( $( this ).parents( 'li' ).find( '> ul' ).is( ':visible' ) ) { 17 $( this ).parents( 'li' ).find( '> ul' ).css( 'display', '' ); 18 } 19 } 20 }); 21 } )( jQuery ); 22 No newline at end of file