/** * Modal jquery code * 11/13/2021 - do not scroll to first focusable field * 8/2/2021 - add code to allow timer modal to optionally display only once via the use of a cookie * 8/17/2021 - do not allow timer modal to display if another modal already open * 11/1/2021 - when setting focus on first element do not scroll * 2/15/2022 - disable close modal on escape if disabled in the frontend * 4/5/2022 - Do not scroll when returning focus on modal close * 5/5/2022 - Allow for modals to call other modals * 6/28/2022 - Allow for checking url for text before triggering modal * 11/22/2022 - custom events for open and close * 1/11/2023 - Provide ability to manually trigger initialization of modals on page. Also only initialize modals when document is ready. */ var bodModalBlock = function(){ "use strict"; var $ = jQuery.noConflict(); const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'; var bodModalCount = 0; // global count of modals var bodModalActive = false; var bodModals = []; var initElements = function(){ bodModalCount = 0; // global count of modals bodModalActive = false; bodModals = []; // if we have already inited this type of element $('.wp-block-bod-modal-block').each(function(){ // for the identified modal we add an instance of the class BodModal // to the data element // $(this).data('bod-block-popup', new BodModal(this)); bodModals.push(new BodModal(this)); }); }; var checkForCookie = function(cookieName){ let name = cookieName + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i