PageSourceSearch

https://kirah.com/wp-content/plugins/cf7-multi-step/assets/frontend/js/cf7mls.js?ver=2.8.0

js kirah.com collected 2026-10-09 23:35:07 UTC 22,101 bytes, 580 lines download raw bytes

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