1(function($) { 2 3 'use strict'; 4 5 if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) { 6 return; 7 } 8 9 _wpcf7 = $.extend({ 10 cached: 0 11 }, _wpcf7); 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('.ajax-loader').addClass('is-active'); 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 40 this.wpcf7ToggleSubmit(); 41 42 this.find('.wpcf7-submit').wpcf7AjaxLoader(); 43 44 this.find('.wpcf7-acceptance').click(function() { 45 $(this).closest('form').wpcf7ToggleSubmit(); 46 }); 47 48 this.find('.wpcf7-exclusive-checkbox').wpcf7ExclusiveCheckbox(); 49 50 this.find('.wpcf7-list-item.has-free-text').wpcf7ToggleCheckboxFreetext(); 51 52 this.find('[placeholder]').wpcf7Placeholder(); 53 54 if (_wpcf7.jqueryUi && ! _wpcf7.supportHtml5.date) { 55 this.find('input.wpcf7-date[type="date"]').each(function() { 56 $(this).datepicker({ 57 dateFormat: 'yy-mm-dd', 58 minDate: new Date($(this).attr('min')), 59 maxDate: new Date($(this).attr('max')) 60 }); 61 }); 62 } 63 64 if (_wpcf7.jqueryUi && ! _wpcf7.supportHtml5.number) { 65 this.find('input.wpcf7-number[type="number"]').each(function() { 66 $(this).spinner({ 67 min: $(this).attr('min'), 68 max: $(this).attr('max'), 69 step: $(this).attr('step') 70 }); 71 }); 72 } 73 74 this.find('.wpcf7-character-count').wpcf7CharacterCount(); 75 76 this.find('.wpcf7-validates-as-url').change(function() { 77 $(this).wpcf7NormalizeUrl(); 78 }); 79 80 this.find('.wpcf7-recaptcha').wpcf7Recaptcha(); 81 }; 82 83 $.wpcf7AjaxSuccess = function(data, status, xhr, $form) { 84 if (! $.isPlainObject(data) || $.isEmptyObject(data)) { 85 return; 86 } 87 88 var $responseOutput = $form.find('div.wpcf7-response-output'); 89 90 $form.wpcf7ClearResponseOutput(); 91 92 $form.find('.wpcf7-form-control').removeClass('wpcf7-not-valid'); 93 $form.removeClass('invalid spam sent failed'); 94 95 if (data.captcha) { 96 $form.wpcf7RefillCaptcha(data.captcha); 97 } 98 99 if (data.quiz) { 100 $form.wpcf7RefillQuiz(data.quiz); 101 } 102 103 if (data.invalids) { 104 $.each(data.invalids, function(i, n) { 105 $form.find(n.into).wpcf7NotValidTip(n.message); 106 $form.find(n.into).find('.wpcf7-form-control').addClass('wpcf7-not-valid'); 107 $form.find(n.into).find('[aria-invalid]').attr('aria-invalid', 'true'); 108 }); 109 110 $responseOutput.addClass('wpcf7-validation-errors'); 111 $form.addClass('invalid'); 112 113 $(data.into).trigger('wpcf7:invalid'); 114 $(data.into).trigger('invalid.wpcf7'); // deprecated 115 116 } else if (1 == data.spam) { 117 $form.find('[name="g-recaptcha-response"]').each(function() { 118 if ('' == $(this).val()) { 119 var $recaptcha = $(this).closest('.wpcf7-form-control-wrap'); 120 $recaptcha.wpcf7NotValidTip(_wpcf7.recaptcha.messages.empty); 121 } 122 }); 123 124 $responseOutput.addClass('wpcf7-spam-blocked'); 125 $form.addClass('spam'); 126 127 $(data.into).trigger('wpcf7:spam'); 128 $(data.into).trigger('spam.wpcf7'); // deprecated 129 130 } else if (1 == data.mailSent) { 131 $responseOutput.addClass('wpcf7-mail-sent-ok'); 132 $form.addClass('sent'); 133 134 if (data.onSentOk) { 135 $.each(data.onSentOk, function(i, n) { eval(n) }); 136 } 137 138 $(data.into).trigger('wpcf7:mailsent'); 139 $(data.into).trigger('mailsent.wpcf7'); // deprecated 140 141 } else { 142 $responseOutput.addClass('wpcf7-mail-sent-ng'); 143 $form.addClass('failed'); 144 145 $(data.into).trigger('wpcf7:mailfailed'); 146 $(data.into).trigger('mailfailed.wpcf7'); // deprecated 147 } 148 149 if (data.onSubmit) { 150 $.each(data.onSubmit, function(i, n) { eval(n) }); 151 } 152 153 $(data.into).trigger('wpcf7:submit'); 154 $(data.into).trigger('submit.wpcf7'); // deprecated 155 156 if (1 == data.mailSent) { 157 $form.resetForm(); 158 } 159 160 $form.find('[placeholder].placeheld').each(function(i, n) { 161 $(n).val($(n).attr('placeholder')); 162 }); 163 164 $responseOutput.append(data.message).slideDown('fast'); 165 $responseOutput.attr('role', 'alert'); 166 167 $.wpcf7UpdateScreenReaderResponse($form, data); 168 }; 169 170 $.fn.wpcf7ExclusiveCheckbox = function() {
171 return this.find('input:checkbox').click(function() { 172 var name = $(this).attr('name'); 173 $(this).closest('form').find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false); 174 }); 175 }; 176 177 $.fn.wpcf7Placeholder = function() { 178 if (_wpcf7.supportHtml5.placeholder) { 179 return this; 180 } 181 182 return this.each(function() { 183 $(this).val($(this).attr('placeholder')); 184 $(this).addClass('placeheld'); 185 186 $(this).focus(function() { 187 if ($(this).hasClass('placeheld')) 188 $(this).val('').removeClass('placeheld'); 189 }); 190 191 $(this).blur(function() { 192 if ('' == $(this).val()) { 193 $(this).val($(this).attr('placeholder')); 194 $(this).addClass('placeheld'); 195 } 196 }); 197 }); 198 }; 199 200 $.fn.wpcf7AjaxLoader = function() { 201 return this.each(function() { 202 $(this).after('<span class="ajax-loader"></span>'); 203 }); 204 }; 205 206 $.fn.wpcf7ToggleSubmit = function() { 207 return this.each(function() { 208 var form = $(this); 209 210 if (this.tagName.toLowerCase() != 'form') { 211 form = $(this).find('form').first(); 212 } 213 214 if (form.hasClass('wpcf7-acceptance-as-validation')) { 215 return; 216 } 217 218 var submit = form.find('input:submit'); 219 if (! submit.length) return; 220 221 var acceptances = form.find('input:checkbox.wpcf7-acceptance'); 222 if (! acceptances.length) return; 223 224 submit.removeAttr('disabled'); 225 acceptances.each(function(i, n) { 226 n = $(n); 227 if (n.hasClass('wpcf7-invert') && n.is(':checked') 228 || ! n.hasClass('wpcf7-invert') && ! n.is(':checked')) { 229 submit.attr('disabled', 'disabled'); 230 } 231 }); 232 }); 233 }; 234 235 $.fn.wpcf7ToggleCheckboxFreetext = function() { 236 return this.each(function() { 237 var $wrap = $(this).closest('.wpcf7-form-control'); 238 239 if ($(this).find(':checkbox, :radio').is(':checked')) { 240 $(this).find(':input.wpcf7-free-text').prop('disabled', false); 241 } else { 242 $(this).find(':input.wpcf7-free-text').prop('disabled', true); 243 } 244 245 $wrap.find(':checkbox, :radio').change(function() { 246 var $cb = $('.has-free-text', $wrap).find(':checkbox, :radio'); 247 var $freetext = $(':input.wpcf7-free-text', $wrap); 248 249 if ($cb.is(':checked')) { 250 $freetext.prop('disabled', false).focus(); 251 } else { 252 $freetext.prop('disabled', true); 253 } 254 }); 255 }); 256 }; 257 258 $.fn.wpcf7CharacterCount = function() { 259 return this.each(function() { 260 var $count = $(this); 261 var name = $count.attr('data-target-name'); 262 var down = $count.hasClass('down'); 263 var starting = parseInt($count.attr('data-starting-value'), 10); 264 var maximum = parseInt($count.attr('data-maximum-value'), 10); 265 var minimum = parseInt($count.attr('data-minimum-value'), 10); 266 267 var updateCount = function($target) { 268 var length = $target.val().length; 269 var count = down ? starting - length : length; 270 $count.attr('data-current-value', count); 271 $count.text(count); 272 273 if (maximum && maximum < length) { 274 $count.addClass('too-long'); 275 } else { 276 $count.removeClass('too-long'); 277 } 278 279 if (minimum && length < minimum) { 280 $count.addClass('too-short'); 281 } else { 282 $count.removeClass('too-short'); 283 } 284 }; 285 286 $count.closest('form').find(':input[name="' + name + '"]').each(function() { 287 updateCount($(this)); 288 289 $(this).keyup(function() { 290 updateCount($(this)); 291 }); 292 }); 293 }); 294 }; 295 296 $.fn.wpcf7NormalizeUrl = function() { 297 return this.each(function() { 298 var val = $.trim($(this).val()); 299 300 if (val && ! val.match(/^[a-z][a-z0-9.+-]*:/i)) { // check the scheme part 301 val = val.replace(/^\/+/, ''); 302 val = 'http://' + val; 303 } 304 305 $(this).val(val); 306 }); 307 }; 308 309 $.fn.wpcf7NotValidTip = function(message) { 310 return this.each(function() { 311 var $into = $(this); 312 313 $into.find('span.wpcf7-not-valid-tip').remove(); 314 $into.append('<span role="alert" class="wpcf7-not-valid-tip">' + message + '</span>'); 315 316 if ($into.is('.use-floating-validation-tip *')) { 317 $('.wpcf7-not-valid-tip', $into).mouseover(function() { 318 $(this).wpcf7FadeOut(); 319 }); 320 321 $(':input', $into).focus(function() { 322 $('.wpcf7-not-valid-tip', $into).not(':hidden').wpcf7FadeOut(); 323 }); 324 } 325 }); 326 }; 327 328 $.fn.wpcf7FadeOut = function() { 329 return this.each(function() { 330 $(this).animate({ 331 opacity: 0 332 }, 'fast', function() { 333 $(this).css({'z-index': -100}); 334 }); 335 }); 336 }; 337 338 $.fn.wpcf7OnloadRefill = function() { 339 return this.each(function() { 340 var url = $(this).attr('action'); 341 342 if (0 < url.indexOf('#')) { 343 url = url.substr(0, url.indexOf('#')); 344 } 345 346 var id = $(this).find('input[name="_wpcf7"]').val(); 347 var unitTag = $(this).find('input[name="_wpcf7_unit_tag"]').val(); 348 349 $.getJSON(url,
350 { _wpcf7_is_ajax_call: 1, _wpcf7: id, _wpcf7_request_ver: $.now() }, 351 function(data) { 352 if (data && data.captcha) { 353 $('#' + unitTag).wpcf7RefillCaptcha(data.captcha); 354 } 355 356 if (data && data.quiz) { 357 $('#' + unitTag).wpcf7RefillQuiz(data.quiz); 358 } 359 } 360 ); 361 }); 362 }; 363 364 $.fn.wpcf7RefillCaptcha = function(captcha) { 365 return this.each(function() { 366 var form = $(this); 367 368 $.each(captcha, function(i, n) { 369 form.find(':input[name="' + i + '"]').clearFields(); 370 form.find('img.wpcf7-captcha-' + i).attr('src', n); 371 var match = /([0-9]+)\.(png|gif|jpeg)$/.exec(n); 372 form.find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[1]); 373 }); 374 }); 375 }; 376 377 $.fn.wpcf7RefillQuiz = function(quiz) { 378 return this.each(function() { 379 var form = $(this); 380 381 $.each(quiz, function(i, n) { 382 form.find(':input[name="' + i + '"]').clearFields(); 383 form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[0]); 384 form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]); 385 }); 386 }); 387 }; 388 389 $.fn.wpcf7ClearResponseOutput = function() { 390 return this.each(function() { 391 $(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'); 392 $(this).find('span.wpcf7-not-valid-tip').remove(); 393 $(this).find('.ajax-loader').removeClass('is-active'); 394 }); 395 }; 396 397 $.fn.wpcf7Recaptcha = function() { 398 return this.each(function() { 399 var events = 'wpcf7:spam wpcf7:mailsent wpcf7:mailfailed'; 400 $(this).closest('div.wpcf7').on(events, function(e) { 401 if (recaptchaWidgets && grecaptcha) { 402 $.each(recaptchaWidgets, function(index, value) { 403 grecaptcha.reset(value); 404 }); 405 } 406 }); 407 }); 408 }; 409 410 $.wpcf7UpdateScreenReaderResponse = function($form, data) { 411 $('.wpcf7 .screen-reader-response').html('').attr('role', ''); 412 413 if (data.message) { 414 var $response = $form.siblings('.screen-reader-response').first(); 415 $response.append(data.message); 416 417 if (data.invalids) { 418 var $invalids = $('<ul></ul>'); 419 420 $.each(data.invalids, function(i, n) { 421 if (n.idref) { 422 var $li = $('<li></li>').append($('<a></a>').attr('href', '#' + n.idref).append(n.message)); 423 } else { 424 var $li = $('<li></li>').append(n.message); 425 } 426 427 $invalids.append($li); 428 }); 429 430 $response.append($invalids); 431 } 432 433 $response.attr('role', 'alert').focus(); 434 } 435 }; 436 437 $.wpcf7SupportHtml5 = function() { 438 var features = {}; 439 var input = document.createElement('input'); 440 441 features.placeholder = 'placeholder' in input; 442 443 var inputTypes = ['email', 'url', 'tel', 'number', 'range', 'date']; 444 445 $.each(inputTypes, function(index, value) { 446 input.setAttribute('type', value); 447 features[value] = input.type !== 'text'; 448 }); 449 450 return features; 451 }; 452 453 $(function() { 454 _wpcf7.supportHtml5 = $.wpcf7SupportHtml5(); 455 $('div.wpcf7 > form').wpcf7InitForm(); 456 }); 457 458})(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.