Ticket #30575: functions.patch
| File functions.patch, 2.2 KB (added by , 10 years ago) |
|---|
-
.js
old new 114 114 } ); 115 115 } 116 116 } 117 118 // Focus styles for menus.119 $( '.primary-navigation, .secondary-navigation' ).find( 'a' ).on( 'focus.twentyfourteen blur.twentyfourteen', function() {120 $( this ).parents().toggleClass( 'focus' );121 } );122 117 } ); 123 118 124 119 /** 120 * Enable hover for dropdown menu for touch devices 121 * 122 * Modification of patch 30575 by Richard van Denderen 123 * @link https://core.trac.wordpress.org/attachment/ticket/30575/30575.patch 124 */ 125 function touchDropdown() { 126 if ( 781 > _window.width() ) { 127 $( '.primary-navigation, .secondary-navigation' ).find( 'a' ).on( 'focus.twentyfourteen blur.twentyfourteen', function() { 128 $( this ).parents().toggleClass( 'focus' ); 129 } ); 130 if ( 'ontouchstart' in window ) { 131 $( document.body ).off( 'touchstart.twentyfourteen' ); 132 } 133 } else { 134 if ( 'ontouchstart' in window ) { 135 $( document.body ).on( 'touchstart.twentyfourteen', '.menu-item-has-children > a, .page_item_has_children > a', function( e ) { 136 var el = $( this ).parent( 'li' ); 137 138 if ( ! el.hasClass( 'focus' ) ) { 139 e.preventDefault(); 140 el.toggleClass( 'focus' ); 141 el.siblings( '.focus' ).removeClass( 'focus' ); 142 } 143 } ); 144 } 145 } 146 } 147 148 /** 125 149 * @summary Add or remove ARIA attributes. 126 150 * Uses jQuery's width() function to determine the size of the window and add 127 151 * the default ARIA attributes for the menu toggle if it's visible. … … 132 156 button.attr( 'aria-expanded', 'false' ); 133 157 menu.attr( 'aria-expanded', 'false' ); 134 158 button.attr( 'aria-controls', 'primary-menu' ); 159 $( '.menu-item-has-children' ).attr( 'aria-haspopup', 'false' ); 135 160 } else { 136 161 button.removeAttr( 'aria-expanded' ); 137 162 menu.removeAttr( 'aria-expanded' ); 138 163 button.removeAttr( 'aria-controls' ); 164 $( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' ); 139 165 } 140 166 } 141 167 142 _window 143 .on( 'load.twentyfourteen', onResizeARIA ) 144 .on( 'resize.twentyfourteen', function() { 168 _window.on( 'load.twentyfourteen resize.twentyfourteen', function() { 169 touchDropdown(); 145 170 onResizeARIA(); 146 171 } ); 147 172