updated plugin GP Premium version 2.2.0

This commit is contained in:
2022-10-27 11:14:35 +00:00
committed by Gitium
parent 1465186bc5
commit a626bfa106
77 changed files with 418 additions and 152 deletions

View File

@ -505,22 +505,35 @@ var generateOffside = offside( '.slideout-navigation', {
slidingElementsSelector:'#slideout-container',
buttonsSelector: '.slideout-mobile .main-navigation .menu-toggle, .slideout-both .main-navigation .menu-toggle, .slideout-both .slideout-toggle, .slideout-desktop .slideout-toggle',
slidingSide: offSide.side,
beforeOpen: function() {
// Turn on visibility so we can transition nicely.
document.querySelector( '.slideout-navigation' ).style.visibility = 'visible';
},
afterOpen: function() {
document.documentElement.classList.add( 'slide-opened' );
document.body.classList.add( 'slide-opened' );
// Get the first link so we can focus on it.
var slideoutMenu = document.querySelector( 'ul.slideout-menu' );
if ( document.body.classList.contains( 'dropdown-hover' ) ) {
var dropdownItems = document.querySelector( '.slideout-navigation' ).querySelectorAll( 'li.menu-item-has-children' );
for ( var i = 0; i < dropdownItems.length; i++ ) {
var spanToggle = dropdownItems[i].querySelector( 'span.dropdown-menu-toggle' );
if ( slideoutMenu ) {
var firstLink = slideoutMenu.firstChild.querySelector( 'a' );
if ( firstLink ) {
setTimeout( function() {
firstLink.focus();
}, 200 );
if ( spanToggle ) {
spanToggle.setAttribute( 'tabindex', 0 );
spanToggle.setAttribute( 'role', 'button' );
spanToggle.setAttribute( 'aria-expanded', true );
}
}
}
// Focus the first focusable element.
var focusable = document.querySelector( '.slideout-navigation' ).querySelectorAll( 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' );
if ( focusable ) {
setTimeout( function() {
focusable[0].focus();
}, 200 );
}
},
afterClose: function() {
var body = document.body,
@ -540,7 +553,7 @@ var generateOffside = offside( '.slideout-navigation', {
}
if ( body.classList.contains( 'dropdown-hover' ) ) {
var dropdownItems = document.querySelector( '.main-navigation:not(.slideout-navigation)' ).querySelectorAll( 'li.menu-item-has-children' );
var dropdownItems = document.querySelector( '.main-navigation:not(.slideout-navigation):not(.mobile-menu-control-wrapper)' ).querySelectorAll( 'li.menu-item-has-children' );
for ( var i = 0; i < dropdownItems.length; i++ ) {
var spanToggle = dropdownItems[i].querySelector( 'span.dropdown-menu-toggle' );
@ -551,6 +564,30 @@ var generateOffside = offside( '.slideout-navigation', {
}
}
}
// Turn off visibility.
setTimeout( function() {
document.querySelector( '.slideout-navigation:not(.is-open)' ).style.visibility = '';
}, 500 );
// Focus our slideout toggle.
if ( window.document.documentElement.clientWidth <= 768 ) {
if ( body.classList.contains( 'slideout-mobile' ) || body.classList.contains( 'slideout-both' ) ) {
document.querySelectorAll( '.main-navigation:not(.slideout-navigation)' ).forEach( function( navigation ) {
if ( navigation && navigation.style.display !== 'none' ) {
navigation.querySelector( '.menu-toggle' ).focus();
}
} );
}
} else {
if ( body.classList.contains( 'slideout-desktop' ) || body.classList.contains( 'slideout-both' ) ) {
document.querySelectorAll( '.main-navigation:not(.slideout-navigation)' ).forEach( function( navigation ) {
if ( navigation && navigation.style.display !== 'none' ) {
navigation.querySelector( '.slideout-toggle a' ).focus();
}
} );
}
}
}
} );
@ -588,20 +625,9 @@ for ( var i = 0; i < slideoutLinks.length; i++ ) {
document.addEventListener( 'keyup', function( e ) {
if ( document.body.classList.contains( 'slide-opened' ) ) {
e = e || window.event;
if ( e.keyCode == 27 ) {
generateOffside.close();
var body = document.body;
if ( window.document.documentElement.clientWidth <= 768 ) {
if ( body.classList.contains( 'slideout-mobile' ) || body.classList.contains( 'slideout-both' ) ) {
document.querySelector( '.main-navigation .menu-toggle' ).focus();
}
} else {
if ( body.classList.contains( 'slideout-desktop' ) || body.classList.contains( 'slideout-both' ) ) {
document.querySelector( '.slideout-toggle a' ).focus();
document.activeElement.blur();
}
}
}
}
} );

File diff suppressed because one or more lines are too long