Changeset 33491
- Timestamp:
- 07/29/2015 06:12:26 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfifteen/js/functions.js
r32807 r33491 12 12 secondary, button; 13 13 14 15 function initMainNavigation() { 14 function initMainNavigation( container ) { 16 15 // 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>' );16 container.find( '.menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' ); 18 17 19 18 // 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' );19 container.find( '.current-menu-ancestor > button' ).addClass( 'toggle-on' ); 20 container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' ); 22 21 23 $( '.dropdown-toggle' ).click( function( e ) {22 container.find( '.dropdown-toggle' ).click( function( e ) { 24 23 var _this = $( this ); 25 24 e.preventDefault(); … … 30 29 } ); 31 30 } 32 initMainNavigation(); 33 $( document ).on( 'customize-preview-menu-refreshed', initMainNavigation ); 31 initMainNavigation( $( '.main-navigation' ) ); 32 33 // Re-initialize the main navigation when it is updated, persisting any existing submenu expanded states. 34 $( document ).on( 'customize-preview-menu-refreshed', function( e, params ) { 35 if ( 'primary' === params.wpNavMenuArgs.theme_location ) { 36 initMainNavigation( params.newContainer ); 37 38 // Re-sync expanded states from oldContainer. 39 params.oldContainer.find( '.dropdown-toggle.toggle-on' ).each(function() { 40 var containerId = $( this ).parent().prop( 'id' ); 41 $( params.newContainer ).find( '#' + containerId + ' > .dropdown-toggle' ).triggerHandler( 'click' ); 42 }); 43 } 44 }); 34 45 35 46 secondary = $( '#secondary' ); -
trunk/src/wp-includes/js/customize-preview-nav-menus.js
r33347 r33491 175 175 */ 176 176 refreshMenuInstance : function( instanceNumber ) { 177 var data, menuId, customized, container, request, wpNav Args, instance, containerInstanceClassName;177 var data, menuId, customized, container, request, wpNavMenuArgs, instance, containerInstanceClassName; 178 178 179 179 if ( ! settings.navMenuInstanceArgs[ instanceNumber ] ) { … … 228 228 data[ settings.renderNoncePostKey ] = settings.renderNonceValue; 229 229 230 wpNav Args = $.extend( {}, instance );231 data.wp_nav_menu_args_hash = wpNav Args.args_hash;232 delete wpNav Args.args_hash;233 data.wp_nav_menu_args = JSON.stringify( wpNav Args );230 wpNavMenuArgs = $.extend( {}, instance ); 231 data.wp_nav_menu_args_hash = wpNavMenuArgs.args_hash; 232 delete wpNavMenuArgs.args_hash; 233 data.wp_nav_menu_args = JSON.stringify( wpNavMenuArgs ); 234 234 235 235 container.addClass( 'customize-partial-refreshing' ); … … 253 253 eventParam = { 254 254 instanceNumber: instanceNumber, 255 wpNavArgs: wpNavArgs, 255 wpNavArgs: wpNavMenuArgs, // @deprecated 256 wpNavMenuArgs: wpNavMenuArgs, 256 257 oldContainer: previousContainer, 257 258 newContainer: container
Note: See TracChangeset
for help on using the changeset viewer.