1(function($) { 2 3 $(function() { 4 try { 5 if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) 6 _wpcf7 = {}; 7 8 _wpcf7 = $.extend({ cached: 0 }, _wpcf7); 9 10 $('div.wpcf7 > form').ajaxForm({ 11 beforeSubmit: function(formData, jqForm, options) { 12 jqForm.wpcf7ClearResponseOutput(); 13 jqForm.find('img.ajax-loader').css({ visibility: 'visible' }); 14 return true; 15 }, 16 beforeSerialize: function(jqForm, options) { 17 jqForm.find('.wpcf7-use-title-as-watermark.watermark').each(function(i, n) { 18 $(n).val(''); 19 }); 20 return true; 21 }, 22 data: { '_wpcf7_is_ajax_call': 1 }, 23 dataType: 'json', 24 success: function(data) { 25 var ro = $(data.into).find('div.wpcf7-response-output'); 26 $(data.into).wpcf7ClearResponseOutput(); 27 28 $(data.into).find('.wpcf7-form-control').removeClass('wpcf7-not-valid'); 29 $(data.into).find('form.wpcf7-form').removeClass('invalid spam sent failed'); 30 31 if (data.captcha) 32 $(data.into).wpcf7RefillCaptcha(data.captcha); 33 34 if (data.quiz) 35 $(data.into).wpcf7RefillQuiz(data.quiz); 36 37 if (data.invalids) { 38 $.each(data.invalids, function(i, n) { 39 $(data.into).find(n.into).wpcf7NotValidTip(n.message); 40 $(data.into).find(n.into).find('.wpcf7-form-control').addClass('wpcf7-not-valid'); 41 }); 42 43 ro.addClass('wpcf7-validation-errors'); 44 $(data.into).find('form.wpcf7-form').addClass('invalid'); 45 46 } else if (1 == data.spam) { 47 ro.addClass('wpcf7-spam-blocked'); 48 $(data.into).find('form.wpcf7-form').addClass('spam'); 49 50 } else if (1 == data.mailSent) { 51 ro.addClass('wpcf7-mail-sent-ok'); 52 $(data.into).find('form.wpcf7-form').addClass('sent'); 53 54 if (data.onSentOk) 55 $.each(data.onSentOk, function(i, n) { eval(n) }); 56 57 } else { 58 ro.addClass('wpcf7-mail-sent-ng'); 59 $(data.into).find('form.wpcf7-form').addClass('failed'); 60 } 61 62 if (data.onSubmit) 63 $.each(data.onSubmit, function(i, n) { eval(n) }); 64 65 if (1 == data.mailSent) 66 $(data.into).find('form').resetForm().clearForm(); 67 68 $(data.into).find('.wpcf7-use-title-as-watermark.watermark').each(function(i, n) { 69 $(n).val($(n).attr('title')); 70 }); 71 72 $(data.into).wpcf7FillResponseOutput(data.message); 73 } 74 }); 75 76 $('div.wpcf7 > form').each(function(i, n) { 77 if (_wpcf7.cached) 78 $(n).wpcf7OnloadRefill(); 79 80 $(n).wpcf7ToggleSubmit(); 81 82 $(n).find('.wpcf7-submit').wpcf7AjaxLoader(); 83 84 $(n).find('.wpcf7-acceptance').click(function() { 85 $(n).wpcf7ToggleSubmit(); 86 }); 87 88 $(n).find('.wpcf7-exclusive-checkbox').each(function(i, n) { 89 $(n).find('input:checkbox').click(function() { 90 $(n).find('input:checkbox').not(this).removeAttr('checked'); 91 }); 92 }); 93 94 $(n).find('.wpcf7-use-title-as-watermark').each(function(i, n) { 95 var input = $(n); 96 input.val(input.attr('title')); 97 input.addClass('watermark'); 98 99 input.focus(function() { 100 if ($(this).hasClass('watermark')) 101 $(this).val('').removeClass('watermark'); 102 }); 103 104 input.blur(function() { 105 if ('' == $(this).val()) 106 $(this).val($(this).attr('title')).addClass('watermark'); 107 }); 108 }); 109 }); 110 111 } catch (e) { 112 } 113 }); 114 115 $.fn.wpcf7AjaxLoader = function() { 116 return this.each(function() { 117 var loader = $('<img class="ajax-loader" />') 118 .attr({ src: _wpcf7.loaderUrl, alt: _wpcf7.sending }) 119 .css('visibility', 'hidden'); 120 121 $(this).after(loader); 122 }); 123 }; 124 125 $.fn.wpcf7ToggleSubmit = function() { 126 return this.each(function() { 127 var form = $(this); 128 if (this.tagName.toLowerCase() != 'form') 129 form = $(this).find('form').first(); 130 131 if (form.hasClass('wpcf7-acceptance-as-validation')) 132 return; 133 134 var submit = form.find('input:submit'); 135 if (! submit.length) return; 136 137 var acceptances = form.find('input:checkbox.wpcf7-acceptance'); 138 if (! acceptances.length) return; 139 140 submit.removeAttr('disabled'); 141 acceptances.each(function(i, n) { 142 n = $(n); 143 if (n.hasClass('wpcf7-invert') && n.is(':checked') 144 || ! n.hasClass('wpcf7-invert') && ! n.is(':checked')) 145 submit.attr('disabled', 'disabled'); 146 }); 147 }); 148 }; 149 150 $.fn.wpcf7NotValidTip = function(message) { 151 return this.each(function() { 152 var into = $(this); 153 into.append('<span class="wpcf7-not-valid-tip">' + message + '</span>'); 154 $('span.wpcf7-not-valid-tip').mouseover(function() { 155 $(this).fadeOut('fast'); 156 }); 157 into.find(':input').mouseover(function() { 158 into.find('.wpcf7-not-valid-tip').not(':hidden').fadeOut('fast'); 159 }); 160 into.find(':input').focus(function() { 161 into.find('.wpcf7-not-valid-tip').not(':hidden').fadeOut('fast'); 162 }); 163 }); 164 }; 165 166 $.fn.wpcf7OnloadRefill = function() { 167 return this.each(function() { 168 var url = $(this).attr('action'); 169 if (0 < url.indexOf('#')) 170 url = url.substr(0, url.indexOf('#')); 171 172 var id = $(this).find('input[name="_wpcf7"]').val(); 173 var unitTag = $(this).find('input[name="_wpcf7_unit_tag"]').val(); 174 175 $.getJSON(url,
176 { _wpcf7_is_ajax_call: 1, _wpcf7: id }, 177 function(data) { 178 if (data && data.captcha) 179 $('#' + unitTag).wpcf7RefillCaptcha(data.captcha); 180 181 if (data && data.quiz) 182 $('#' + unitTag).wpcf7RefillQuiz(data.quiz); 183 } 184 ); 185 }); 186 }; 187 188 $.fn.wpcf7RefillCaptcha = function(captcha) { 189 return this.each(function() { 190 var form = $(this); 191 192 $.each(captcha, function(i, n) { 193 form.find(':input[name="' + i + '"]').clearFields(); 194 form.find('img.wpcf7-captcha-' + i).attr('src', n); 195 var match = /([0-9]+)\.(png|gif|jpeg)$/.exec(n); 196 form.find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[1]); 197 }); 198 }); 199 }; 200 201 $.fn.wpcf7RefillQuiz = function(quiz) { 202 return this.each(function() { 203 var form = $(this); 204 205 $.each(quiz, function(i, n) { 206 form.find(':input[name="' + i + '"]').clearFields(); 207 form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[0]); 208 form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]); 209 }); 210 }); 211 }; 212 213 $.fn.wpcf7ClearResponseOutput = function() { 214 return this.each(function() { 215 $(this).find('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked'); 216 $(this).find('span.wpcf7-not-valid-tip').remove(); 217 $(this).find('img.ajax-loader').css({ visibility: 'hidden' }); 218 }); 219 }; 220 221 $.fn.wpcf7FillResponseOutput = function(message) { 222 return this.each(function() { 223 $(this).find('div.wpcf7-response-output').append(message).slideDown('fast'); 224 }); 225 }; 226 227})(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.