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. Built from https://develop.svn.wordpress.org/trunk@32807 git-svn-id: http://core.svn.wordpress.org/trunk@32778 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
62e3a0c15c
commit
b2b3f1c3ff
|
@ -9,23 +9,28 @@
|
||||||
var $body, $window, $sidebar, adminbarOffset, top = false,
|
var $body, $window, $sidebar, adminbarOffset, top = false,
|
||||||
bottom = false, windowWidth, windowHeight, lastWindowPos = 0,
|
bottom = false, windowWidth, windowHeight, lastWindowPos = 0,
|
||||||
topOffset = 0, bodyHeight, sidebarHeight, resizeTimer,
|
topOffset = 0, bodyHeight, sidebarHeight, resizeTimer,
|
||||||
secondary, button;
|
secondary, button;
|
||||||
|
|
||||||
// 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>' );
|
|
||||||
|
|
||||||
// Toggle buttons and submenu items with active children menu items.
|
function initMainNavigation() {
|
||||||
$( '.main-navigation .current-menu-ancestor > button' ).addClass( 'toggle-on' );
|
// Add dropdown toggle that display child menu items.
|
||||||
$( '.main-navigation .current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );
|
$( '.main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' );
|
||||||
|
|
||||||
$( '.dropdown-toggle' ).click( function( e ) {
|
// Toggle buttons and submenu items with active children menu items.
|
||||||
var _this = $( this );
|
$( '.main-navigation .current-menu-ancestor > button' ).addClass( 'toggle-on' );
|
||||||
e.preventDefault();
|
$( '.main-navigation .current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );
|
||||||
_this.toggleClass( 'toggle-on' );
|
|
||||||
_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
|
$( '.dropdown-toggle' ).click( function( e ) {
|
||||||
_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
|
var _this = $( this );
|
||||||
_this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand );
|
e.preventDefault();
|
||||||
} );
|
_this.toggleClass( 'toggle-on' );
|
||||||
|
_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
|
||||||
|
_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
|
||||||
|
_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' );
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-32806';
|
$wp_version = '4.3-alpha-32807';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue