diff --git src/wp-content/themes/twentyfifteen/js/functions.js src/wp-content/themes/twentyfifteen/js/functions.js
index 64a6968..7e66fee 100644
|
|
|
11 | 11 | topOffset = 0, bodyHeight, sidebarHeight, resizeTimer, |
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(); |
26 | 25 | _this.toggleClass( 'toggle-on' ); |
… |
… |
|
29 | 28 | _this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand ); |
30 | 29 | } ); |
31 | 30 | } |
32 | | initMainNavigation(); |
33 | | $( document ).on( 'customize-preview-menu-refreshed', initMainNavigation ); |
| 31 | initMainNavigation( $( '.main-navigation' ) ); |
| 32 | $( document ).on( 'customize-preview-menu-refreshed', function( e, params ) { |
| 33 | if ( 'primary' === params.wpNavMenuArgs.theme_location ) { |
| 34 | initMainNavigation( params.newContainer ); |
| 35 | |
| 36 | // Re-sync expanded states from oldContainer |
| 37 | params.oldContainer.find( '.dropdown-toggle.toggle-on' ).each(function() { |
| 38 | var containerId = $( this ).parent().prop( 'id' ); |
| 39 | $( params.newContainer ).find( '#' + containerId + ' > .dropdown-toggle' ).triggerHandler( 'click' ); |
| 40 | }); |
| 41 | } |
| 42 | } ); |
34 | 43 | |
35 | 44 | secondary = $( '#secondary' ); |
36 | 45 | button = $( '.site-branding' ).find( '.secondary-toggle' ); |
diff --git src/wp-includes/js/customize-preview-nav-menus.js src/wp-includes/js/customize-preview-nav-menus.js
index 017d1f1..814c6f2 100644
|
|
|
174 | 174 | * @param {int} instanceNumber |
175 | 175 | */ |
176 | 176 | refreshMenuInstance : function( instanceNumber ) { |
177 | | var data, menuId, customized, container, request, wpNavArgs, instance, containerInstanceClassName; |
| 177 | var data, menuId, customized, container, request, wpNavMenuArgs, instance, containerInstanceClassName; |
178 | 178 | |
179 | 179 | if ( ! settings.navMenuInstanceArgs[ instanceNumber ] ) { |
180 | 180 | throw new Error( 'unknown_instance_number' ); |
… |
… |
|
227 | 227 | data.customized = JSON.stringify( customized ); |
228 | 228 | data[ settings.renderNoncePostKey ] = settings.renderNonceValue; |
229 | 229 | |
230 | | wpNavArgs = $.extend( {}, instance ); |
231 | | data.wp_nav_menu_args_hash = wpNavArgs.args_hash; |
232 | | delete wpNavArgs.args_hash; |
233 | | data.wp_nav_menu_args = JSON.stringify( wpNavArgs ); |
| 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' ); |
236 | 236 | |
… |
… |
|
252 | 252 | previousContainer.replaceWith( container ); |
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 |
258 | 259 | }; |