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 console.log($form); 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//-----------------------------------------------------------------------Custom---------------------------------------------------------- 183if( $form.find(".container-cf7-steps").length > 0 ) { 184 185 var step_comfirm_html = '<div class="cf7-container-step-confirm">'; 186 var cout_tab = $(".cf7-display-steps-container li").length - 2; 187 188 189 190 $( ".cf7-display-steps-container li" ).each(function( index ) { 191 if( index > cout_tab ){ 192 return; 193 } 194 step_comfirm_html +='<div class="cf7-step-confirm-title">'+ $( this ).text() +'</div>'; 195 var tab_name = $(this).data("tab"); 196 var name_tab = []; 197 $( tab_name + " input," + tab_name + " select," + tab_name +" textarea" ).each(function( index, joc ) { 198 if ($(this).attr("name") != "" && typeof $(this).attr("name") != 'undefined') { 199 var name = $(this).attr("name").replace("[]", ""); 200 if( name_tab.indexOf(name) < 0 ) { 201 name_tab.push(name); 202 var value = cf7_step_confirm[name]; 203 if(value === undefined || value == "" ) { 204 value = name 205 } 206 var type =$(this).attr("type"); 207 var data =""; 208 if( type == "radio" ){ 209 var chkArray = []; 210 $("input[name="+name+"]:checked").each(function() { 211 chkArray.push($(this).val()); 212 }); 213 data = chkArray.join(',') ; 214 } else if(type == "checkbox"){ 215 var chkArray = []; 216 $('input[name="'+name+'[]"]:checked').each(function() { 217 chkArray.push($(this).val()); 218 }); 219 data = chkArray.join(',') ; 220 } else{ 221 data = $(this).val(); 222 } 223 step_comfirm_html +='<div class="cf7-step-confirm-item"><div class="cf7-step-confirm-name">'+ value+': </div><div class="cf7-step-confirm-value">'+ data +'</div></div>'; 224 } 225 } 226 }) 227 //console.log(name_tab); 228 229 }); 230 //console.log(1); 231 step_comfirm_html +="</div>"; 232 $(".cf7-data-confirm").html(step_comfirm_html); 233 var tab_current = $( '.wpcf7_check_tab', $form ).val(); 234 $(".cf7-tab-"+tab_current + " .multistep-nav-right .ajax-loader", $form).removeClass("hidden"); 235 $( '[placeholder].placeheld', $form ).each( function( i, n ) { 236 $( n ).val( '' ); 237 } ); 238 239 wpcf7.clearResponse( $form ); 240 $( '.ajax-loader', $form ).addClass( 'is-active' ); 241 242 if ( typeof window.FormData !== 'function' ) { 243 return; 244 } 245 246 var formData = new FormData( $form.get( 0 ) ); 247 248 var ajaxSuccess = function( data, status, xhr, $form ) { 249 $(".multistep-nav .ajax-loader", $form).addClass("hidden"); 250 251 var detail = { 252 id: $( data.into ).attr( 'id' ),
253 status: data.status, 254 inputs: [] 255 }; 256 257 $.each( $form.serializeArray(), function( i, field ) { 258 if ( '_wpcf7' == field.name ) { 259 detail.contactFormId = field.value; 260 } else if ( '_wpcf7_version' == field.name ) { 261 detail.pluginVersion = field.value; 262 } else if ( '_wpcf7_locale' == field.name ) { 263 detail.contactFormLocale = field.value; 264 } else if ( '_wpcf7_unit_tag' == field.name ) { 265 detail.unitTag = field.value; 266 } else if ( '_wpcf7_container_post' == field.name ) { 267 detail.containerPostId = field.value; 268 } else if ( field.name.match( /^_/ ) ) { 269 // do nothing 270 } else { 271 detail.inputs.push( field ); 272 } 273 } ); 274 275 var $message = $( '.wpcf7-response-output', $form ); 276 277 switch ( data.status ) { 278 case 'validation_failed': 279 var error_tab = false; 280 var tab_current = parseInt( $(".wpcf7_check_tab", $form).val() ); 281 282 $.each( data.invalidFields, function( i, n ) { 283 $( n.into, $form ).each( function() { 284 285 if( $(".cf7-tab-"+tab_current +" " +n.into , $form ).length > 0 ) { 286 error_tab = true; 287 wpcf7.notValidTip( this, n.message ); 288 $form.find( ".cf7-tab-"+tab_current +" "+n.into, $form ).find( '.wpcf7-form-control' ).addClass( 'wpcf7-not-valid' ); 289 $form.find( ".cf7-tab-"+tab_current +" "+n.into, $form ).find( '[aria-invalid]' ).attr( 'aria-invalid', 'true' ); 290 } 291 292 } ); 293 } ); 294 if( !error_tab ) { 295 /* 296 * Next tab 297 */ 298 var next_tab = tab_current+1; 299 $(".cf7-tab", $form).addClass("hidden"); 300 $(".cf7-tab-"+next_tab, $form).removeClass("hidden"); 301 $(".wpcf7_check_tab", $form).val( next_tab ).change(); 302 $(".wpcf7-response-output", $form).addClass("hidden"); 303 $(".cf7-display-steps-container li", $form).removeClass("active"); 304 $(".cf7-display-steps-container .cf7-steps-"+next_tab, $form).addClass("active"); 305 for(var i=1;i<next_tab;i++){ 306 $(".cf7-display-steps-container li.cf7-steps-"+i, $form).addClass("enabled"); 307 } 308 $(".cf7-tab-"+tab_current + " .multistep-nav-right .ajax-loader", $form).addClass("hidden"); 309 var top = $('.container-multistep-header', $form).offset().top - 200; 310 311 $('html, body').animate({scrollTop : top},800); 312 // var tab_final = next_tab + 1; 313 if( next_tab == $(".multistep_total", $form).val() ){ 314 $(".multistep-check input", $form).val("ok"); 315 } 316 }else{ 317 $(".wpcf7-response-output", $form).removeClass("hidden"); 318 } 319 320 321 $message.addClass( 'wpcf7-validation-errors' ); 322 $form.addClass( 'invalid' ); 323 324 wpcf7.triggerEvent( data.into, 'invalid', detail ); 325 break; 326 case 'spam': 327 $message.addClass( 'wpcf7-spam-blocked' ); 328 $form.addClass( 'spam' ); 329 330 $( '[name="g-recaptcha-response"]', $form ).each( function() { 331 if ( '' === $( this ).val() ) { 332 var $recaptcha = $( this ).closest( '.wpcf7-form-control-wrap' ); 333 wpcf7.notValidTip( $recaptcha, wpcf7.recaptcha.messages.empty ); 334 } 335 } ); 336 337 wpcf7.triggerEvent( data.into, 'spam', detail ); 338 break; 339 case 'mail_sent': 340 $message.addClass( 'wpcf7-mail-sent-ok' ); 341 $form.addClass( 'sent' ); 342 343 if ( data.onSentOk ) { 344 $.each( data.onSentOk, function( i, n ) { eval( n ) } ); 345 } 346 347 wpcf7.triggerEvent( data.into, 'mailsent', detail ); 348 $(".cf7-display-steps-container li", $form).removeClass("enabled").removeClass("active"); 349 $(".cf7-steps-1", $form).addClass("active"); 350 $(".cf7-tab", $form).addClass("hidden"); 351 $(".cf7-tab-1", $form).removeClass("hidden"); 352 $(".wpcf7_check_tab", $form).val(1); 353 $(".wpcf7-response-output", $form).removeClass("hidden"); 354 var top = $('.container-multistep-header', $form).offset().top - 200; 355 356 $('html, body').animate({scrollTop : top},800); 357 if( $form.find(".cf7-thankyou-page-success").length > 0 ) { 358 var check = $form.find('.cf7-thankyou-page-success').val(); 359 if( check != 0 ){ 360 window.location.href = check; 361 } 362 } 363 364 break; 365 case 'mail_failed': 366 case 'acceptance_missing': 367 default: 368 369 $message.addClass( 'wpcf7-mail-sent-ng' ); 370 $form.addClass( 'failed' ); 371 372 wpcf7.triggerEvent( data.into, 'mailfailed', detail ); 373 if( $form.find(".cf7-thankyou-page-failed").length > 0 ) { 374 var check = $form.find('.cf7-thankyou-page-failed').val(); 375 if( check != 0 ){ 376 window.location.href = check; 377 } 378 } 379 } 380 381 wpcf7.refill( $form, data ); 382 383 if ( data.onSubmit ) { 384 $.each( data.onSubmit, function( i, n ) { eval( n ) } ); 385 } 386 387 wpcf7.triggerEvent( data.into, 'submit', detail ); 388 389 if ( 'mail_sent' == data.status ) { 390 $form.each( function() { 391 this.reset(); 392 } ); 393 } 394 395 $form.find( '[placeholder].placeheld' ).each( function( i, n ) { 396 $( n ).val( $( n ).attr( 'placeholder' ) ); 397 } ); 398 399 $message.append( data.message ).slideDown( 'fast' ); 400 $message.attr( 'role', 'alert' ); 401 402 $( '.screen-reader-response', $form.closest( '.wpcf7' ) ).each( function() { 403 var $response = $( this ); 404 $response.html( '' ).attr( 'role', '' ).append( data.message ); 405 406 if ( data.invalidFields ) { 407 var $invalids = $( '<ul></ul>' ); 408 409 $.each( data.invalidFields, function( i, n ) { 410 if ( n.idref ) { 411 var $li = $( '<li></li>' ).append( $( '<a></a>' ).attr( 'href', '#' + n.idref ).append( n.message ) ); 412 } else { 413 var $li = $( '<li></li>' ).append( n.message ); 414 } 415 416 $invalids.append( $li ); 417 } ); 418
419 $response.append( $invalids ); 420 } 421 422 $response.attr( 'role', 'alert' ).focus(); 423 } ); 424 }; 425 426 $.ajax( { 427 type: 'POST', 428 url: wpcf7.apiSettings.root + wpcf7.apiSettings.namespace + 429 '/contact-forms/' + wpcf7.getId( $form ) + '/feedback', 430 data: formData, 431 dataType: 'json', 432 processData: false, 433 contentType: false 434 } ).done( function( data, status, xhr ) { 435 ajaxSuccess( data, status, xhr, $form ); 436 $( '.ajax-loader', $form ).removeClass( 'is-active' ); 437 } ).fail( function( xhr, status, error ) { 438 var $e = $( '<div class="ajax-error"></div>' ).text( error.message ); 439 $form.after( $e ); 440 } ); 441 442//----------------------------------------------------------------------------End custom--------------------------------------------------------- 443 }else { 444 445 446 $( '[placeholder].placeheld', $form ).each( function( i, n ) { 447 $( n ).val( '' ); 448 } ); 449 450 wpcf7.clearResponse( $form ); 451 $( '.ajax-loader', $form ).addClass( 'is-active' ); 452 453 if ( typeof window.FormData !== 'function' ) { 454 return; 455 } 456 457 var formData = new FormData( $form.get( 0 ) ); 458 459 var ajaxSuccess = function( data, status, xhr, $form ) { 460 var detail = { 461 id: $( data.into ).attr( 'id' ), 462 status: data.status, 463 inputs: [] 464 }; 465 466 $.each( $form.serializeArray(), function( i, field ) { 467 if ( '_wpcf7' == field.name ) { 468 detail.contactFormId = field.value; 469 } else if ( '_wpcf7_version' == field.name ) { 470 detail.pluginVersion = field.value; 471 } else if ( '_wpcf7_locale' == field.name ) { 472 detail.contactFormLocale = field.value; 473 } else if ( '_wpcf7_unit_tag' == field.name ) { 474 detail.unitTag = field.value; 475 } else if ( '_wpcf7_container_post' == field.name ) { 476 detail.containerPostId = field.value; 477 } else if ( field.name.match( /^_/ ) ) { 478 // do nothing 479 } else { 480 detail.inputs.push( field ); 481 } 482 } ); 483 484 var $message = $( '.wpcf7-response-output', $form ); 485 486 switch ( data.status ) { 487 case 'validation_failed': 488 $.each( data.invalidFields, function( i, n ) { 489 $( n.into, $form ).each( function() { 490 wpcf7.notValidTip( this, n.message ); 491 $( '.wpcf7-form-control', this ).addClass( 'wpcf7-not-valid' ); 492 $( '[aria-invalid]', this ).attr( 'aria-invalid', 'true' ); 493 } ); 494 } ); 495 496 $message.addClass( 'wpcf7-validation-errors' ); 497 $form.addClass( 'invalid' ); 498 499 wpcf7.triggerEvent( data.into, 'invalid', detail ); 500 break; 501 case 'spam': 502 $message.addClass( 'wpcf7-spam-blocked' ); 503 $form.addClass( 'spam' ); 504 505 $( '[name="g-recaptcha-response"]', $form ).each( function() { 506 if ( '' === $( this ).val() ) { 507 var $recaptcha = $( this ).closest( '.wpcf7-form-control-wrap' ); 508 wpcf7.notValidTip( $recaptcha, wpcf7.recaptcha.messages.empty ); 509 } 510 } ); 511 512 wpcf7.triggerEvent( data.into, 'spam', detail ); 513 break; 514 case 'mail_sent': 515 $message.addClass( 'wpcf7-mail-sent-ok' ); 516 $form.addClass( 'sent' ); 517 518 if ( data.onSentOk ) { 519 $.each( data.onSentOk, function( i, n ) { eval( n ) } ); 520 } 521 522 wpcf7.triggerEvent( data.into, 'mailsent', detail ); 523 if( $form.find(".cf7-thankyou-page-success").length > 0 ) { 524 var check = $form.find('.cf7-thankyou-page-success').val(); 525 if( check != 0 ){ 526 window.location.href = check; 527 } 528 } 529 break; 530 case 'mail_failed': 531 case 'acceptance_missing': 532 default: 533 $message.addClass( 'wpcf7-mail-sent-ng' ); 534 $form.addClass( 'failed' ); 535 536 wpcf7.triggerEvent( data.into, 'mailfailed', detail ); 537 if( $form.find(".cf7-thankyou-page-failed").length > 0 ) { 538 var check = $form.find('.cf7-thankyou-page-failed').val(); 539 if( check != 0 ){ 540 window.location.href = check; 541 } 542 } 543 } 544 545 wpcf7.refill( $form, data ); 546 547 if ( data.onSubmit ) { 548 $.each( data.onSubmit, function( i, n ) { eval( n ) } ); 549 } 550 551 wpcf7.triggerEvent( data.into, 'submit', detail ); 552 553 if ( 'mail_sent' == data.status ) { 554 $form.each( function() { 555 this.reset(); 556 } ); 557 } 558 559 $form.find( '[placeholder].placeheld' ).each( function( i, n ) { 560 $( n ).val( $( n ).attr( 'placeholder' ) ); 561 } ); 562 563 $message.append( data.message ).slideDown( 'fast' ); 564 $message.attr( 'role', 'alert' ); 565 566 $( '.screen-reader-response', $form.closest( '.wpcf7' ) ).each( function() { 567 var $response = $( this ); 568 $response.html( '' ).attr( 'role', '' ).append( data.message ); 569 570 if ( data.invalidFields ) { 571 var $invalids = $( '<ul></ul>' ); 572 573 $.each( data.invalidFields, function( i, n ) { 574 if ( n.idref ) { 575 var $li = $( '<li></li>' ).append( $( '<a></a>' ).attr( 'href', '#' + n.idref ).append( n.message ) ); 576 } else { 577 var $li = $( '<li></li>' ).append( n.message ); 578 } 579 580 $invalids.append( $li ); 581 } ); 582
583 $response.append( $invalids ); 584 } 585 586 $response.attr( 'role', 'alert' ).focus(); 587 } ); 588 }; 589 590 $.ajax( { 591 type: 'POST', 592 url: wpcf7.apiSettings.root + wpcf7.apiSettings.namespace + 593 '/contact-forms/' + wpcf7.getId( $form ) + '/feedback', 594 data: formData, 595 dataType: 'json', 596 processData: false, 597 contentType: false 598 } ).done( function( data, status, xhr ) { 599 ajaxSuccess( data, status, xhr, $form ); 600 $( '.ajax-loader', $form ).removeClass( 'is-active' ); 601 } ).fail( function( xhr, status, error ) { 602 var $e = $( '<div class="ajax-error"></div>' ).text( error.message ); 603 $form.after( $e ); 604 } ); 605 606 607 } 608 /* 609 End custom 610 */ 611 }; 612 613 wpcf7.triggerEvent = function( target, name, detail ) { 614 var $target = $( target ); 615 616 /* DOM event */ 617 var event = new CustomEvent( 'wpcf7' + name, { 618 bubbles: true, 619 detail: detail 620 } ); 621 622 $target.get( 0 ).dispatchEvent( event ); 623 624 /* jQuery event */ 625 $target.trigger( 'wpcf7:' + name, detail ); 626 $target.trigger( name + '.wpcf7', detail ); // deprecated 627 }; 628 629 wpcf7.toggleSubmit = function( form, state ) { 630 var $form = $( form ); 631 var $submit = $( 'input:submit', $form ); 632 633 if ( typeof state !== 'undefined' ) { 634 $submit.prop( 'disabled', ! state ); 635 return; 636 } 637 638 if ( $form.hasClass( 'wpcf7-acceptance-as-validation' ) ) { 639 return; 640 } 641 642 $submit.prop( 'disabled', false ); 643 644 $( 'input:checkbox.wpcf7-acceptance', $form ).each( function() { 645 var $a = $( this ); 646 647 if ( $a.hasClass( 'wpcf7-invert' ) && $a.is( ':checked' ) 648 || ! $a.hasClass( 'wpcf7-invert' ) && ! $a.is( ':checked' ) ) { 649 $submit.prop( 'disabled', true ); 650 return false; 651 } 652 } ); 653 }; 654 655 wpcf7.notValidTip = function( target, message ) { 656 var $target = $( target ); 657 $( '.wpcf7-not-valid-tip', $target ).remove(); 658 $( '<span role="alert" class="wpcf7-not-valid-tip"></span>' ) 659 .text( message ).appendTo( $target ); 660 661 if ( $target.is( '.use-floating-validation-tip *' ) ) { 662 var fadeOut = function( target ) { 663 $( target ).not( ':hidden' ).animate( { 664 opacity: 0 665 }, 'fast', function() { 666 $( this ).css( { 'z-index': -100 } ); 667 } ); 668 } 669 670 $target.on( 'mouseover', '.wpcf7-not-valid-tip', function() { 671 fadeOut( this ); 672 } ); 673 674 $target.on( 'focus', ':input', function() { 675 fadeOut( $( '.wpcf7-not-valid-tip', $target ) ); 676 } ); 677 } 678 } 679 680 wpcf7.refill = function( form, data ) { 681 var $form = $( form ); 682 683 var refillCaptcha = function( $form, items ) { 684 $.each( items, function( i, n ) { 685 $form.find( ':input[name="' + i + '"]' ).val( '' );
686 $form.find( 'img.wpcf7-captcha-' + i ).attr( 'src', n ); 687 var match = /([0-9]+)\.(png|gif|jpeg)$/.exec( n ); 688 $form.find( 'input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]' ).attr( 'value', match[ 1 ] ); 689 } ); 690 }; 691 692 var refillQuiz = function( $form, items ) { 693 $.each( items, function( i, n ) { 694 $form.find( ':input[name="' + i + '"]' ).val( '' ); 695 $form.find( ':input[name="' + i + '"]' ).siblings( 'span.wpcf7-quiz-label' ).text( n[ 0 ] ); 696 $form.find( 'input:hidden[name="_wpcf7_quiz_answer_' + i + '"]' ).attr( 'value', n[ 1 ] ); 697 } ); 698 }; 699 700 if ( typeof data === 'undefined' ) { 701 $.ajax( { 702 type: 'GET', 703 url: wpcf7.apiSettings.root + wpcf7.apiSettings.namespace + 704 '/contact-forms/' + wpcf7.getId( $form ) + '/refill', 705 dataType: 'json' 706 } ).done( function( data, status, xhr ) { 707 if ( data.captcha ) { 708 refillCaptcha( $form, data.captcha ); 709 } 710 711 if ( data.quiz ) { 712 refillQuiz( $form, data.quiz ); 713 } 714 } ); 715 716 } else { 717 if ( data.captcha ) { 718 refillCaptcha( $form, data.captcha ); 719 } 720 721 if ( data.quiz ) { 722 refillQuiz( $form, data.quiz ); 723 } 724 } 725 }; 726 727 wpcf7.clearResponse = function( form ) { 728 var $form = $( form ); 729 $form.removeClass( 'invalid spam sent failed' ); 730 $form.siblings( '.screen-reader-response' ).html( '' ).attr( 'role', '' ); 731 732 $( '.wpcf7-not-valid-tip', $form ).remove(); 733 $( '[aria-invalid]', $form ).attr( 'aria-invalid', 'false' ); 734 $( '.wpcf7-form-control', $form ).removeClass( 'wpcf7-not-valid' ); 735 736 $( '.wpcf7-response-output', $form ) 737 .hide().empty().removeAttr( 'role' ) 738 .removeClass( 'wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked' ); 739 }; 740 741} )( jQuery ); 742 743/* 744 * Polyfill for Internet Explorer 745 * See https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent 746 */ 747( function () { 748 if ( typeof window.CustomEvent === "function" ) return false; 749 750 function CustomEvent ( event, params ) { 751 params = params || { bubbles: false, cancelable: false, detail: undefined }; 752 var evt = document.createEvent( 'CustomEvent' ); 753 evt.initCustomEvent( event, 754 params.bubbles, params.cancelable, params.detail ); 755 return evt; 756 } 757 758 CustomEvent.prototype = window.Event.prototype; 759 760 window.CustomEvent = CustomEvent; 761} )();
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.