1document.addEventListener("DOMContentLoaded",function(){const feedbackComponent=document.getElementById("feedbackComponent"),isPopupOpen=feedbackComponent.dataset.modalOpen,feedbackButton=document.getElementById("feedbackButton"),closeButton=document.getElementById("closeButton");function toggleModal(close=!1){close?document.body.classList.remove("modal-open-no-scroll"):(document.querySelector('[name="feedback_page_url"]').value=window.location.href,document.querySelector('[name="feedback_device_info"]').value=window.navigator.userAgent,document.body.classList.add("modal-open-no-scroll"),closeButton.focus()),feedbackComponent.dataset.modalOpen=!close,showThankYouMessage(!1),toggleFormError(!1),resetFields()}feedbackButton.addEventListener("keypress",function(event){event.key==="Enter"&&toggleModal(isPopupOpen==="true")}),feedbackButton.addEventListener("click",function(){toggleModal(isPopupOpen==="true")}),closeButton.addEventListener("click",function(){toggleModal(!0)}),document.querySelectorAll('[role="radiogroup"]').forEach(radioGroup=>{radioGroup.addEventListener("change",function(){const input=radioGroup.querySelector("input:checked");input&&(radioGroup.setAttribute("aria-invalid","false"),toggleFieldError(input,!1))});const radioButtons=radioGroup.querySelectorAll('input[type="radio"]');let currentIndex=0;radioButtons.forEach((radio,index)=>{radio.setAttribute("tabindex","0"),radio.addEventListener("keydown",function(e){if(e.key==="Tab"){currentIndex=index;const nextIndex=e.shiftKey?currentIndex-1:(currentIndex+1)%radioButtons.length;(!e.shiftKey&¤tIndex!==radioButtons.length-1||e.shiftKey&&nextIndex>=0)&&(e.preventDefault(),radioButtons[nextIndex].focus())}})})});const textarea=document.getElementById("feedback_message");if(textarea){const modernField=textarea.closest(".modern-field"),maxLen=parseInt(textarea.dataset.inputMax,10);textarea.addEventListener("input",function(){const currentLength=textarea.value.length,inputMaxContainer=modernField.querySelector(".input-max");currentLength>maxLen?(modernField.classList.add("has-error"),inputMaxContainer.classList.add("text-error"),inputMaxContainer.textContent=`Exceeded the maximum character ${currentLength}/${maxLen}`):(modernField.classList.remove("show-error"),modernField.classList.remove("has-error"),inputMaxContainer.classList.remove("text-error"),inputMaxContainer.textContent=`${currentLength}/${maxLen} Max`)})}async function submitForm(form2){const submitButton=form2.querySelector("button"),formData=new FormData(form2),apiUrl=form2.getAttribute("action");if(!validateFields())try{submitButton.disabled=!0,showLoader(!0);const result=await(await fetch(apiUrl,{method:"POST",body:formData})).json(),{status,invalid_fields}=result;status==="validation_failed"?invalid_fields.forEach(({field})=>{const fieldElement=document.querySelector(`[name="${field}"]`);fieldElement&&toggleFieldError(fieldElement,!0),showLoader(!1)}):status==="mail_sent"?(showThankYouMessage(!0),form2.reset()):status==="spam"?(console.error(result?.message),toggleFormError(!0),showLoader(!1)):(console.error(result),toggleFormError(!0),showLoader(!1)),submitButton.disabled=!1}catch(error){console.error(error),submitButton.disabled=!1,toggleFormError(!0),showLoader(!1)}}const form=document.getElementById("feedbackForm");form&&form.addEventListener("submit",async function(event){event.preventDefault();try{grecaptcha.ready(async()=>{const token=await grecaptcha.execute("6LfrvFMqAAAAALeqepYXuKzOt35CIFHGf9HSywO9",{action:"submit"});document.querySelector('[name="_wpcf7_recaptcha_response"]').value=token,await submitForm(form)})}catch(e){toggleFormError(!0),console.error("grecaptcha error"),console.error(e)}});function validateFields(){const fields=form.querySelectorAll('[aria-required="true"]');let notValid=!1;return fields.forEach(field=>{let hasValue=!1;if(field.role==="radiogroup"){const radios=field.querySelectorAll('input[type="radio"]');hasValue=Array.from(radios).some(radio=>radio.checked)}else{let input=field.querySelector("input");input||(input=field.querySelector("textarea")),hasValue=!!(input?.value||"").trim()}hasValue||(notValid=!0),toggleFieldError(field,!hasValue)}),document.querySelectorAll("[data-input-max]").forEach(field=>{const currentLength=field.value.length,maxLength=field.dataset.inputMa
1x;currentLength>maxLength&&(notValid=!0)}),document.querySelector(".show-error input")&&(console.log("FOCUS"),document.querySelector(".show-error input").focus()),notValid}function showThankYouMessage(show=!1){document.querySelector(".feedback__loader").style.display="none",document.querySelector(".feedback__content").style.display=show?"none":"block",document.querySelector(".feedback__success").style.display=show?"block":"none"}function showLoader(show=!1){document.querySelector(".feedback__success").style.display="none",document.querySelector(".feedback__content").style.display=show?"none":"block",document.querySelector(".feedback__loader").style.display=show?"flex":"none"}function toggleFieldError(field,error=!1){const modernField=field.closest(".modern-field");modernField&&(error?(modernField.classList.add("show-error"),modernField.setAttribute("aria-invalid","true")):(modernField.classList.remove("show-error"),modernField.setAttribute("aria-invalid","false")))}function toggleFormError(showError=!1){const submitButton=form.querySelector("button"),formError=form.querySelector(".feedback-form__error");showError?(submitButton.classList.add("button-error"),formError.classList.add("show-error"),setTimeout(()=>{submitButton.scrollIntoView({behavior:"smooth",block:"center"})},1)):(submitButton.classList.remove("button-error"),formError.classList.remove("show-error"))}function resetFields(){const textarea2=document.getElementById("feedback_message"),maxLen=parseInt(textarea2.dataset.inputMax,10);document.querySelectorAll(".modern-field .input-max").forEach(item=>{item.textContent=`0/${maxLen} Max`})}}); 2//# sourceMappingURL=/cdn/shop/t/165/assets/component-feedback.js.map?v=70964473632165376921788964586
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.