PageSourceSearch

https://finblick.com/wp-content/themes/cloudwharf_new/assets/js/forms/forms.js?20260903_1

js finblick.com collected 2026-09-29 16:07:28 UTC 5,840 bytes, 158 lines download raw bytes

1(function () {
2  "use strict";
3  document.addEventListener(
4    "DOMContentLoaded",
5    function () {
6      // Fetch all the forms we want to apply custom Bootstrap validation styles to
7      var forms = document.getElementsByClassName("needs-validation");
8      // Loop over them and prevent submission
9      var validation = Array.prototype.filter.call(forms, function (form) {
10        // form.addEventListener('submit', function(event) {
11        //     if (form.checkValidity()) {
12
13        //       //-----------------------------------------------------------------------
14        //       //var urlToPardot = "https://go.cloudwharf.com/l/722213/2019-03-26/g9h3";
15
16        //       if($(form).hasClass("CONTACT_FORM")){
17        //         $(form).attr("action", "https://go.cloudwharf.com/l/722213/2026-02-09/35vv5l");
18        //         $(form).submit();
19        //       }else
20        //       if($(form).hasClass("SUPPORT_FORM")){
21        //         $(form).attr("action", "https://webto.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8&orgId=00D61000000elGB");
22        //         $(form).submit();
23        //       }else{
24        //         $(form).submit();
25        //       }
26
27        //       /*
28        //       if($(form).hasClass("WEBINAR_FORM")){
29        //         // alert("!!!!!");
30        //         $(form).attr("action", "https://go.cloudwharf.com/l/722213/2024-11-06/353gvg");
31        //         //$("form.CONTACT_FORM").submit();
32        //       }*/
33
34        //       /*
35        //       $('#started').modal('hide');
36        //       $('#success').modal('show');
37        //       */
38        //       //-----------------------------------------------------------------------
39
40        //     }
41        //     event.preventDefault();
42        //     event.stopPropagation();
43        //     form.classList.add('was-validated');
44
45        //     let invalidInputsJS = this.querySelectorAll('.was-validated :invalid');
46        //     if(invalidInputsJS.length > 0){
47        //         invalidInputsJS[0].focus();
48        //         // Делаем скролл к невалидному полю
49        //         let scrollValue = invalidInputsJS[0].getBoundingClientRect().top + scrollLayout.scrollTop - 20
50        //         setTimeout(()=>{
51        //             scrollLayout.scrollTop = scrollValue
52        //         }, 10)
53        //     }
54        //     // console.log(form.closest('.container').querySelector('.feedback-success'))
55
56        // }, false);
57
58        form.addEventListener("submit", function (event) {
59          event.preventDefault();
60          event.stopPropagation();
61
62          if (!form.checkValidity()) {
63            form.classList.add("was-validated");
64
65            // Находим все невалидные поля
66            let invalidInputsJS = this.querySelectorAll(":invalid");
67
68            if (invalidInputsJS.length > 0) {
69              let firstInvalidInput = invalidInputsJS[0];
70
71              // Ставим фокус на поле
72              firstInvalidInput.focus();
73
74              // Нативный и точный скролл к элементу (браузер всё сделает сам)
75              firstInvalidInput.scrollIntoView({
76                behavior: "smooth",
77                block: "center", // Прокрутит так, чтобы поле оказалось по центру экрана/модалки
78              });
79            }
80            return;
81          }
82
83          const formData = new FormData(form);
84
85          // проверяем наличие капчи
86          const captcha = formData.get("frc-captcha-response");
87          if (!captcha) {
88            alert("Please complete the captcha");
89            return;
90          }
91
92          // определяем тип формы
93          if ($(form).hasClass("CONTACT_FORM")) {
94            formData.append("form_type", "contact");
95          } else if ($(form).hasClass("SUPPORT_FORM")) {
96            formData.append("form_type", "support");
97          }
98
99          fetch("/wp-json/custom/v1/submit-form", {
100            method: "POST",
101            body: formData,
102          })
103            .then((res) => res.json())
104            .then((data) => {
105              if (data.success) {
106                // Прячем модалку с формой и показываем модалку успеха
107                if ($(form).hasClass("CONTACT_FORM")) {
108                  $("#started").modal("hide");
109                } else if ($(form).hasClass("SUPPORT_FORM")) {
110                  $("#support").modal("hide");
111                }
112
113                $("#success").modal("show");
114
115                form.reset(); // Очищаем поля формы
116              } else {
117                alert(data.message || "Submission failed");
118              }
119            })
120            .catch(() => {
121              alert("Network error");
122            })
123            .finally(() => {
124              const captchaElement = form.querySelector(".frc-captcha");
125              captchaElement?.["frcWidget"]?.reset();
126            });
127        });
128      });
129    },
130    false,
131  );
132
133  // alert("!!")
134  $(document).on("focusin", ".animated-form .form-control", function () {
135    $(this).parent().addClass("active");
136  });
137
138  $(document).on("focusout", ".animated-form .form-control", function () {
139    if ($(this).val() == "") {
140      $(this).siblings("label").removeClass("no-trans");
141      $(this).parent().removeClass("active");
142    }
143  });
144
145  checkFormLabelsPosition();
146  function checkFormLabelsPosition() {
147    let inputsList = $(".animated-form .form-control");
148    inputsList.each(function () {
149      if ($(this).val() === "") {
150        $(this).parent().removeClass("active");
151      } else {
152        $(this).parent().addClass("active");
153      }
154    });
155  }
156
157  // VALIDATION FUNCTIONS
158})();

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.