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