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 inputs: [] 12 }, wpcf7 ); 13 14 $( function() { 15 wpcf7.supportHtml5 = ( function() { 16 var features = {}; 17 var input = document.createElement( 'input' ); 18 19 features.placeholder = 'placeholder' in input; 20 21 var inputTypes = [ 'email', 'url', 'tel', 'number', 'range', 'date' ]; 22 23 $.each( inputTypes, function( index, value ) { 24 input.setAttribute( 'type', value ); 25 features[ value ] = input.type !== 'text'; 26 } ); 27 28 return features; 29 } )(); 30 31 $( 'div.wpcf7 > form' ).each( function() { 32 var $form = $( this ); 33 wpcf7.initForm( $form ); 34 35 if ( wpcf7.cached ) { 36 wpcf7.refill( $form ); 37 } 38 } ); 39 } ); 40 41 wpcf7.getId = function( form ) { 42 return parseInt( $( 'input[name="_wpcf7"]', form ).val(), 10 ); 43 }; 44 45 wpcf7.initForm = function( form ) { 46 var $form = $( form ); 47 48 wpcf7.setStatus( $form, 'init' ); 49 50 $form.submit( function( event ) { 51 if ( ! wpcf7.supportHtml5.placeholder ) { 52 $( '[placeholder].placeheld', $form ).each( function( i, n ) { 53 $( n ).val( '' ).removeClass( 'placeheld' ); 54 } ); 55 } 56 57 if ( typeof window.FormData === 'function' ) { 58 wpcf7.submit( $form ); 59 event.preventDefault(); 60 } 61 } ); 62 63 $( '.wpcf7-submit', $form ).after( '<span class="ajax-loader"></span>' ); 64 65 wpcf7.toggleSubmit( $form ); 66 67 $form.on( 'click', '.wpcf7-acceptance', function() { 68 wpcf7.toggleSubmit( $form ); 69 } ); 70 71 // Exclusive Checkbox 72 $( '.wpcf7-exclusive-checkbox', $form ).on( 'click', 'input:checkbox', function() { 73 var name = $( this ).attr( 'name' );
74 $form.find( 'input:checkbox[name="' + name + '"]' ).not( this ).prop( 'checked', false ); 75 } ); 76 77 // Free Text Option for Checkboxes and Radio Buttons 78 $( '.wpcf7-list-item.has-free-text', $form ).each( function() { 79 var $freetext = $( ':input.wpcf7-free-text', this ); 80 var $wrap = $( this ).closest( '.wpcf7-form-control' ); 81 82 if ( $( ':checkbox, :radio', this ).is( ':checked' ) ) { 83 $freetext.prop( 'disabled', false ); 84 } else { 85 $freetext.prop( 'disabled', true ); 86 } 87 88 $wrap.on( 'change', ':checkbox, :radio', function() { 89 var $cb = $( '.has-free-text', $wrap ).find( ':checkbox, :radio' ); 90 91 if ( $cb.is( ':checked' ) ) { 92 $freetext.prop( 'disabled', false ).focus(); 93 } else { 94 $freetext.prop( 'disabled', true ); 95 } 96 } ); 97 } ); 98 99 // Placeholder Fallback 100 if ( ! wpcf7.supportHtml5.placeholder ) { 101 $( '[placeholder]', $form ).each( function() { 102 $( this ).val( $( this ).attr( 'placeholder' ) ); 103 $( this ).addClass( 'placeheld' ); 104 105 $( this ).focus( function() { 106 if ( $( this ).hasClass( 'placeheld' ) ) { 107 $( this ).val( '' ).removeClass( 'placeheld' ); 108 } 109 } ); 110 111 $( this ).blur( function() { 112 if ( '' === $( this ).val() ) { 113 $( this ).val( $( this ).attr( 'placeholder' ) ); 114 $( this ).addClass( 'placeheld' ); 115 } 116 } ); 117 } ); 118 } 119 120 if ( wpcf7.jqueryUi && ! wpcf7.supportHtml5.date ) {
121 $form.find( 'input.wpcf7-date[type="date"]' ).each( function() { 122 $( this ).datepicker( { 123 dateFormat: 'yy-mm-dd', 124 minDate: new Date( $( this ).attr( 'min' ) ), 125 maxDate: new Date( $( this ).attr( 'max' ) ) 126 } ); 127 } ); 128 } 129 130 if ( wpcf7.jqueryUi && ! wpcf7.supportHtml5.number ) { 131 $form.find( 'input.wpcf7-number[type="number"]' ).each( function() { 132 $( this ).spinner( { 133 min: $( this ).attr( 'min' ), 134 max: $( this ).attr( 'max' ), 135 step: $( this ).attr( 'step' ) 136 } ); 137 } ); 138 } 139 140 // Character Count 141 wpcf7.resetCounter( $form ); 142 143 // URL Input Correction 144 $form.on( 'change', '.wpcf7-validates-as-url', function() { 145 var val = $.trim( $( this ).val() ); 146 147 if ( val 148 && ! val.match( /^[a-z][a-z0-9.+-]*:/i ) 149 && -1 !== val.indexOf( '.' ) ) { 150 val = val.replace( /^\/+/, '' ); 151 val = 'http://' + val; 152 } 153 154 $( this ).val( val ); 155 } ); 156 }; 157 158 wpcf7.submit = function( form ) { 159 if ( typeof window.FormData !== 'function' ) { 160 return; 161 } 162 163 var $form = $( form ); 164 165 $( '.ajax-loader', $form ).addClass( 'is-active' ); 166 wpcf7.clearResponse( $form ); 167 168 var formData = new FormData( $form.get( 0 ) ); 169 170 var detail = { 171 id: $form.closest( 'div.wpcf7' ).attr( 'id' ), 172 status: 'init', 173 inputs: [], 174 formData: formData 175 }; 176 177 $.each( $form.serializeArray(), function( i, field ) { 178 if ( '_wpcf7' == field.name ) { 179 detail.contactFormId = field.value; 180 } else if ( '_wpcf7_version' == field.name ) { 181 detail.pluginVersion = field.value; 182 } else if ( '_wpcf7_locale' == field.name ) { 183 detail.contactFormLocale = field.value; 184 } else if ( '_wpcf7_unit_tag' == field.name ) { 185 detail.unitTag = field.value; 186 } else if ( '_wpcf7_container_post' == field.name ) { 187 detail.containerPostId = field.value; 188 } else if ( field.name.match( /^_/ ) ) { 189 // do nothing 190 } else { 191 detail.inputs.push( field ); 192 } 193 } ); 194 195 wpcf7.triggerEvent( $form.closest( 'div.wpcf7' ), 'beforesubmit', detail ); 196 197 var ajaxSuccess = function( data, status, xhr, $form ) { 198 detail.id = $( data.into ).attr( 'id' ); 199 detail.status = data.status; 200 detail.apiResponse = data; 201 202 switch ( data.status ) { 203 case 'init': 204 wpcf7.setStatus( $form, 'init' ); 205 break; 206 case 'validation_failed': 207 $.each( data.invalid_fields, function( i, n ) { 208 $( n.into, $form ).each( function() { 209 wpcf7.notValidTip( this, n.message ); 210 $( '.wpcf7-form-control', this ).addClass( 'wpcf7-not-valid' ); 211 $( '[aria-invalid]', this ).attr( 'aria-invalid', 'true' ); 212 213 } ); 214 } ); 215 216 wpcf7.setStatus( $form, 'invalid' ); 217 wpcf7.triggerEvent( data.into, 'invalid', detail ); 218 break; 219 case 'acceptance_missing': 220 wpcf7.setStatus( $form, 'unaccepted' ); 221 wpcf7.triggerEvent( data.into, 'unaccepted', detail ); 222 break; 223 case 'spam': 224 wpcf7.setStatus( $form, 'spam' ); 225 wpcf7.triggerEvent( data.into, 'spam', detail ); 226 break; 227 case 'aborted': 228 wpcf7.setStatus( $form, 'aborted' ); 229 wpcf7.triggerEvent( data.into, 'aborted', detail ); 230 break; 231 case 'mail_sent': 232 wpcf7.setStatus( $form, 'sent' ); 233 wpcf7.triggerEvent( data.into, 'mailsent', detail ); 234 $( '.your-name', $form ).hide().empty(); 235$( '.tel-761', $form ).hide().empty(); 236$( '.acceptance-930', $form ).hide().empty(); 237$( '.wpcf7-submit', $form ).hide().empty(); 238$( 'br', $form ).hide().empty(); 239 240 break; 241 case 'mail_failed': 242 wpcf7.setStatus( $form, 'failed' ); 243 wpcf7.triggerEvent( data.into, 'mailfailed', detail ); 244 break; 245 default: 246 wpcf7.setStatus( $form, 247 'custom-' + data.status.replace( /[^0-9a-z]+/i, '-' ) 248 ); 249 } 250 251 wpcf7.refill( $form, data ); 252 253 wpcf7.triggerEvent( data.into, 'submit', detail ); 254 255 if ( 'mail_sent' == data.status ) { 256 $form.each( function() { 257 this.reset(); 258 } ); 259 260 wpcf7.toggleSubmit( $form ); 261 wpcf7.resetCounter( $form ); 262 } 263 264 if ( ! wpcf7.supportHtml5.placeholder ) { 265 $form.find( '[placeholder].placeheld' ).each( function( i, n ) { 266 $( n ).val( $( n ).attr( 'placeholder' ) ); 267 } ); 268 } 269 270 $( '.wpcf7-response-output', $form ) 271 .html( '' ).append( data.message ).slideDown( 'fast' ); 272 273 $( '.screen-reader-response', $form.closest( '.wpcf7' ) ).each( function() { 274 var $response = $( this ); 275 $response.html( '' ).append( data.message ); 276 277 if ( data.invalid_fields ) { 278 var $invalids = $( '<ul></ul>' ); 279 280 $.each( data.invalid_fields, function( i, n ) { 281 if ( n.idref ) { 282 var $li = $( '<li></li>' ).append( $( '<a></a>' ).attr( 'href', '#' + n.idref ).append( n.message ) ); 283 } else { 284 var $li = $( '<li></li>' ).append( n.message ); 285 } 286 287 $invalids.append( $li ); 288 } ); 289
290 $response.append( $invalids ); 291 } 292 293 $response.focus(); 294 } ); 295 296 if ( data.posted_data_hash ) { 297 $form.find( 'input[name="_wpcf7_posted_data_hash"]' ).first() 298 .val( data.posted_data_hash ); 299 } 300 }; 301 302 $.ajax( { 303 type: 'POST', 304 url: wpcf7.apiSettings.getRoute( 305 '/contact-forms/' + wpcf7.getId( $form ) + '/feedback' ), 306 data: formData, 307 dataType: 'json', 308 processData: false, 309 contentType: false 310 } ).done( function( data, status, xhr ) { 311 ajaxSuccess( data, status, xhr, $form ); 312 $( '.ajax-loader', $form ).removeClass( 'is-active' ); 313 } ).fail( function( xhr, status, error ) { 314 var $e = $( '<div class="ajax-error"></div>' ).text( error.message ); 315 $form.after( $e ); 316 } ); 317 }; 318 319 wpcf7.triggerEvent = function( target, name, detail ) { 320 var event = new CustomEvent( 'wpcf7' + name, { 321 bubbles: true, 322 detail: detail 323 } ); 324 325 $( target ).get( 0 ).dispatchEvent( event ); 326 }; 327 328 wpcf7.setStatus = function( form, status ) { 329 var $form = $( form ); 330 var prevStatus = $form.data( 'status' ); 331 332 $form.data( 'status', status ); 333 $form.addClass( status ); 334 335 if ( prevStatus && prevStatus !== status ) { 336 $form.removeClass( prevStatus ); 337 } 338 } 339 340 wpcf7.toggleSubmit = function( form, state ) { 341 var $form = $( form ); 342 var $submit = $( 'input:submit', $form ); 343 344 if ( typeof state !== 'undefined' ) { 345 $submit.prop( 'disabled', ! state ); 346 return; 347 } 348 349 if ( $form.hasClass( 'wpcf7-acceptance-as-validation' ) ) { 350 return; 351 } 352 353 $submit.prop( 'disabled', false ); 354 355 $( '.wpcf7-acceptance', $form ).each( function() { 356 var $span = $( this ); 357 var $input = $( 'input:checkbox', $span ); 358 359 if ( ! $span.hasClass( 'optional' ) ) { 360 if ( $span.hasClass( 'invert' ) && $input.is( ':checked' ) 361 || ! $span.hasClass( 'invert' ) && ! $input.is( ':checked' ) ) { 362 $submit.prop( 'disabled', true ); 363 return false; 364 } 365 } 366 } ); 367 }; 368 369 wpcf7.resetCounter = function( form ) { 370 var $form = $( form ); 371 372 $( '.wpcf7-character-count', $form ).each( function() { 373 var $count = $( this ); 374 var name = $count.attr( 'data-target-name' ); 375 var down = $count.hasClass( 'down' ); 376 var starting = parseInt( $count.attr( 'data-starting-value' ), 10 ); 377 var maximum = parseInt( $count.attr( 'data-maximum-value' ), 10 ); 378 var minimum = parseInt( $count.attr( 'data-minimum-value' ), 10 ); 379 380 var updateCount = function( target ) { 381 var $target = $( target ); 382 var length = $target.val().length; 383 var count = down ? starting - length : length; 384 $count.attr( 'data-current-value', count ); 385 $count.text( count ); 386 387 if ( maximum && maximum < length ) { 388 $count.addClass( 'too-long' ); 389 } else { 390 $count.removeClass( 'too-long' ); 391 } 392 393 if ( minimum && length < minimum ) { 394 $count.addClass( 'too-short' ); 395 } else { 396 $count.removeClass( 'too-short' ); 397 } 398 }; 399 400 $( ':input[name="' + name + '"]', $form ).each( function() { 401 updateCount( this ); 402 403 $( this ).keyup( function() { 404 updateCount( this ); 405 } ); 406 } ); 407 } ); 408 }; 409 410 wpcf7.notValidTip = function( target, message ) { 411 var $target = $( target ); 412 $( '.wpcf7-not-valid-tip', $target ).remove(); 413 414 $( '<span></span>' ).attr( { 415 'class': 'wpcf7-not-valid-tip', 416 'role': 'alert', 417 'aria-hidden': 'true', 418 } ).text( message ).appendTo( $target ); 419 420 if ( $target.is( '.use-floating-validation-tip *' ) ) { 421 var fadeOut = function( target ) { 422 $( target ).not( ':hidden' ).animate( { 423 opacity: 0 424 }, 'fast', function() { 425 $( this ).css( { 'z-index': -100 } ); 426 } ); 427 }; 428 429 $target.on( 'mouseover', '.wpcf7-not-valid-tip', function() { 430 fadeOut( this ); 431 } ); 432 433 $target.on( 'focus', ':input', function() { 434 fadeOut( $( '.wpcf7-not-valid-tip', $target ) ); 435 } ); 436 } 437 }; 438 439 wpcf7.refill = function( form, data ) { 440 var $form = $( form ); 441 442 var refillCaptcha = function( $form, items ) { 443 $.each( items, function( i, n ) { 444 $form.find( ':input[name="' + i + '"]' ).val( '' );
445 $form.find( 'img.wpcf7-captcha-' + i ).attr( 'src', n ); 446 var match = /([0-9]+)\.(png|gif|jpeg)$/.exec( n ); 447 $form.find( 'input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]' ).attr( 'value', match[ 1 ] ); 448 } ); 449 }; 450 451 var refillQuiz = function( $form, items ) { 452 $.each( items, function( i, n ) { 453 $form.find( ':input[name="' + i + '"]' ).val( '' ); 454 $form.find( ':input[name="' + i + '"]' ).siblings( 'span.wpcf7-quiz-label' ).text( n[ 0 ] ); 455 $form.find( 'input:hidden[name="_wpcf7_quiz_answer_' + i + '"]' ).attr( 'value', n[ 1 ] ); 456 } ); 457 }; 458 459 if ( typeof data === 'undefined' ) { 460 $.ajax( { 461 type: 'GET', 462 url: wpcf7.apiSettings.getRoute( 463 '/contact-forms/' + wpcf7.getId( $form ) + '/refill' ), 464 beforeSend: function( xhr ) { 465 var nonce = $form.find( ':input[name="_wpnonce"]' ).val(); 466 467 if ( nonce ) { 468 xhr.setRequestHeader( 'X-WP-Nonce', nonce ); 469 } 470 }, 471 dataType: 'json' 472 } ).done( function( data, status, xhr ) { 473 if ( data.captcha ) { 474 refillCaptcha( $form, data.captcha ); 475 } 476 477 if ( data.quiz ) { 478 refillQuiz( $form, data.quiz ); 479 } 480 } ); 481 482 } else { 483 if ( data.captcha ) { 484 refillCaptcha( $form, data.captcha ); 485 } 486 487 if ( data.quiz ) { 488 refillQuiz( $form, data.quiz ); 489 } 490 } 491 }; 492 493 wpcf7.clearResponse = function( form ) { 494 var $form = $( form ); 495 $form.siblings( '.screen-reader-response' ).html( '' ); 496 497 $( '.wpcf7-not-valid-tip', $form ).remove(); 498 $( '[aria-invalid]', $form ).attr( 'aria-invalid', 'false' ); 499 $( '.wpcf7-form-control', $form ).removeClass( 'wpcf7-not-valid' ); 500 501 $( '.wpcf7-response-output', $form ).hide().empty(); 502 503 }; 504 505 wpcf7.apiSettings.getRoute = function( path ) { 506 var url = wpcf7.apiSettings.root; 507 508 url = url.replace( 509 wpcf7.apiSettings.namespace, 510 wpcf7.apiSettings.namespace + path ); 511 512 return url; 513 }; 514 515} )( jQuery ); 516 517/* 518 * Polyfill for Internet Explorer 519 * See https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent 520 */ 521( function () { 522 if ( typeof window.CustomEvent === "function" ) return false; 523 524 function CustomEvent ( event, params ) { 525 params = params || { bubbles: false, cancelable: false, detail: undefined }; 526 var evt = document.createEvent( 'CustomEvent' ); 527 evt.initCustomEvent( event, 528 params.bubbles, params.cancelable, params.detail ); 529 return evt; 530 } 531 532 CustomEvent.prototype = window.Event.prototype; 533 534 window.CustomEvent = CustomEvent; 535} )();
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.