Twenty Fifteen: Wrap navigation helpers into a function so it can be called on a refresh event of the Customize Preview.

props westonruter.
see #32576.

git-svn-id: https://develop.svn.wordpress.org/trunk@32807 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-06-16 22:17:39 +00:00
parent c0a66eba79
commit d0a8130970

View File

@ -11,6 +11,8 @@
topOffset = 0, bodyHeight, sidebarHeight, resizeTimer, topOffset = 0, bodyHeight, sidebarHeight, resizeTimer,
secondary, button; secondary, button;
function initMainNavigation() {
// Add dropdown toggle that display child menu items. // Add dropdown toggle that display child menu items.
$( '.main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' ); $( '.main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' );
@ -26,6 +28,9 @@
_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
_this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand ); _this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand );
} ); } );
}
initMainNavigation();
$( document ).on( 'customize-preview-menu-refreshed', initMainNavigation );
secondary = $( '#secondary' ); secondary = $( '#secondary' );
button = $( '.site-branding' ).find( '.secondary-toggle' ); button = $( '.site-branding' ).find( '.secondary-toggle' );