1const input = document.querySelector("#cf_phone"); 2window.intlTelInput(input, { 3 initialCountry: "ua", 4 separateDialCode: true, 5 onlyCountries: ["ua"], 6 // allowDropdown:false, 7 // showSelectedDialCode:true, 8 autoPlaceholder: "aggressive", 9 strictMode:true, 10 countrySearch:false, 11 utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/21.1.3/js/utils.js" 12}); 13$(function() { 14 // Initialize form validation on the registration form. 15 // It has the name attribute "registration" 16 $("form[name='contact_form']").validate({ 17 // Specify validation rules 18 lang: document.documentElement.lang == 'uk-UA' ? 'uk' : 'en', 19 rules: { 20 // The key name on the left side is the name attribute 21 // of an input field. Validation rules are defined 22 // on the right side 23 name: "required", 24 email: { 25 required: true, 26 // Specify that email should be validated 27 // by the built-in "email" rule 28 email: true 29 }, 30 phone: "required", 31 theme: "required", 32 message: "required", 33 term: "required", 34 }, 35 submitHandler: function(form) { 36 var name = jQuery(".cf_name").val(); 37 var email = jQuery(".cf_email").val(); 38 var phone = jQuery(".cf_phone").val(); 39 var theme = jQuery(".cf_theme").val(); 40 var message = jQuery(".cf_message").val(); 41 var term = jQuery(".cf_term").val(); 42 jQuery.ajax({ 43 url: "/wp-admin/admin-ajax.php", 44 type: "post", 45 data: { 46 action: "email_contact_forms", 47 name: name, 48 email: email, 49 phone: phone, 50 theme: theme, 51 message: message, 52 term: term 53 }, 54 success: function (data) { 55 form.reset(); 56 toggleModal('modal_confirm'); 57 setTimeout( () => { 58 toggleModal('modal_confirm'); 59 }, 3000) 60 } 61 }) 62 } 63 }); 64 65 66}); 67window.addEventListener("load", function() { 68 const modalTriggerButtons = document.querySelectorAll("[data-modal-target]"); 69 const modals = document.querySelectorAll(".modal"); 70 const modalCloseButtons = document.querySelectorAll(".modal-close"); 71 72 modalTriggerButtons.forEach(elem => { 73 elem.addEventListener("click", event => toggleModal(event.currentTarget.getAttribute("data-modal-target"))); 74 }); 75 modalCloseButtons.forEach(elem => { 76 elem.addEventListener("click", event => toggleModal(event.currentTarget.closest(".modal").id)); 77 }); 78 modals.forEach(elem => { 79 elem.addEventListener("click", event => { 80 if (event.currentTarget === event.target) toggleModal(event.currentTarget.id); 81 }); 82 }); 83 84// Maybe also close with "Esc"... 85 document.addEventListener("keydown", event => { 86 if (event.keyCode === 27 && document.querySelector(".modal.modal-show")) { 87 toggleModal(document.querySelector(".modal.modal-show").id); 88 } 89 }); 90}); 91function toggleModal(modalId) { 92 const modal = document.getElementById(modalId); 93 94 if(getComputedStyle(modal).display==="flex") { // alternatively: if(modal.classList.contains("modal-show")) 95 modal.classList.add("modal-hide"); 96 setTimeout(() => { 97 document.body.style.overflow = "initial"; // Optional: in order to enable/disable page scrolling while modal is hidden/shown - in this case: "initial" <=> "visible" 98 modal.classList.remove("modal-show", "modal-hide"); 99 modal.style.display = "none"; 100 }, 200); 101 } 102 else { 103 document.body.style.overflow = "hidden"; // Optional: in order to enable/disable page scrolling while modal is hidden/shown 104 modal.style.display = "flex"; 105 modal.classList.add("modal-show"); 106 } 107}
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.