1jQuery(document).ready(function() { 2 try { 3 jQuery('div.wpcf7 > form').ajaxForm({ 4 beforeSubmit: wpcf7BeforeSubmit, 5 dataType: 'json', 6 success: wpcf7ProcessJson 7 }); 8 } catch (e) { 9 } 10 11 try { 12 jQuery('div.wpcf7 > form').each(function(i, n) { 13 wpcf7ToggleSubmit(jQuery(n)); 14 }); 15 } catch (e) { 16 } 17 18 try { 19 if (_wpcf7.cached) { 20 jQuery('div.wpcf7 > form').each(function(i, n) { 21 wpcf7OnloadRefill(n); 22 }); 23 } 24 } catch (e) { 25 } 26}); 27 28// Exclusive checkbox 29function wpcf7ExclusiveCheckbox(elem) { 30 jQuery(elem.form).find('input:checkbox[name="' + elem.name + '"]').not(elem).removeAttr('checked'); 31} 32 33// Toggle submit button 34function wpcf7ToggleSubmit(form) { 35 var submit = jQuery(form).find('input:submit'); 36 if (! submit.length) return; 37 38 var acceptances = jQuery(form).find('input:checkbox.wpcf7-acceptance'); 39 if (! acceptances.length) return; 40 41 submit.removeAttr('disabled'); 42 acceptances.each(function(i, n) { 43 n = jQuery(n); 44 if (n.hasClass('wpcf7-invert') && n.is(':checked') || ! n.hasClass('wpcf7-invert') && ! n.is(':checked')) 45 submit.attr('disabled', 'disabled'); 46 }); 47} 48 49function wpcf7BeforeSubmit(formData, jqForm, options) { 50 wpcf7ClearResponseOutput(); 51 jQuery('img.ajax-loader', jqForm[0]).css({ visibility: 'visible' }); 52 53 formData.push({name: '_wpcf7_is_ajax_call', value: 1}); 54 jQuery(jqForm[0]).append('<input type="hidden" name="_wpcf7_is_ajax_call" value="1" />'); 55 56 return true; 57} 58 59function wpcf7NotValidTip(into, message) { 60 jQuery(into).append('<span class="wpcf7-not-valid-tip">' + message + '</span>'); 61 jQuery('span.wpcf7-not-valid-tip').mouseover(function() { 62 jQuery(this).fadeOut('fast'); 63 }); 64 jQuery(into).find(':input').mouseover(function() { 65 jQuery(into).find('.wpcf7-not-valid-tip').not(':hidden').fadeOut('fast'); 66 }); 67 jQuery(into).find(':input').focus(function() { 68 jQuery(into).find('.wpcf7-not-valid-tip').not(':hidden').fadeOut('fast'); 69 }); 70} 71 72function wpcf7OnloadRefill(form) { 73 var url = jQuery(form).attr('action'); 74 if (0 < url.indexOf('#')) 75 url = url.substr(0, url.indexOf('#')); 76 77 var id = jQuery(form).find('input[name="_wpcf7"]').val(); 78 var unitTag = jQuery(form).find('input[name="_wpcf7_unit_tag"]').val(); 79 80 jQuery.getJSON(url, 81 { _wpcf7_is_ajax_call: 1, _wpcf7: id }, 82 function(data) { 83 if (data && data.captcha) { 84 wpcf7RefillCaptcha('#' + unitTag, data.captcha); 85 } 86 if (data && data.quiz) { 87 wpcf7RefillQuiz('#' + unitTag, data.quiz); 88 } 89 } 90 ); 91} 92 93function wpcf7ProcessJson(data) { 94 var wpcf7ResponseOutput = jQuery(data.into).find('div.wpcf7-response-output'); 95 wpcf7ClearResponseOutput(); 96 97 if (data.invalids) { 98 jQuery.each(data.invalids, function(i, n) { 99 wpcf7NotValidTip(jQuery(data.into).find(n.into), n.message); 100 }); 101 wpcf7ResponseOutput.addClass('wpcf7-validation-errors'); 102 } 103 104 if (data.captcha) { 105 wpcf7RefillCaptcha(data.into, data.captcha); 106 } 107 108 if (data.quiz) { 109 wpcf7RefillQuiz(data.into, data.quiz); 110 } 111 112 if (1 == data.spam) { 113 wpcf7ResponseOutput.addClass('wpcf7-spam-blocked'); 114 } 115 116 if (1 == data.mailSent) { 117 jQuery(data.into).find('form').resetForm().clearForm(); 118 wpcf7ResponseOutput.addClass('wpcf7-mail-sent-ok'); 119 120 if (data.onSentOk) 121 jQuery.each(data.onSentOk, function(i, n) { eval(n) }); 122 } else { 123 wpcf7ResponseOutput.addClass('wpcf7-mail-sent-ng'); 124 } 125 126 if (data.onSubmit) 127 jQuery.each(data.onSubmit, function(i, n) { eval(n) }); 128 129 wpcf7ResponseOutput.append(data.message).slideDown('fast'); 130} 131 132function wpcf7RefillCaptcha(form, captcha) { 133 jQuery.each(captcha, function(i, n) { 134 jQuery(form).find(':input[name="' + i + '"]').clearFields(); 135 jQuery(form).find('img.wpcf7-captcha-' + i).attr('src', n); 136 var match = /([0-9]+)\.(png|gif|jpeg)$/.exec(n); 137 jQuery(form).find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[1]); 138 }); 139} 140 141function wpcf7RefillQuiz(form, quiz) { 142 jQuery.each(quiz, function(i, n) { 143 jQuery(form).find(':input[name="' + i + '"]').clearFields(); 144 jQuery(form).find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[0]);
145 jQuery(form).find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]); 146 }); 147} 148 149function wpcf7ClearResponseOutput() { 150 jQuery('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked'); 151 jQuery('span.wpcf7-not-valid-tip').remove(); 152 jQuery('img.ajax-loader').css({ visibility: 'hidden' }); 153}
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.