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