(x), close the modal document.querySelector('.data-verification-close').addEventListener('click', function(e) { e.preventDefault(); closeVerificationModal(); }); document.querySelector('#data-verification-icon, #data-verification-container p').addEventListener('click', function(e) { e.preventDefault(); // Detect a href's click, because it is overwritten. if(e.target.tagName === "A") { window.open(e.target.href, '_blank'); return; } document.querySelector('#data-verification-icon').classList.add("clicked"); setTimeout(()=>{ toggleFadeiSense(document.querySelector("#data-verification-modal"), false); document.querySelector('#data-verification-background .loading').style.display = 'inline-block'; consentGiven = true; gdprSendRequest(function(resp) { consentGiven = false; closeVerificationModal(); }); }, 400); }); }); function openVerificationModal(){ toggleFadeiSense(document.querySelector("#data-verification-modal"), true); toggleFadeiSense(document.querySelector('#data-verification-background'), true); document.querySelector('#data-verification-container input').focus(); } function closeVerificationModal(){ toggleFadeiSense(document.querySelector("#data-verification-background"), false); document.querySelector('#data-verification-icon').classList.remove("clicked"); document.querySelector('#data-verification-background .loading').style.display = 'none'; // Focus the button of the request type that was picked let gdprForms = document.querySelectorAll('.form-gdpr-request'); gdprForms.forEach(function(gdprForm) { if (gdprForm.style.display !== "none") { let gdprFormLinks = gdprForm.previousElementSibling.querySelectorAll('li'); if (gdprFormLinks.length === 1) { gdprFormLinks[0].querySelector('button').focus(); } else if (gdprFormLinks.length > 1) { gdprFormPickedLinkValue = document.querySelector('#form-gdpr-data-account-request-request-type').value; switch (gdprFormPickedLinkValue) { case 'customer/requests': gdprFormLinks[0].querySelector('button').focus(); break; case 'customer/personal_info': gdprFormLinks[1].querySelector('button').focus(); break; case 'customer/orders': gdprFormLinks[2].querySelector('button').focus(); break; default: break; } } } }); } document.querySelector('#btn-gdpr-edit-account-request').addEventListener('click', function(e) { e.preventDefault(); gdprSlideUpAll(); slideDown(document.querySelector('#form-gdpr-edit-account-request'), 200); this.setAttribute("aria-expanded", "true"); }); document.querySelector('#form-gdpr-edit-account-request-submit').addEventListener('click', function(e) { e.preventDefault(); email = document.querySelector('#form-gdpr-edit-account-request-email').value; type = 'customer/edit'; openVerificationModal(); }); document.querySelectorAll('#btn-gdpr-requests-request, #btn-gdpr-personal-information-request, #btn-gdpr-orders-request').forEach(element => { element.addEventListener('click', function(e) { e.preventDefault(); gdprSlideUpAll(); type = ''; switch(this.getAttribute('id')) { case 'btn-gdpr-requests-request': type = 'customer/requests'; break; case 'btn-gdpr-personal-information-request': type = 'customer/personal_info'; break; case 'btn-gdpr-orders-request': type = 'customer/orders'; break; } document.querySelector('#form-gdpr-data-account-request-request-type').value = type; slideDown(document.querySelector('#form-gdpr-data-account-request'), 200); this.setAttribute("aria-expanded", "true"); }) }); document.querySelector('#form-gdpr-data-account-request-submit').addEventListener('click', function(e) { e.preventDefault(); email = document.querySelector('#form-gdpr-data-account-request-email').value; type = document.querySelector('#form-gdpr-data-account-request-request-type').value; openVerificationModal(); }); document.querySelector('#btn-gdpr-personal-data-report-request').addEventListener('click', function(e) { e.preventDefault(); gdprSlideUpAll(); slideDown(document.querySelector('#form-gdpr-personal-data-report-request'), 200); this.setAttribute("aria-expanded", "true"); }); document.querySelector('#form-gdpr-personal-data-report-request-submit').addEventListener('click', function(e) { e.preventDefault(); email = document.querySelector('#form-gdpr-personal-data-report-request-email').value; type = 'customer/report'; openVerificationModal(); }); document.querySelector('#btn-gdpr-delete-account-request').addEventListener('click', function(e) { e.preventDefault(); gdprSlideUpAll(); slideDown(document.querySelector('#form-gdpr-delete-account-request'), 200); this.setAttribute("aria-expanded", "true"); }); document.querySelector('#form-gdpr-delete-account-request-submit').addEventListener('click', function(e) { e.preventDefault(); email = document.querySelector('#form-gdpr-delete-account-request-email').value; type = 'customer/delete'; openVerificationModal(); }); // Keyboard navigation for the compliance page's requests document.querySelector('#gdpr_page').addEventListener('keydown', function(e) { let isTabPressed = e.keyCode === 9 || e.key === "Tab" || e.code === "Tab"; // This function saves us the trouble of calling e.preventDefault() after every focusing let executeFocus = (focusElement) => {focusElement.focus();e.preventDefault();} if (isTabPressed) { let gdprFormPickedLinkValue = document.querySelector('#form-gdpr-data-account-request-request-type').value; let gdprRequestsButton = document.querySelector('#btn-gdpr-requests-request'); let personalInformationButton = document.querySelector('#btn-gdpr-personal-information-request'); let ordersButton = document.querySelector('#btn-gdpr-orders-request'); let personalDataReportButton = document.querySelector('#btn-gdpr-personal-data-report-request'); let dataAccountFormEmailField = document.querySelector('#form-gdpr-data-account-request-email'); let dataAccountFormSubmitButton = document.querySelector('#form-gdpr-data-account-request-submit'); if (e.shiftKey) { if ((document.activeElement === personalInformationButton && gdprFormPickedLinkValue === 'customer/requests') || (document.activeElement === ordersButton && gdprFormPickedLinkValue === 'customer/personal_info')) { executeFocus(dataAccountFormSubmitButton); } else if (document.activeElement === dataAccountFormEmailField) { if (gdprFormPickedLinkValue === 'customer/requests') { executeFocus(gdprRequestsButton); } else if (gdprFormPickedLinkValue === 'customer/personal_info') { executeFocus(personalInformationButton); } } else if (document.activeElement === personalDataReportButton) { if (gdprFormPickedLinkValue !== 'customer/orders') { executeFocus(ordersButton); } } } else { if ((document.activeElement === gdprRequestsButton && gdprFormPickedLinkValue === 'customer/requests') || (document.activeElement === personalInformationButton && gdprFormPickedLinkValue === 'customer/personal_info')) { executeFocus(dataAccountFormEmailField); } else if (document.activeElement === dataAccountFormSubmitButton) { if (gdprFormPickedLinkValue === 'customer/requests') { executeFocus(personalInformationButton); } else if (gdprFormPickedLinkValue === 'customer/personal_info') { executeFocus(ordersButton); } } else if (document.activeElement === ordersButton) { if (gdprFormPickedLinkValue !== 'customer/orders') { executeFocus(personalDataReportButton); } } } } }); // Keyboard navigation in data verification modal for accesibility document.querySelector('#data-verification-modal').addEventListener('keydown', function(e) { let isTabPressed = e.keyCode === 9 || e.key === "Tab" || e.code === "Tab"; let isEscapePressed = e.keyCode === 27 || e.key === "Escape" || e.code === "Escape"; let isSpacePressed = event.keyCode === 32 || e.key === " " || event.code === "Space"; let isEnterPressed = event.keyCode === 13 || e.key === "Enter" || event.code === "Enter"; let dataVerificationCloseButton = document.querySelector('.data-verification-close'); let dataVerificationCheckbox = document.querySelector('#data-verification-container input'); let dataVerificationLink = document.querySelector('#data-verification-container a'); // This function saves us the trouble of calling e.preventDefault() after every focusing let executeFocus = (focusElement) => {focusElement.focus();e.preventDefault();} if (isEscapePressed) { if (dataVerificationCloseButton) { dataVerificationCloseButton.click(); } } if (isSpacePressed || isEnterPressed) { if (document.activeElement === dataVerificationCheckbox) { document.querySelector('#data-verification-container #data-verification-icon').click(); } } if (isSpacePressed || isEnterPressed) { let dataVerificationCheckbox = document.querySelector('#data-verification-container input'); if (document.activeElement === dataVerificationCheckbox) { document.querySelector('#data-verification-container #data-verification-icon').click(); } } if (isTabPressed) { if (e.shiftKey) { if (dataVerificationCloseButton && document.activeElement === dataVerificationCloseButton) { executeFocus(dataVerificationLink); } } else { if (dataVerificationLink && document.activeElement === dataVerificationLink) { executeFocus(dataVerificationCloseButton); } } } }); Use left/right arrows to navigate the slideshow or swipe left/right if using a mobile device