https://thelearningapps.com/wp-content/plugins/cf7-multi-step/assets/frontend/js/cf7mls.js?ver=2.7.5
1(function ($) { 2 //jQuery time 3 var current_fs, next_fs, previous_fs; //fieldsets 4 var left, opacity, scale; //fieldset properties which we will animate 5 var animating; //flag to prevent quick multi-click glitches 6 var has_response = false; 7 var next_clicked = false; 8 9 jQuery(document).ready(function ($) { 10 if(typeof next_clicked === 'undefined') 11 next_clicked = false; 12 if(typeof has_response === 'undefined') 13 has_response = false; 14 $("form.wpcf7-form").each(function (index, el) { 15 var totalFieldset = 0; 16 var this_form = $(el); 17 var findFieldset = $(el).find("fieldset.fieldset-cf7mls"); 18 if (findFieldset.length > 0) { 19 this_form.addClass('cf7mls') 20 $.each(findFieldset, function (i2, el2) { 21 if (i2 == 0) { 22 $(el2).addClass("cf7mls_current_fs"); 23 } 24 25 jQuery(el2).attr("data-cf7mls-order", i2); 26 totalFieldset = totalFieldset + 1; 27 //disable next button if the fieldset has wpcf7-acceptance 28 var acceptances = jQuery(el2).find("input:checkbox.wpcf7-acceptance"); 29 if (acceptances.length) { 30 cf7mls_toggle_next_btn(acceptances, el2); 31 } 32 }); 33 $.each(findFieldset, function (i2, el2) { 34 if (i2 == totalFieldset - 1) { 35 $(el2) 36 .find(".cf7mls_next") 37 .remove(); 38 } 39 }); 40 $(el).attr("data-count-fieldset", totalFieldset); 41 //on form submit 42 if(cf7mls_object.disable_submit == 'true') { 43 if (cf7mls_object.disable_enter_key) { 44 $(el) 45 .find('[type="submit"]') 46 .click(function (event) { 47 var findFieldset = $(el).find( 48 "fieldset.fieldset-cf7mls.cf7mls_current_fs" 49 ); 50 if (findFieldset.data("cf7mls-order") != totalFieldset - 1) { 51 findFieldset.find(".cf7mls_next").click(); 52 return false; 53 } 54 }); 55 } else { 56 $(el).submit(function (event) { 57 var findFieldset = $(el).find( 58 "fieldset.fieldset-cf7mls.cf7mls_current_fs" 59 ); 60 if (findFieldset.data("cf7mls-order") != totalFieldset - 1) { 61 findFieldset.find(".cf7mls_next").click(); 62 return false; 63 } 64 }); 65 } 66 } 67 } 68 }); 69 70 jQuery(document).on( 71 "click", 72 "form.wpcf7-form input:checkbox.wpcf7-acceptance", 73 function (event) { 74 //event.preventDefault(); 75 var $this = jQuery(this); 76 var parent_fieldset = $this.closest("fieldset.fieldset-cf7mls"); 77 if (parent_fieldset.length) { 78 var acceptances = jQuery(parent_fieldset).find( 79 "input:checkbox.wpcf7-acceptance" 80 ); 81 if (acceptances.length) { 82 cf7mls_toggle_next_btn(acceptances, parent_fieldset); 83 } 84 } 85 } 86 ); 87 88 $(document).on("click", ".cf7mls_next", function (event) { 89 if(next_clicked == false) { 90 next_clicked = true; 91 event.preventDefault(); 92 var $this = $(this); 93 $this.addClass("sending"); 94 current_fs = $this.closest(".fieldset-cf7mls"); 95 next_fs = current_fs.next(); 96 97 var form = $this.parent().closest("form.wpcf7-form"); 98 if(form.hasClass("sent")) { 99 form.removeClass("sent"); 100 form.addClass("init"); 101 form.attr('data-status', 'init'); 102 if (form.find('.wpcf7-response-output').length) { 103 form.find('.wpcf7-response-output').html(""); 104 } 105 } 106 107 //signature fields 108 current_fs.find('.wpcf7-form-control-signature-global-wrap').each(function(j, wrapper){ 109 var f_id = $(wrapper).attr('data-field-id') 110 var canvas = $(wrapper).find('canvas') 111 if(typeof signatures != 'undefined') { 112 $.each(signatures, function(s_i, signature){ 113 if(signature.canvas.id == canvas.attr('id')) { 114 if (!signature.signature.isEmpty()){ 115 $('input[name="'+f_id+'"]').val(signature.canvas.toDataURL()) 116 }else{ 117 $('input[name="'+f_id+'"]').val("") 118 } 119 120 } 121 }) 122 } 123 }); 124 125 var fd = new FormData(form[0]); 126 127 $.ajax({ 128 url: cf7mls_object.ajax_url + "v1/cf7mls_validation", 129 type: "POST", 130 crossDomain: true, 131 data: fd, 132 processData: false, 133 contentType: false 134 }) 135 .done(function (json) { 136 $this.removeClass("sending"); 137 138 /* 139 * Insert _form_data_id if 'json variable' has 140 */ 141 if (typeof json._cf7mls_db_form_data_id != "undefined") { 142 if (!form.find('input[name="_cf7mls_db_form_data_id"]').length) { 143 form.append( 144 '<input type="hidden" name="_cf7mls_db_form_data_id" value="' + 145 json._cf7mls_db_form_data_id + 146 '" />' 147 ); 148 } 149 } 150 151 if (!json.success) { 152 var checkError = 0; 153 var firstError = null; 154 //reset error messages 155 current_fs 156 .find(".wpcf7-form-control-wrap") 157 .removeClass("cf7mls-invalid"); 158 current_fs.find(".cf7mls-invalid").removeClass("cf7mls-invalid"); 159 160 current_fs 161 .find(".wpcf7-form-control-wrap .wpcf7-not-valid-tip") 162 .remove(); 163 164 current_fs 165 .find(".wpcf7-form-control-wrap .wpcf7-not-valid") 166 .removeClass("wpcf7-not-valid"); 167 168 if (has_response) { 169 current_fs 170 .find(".wpcf7-response-output.wpcf7-validation-errors") 171 .removeClass("wpcf7-validation-errors"); 172 } else { 173 current_fs 174 .find(".wpcf7-response-output.wpcf7-validation-errors") 175 .remove(); 176 } 177 178 $.each(json.invalid_fields, function (index, el) { 179 if ( 180 current_fs.find('input[name="' + index + '"]').length || 181 current_fs.find('input[name="' + index + '[]"]').length || 182 current_fs.find('select[name="' + index + '"]').length || 183 current_fs.find('select[name="' + index + '[]"]').length || 184 current_fs.find('textarea[name="' + index + '"]').length || 185 current_fs.find('textarea[name="' + index + '[]"]').length || 186 current_fs.find('input[data-name="' + index + '"]').length || 187 current_fs.find('input[data-name="' + index + '[]"]').length 188 ) { 189 checkError = checkError + 1; 190 191 //var controlWrap = $('.wpcf7-form-control-wrap.' + index, form); 192 var controlWraps = [ 193 $('[name="' + index + '"]', form).parent(), 194 $('[name="' + index + '[]"]', form).parent(), 195 $('[data-name="' + index + '"]', form).parent(), 196 $('[data-name="' + index + '[]"]', form).parent() 197 ]; 198 $.each(controlWraps, function (i1, e1) { 199 if(e1.hasClass("wpcf7-form-control-wrap") || e1.parents(".wpcf7-form-control-wrap").length || e1.parents(".wpcf7-checkbox").length || e1.parents(".wpcf7-radio").length) { 200 var _c = "wpcf7-not-valid-tip"; 201 if (e1.hasClass("form-group")) { 202 e1.addClass("has-error"); 203 _c += " help-block"; 204 } 205 if(firstError === null) { 206 firstError = e1; 207 } 208 e1.addClass("cf7mls-invalid"); 209 e1.find("span.wpcf7-not-valid-tip").remove(); 210 e1.find(".wpcf7-validates-as-required").addClass( 211 "wpcf7-not-valid" 212 ); 213 214 if (e1.parents(".wpcf7-checkbox").length) { 215 e1.parents(".wpcf7-checkbox").after( 216 '<span role="alert" class="' + 217 _c + 218 '">' + 219 el.reason + 220 "</span>" 221 ); 222 } else if (e1.parents(".wpcf7-radio").length) { 223 e1.parents(".wpcf7-radio").after( 224 '<span role="alert" class="' + 225 _c + 226 '">' + 227 el.reason + 228 "</span>" 229 ); 230 } else if (e1.parents(".wpcf7-form-control-wrap").length) { 231 e1.parents(".wpcf7-form-control-wrap").append( 232 '<span role="alert" class="' + 233 _c + 234 '">' + 235 el.reason + 236 "</span>" 237 ); 238 } else { 239 e1.append( 240 '<span role="alert" class="' + 241 _c + 242 '">' + 243 el.reason + 244 "</span>" 245 ); 246 } 247 } 248 }); 249 250 //return false;
251 } 252 }); 253 254 if (checkError == 0) { 255 json.success = true; 256 has_response = false; 257 // jQuery("html, body").animate( 258 // { 259 // scrollTop: jQuery($this.closest("form")).offset().top - 110 260 // }, 261 // 1000 262 // ); 263 } else { 264 $('html, body').animate({ 265 scrollTop: $(firstError).offset().top - 100 266 }, 500); 267 if (current_fs.find(".wpcf7-response-output").length) { 268 has_response = true; 269 $icon = ''; 270 $icon += '<svg class="wpcf7-icon-wraning" width="18px" height="18px" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">'; 271 $icon += '<g><path d="M499.9,361.6c-12.7,0-23,10.3-23,23v352.2c0,12.7,10.3,23,23,23s23-10.3,23-23V384.6C522.9,371.9,512.6,361.6,499.9,361.6z"/>'; 272 $icon += '<path d="M500.1,240.2c-12.7,0-23,10.3-23,23v30.6c0,12.7,10.3,23,23,23c12.7,0,23-10.3,23-23v-30.6C523.1,250.5,512.8,240.2,500.1,240.2z"/>'; 273 $icon += '<path d="M500,10C229.4,10,10,229.4,10,500c0,270.6,219.4,490,490,490c270.6,0,490-219.4,490-490C990,229.4,770.6,10,500,10z M500,944.1C254.8,944.1,55.9,745.2,55.9,500C55.9,254.8,254.8,55.9,500,55.9S944.1,254.8,944.1,500C944.1,745.2,745.2,944.1,500,944.1z"/></g></svg>'; 274 current_fs 275 .find(".wpcf7-response-output") 276 .addClass("wpcf7-validation-errors") 277 .show() 278 .html($icon + json.message); 279 } else { 280 has_response = false; 281 $icon = ''; 282 $icon += '<svg class="wpcf7-icon-wraning" width="18px" height="18px" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">'; 283 $icon += '<g><path d="M499.9,361.6c-12.7,0-23,10.3-23,23v352.2c0,12.7,10.3,23,23,23s23-10.3,23-23V384.6C522.9,371.9,512.6,361.6,499.9,361.6z"/>'; 284 $icon += '<path d="M500.1,240.2c-12.7,0-23,10.3-23,23v30.6c0,12.7,10.3,23,23,23c12.7,0,23-10.3,23-23v-30.6C523.1,250.5,512.8,240.2,500.1,240.2z"/>'; 285 $icon += '<path d="M500,10C229.4,10,10,229.4,10,500c0,270.6,219.4,490,490,490c270.6,0,490-219.4,490-490C990,229.4,770.6,10,500,10z M500,944.1C254.8,944.1,55.9,745.2,55.9,500C55.9,254.8,254.8,55.9,500,55.9S944.1,254.8,944.1,500C944.1,745.2,745.2,944.1,500,944.1z"/></g></svg>'; 286 287 current_fs.append( 288 '<div class="wpcf7-response-output wpcf7-display-none wpcf7-validation-errors" style="display: block;" role="alert">' + $icon + 289 json.message + 290 "</div>" 291 ); 292 } 293 } 294 } 295 296 if (json.success) { 297 /* 298 current_fs.fadeOut('400', function() { 299 next_fs.fadeIn('400'); 300 }); 301 302 }); 303 */ 304 305 //reset error messages 306 current_fs 307 .find(".wpcf7-form-control-wrap") 308 .removeClass("cf7mls-invalid"); 309 current_fs.find(".cf7mls-invalid").removeClass("cf7mls-invalid"); 310 current_fs.find(".wpcf7-not-valid").removeClass("wpcf7-not-valid"); 311 current_fs 312 .find(".wpcf7-form-control-wrap .wpcf7-not-valid-tip") 313 .remove(); 314 315 /* 316 * Instead of hiding current fs, we hide all 317 */ 318 /* 319 current_fs.css({ 320 height: '0px', 321 overflow: 'hidden', 322 opacity: '0', 323 'visibility': 'hidden' 324 }).removeClass('cf7mls_current_fs'); 325 */ 326 327 form.find(".cf7mls_current_fs").addClass("cf7mls_back_fs"); 328 329 form.find(".fieldset-cf7mls").removeClass("cf7mls_current_fs"); 330 331 next_fs.addClass("cf7mls_current_fs"); 332 next_fs.find('input, textarea').first().focus(); 333 334 if (form.find(".cf7mls_progress_bar").length) { 335 let allow_choose_step = form.find('.cf7mls_progress_bar').attr('data-allow-choose-step'); 336 let order_cur = Number(form.find('fieldset.cf7mls-choose-step').attr('data-cf7mls-order')); 337 let step_cur = Number(form.find(".cf7mls_progress_bar li.current").attr('data-counter')) - 1; 338 339 // allow choose step 340 if(allow_choose_step === 'on') {
341 form.find('fieldset.fieldset-cf7mls').css({display: ''}); 342 form.find("fieldset.fieldset-cf7mls").removeClass("cf7mls-choose-step"); 343 } 344 345 if((allow_choose_step === 'on') && 346 ((order_cur !== step_cur) && ((order_cur === 0) || order_cur)) 347 ) { 348 form.find("fieldset.fieldset-cf7mls").removeClass("cf7mls_back_fs"); 349 form.find("fieldset.fieldset-cf7mls").removeClass("cf7mls_current_fs"); 350 351 form.find('fieldset.fieldset-cf7mls').each(function( index, el ) { 352 if(index > step_cur) { 353 return; 354 } 355 $(el).addClass("cf7mls_back_fs"); 356 if(index === step_cur) { 357 $(el).removeClass("cf7mls_back_fs"); 358 $(el).addClass("cf7mls_current_fs"); 359 } 360 }); 361 }else { 362 var cur = form.find("fieldset.fieldset-cf7mls").index(current_fs); 363 var nex = form.find("fieldset.fieldset-cf7mls").index(next_fs); 364 // if(cf7mls_object.is_rtl == '1') { 365 // cur = 0 - cur 366 // nex = 0 - nex 367 // } 368 } 369 } 370 371 dhScrollTo(form); 372 return false; 373 } else {} 374 next_clicked = false; 375 }) 376 .fail(function () { 377 $this.removeClass("sending"); 378 next_clicked = false; 379 // console.log("Validation error"); 380 }) 381 .always(function () { 382 $this.removeClass("sending"); 383 next_clicked = false; 384 // console.log("Validation complete"); 385 }); 386 387 return false; 388 } 389 }); 390 391 $(document).on("click", ".cf7mls_back", function (event) { 392 var $this = $(this); 393 var form = $this.parent().closest("form.wpcf7-form"); 394 395 $(".wpcf7-response-output.wpcf7-display-none") 396 .removeClass("wpcf7-validation-errors") 397 .removeAttr("style") 398 .html(""); 399 $(".wpcf7-response-output.wpcf7-display-none.wpcf7-mail-sent-ok").hide(); 400 401 current_fs = $this.closest(".fieldset-cf7mls"); 402 previous_fs = current_fs.prev(); 403 404 //reset error messages 405 current_fs.find(".wpcf7-form-control-wrap").removeClass("cf7mls-invalid"); 406 current_fs.find(".cf7mls-invalid").removeClass("cf7mls-invalid"); 407 current_fs.find(".wpcf7-not-valid").removeClass("wpcf7-not-valid"); 408 current_fs.find(".wpcf7-form-control-wrap .wpcf7-not-valid-tip").remove(); 409 410 /* 411 * Instead of hide current fs, we hide all 412 */ 413 /*current_fs.css({ 414 height: '0px', 415 overflow: 'hidden', 416 opacity: '0', 417 'visibility': 'hidden' 418 }).removeClass('cf7mls_current_fs');*/ 419 form.find(".fieldset-cf7mls").removeClass("cf7mls_current_fs"); 420 421 previous_fs.addClass("cf7mls_current_fs").removeClass("cf7mls_back_fs"); 422 423 dhScrollTo(form); 424 return false; 425 }); 426 427 $(document).on("click", ".cf7mls-auto-next-step", function (event) { 428 var $this = $(this); 429 if($this.is("input")) { 430 $(document).on("change", $this, function (event) { 431 var currentFieldSet = $this.parent().closest("fieldset.fieldset-cf7mls"); 432 $(currentFieldSet).find( ".cf7mls_next" ).trigger('click'); 433 }); 434 }else { 435 var currentFieldSet = $this.parent().closest("fieldset.fieldset-cf7mls"); 436 $(currentFieldSet).find( ".cf7mls_next" ).trigger('click'); 437 } 438 439 }); 440 441 $(document).on("wpcf7mailsent", ".wpcf7-form.cf7mls-auto-return-first-step", function (event) { 442 $(this).find(".fieldset-cf7mls-wrapper fieldset.fieldset-cf7mls").each(function(index) { 443 if($(this).hasClass('cf7mls_back_fs')) { 444 $(this).removeClass('cf7mls_back_fs'); 445 } 446 447 if(index != 0) { 448 if($(this).hasClass('cf7mls_current_fs')) { 449 $(this).removeClass('cf7mls_current_fs'); 450 } 451 } else { 452 if(!$(this).hasClass('cf7mls_current_fs')) { 453 $(this).addClass('cf7mls_current_fs'); 454 } 455 } 456 }); 457 }); 458 459 function dhScrollTo(el) { 460 if (el.find(".fieldset-cf7mls-wrapper.no-scroll").length || el.hasClass('cf7mls-no-scroll')) { 461 return; 462 } 463 if (cf7mls_object.scroll_step == "true") { 464 $("html, body").animate({ 465 scrollTop: el.offset().top - 110 466 }, 467 "slow" 468 ); 469 } else if (cf7mls_object.scroll_step == "scroll_to_top") { 470 $("html, body").animate({ 471 scrollTop: $("body").offset().top - 110 472 }, 473 "slow" 474 ); 475 } 476 } 477 478 function cf7mls_toggle_next_btn(acceptances, fieldset) { 479 if (acceptances.length > 0) { 480 var ii = 0; 481 $.each(acceptances, function (i, v) { 482 if ($(v).is(":checked")) { 483 //console.log('checked'); 484 } else { 485 ii++; 486 } 487 }); 488 if (ii > 0) { 489 //console.log(ii); 490 $(fieldset) 491 .find(".cf7mls_next") 492 .attr("disabled", "disabled"); 493 } else { 494 $(fieldset) 495 .find(".cf7mls_next") 496 .removeAttr("disabled"); 497 } 498 } 499 } 500 }); 501 502 503 504})(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.