391 lines
13 KiB
JavaScript
391 lines
13 KiB
JavaScript
jQuery(document).ready(function( $ ){
|
|
|
|
//Add landmark roles
|
|
$('.elementor-location-header').attr('role', 'banner');
|
|
$('.elementor-location-footer').attr('role', 'contentinfo');
|
|
$('div[data-elementor-type=wp-page], div[data-elementor-type=wp-post], div[data-elementor-type=archive], div[data-elementor-type=single-post], div[data-elementor-type=error-404], div.pass-protected').attr('role', 'main').attr('id', 'main-content').attr('tabindex','-1');
|
|
|
|
$("#skiplink").click(function() {
|
|
$('#main-content').focus();
|
|
});
|
|
|
|
|
|
// close mega menu when tabbing through a flyout and out onto the top level nav items
|
|
jQuery(function($) {
|
|
$('.mega-sub-menu').on('focusout', function(e) {
|
|
e.preventDefault();
|
|
if (!$(this).has(event.relatedTarget).length && !$(this).is(event.relatedTarget)) {
|
|
// Focus has moved outside the menu, so close it
|
|
$('.max-mega-menu').data('maxmegamenu').hideAllPanels();
|
|
}
|
|
});
|
|
});
|
|
|
|
// make svg invisible to SR
|
|
$('.elementor-icon-list-icon svg, svg.e-font-icon-svg').attr('role','presentation').attr('tabindex','-1');
|
|
|
|
// Add aria-labels to roles
|
|
$('.utility nav').attr('aria-label', 'Utility');
|
|
$('.mainNav nav').attr('aria-label', 'Global');
|
|
$('.footer nav').attr('aria-label', 'Footer');
|
|
|
|
// Add title text for Read More links for posts
|
|
$('.news .jet-listing-grid__item').each(function () {
|
|
var title = $('.title .elementor-heading-title a', this).html();
|
|
var viewDetails = $('.link a', this);
|
|
$(viewDetails).append('<span class="visuallyhidden"> about ' +title+ '</span>');
|
|
});
|
|
|
|
// Add title text for Read More links
|
|
$('.hidden-text .elementor-column').each(function () {
|
|
var title = $('.title .elementor-heading-title', this).html();
|
|
var viewDetails = $('.link a', this);
|
|
$(viewDetails).append('<span class="visuallyhidden"> for ' +title+ '</span>');
|
|
});
|
|
|
|
// Remove role Button
|
|
$('.elementor-button-link').removeAttr('role', 'button');
|
|
|
|
|
|
// Announcer
|
|
//Move Banner Top to below skip link in the DOM
|
|
var banner = $(".ancr-group.ancr-pos-top")
|
|
$(banner).insertAfter('.elementor-location-header #skiplink');
|
|
//Move bottom Banners to footer in the DOM
|
|
var bannerBottom = $(".ancr-group.ancr-pos-bottom")
|
|
$("div[data-elementor-type=footer]").prepend(bannerBottom);
|
|
//Move Banner close button in the DOM
|
|
$('.ancr-wrap').each(function() {
|
|
var $this = $(this),
|
|
$closeBtn = $this.find('.ancr-close-btn'),
|
|
$target = $this.find('.ancr-content');
|
|
$target.append($closeBtn);
|
|
});
|
|
|
|
// Accordion accessibility (New)
|
|
$('div.e-n-accordion').removeAttr('aria-label');
|
|
$('details div').removeAttr('role').removeAttr('aria-labelledby');
|
|
$('details summary').removeAttr('tabindex');
|
|
|
|
// Add id and for to News/Blog Search
|
|
$(".search .jet-filter-label").replaceWith(function(){
|
|
$(this).attr('for', 'search');
|
|
return this.outerHTML.replace("<div", "<label").replace("</div", "</label")
|
|
});
|
|
$('.search .jet-search-filter__input').attr('id', 'search');
|
|
|
|
// Add aria-label to Search button
|
|
$('.search .jet-search-filter__submit').attr('aria-label', 'Search')
|
|
|
|
|
|
// Click enter in input field to click button search for redirect jetsmartfilter
|
|
$( document ).ready(function() {
|
|
$('.jet-search-filter__input').keyup(function(event) {
|
|
if (event.which === 13) {
|
|
$(this).parents(".elementor-widget-jet-smart-filters-search").siblings().find(".apply-filters__button").click()
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
|
|
// Add keyboard access to pagination
|
|
$( document ).ready(function() {
|
|
$('.jet-filters-pagination__link').attr('tabindex', 0);
|
|
$('.jet-filters-pagination__item').removeAttr('tabindex');
|
|
|
|
$('.jet-filters-pagination__link').keyup(function(event) {
|
|
if (event.which === 13) {
|
|
$(this).click();
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
// Aria for Checkbox Filters
|
|
$( document ).ready(function() {
|
|
$('.filter.multi .jet-filters-group .jet-filter').each(function (i) {
|
|
var identifier = 0 + i;
|
|
var group = $(this);
|
|
var label = $('.jet-filter-label', this);
|
|
$(group).attr('role', 'group').attr('aria-labelledby', 'filter-heading' + identifier)
|
|
$(label).attr('id', 'filter-heading' + identifier)
|
|
});
|
|
|
|
|
|
$('.filter:not(.multi) .jet-filter').attr('role', 'group').attr('aria-labelledby', 'filter-heading');
|
|
|
|
$('.filter:not(.multi) .jet-filter-label').attr('id', 'filter-heading');
|
|
|
|
$('.filter .jet-checkboxes-list__input, .filter .jet-radio-list__input').attr('aria-checked', 'false');
|
|
|
|
$('.filter .jet-checkboxes-list__input, .filter .jet-radio-list__input').click(function() {
|
|
if ($(this).attr('aria-checked') == "false") {
|
|
$(this).attr("aria-checked","true");
|
|
}
|
|
else {
|
|
$(this).attr("aria-checked", "false");
|
|
}
|
|
});
|
|
|
|
$('.filter .jet-checkboxes-list__input, .filter .jet-radio-list__input').keyup(function(event) {
|
|
if (event.which === 13) {
|
|
$(this).click();
|
|
}
|
|
});
|
|
|
|
$('.filter .jet-filter-row').each(function (i) {
|
|
var identifier = 0 + i;
|
|
var label = $('.jet-checkboxes-list__item, .jet-radio-list__input', this);
|
|
var checkbox = $('.jet-checkboxes-list__input, .jet-radio-list__input', this);
|
|
$(label).attr('for', 'checkbox' + identifier)
|
|
$(checkbox).attr('id', 'checkbox' + identifier)
|
|
|
|
});
|
|
});
|
|
|
|
// Keyboard navigtion for Active filters
|
|
// Need to add a mutation observer to look for changes
|
|
// when filter is selected. .jet-active-filter is not
|
|
// in the DOM on page load only after filter selection
|
|
var targetNodes = $(".jet-active-filters");
|
|
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
|
var myObserver = new MutationObserver(mutationHandler);
|
|
var obsConfig = {
|
|
childList: true,
|
|
characterData: true,
|
|
attributes: true,
|
|
subtree: true
|
|
};
|
|
|
|
//--- Add a target node to the observer. Can only add one node at a time.
|
|
targetNodes.each(function() {
|
|
myObserver.observe(this, obsConfig);
|
|
});
|
|
|
|
function mutationHandler(mutationRecords) {
|
|
mutationRecords.forEach(function(mutation) {
|
|
if (typeof mutation.removedNodes == "object") {
|
|
var jq = $(mutation.removedNodes);
|
|
}
|
|
});
|
|
}
|
|
|
|
setTimeout(function() {
|
|
$('.jet-active-filter').attr('tabindex', 0);
|
|
$('.jet-active-filter').keyup(function(event) {
|
|
if (event.which === 13) {
|
|
$(this).click();
|
|
}
|
|
});
|
|
},1000)
|
|
// End mutation observer
|
|
|
|
|
|
$(document).ready(function() {
|
|
$("#checkboxes, #radio").replaceWith(function(){
|
|
return this.outerHTML.replace("<span", "<fieldset").replace("</span", "</fieldset")
|
|
});
|
|
});
|
|
|
|
var selected = [];
|
|
$('input[type=checkbox], input[type=radio]').each(function() {
|
|
var value = $(this).val();
|
|
var name = $(this).attr('name').replace(/ /g,'').replace(/[^a-z0-9\s]/gi, '');
|
|
var id = value.replace(/ /g,'').replace(/[^a-z0-9\s]/gi, '');
|
|
$(this).attr({ id: $(this).attr("id") + ' ' +id });
|
|
var newId = $(this).attr('id');
|
|
$(this).siblings('label').attr('for', newId);
|
|
|
|
});
|
|
|
|
// Refreshes carousels inside tab widgets
|
|
var refreshSliders = function(){
|
|
jQuery( ".swiper-container" ).each(function( index ) {
|
|
swiperInstance = jQuery(this).data('swiper');
|
|
swiperInstance.params.observer = true;
|
|
swiperInstance.params.observeParents = true;
|
|
swiperInstance.update();
|
|
});
|
|
}
|
|
window.onload = function() {
|
|
jQuery(".elementor-tab-title").on("click", function(){
|
|
var $this = jQuery(this);
|
|
refreshSliders();
|
|
jQuery('html,body').animate({
|
|
scrollTop: $this.offset().top - 220
|
|
}, 500);
|
|
});
|
|
}
|
|
// Carousel refresh inside tab widgets
|
|
|
|
//Update Tabbing of Tabs
|
|
|
|
$(function($) {
|
|
$('.elementor-tabs .elementor-tab-title a').replaceWith(function(){
|
|
$(this).removeAttr('href');
|
|
return this.outerHTML.replace("<a", "<h3").replace("</a", "</h3")
|
|
});
|
|
});
|
|
|
|
$('.elementor-tabs .elementor-tab-title').attr('tabindex', 0);
|
|
$('.elementor-tabs .elementor-tab-content').attr('tabindex', -1);
|
|
|
|
if ($(window).width() < 500) {
|
|
|
|
// Close Tab widget on mobile on page load
|
|
const delay = 10;
|
|
setTimeout(function() {
|
|
$('.elementor-tab-title').removeClass('elementor-active');
|
|
$('.elementor-tab-content').css('display', 'none');
|
|
}, delay);
|
|
}
|
|
|
|
// Anchor scroll offset top
|
|
$('a[href*="#"]:not([href="#"])').click(function() {
|
|
var offset = -200; // <-- change the value here
|
|
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
|
|
var target = $(this.hash);
|
|
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
|
|
if (target.length) {
|
|
$('html, body').animate({
|
|
scrollTop: target.offset().top + offset
|
|
}, 300);
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
|
|
// Hide and Show header search form
|
|
$('.openSearch').click(function(e) {
|
|
e.preventDefault();
|
|
$('.closeSearch, #searchForm').removeClass("hide");
|
|
$('.openSearch, .util-nav').addClass("hide");
|
|
setTimeout(function() {
|
|
$('#search-59bc91d').focus();
|
|
}, 100);
|
|
});
|
|
$('.closeSearch').click(function(e) {
|
|
e.preventDefault();
|
|
$('.closeSearch, #searchForm').addClass("hide");
|
|
$('.openSearch, .uti-nav').removeClass("hide");
|
|
setTimeout(function() {
|
|
$('.openSearch a').focus();
|
|
}, 100);
|
|
});
|
|
|
|
});
|
|
|
|
|
|
/* Code from https://element.how/elementor-tabs-closed-by-default/
|
|
* Copyright 2024 Element.How
|
|
* Automatically close the tabs on page load for mobile devices
|
|
*/
|
|
window.addEventListener('load', function () {
|
|
if (window.innerWidth > 767) return;
|
|
setTimeout(function () {
|
|
let tabsElems = document.querySelectorAll('.e-n-tabs')
|
|
tabsElems.forEach(e => {
|
|
let activeTitles = e.querySelectorAll('.e-n-tab-title[aria-selected="true"]');
|
|
let activeContent = e.querySelector('.e-con.e-active')
|
|
activeContent.style.display = 'none';
|
|
activeContent.classList.remove('e-active');
|
|
activeTitles.forEach(activeTitle => activeTitle.setAttribute('aria-selected', false));
|
|
activeTitles.forEach(activeTitle => activeTitle.setAttribute('tabindex', -1));
|
|
});
|
|
}, 300);
|
|
});
|
|
|
|
/* Code from https://element.how/elementor-tabs-closed-by-default/
|
|
* Copyright 2024 Element.How
|
|
* Make the Elementor tabs closable
|
|
*/
|
|
(function () {
|
|
if (window.innerWidth > 767) return;
|
|
let isOnPageLoad = true;
|
|
window.addEventListener('load', () => {
|
|
setTimeout(() => {
|
|
isOnPageLoad = false;
|
|
}, 600);
|
|
});
|
|
if (document.querySelector('.elementor-editor-active')) return;
|
|
document.querySelectorAll('.e-n-tab-title').forEach(tabTitle => {
|
|
tabTitle.addEventListener('click', function () {
|
|
if (isOnPageLoad) return;
|
|
if (this.getAttribute('aria-selected') === 'true') {
|
|
setTimeout(() => {
|
|
const tabId = this.getAttribute('aria-controls');
|
|
const tabContent = document.getElementById(tabId);
|
|
if (tabContent) {
|
|
tabContent.style.display = 'none';
|
|
tabContent.classList.remove('e-active');
|
|
}
|
|
this.setAttribute('aria-selected', 'false');
|
|
}, 30);
|
|
}
|
|
});
|
|
});
|
|
}());
|
|
|
|
|
|
|
|
/* Control the Elementor Tabs from the URL
|
|
* Code from https://element.how/elementor-open-specific-tab-toggle-accordion/
|
|
* Copyright 2023 Element.how
|
|
* Updated 2023/12/05
|
|
*/
|
|
window.addEventListener('load', () => {
|
|
setTimeout(function () {
|
|
|
|
let scrollOffset = 200; /* scroll offset from the top of title */
|
|
|
|
const tabsAccordionToggleTitles = document.querySelectorAll('.e-n-accordion-item-title, .e-n-tab-title, .elementor-tab-title');
|
|
|
|
const clickTitleWithAnchor = (anchor) => {
|
|
tabsAccordionToggleTitles.forEach(title => {
|
|
if (title.querySelector(`#${anchor}`) != null || title.id === anchor || (title.closest('details') && title.closest('details').id === anchor)) {
|
|
if (title.getAttribute('aria-expanded') !== 'true' && !title.classList.contains('elementor-active')) title.click();
|
|
let timing = 0;
|
|
let scrollTarget = title;
|
|
if (getComputedStyle(title.closest('.elementor-element')).getPropertyValue('--n-tabs-direction') == 'row') scrollTarget = title.closest('.elementor-element');
|
|
if (title.closest('.e-n-accordion, .elementor-accordion-item, .elementor-toggle-item')) {
|
|
timing = 400;
|
|
}
|
|
setTimeout(function () {
|
|
jQuery('html, body').animate({
|
|
scrollTop: jQuery(scrollTarget).offset().top - scrollOffset,
|
|
}, 'slow');
|
|
}, timing);
|
|
}
|
|
});
|
|
};
|
|
|
|
document.addEventListener('click', (event) => {
|
|
if (event.target.closest('a') && event.target.closest('a').href.includes('#')) {
|
|
const anchor = extractAnchor(event.target.closest('a').href);
|
|
if (anchor && isAnchorInTitles(anchor, tabsAccordionToggleTitles)) {
|
|
event.preventDefault();
|
|
clickTitleWithAnchor(anchor);
|
|
}
|
|
}
|
|
});
|
|
|
|
const currentAnchor = extractAnchor(window.location.href);
|
|
if (currentAnchor) {
|
|
clickTitleWithAnchor(currentAnchor);
|
|
}
|
|
|
|
function extractAnchor(url) {
|
|
const match = url.match(/#([^?]+)/);
|
|
return match ? match[1] : null;
|
|
};
|
|
|
|
function isAnchorInTitles(anchor, titles) {
|
|
return Array.from(titles).some(title => {
|
|
return title.querySelector(`#${anchor}`) !== null || title.id === anchor || (title.closest('details') && title.closest('details').id === anchor);
|
|
});
|
|
};
|
|
|
|
}, 300);
|
|
});
|