Changeset 32807
- Timestamp:
- 06/16/2015 10:17:39 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfifteen/js/functions.js
r31934 r32807 10 10 bottom = false, windowWidth, windowHeight, lastWindowPos = 0, 11 11 topOffset = 0, bodyHeight, sidebarHeight, resizeTimer, 12 12 secondary, button; 13 13 14 // Add dropdown toggle that display child menu items.15 $( '.main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' );16 14 17 // Toggle buttons and submenu items with active children menu items.18 $( '.main-navigation .current-menu-ancestor > button' ).addClass( 'toggle-on' );19 $( '.main-navigation .current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );15 function initMainNavigation() { 16 // Add dropdown toggle that display child menu items. 17 $( '.main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' ); 20 18 21 $( '.dropdown-toggle' ).click( function( e ) { 22 var _this = $( this ); 23 e.preventDefault(); 24 _this.toggleClass( 'toggle-on' ); 25 _this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' ); 26 _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); 27 _this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand ); 28 } ); 19 // Toggle buttons and submenu items with active children menu items. 20 $( '.main-navigation .current-menu-ancestor > button' ).addClass( 'toggle-on' ); 21 $( '.main-navigation .current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' ); 22 23 $( '.dropdown-toggle' ).click( function( e ) { 24 var _this = $( this ); 25 e.preventDefault(); 26 _this.toggleClass( 'toggle-on' ); 27 _this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' ); 28 _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); 29 _this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand ); 30 } ); 31 } 32 initMainNavigation(); 33 $( document ).on( 'customize-preview-menu-refreshed', initMainNavigation ); 29 34 30 35 secondary = $( '#secondary' );
Note: See TracChangeset
for help on using the changeset viewer.