1jQuery(function($) { 2 $(".js-open-form").on("click", function() { 3 getForm($(this)); 4 return false; 5 }); 6 7 $(document).on("click", ".js-close-modal", function(e) { 8 e.preventDefault(); 9 $(".modal-overlay").remove(); 10 }); 11 12 $(document).on("click", ".js-submit", function(e) { 13 e.preventDefault(); 14 submitForm(); 15 }); 16 17 $(document).on("keyup", ".modal-overlay form input", function(e) { 18 $(".warning").text(""); 19 }); 20 21 function getForm(el) { 22 var event = el.data("event"); 23 var email_address = el.data("email"); 24 var form = ` 25 <div class="modal-overlay"> 26 <div class="modal"> 27 <div class="form"> 28 <h4>Contact Us About</h4> 29 <div>${event}</div> 30 <form class="tlc-form"> 31 <div><label>Name</label><input type="text" name="name"></div> 32 <div><label>Email</label><input type="text" name="email"></div> 33 <div><label>Phone</label><input type="text" name="phone"></div> 34 <div><label>Comment</label><textarea name="comment" ></textarea></div> 35 <div class="text-right"><button class="cert-button js-submit">Submit</button></div> 36 <input type="hidden" name="event" value="${event}"> 37 <input type="hidden" name="send_to" value="${email_address}"> 38 </form>
39 </div> 40 <div class="warning"></div> 41 <div class="success"></div> 42 <a href="#" class="close js-close-modal">×</a> 43 </div> 44 </div>`; 45 46 $("body").append(form); 47 } 48 49 function submitForm() { 50 var post_data = $(".tlc-form").serializeArray(); 51 console.log(post_data); 52 var errors = false; 53 $.each(post_data, function(index, value) { 54 if (value.value == "") { 55 errors = true; 56 } 57 }); 58 if (errors) { 59 $(".warning").text("Fill out all fields"); 60 } else { 61 $.ajax({ 62 url: tlc_local_script.url, 63 data: { 64 post_data: post_data, 65 action: "tlc_submit_form" 66 }, 67 type: "POST", 68 beforeSend: function() { 69 $(".alert").empty(); 70 $(".js-submit") 71 .text("Processing") 72 .prop("disabled", true) 73 .css("opacity", 0.5); 74 }, 75 success: function(data) { 76 if (data.success) { 77 $(".form").hide(); 78 $(".success").text("Message sent!"); 79 setTimeout(function() { 80 $(".modal-overlay").remove(); 81 }, 3000); 82 } else { 83 $(".form").hide();
84 $(".success").text("Message did not send!"); 85 setTimeout(function() { 86 $(".modal-overlay").remove(); 87 }, 3000); 88 } 89 } 90 }); 91 } 92 } 93});
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.