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