Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
/**
|
|
|
|
* File primary-navigation.js.
|
|
|
|
*
|
|
|
|
* Required to open and close the mobile navigation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle an attribute's value
|
|
|
|
*
|
2021-07-02 04:57:57 -04:00
|
|
|
* @since Twenty Twenty-One 1.0
|
|
|
|
*
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
* @param {Element} el - The element.
|
|
|
|
* @param {boolean} withListeners - Whether we want to add/remove listeners or not.
|
|
|
|
*/
|
|
|
|
function twentytwentyoneToggleAriaExpanded( el, withListeners ) {
|
|
|
|
if ( 'true' !== el.getAttribute( 'aria-expanded' ) ) {
|
|
|
|
el.setAttribute( 'aria-expanded', 'true' );
|
2020-11-02 14:45:07 -05:00
|
|
|
twentytwentyoneSubmenuPosition( el.parentElement );
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
if ( withListeners ) {
|
|
|
|
document.addEventListener( 'click', twentytwentyoneCollapseMenuOnClickOutside );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
el.setAttribute( 'aria-expanded', 'false' );
|
|
|
|
if ( withListeners ) {
|
|
|
|
document.removeEventListener( 'click', twentytwentyoneCollapseMenuOnClickOutside );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function twentytwentyoneCollapseMenuOnClickOutside( event ) {
|
|
|
|
if ( ! document.getElementById( 'site-navigation' ).contains( event.target ) ) {
|
|
|
|
document.getElementById( 'site-navigation' ).querySelectorAll( '.sub-menu-toggle' ).forEach( function( button ) {
|
|
|
|
button.setAttribute( 'aria-expanded', 'false' );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-02 14:45:07 -05:00
|
|
|
/**
|
|
|
|
* Changes the position of submenus so they always fit the screen horizontally.
|
|
|
|
*
|
2021-07-02 04:57:57 -04:00
|
|
|
* @since Twenty Twenty-One 1.0
|
|
|
|
*
|
2020-11-02 14:45:07 -05:00
|
|
|
* @param {Element} li - The li element.
|
|
|
|
*/
|
|
|
|
function twentytwentyoneSubmenuPosition( li ) {
|
|
|
|
var subMenu = li.querySelector( 'ul.sub-menu' ),
|
Twenty Twenty-One: Sync the latest changes for 5.6 RC2.
This will be the final sync from GitHub before placing that repository into read-only mode. All further changes should now flow entirely through Trac.
For a full list of changes since [49633], see https://github.com/WordPress/twentytwentyone/compare/1d5a895...53acd9b.
Props poena, luminuu, kjellr, ryelle, allancole, melchoyce, felipeelia, aljullu, kebbet, chaton666, Clorith, mkaz, ingereck, paaljoachim.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49726
git-svn-id: http://core.svn.wordpress.org/trunk@49449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-12-01 14:09:05 -05:00
|
|
|
rect,
|
|
|
|
right,
|
|
|
|
left,
|
|
|
|
windowWidth;
|
|
|
|
|
|
|
|
if ( ! subMenu ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rect = subMenu.getBoundingClientRect();
|
|
|
|
right = Math.round( rect.right );
|
|
|
|
left = Math.round( rect.left );
|
|
|
|
windowWidth = Math.round( window.innerWidth );
|
2020-11-02 14:45:07 -05:00
|
|
|
|
|
|
|
if ( right > windowWidth ) {
|
|
|
|
subMenu.classList.add( 'submenu-reposition-right' );
|
|
|
|
} else if ( document.body.classList.contains( 'rtl' ) && left < 0 ) {
|
|
|
|
subMenu.classList.add( 'submenu-reposition-left' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
/**
|
|
|
|
* Handle clicks on submenu toggles.
|
|
|
|
*
|
2021-07-02 04:57:57 -04:00
|
|
|
* @since Twenty Twenty-One 1.0
|
|
|
|
*
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
* @param {Element} el - The element.
|
|
|
|
*/
|
2020-11-12 13:48:08 -05:00
|
|
|
function twentytwentyoneExpandSubMenu( el ) { // jshint ignore:line
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
// Close other expanded items.
|
|
|
|
el.closest( 'nav' ).querySelectorAll( '.sub-menu-toggle' ).forEach( function( button ) {
|
|
|
|
if ( button !== el ) {
|
|
|
|
button.setAttribute( 'aria-expanded', 'false' );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Toggle aria-expanded on the button.
|
|
|
|
twentytwentyoneToggleAriaExpanded( el, true );
|
|
|
|
|
|
|
|
// On tab-away collapse the menu.
|
|
|
|
el.parentNode.querySelectorAll( 'ul > li:last-child > a' ).forEach( function( linkEl ) {
|
|
|
|
linkEl.addEventListener( 'blur', function( event ) {
|
|
|
|
if ( ! el.parentNode.contains( event.relatedTarget ) ) {
|
|
|
|
el.setAttribute( 'aria-expanded', 'false' );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
( function() {
|
|
|
|
/**
|
|
|
|
* Menu Toggle Behaviors
|
|
|
|
*
|
2021-07-02 04:57:57 -04:00
|
|
|
* @since Twenty Twenty-One 1.0
|
|
|
|
*
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
* @param {string} id - The ID.
|
|
|
|
*/
|
|
|
|
var navMenu = function( id ) {
|
|
|
|
var wrapper = document.body, // this is the element to which a CSS class is added when a mobile nav menu is open
|
2021-06-04 13:08:00 -04:00
|
|
|
mobileButton = document.getElementById( id + '-mobile-menu' ),
|
|
|
|
navMenuEl = document.getElementById( 'site-navigation' );
|
|
|
|
|
|
|
|
// If there's no nav menu, none of this is necessary.
|
|
|
|
if ( ! navMenuEl ) {
|
|
|
|
return;
|
|
|
|
}
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
|
|
|
|
if ( mobileButton ) {
|
|
|
|
mobileButton.onclick = function() {
|
|
|
|
wrapper.classList.toggle( id + '-navigation-open' );
|
|
|
|
wrapper.classList.toggle( 'lock-scrolling' );
|
|
|
|
twentytwentyoneToggleAriaExpanded( mobileButton );
|
|
|
|
mobileButton.focus();
|
|
|
|
};
|
|
|
|
}
|
2021-07-02 04:57:57 -04:00
|
|
|
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
/**
|
|
|
|
* Trap keyboard navigation in the menu modal.
|
2021-07-02 04:57:57 -04:00
|
|
|
* Adapted from Twenty Twenty.
|
|
|
|
*
|
|
|
|
* @since Twenty Twenty-One 1.0
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
*/
|
|
|
|
document.addEventListener( 'keydown', function( event ) {
|
|
|
|
var modal, elements, selectors, lastEl, firstEl, activeEl, tabKey, shiftKey, escKey;
|
|
|
|
if ( ! wrapper.classList.contains( id + '-navigation-open' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
modal = document.querySelector( '.' + id + '-navigation' );
|
|
|
|
selectors = 'input, a, button';
|
|
|
|
elements = modal.querySelectorAll( selectors );
|
|
|
|
elements = Array.prototype.slice.call( elements );
|
|
|
|
tabKey = event.keyCode === 9;
|
|
|
|
shiftKey = event.shiftKey;
|
|
|
|
escKey = event.keyCode === 27;
|
2020-11-17 14:00:08 -05:00
|
|
|
activeEl = document.activeElement; // eslint-disable-line @wordpress/no-global-active-element
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
lastEl = elements[ elements.length - 1 ];
|
|
|
|
firstEl = elements[0];
|
|
|
|
|
|
|
|
if ( escKey ) {
|
|
|
|
event.preventDefault();
|
|
|
|
wrapper.classList.remove( id + '-navigation-open', 'lock-scrolling' );
|
|
|
|
twentytwentyoneToggleAriaExpanded( mobileButton );
|
|
|
|
mobileButton.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! shiftKey && tabKey && lastEl === activeEl ) {
|
|
|
|
event.preventDefault();
|
|
|
|
firstEl.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( shiftKey && tabKey && firstEl === activeEl ) {
|
|
|
|
event.preventDefault();
|
|
|
|
lastEl.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there are no elements in the menu, don't move the focus
|
|
|
|
if ( tabKey && firstEl === lastEl ) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2020-12-21 10:05:08 -05:00
|
|
|
/**
|
|
|
|
* Close menu and scroll to anchor when an anchor link is clicked.
|
2021-07-02 04:57:57 -04:00
|
|
|
* Adapted from Twenty Twenty.
|
|
|
|
*
|
|
|
|
* @since Twenty Twenty-One 1.1
|
2020-12-21 10:05:08 -05:00
|
|
|
*/
|
|
|
|
document.addEventListener( 'click', function( event ) {
|
|
|
|
// If target onclick is <a> with # within the href attribute
|
|
|
|
if ( event.target.hash && event.target.hash.includes( '#' ) ) {
|
|
|
|
wrapper.classList.remove( id + '-navigation-open', 'lock-scrolling' );
|
|
|
|
twentytwentyoneToggleAriaExpanded( mobileButton );
|
|
|
|
// Wait 550 and scroll to the anchor.
|
|
|
|
setTimeout(function () {
|
|
|
|
var anchor = document.getElementById(event.target.hash.slice(1));
|
2021-11-19 08:03:01 -05:00
|
|
|
if ( anchor ) {
|
|
|
|
anchor.scrollIntoView();
|
|
|
|
}
|
2020-12-21 10:05:08 -05:00
|
|
|
}, 550);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2021-06-04 13:08:00 -04:00
|
|
|
navMenuEl.querySelectorAll( '.menu-wrapper > .menu-item-has-children' ).forEach( function( li ) {
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
li.addEventListener( 'mouseenter', function() {
|
2020-10-26 22:00:07 -04:00
|
|
|
this.querySelector( '.sub-menu-toggle' ).setAttribute( 'aria-expanded', 'true' );
|
2020-11-02 14:45:07 -05:00
|
|
|
twentytwentyoneSubmenuPosition( li );
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
} );
|
|
|
|
li.addEventListener( 'mouseleave', function() {
|
2020-10-26 22:00:07 -04:00
|
|
|
this.querySelector( '.sub-menu-toggle' ).setAttribute( 'aria-expanded', 'false' );
|
Bundled Themes: Import Twenty Twenty-One, the new default theme for WordPress 5.6.
Welcome to the bundled themes family!
Twenty Twenty-One is a blank canvas for your ideas, making the block editor your best brush.
Theme development to this point has taken place on GitHub. See: https://github.com/WordPress/twentytwentyone/.
Props poena, melchoyce, luminuu, elmastudio, bethsoderberg, williampatton, aristath, jffng, kjellr, jeffikus, audrasjb, fabiankaegy, mukesh27, dingo_d, kellylawrence, acosmin, whyisjake, metodiew, ryelle, nielslange, littlebigthing, mahesh901122, zebulan, kishanjasani, lukecavanagh, scruffian, abhijitrakas, utz119, sudoshreyansh, kau-boy, justinahinon, joostdevalk, bduclos, hareesh-pillai, mager19, rolfsiebers, webmigrates, sresok, guidooffermans, francina, marybaum, hareshlive, navanathbhosale, afercia, richtabor, joyously, sarahricker, nrqsnchz, glauberglauber, sabernhardt, kraftbj, ItsJonQ, joen, CTMartin0, decrecementofeliz, bhautikvirani.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49216
git-svn-id: http://core.svn.wordpress.org/trunk@48978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-19 21:14:10 -04:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener( 'load', function() {
|
|
|
|
new navMenu( 'primary' );
|
|
|
|
} );
|
|
|
|
}() );
|