1/** 2 * File contact-form.js. 3 * 4 * @package pardon. 5 */ 6 7(function ($) { 8 9 let successMsg = 0 < $( '#pardon-contact-form .message-sent' ).length ? $( '#pardon-contact-form .message-sent' ).val() : ''; 10 let thanksMsg = 0 < $( '#pardon-contact-form .success-message' ).length ? $( '#pardon-contact-form .success-message' ).val() : 'Thank you for contacting Pardon. Someone will be responding to you soon!'; 11 let emailRegex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 12 13 $( document ).on( 14 'click', 15 '#pardon-contact-form button', 16 function(e){ 17 e.preventDefault(); 18 let emailElement = $( '#pardon-contact-form' ).find( '#contact-email' ); 19 let inquiryElement = $( '#pardon-contact-form' ).find( '#contact-inquiry' ); 20 let nameElement = $( '#pardon-contact-form' ).find( '#contact-name' ); 21 let msgElement = $( '#pardon-contact-form' ).find( '#contact-message' ); 22 let subElement = $( '#pardon-contact-form' ).find( '.email-subject' ); 23 let inquiryEmails = $( '#pardon-contact-form' ).find( '.to-emails' ); 24 let selectBoxEnable = $( '#pardon-contact-form' ).find( '.selectbox-is-required' ); 25 let showFormSubmit = $( '#pardon-contact-form' ).find( '.show-form-after-submit' ); 26 let showTitleSubmit = $( '#pardon-contact-form' ).find( '.show-title-after-submit' ); 27 let showBackButtonSubmit = $( '#pardon-contact-form' ).find( '.show-back-button-after-submit' ); 28 let selectBoxLabel = $( '#pardon-contact-form' ).find( '.selectbox-label' ); 29 30 $( '#pardon-contact-form' ).find( '#contact-name, #contact-email, #contact-inquiry, #contact-message' ).removeClass( "input-error" ); 31 $.ajax( 32 { 33 url: pardon_global.ajax_url, 34 type: "POST", 35 data: { 36 action: 'pardon_contact_form_submission', 37 pardon_nonce: pardon_global.pardon_nonce, 38 email_address: emailElement.val(), 39 inquiry: inquiryElement.val(), 40 name: nameElement.val(), 41 message: msgElement.val(), 42 subject: subElement.val(), 43 select_box_enable: selectBoxEnable.val(), 44 show_form_submit: showFormSubmit.val(), 45 show_title_submit: showTitleSubmit.val(), 46 show_back_button_submit: showBackButtonSubmit.val(), 47 select_box_label: selectBoxLabel.val(), 48 to_email_address: inquiryEmails.val() 49 }, 50 success : function(data){ 51 let errorElement = document.querySelector( '.contact-us-form-inner .display-error' ); 52 let errorClassElement = document.querySelector( '#pardon-contact-form #contact-' + data.field + '' ); 53 showBackButton = data.show_back_button_submit; 54 55 if (data.code == "200") { 56 pardonCreateNoticeElement( successMsg, thanksMsg, showBackButton ); 57 $( '.contact-us-form-inner .contact-us-box-head p' ).hide(); 58 $( '.contact-us-form-inner .inquiry-field' ).hide(); 59 $( '.contact-us-form-inner .contact-us-form-body .submit' ).hide(); 60 if(data.show_title_submit === 'disable'){ 61 $( '.contact-us-form-inner h1' ).hide(); 62 } 63 if(data.show_form_submit === 'disable'){ 64 $( '.contact-us-form-inner #pardon-contact-form' ).hide(); 65 } 66 $( ".contact-us-form-inner input" ).val( "" ); 67 $( "#contact-message" ).val( "" ); 68 errorElement.setAttribute( "style", "display:none;" ); 69 70 if ( window.location.href.indexOf( "recommendedreads" ) > -1 ) { 71 rrContactSuccess() 72 } 73 } else { 74 errorClassElement.setAttribute( 'class', 'input-error' ); 75 errorElement.setAttribute( "style", "display:block;" ); 76 let errorElementSpan = document.createElement( 'span' ); 77 errorElement.innerText = ""; 78 errorElementSpan.innerText = data.msg; 79 errorElement.appendChild( errorElementSpan ); 80 document.getElementById( 'contact-' + data.field ).focus(); 81 } 82 } 83 } 84 ); 85 } 86 ); 87 88 function rrContactSuccess() { 89 // Hide the form. 90 $( '#pardon-contact-form' ).hide(); 91 $('.contact-us-form-body .form-alert').addClass('rr-contact-success'); 92 } 93 94 function pardonCreateNoticeElement( successMsg, msg, showBackButton ) { 95 96 let mainElement = document.querySelector( '.contact-us-form-inner .form-alert' ); 97 let messageSent = document.createElement( 'span' ); 98 messageSent.setAttribute( 'class', 'message-sent' ); 99 messageSent.innerText = successMsg; 100 mainElement.appendChild( messageSent ); 101 let noticeElement = document.createElement( 'p' ); 102 noticeElement.setAttribute( 'class', 'form-notice-msg' ); 103 noticeElement.innerText = msg; 104 mainElement.appendChild( noticeElement ); 105 if(showBackButton === 'enable'){ 106 let noticeElementanchor = document.createElement( 'a' ); 107 noticeElementanchor.setAttribute( 'class', 'return-home' ); 108 noticeElementanchor.setAttribute( 'href', pardon_global.siteUrl ); 109 noticeElementanchor.innerText = "Back to Homepage"; 110 mainElement.appendChild( noticeElementanchor ); 111 } 112 } 113 114 // Pre Launch Block Form Handling Start. 115 $( document ).ready( 116 function(){ 117 $( '#prelaunch-form' ).on( 118 'submit', 119 function(e){ 120 e.preventDefault(); 121 $( '.prelaunch-wrap .prelaunch-form-body form#prelaunch-form' ).css( { 'visibility' : 'hidden'} ); 122 $( '.prelaunch-main .prelaunch-wrap > p' ).css( { 'display' : 'none'} ); 123 $( '.prelaunch-wrap .free-msg.pl-succes-smsg-after-submit' ).css( { 'display' : 'block', 'height' : '167px' } ); 124 } 125 ); 126 } 127 ); 128 // Pre Launch Block Form Handling End. 129})( jQuery );
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.