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