Changeset 31644
- Timestamp:
- 03/06/2015 05:33:38 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfifteen/js/functions.js
r31214 r31644 9 9 var $body, $window, $sidebar, adminbarOffset, top = false, 10 10 bottom = false, windowWidth, windowHeight, lastWindowPos = 0, 11 topOffset = 0, bodyHeight, sidebarHeight, resizeTimer; 11 topOffset = 0, bodyHeight, sidebarHeight, resizeTimer, 12 secondary, button; 12 13 13 14 // Add dropdown toggle that display child menu items. … … 27 28 } ); 28 29 30 secondary = $( '#secondary' ); 31 button = $( '.site-branding' ).find( '.secondary-toggle' ); 32 29 33 // Enable menu toggle for small screens. 30 34 ( function() { 31 var secondary = $( '#secondary' ), button, menu, widgets, social; 32 if ( ! secondary ) { 33 return; 34 } 35 36 button = $( '.site-branding' ).find( '.secondary-toggle' ); 37 if ( ! button ) { 35 var menu, widgets, social; 36 if ( ! secondary || ! button ) { 38 37 return; 39 38 } … … 52 51 secondary.trigger( 'resize' ); 53 52 $( this ).toggleClass( 'toggled-on' ); 53 if ( $( this, secondary ).hasClass( 'toggled-on' ) ) { 54 $( this ).attr( 'aria-expanded', 'true' ); 55 secondary.attr( 'aria-expanded', 'true' ); 56 } else { 57 $( this ).attr( 'aria-expanded', 'false' ); 58 secondary.attr( 'aria-expanded', 'false' ); 59 } 54 60 } ); 55 61 } )(); 62 63 // Add or remove ARIA attributes. 64 function onResizeARIA() { 65 if ( 955 > $window.width() ) { 66 button.attr( 'aria-expanded', 'false' ); 67 secondary.attr( 'aria-expanded', 'false' ); 68 button.attr( 'aria-controls', 'secondary' ); 69 } else { 70 button.removeAttr( 'aria-expanded' ); 71 secondary.removeAttr( 'aria-expanded' ); 72 button.removeAttr( 'aria-controls' ); 73 } 74 } 56 75 57 76 // Sidebar scrolling. … … 120 139 $window 121 140 .on( 'scroll.twentyfifteen', scroll ) 141 .on( 'load.twentyfifteen', onResizeARIA ) 122 142 .on( 'resize.twentyfifteen', function() { 123 143 clearTimeout( resizeTimer ); 124 144 resizeTimer = setTimeout( resizeAndScroll, 500 ); 145 onResizeARIA(); 125 146 } ); 126 $sidebar.on( 'click keydown', 'button', resizeAndScroll );147 $sidebar.on( 'click.twentyfifteen keydown.twentyfifteen', 'button', resizeAndScroll ); 127 148 128 149 resizeAndScroll();
Note: See TracChangeset
for help on using the changeset viewer.