1(function($) { 2 3 if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) 4 _wpcf7 = {}; 5 6 _wpcf7 = $.extend({ cached: 0 }, _wpcf7); 7 8 $(function() { 9 _wpcf7.supportHtml5 = $.wpcf7SupportHtml5(); 10 $('div.wpcf7 > form').wpcf7InitForm(); 11 }); 12 13 $.fn.wpcf7InitForm = function() { 14 this.ajaxForm({ 15 beforeSubmit: function(arr, $form, options) { 16 $form.wpcf7ClearResponseOutput(); 17 $form.find('[aria-invalid]').attr('aria-invalid', 'false'); 18 $form.find('img.ajax-loader').css({ visibility: 'visible' }); 19 return true; 20 }, 21 beforeSerialize: function($form, options) { 22 $form.find('[placeholder].placeheld').each(function(i, n) { 23 $(n).val(''); 24 }); 25 return true; 26 }, 27 data: { '_wpcf7_is_ajax_call': 1 }, 28 dataType: 'json', 29 success: $.wpcf7AjaxSuccess, 30 error: function(xhr, status, error, $form) { 31 var e = $('<div class="ajax-error"></div>').text(error.message); 32 $form.after(e); 33 } 34 }); 35 36 if (_wpcf7.cached) 37 this.wpcf7OnloadRefill(); 38 39 this.wpcf7ToggleSubmit(); 40 41 this.find('.wpcf7-submit').wpcf7AjaxLoader(); 42 43 this.find('.wpcf7-acceptance').click(function() { 44 $(this).closest('form').wpcf7ToggleSubmit(); 45 }); 46 47 this.find('.wpcf7-exclusive-checkbox').wpcf7ExclusiveCheckbox(); 48 49 this.find('.wpcf7-list-item.has-free-text').wpcf7ToggleCheckboxFreetext(); 50 51 this.find('[placeholder]').wpcf7Placeholder(); 52 53 if (_wpcf7.jqueryUi && ! _wpcf7.supportHtml5.date) { 54 this.find('input.wpcf7-date[type="date"]').each(function() { 55 $(this).datepicker({ 56 dateFormat: 'yy-mm-dd', 57 minDate: new Date($(this).attr('min')), 58 maxDate: new Date($(this).attr('max')) 59 }); 60 }); 61 } 62 63 if (_wpcf7.jqueryUi && ! _wpcf7.supportHtml5.number) { 64 this.find('input.wpcf7-number[type="number"]').each(function() { 65 $(this).spinner({ 66 min: $(this).attr('min'), 67 max: $(this).attr('max'), 68 step: $(this).attr('step') 69 }); 70 }); 71 } 72 }; 73 74 $.wpcf7AjaxSuccess = function(data, status, xhr, $form) { 75 if (! $.isPlainObject(data) || $.isEmptyObject(data)) 76 return; 77 78 var $responseOutput = $form.find('div.wpcf7-response-output'); 79 80 $form.wpcf7ClearResponseOutput(); 81 82 $form.find('.wpcf7-form-control').removeClass('wpcf7-not-valid'); 83 $form.removeClass('invalid spam sent failed'); 84 85 if (data.captcha) 86 $form.wpcf7RefillCaptcha(data.captcha); 87 88 if (data.quiz) 89 $form.wpcf7RefillQuiz(data.quiz); 90 91 if (data.invalids) { 92 $.each(data.invalids, function(i, n) { 93 $form.find(n.into).wpcf7NotValidTip(n.message); 94 $form.find(n.into).find('.wpcf7-form-control').addClass('wpcf7-not-valid'); 95 $form.find(n.into).find('[aria-invalid]').attr('aria-invalid', 'true'); 96 }); 97 98 $responseOutput.addClass('wpcf7-validation-errors'); 99 $form.addClass('invalid'); 100 101 $(data.into).trigger('invalid.wpcf7'); 102 103 } else if (1 == data.spam) { 104 $responseOutput.addClass('wpcf7-spam-blocked'); 105 $form.addClass('spam'); 106 107 $(data.into).trigger('spam.wpcf7'); 108 109 } else if (1 == data.mailSent) { 110 $responseOutput.addClass('wpcf7-mail-sent-ok'); 111 $form.addClass('sent'); 112 113 if (data.onSentOk) 114 $.each(data.onSentOk, function(i, n) { eval(n) }); 115 116 $(data.into).trigger('mailsent.wpcf7'); 117 118 } else { 119 $responseOutput.addClass('wpcf7-mail-sent-ng'); 120 $form.addClass('failed'); 121 122 $(data.into).trigger('mailfailed.wpcf7'); 123 } 124 125 if (data.onSubmit) 126 $.each(data.onSubmit, function(i, n) { eval(n) }); 127 128 $(data.into).trigger('submit.wpcf7'); 129 130 if (1 == data.mailSent) 131 $form.resetForm().clearForm(); 132 133 $form.find('[placeholder].placeheld').each(function(i, n) { 134 $(n).val($(n).attr('placeholder')); 135 }); 136 137 $responseOutput.append(data.message).slideDown('fast'); 138 $responseOutput.attr('role', 'alert'); 139 } 140 141 $.fn.wpcf7ExclusiveCheckbox = function() { 142 return this.find('input:checkbox').click(function() { 143 $(this).closest('.wpcf7-checkbox').find('input:checkbox').not(this).removeAttr('checked'); 144 }); 145 }; 146 147 $.fn.wpcf7Placeholder = function() { 148 if (_wpcf7.supportHtml5.placeholder) 149 return this; 150 151 return this.each(function() { 152 $(this).val($(this).attr('placeholder')); 153 $(this).addClass('placeheld'); 154 155 $(this).focus(function() { 156 if ($(this).hasClass('placeheld')) 157 $(this).val('').removeClass('placeheld'); 158 }); 159 160 $(this).blur(function() { 161 if ('' == $(this).val()) { 162 $(this).val($(this).attr('placeholder')); 163 $(this).addClass('placeheld'); 164 } 165 }); 166 }); 167 }; 168 169 $.fn.wpcf7AjaxLoader = function() { 170 return this.each(function() { 171 var loader = $('<img class="ajax-loader" />') 172 .attr({ src: _wpcf7.loaderUrl, alt: _wpcf7.sending }) 173 .css('visibility', 'hidden'); 174 175 $(this).after(loader); 176 }); 177 }; 178 179 $.fn.wpcf7ToggleSubmit = function() { 180 return this.each(function() { 181 var form = $(this); 182 if (this.tagName.toLowerCase() != 'form') 183 form = $(this).find('form').first(); 184 185 if (form.hasClass('wpcf7-acceptance-as-validation')) 186 return; 187
188 var submit = form.find('input:submit'); 189 if (! submit.length) return; 190 191 var acceptances = form.find('input:checkbox.wpcf7-acceptance'); 192 if (! acceptances.length) return; 193 194 submit.removeAttr('disabled'); 195 acceptances.each(function(i, n) { 196 n = $(n); 197 if (n.hasClass('wpcf7-invert') && n.is(':checked') 198 || ! n.hasClass('wpcf7-invert') && ! n.is(':checked')) 199 submit.attr('disabled', 'disabled'); 200 }); 201 }); 202 }; 203 204 $.fn.wpcf7ToggleCheckboxFreetext = function() { 205 return this.each(function() { 206 var $wrap = $(this).closest('.wpcf7-form-control'); 207 208 if ($(this).find(':checkbox, :radio').is(':checked')) { 209 $(this).find(':input.wpcf7-free-text').prop('disabled', false); 210 } else { 211 $(this).find(':input.wpcf7-free-text').prop('disabled', true); 212 } 213 214 $wrap.find(':checkbox, :radio').change(function() { 215 var $cb = $('.has-free-text', $wrap).find(':checkbox, :radio'); 216 var $freetext = $(':input.wpcf7-free-text', $wrap); 217 218 if ($cb.is(':checked')) { 219 $freetext.prop('disabled', false).focus(); 220 } else { 221 $freetext.prop('disabled', true); 222 } 223 }); 224 }); 225 }; 226 227 $.fn.wpcf7NotValidTip = function(message) { 228 return this.each(function() { 229 var $into = $(this); 230 $into.hide().append('<span role="alert" class="wpcf7-not-valid-tip">' + message + '</span>').slideDown('fast'); 231 232 if ($into.is('.use-floating-validation-tip *')) { 233 $('.wpcf7-not-valid-tip', $into).mouseover(function() { 234 $(this).wpcf7FadeOut(); 235 }); 236 237 $(':input', $into).focus(function() { 238 $('.wpcf7-not-valid-tip', $into).not(':hidden').wpcf7FadeOut(); 239 }); 240 } 241 }); 242 }; 243 244 $.fn.wpcf7FadeOut = function() { 245 return this.each(function() { 246 $(this).animate({ 247 opacity: 0 248 }, 'fast', function() { 249 $(this).css({'z-index': -100}); 250 }); 251 }); 252 }; 253 254 $.fn.wpcf7OnloadRefill = function() { 255 return this.each(function() { 256 var url = $(this).attr('action'); 257 if (0 < url.indexOf('#')) 258 url = url.substr(0, url.indexOf('#')); 259 260 var id = $(this).find('input[name="_wpcf7"]').val(); 261 var unitTag = $(this).find('input[name="_wpcf7_unit_tag"]').val(); 262 263 $.getJSON(url, 264 { _wpcf7_is_ajax_call: 1, _wpcf7: id, _wpcf7_request_ver: $.now() }, 265 function(data) { 266 if (data && data.captcha) 267 $('#' + unitTag).wpcf7RefillCaptcha(data.captcha); 268 269 if (data && data.quiz) 270 $('#' + unitTag).wpcf7RefillQuiz(data.quiz); 271 } 272 ); 273 }); 274 }; 275 276 $.fn.wpcf7RefillCaptcha = function(captcha) { 277 return this.each(function() { 278 var form = $(this); 279 280 $.each(captcha, function(i, n) { 281 form.find(':input[name="' + i + '"]').clearFields(); 282 form.find('img.wpcf7-captcha-' + i).attr('src', n); 283 var match = /([0-9]+)\.(png|gif|jpeg)$/.exec(n); 284 form.find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[1]); 285 }); 286 }); 287 }; 288 289 $.fn.wpcf7RefillQuiz = function(quiz) { 290 return this.each(function() { 291 var form = $(this); 292 293 $.each(quiz, function(i, n) { 294 form.find(':input[name="' + i + '"]').clearFields(); 295 form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[0]); 296 form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]); 297 }); 298 }); 299 }; 300 301 $.fn.wpcf7ClearResponseOutput = function() { 302 return this.each(function() { 303 $(this).find('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked').removeAttr('role'); 304 $(this).find('span.wpcf7-not-valid-tip').remove(); 305 $(this).find('img.ajax-loader').css({ visibility: 'hidden' }); 306 }); 307 }; 308 309 $.wpcf7SupportHtml5 = function() { 310 var features = {}; 311 var input = document.createElement('input'); 312 313 features.placeholder = 'placeholder' in input; 314 315 var inputTypes = ['email', 'url', 'tel', 'number', 'range', 'date']; 316 317 $.each(inputTypes, function(index, value) { 318 input.setAttribute('type', value); 319 features[value] = input.type !== 'text'; 320 }); 321 322 return features; 323 }; 324 325})(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.