PageSourceSearch

https://www.barnabaautosport.com/wp-content/plugins/cf7-multi-step/assets/frontend/js/cf7mls.js?ver=2.7.3

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