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