1(function($){ 2 "use strict"; 3 jQuery(document).ready(function($) { 4 5 if($("a[rel^='prettyPhoto']").length){ 6 $("a[rel^='prettyPhoto']").prettyPhoto({ 7 animation_speed:'normal', 8 slideshow:3000, 9 autoplay_slideshow: false, 10 social_tools: false 11 }); 12 } 13 14 15 var is_sending = false; 16 17 $('#ccvcContactForm').submit(function (e) { 18 if (is_sending || !validateInputs()) { 19 return false; // Don't let someone submit the form while it is in-progress... 20 } 21 e.preventDefault(); // Prevent the default form submit 22 var $this = $(this); // Cache this 23 $.ajax({ 24 url: script_params.ajax_url, // Let WordPress figure this url out... 25 type: 'post', 26 dataType: 'JSON', // Set this so we don't need to decode the response... 27 data: $this.serialize(), // One-liner form data prep... 28 beforeSend: function () { 29 is_sending = true; 30 // You could do an animation here... 31 }, 32 error: handleFormError( "Message wasn't send. Error occured." ), 33 success: function (data) { 34 if (data.status === 'success') { 35 // Here, you could trigger a success message 36 $('#ccvc_contact_error').html( data.message ); 37 } else { 38 handleFormError( data.message ); // If we don't get the expected response, it's an error... 39 } 40 } 41 }); 42 }); 43 44 function handleFormError ( error ) { 45 46 is_sending = false; // Reset the is_sending var so they can try again... 47 $('#ccvc_contact_error').html( error ); 48 } 49 50 function validateInputs () { 51 var $name = $('#ccvcContactName').val(), 52 $email = $('#ccvcEmail').val(), 53 $message = $('#ccvcCommentsText').val(); 54 if (!$name || !$email || !$message) { 55 $('#ccvc_contact_error').html('Before sending, please make sure to provide your name, email, and message.'); 56 return false; 57 } 58 return true; 59 } 60 }); 61})(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.