mirror of
https://ghproxy.net/https://github.com/AlxMedia/magaziner.git
synced 2025-08-27 18:38:17 +08:00
FA 5.15.2 + trap js/html + regen lang + menu css fix + dropdown width + style.css version number + pingback header fix + disable nav mods
This commit is contained in:
parent
d883231cc9
commit
b3f8c93498
21 changed files with 6747 additions and 1611 deletions
|
@ -133,5 +133,39 @@ jQuery(document).ready(function($) {
|
|||
/* Social count plus override
|
||||
/* ------------------------------------ */
|
||||
$('.social-count-plus ul li span').attr('style', 'color: #fff');
|
||||
|
||||
/* Trap focus
|
||||
/* ------------------------------------ */
|
||||
// add all the elements inside modal which you want to make focusable
|
||||
const focusableElements =
|
||||
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
||||
const modal = document.querySelector('.search-trap-focus'); // select the modal by it's id
|
||||
|
||||
if ( modal ) {
|
||||
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
|
||||
const focusableContent = modal.querySelectorAll(focusableElements);
|
||||
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
|
||||
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
|
||||
|
||||
if (!isTabPressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey) { // if shift key pressed for shift + tab combination
|
||||
if (document.activeElement === firstFocusableElement) {
|
||||
lastFocusableElement.focus(); // add focus for the last focusable element
|
||||
e.preventDefault();
|
||||
}
|
||||
} else { // if tab key is pressed
|
||||
if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab
|
||||
firstFocusableElement.focus(); // add focus for the first focusable element
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue