1$(function(){ 2 3 var sendWebForm = function(event, data){ 4 5 var formData = new FormData(this); 6 var requiredErrorPosition = false; 7 var requiredError = false; 8 9 var $thisForm = $(this).addClass("loading"); 10 var $parentThis = $thisForm.parents(".webFormDw"); 11 var $thisFormFields = $thisForm.find(".webFormItemField"); 12 var $thisFormErrors = $thisForm.find(".webFormItemError"); 13 var $submitButton = $thisForm.find('input[type="submit"]').addClass("loading"); 14 var $webFormError = $thisForm.find(".webFormError"); 15 var $webFormCaptchaSid = $thisForm.find(".webFormCaptchaSid"); 16 var $webFormCaptchaImage = $thisForm.find(".webFormCaptchaImage"); 17 18 var formId = $parentThis.data("id"); 19 20 $thisFormFields.each(function(i, nextField){ 21 22 var $nextField = $(nextField); 23 if($nextField.data("required") == "Y"){ 24 var $nextFieldEx = $nextField.find('input[type="text"], input[type="password"], input[type="file"], input[type="checkbox"], select, textarea'); 25 if($nextFieldEx.attr("name")){ 26 if(!$nextFieldEx.val() || $nextFieldEx.val().length == 0){ 27 $nextFieldEx.addClass("error"); 28 if(!requiredError){ 29 requiredErrorPosition = $nextFieldEx.offset().top; 30 requiredError = true; 31 } 32 } 33 } 34 if($nextFieldEx.attr("type") == 'checkbox'){ 35 if(!$nextFieldEx.is(":checked")){ 36 $nextFieldEx.parent().addClass("error"); 37 if (!requiredError) { 38 requiredErrorPosition = $nextFieldEx.offset().top; 39 requiredError = true; 40 } 41 } 42 } 43 } 44 }); 45 46 console.log('default'); 47 formData.set('g-recaptcha-response', ''); 48 49 grecaptcha.ready(function () { 50 grecaptcha.execute('6Le697gpAAAAAC4BMoHBbAYFi1XI1Ab5pOKx5mab').then(function (token) { 51 formData.set('g-recaptcha-response', token); 52 if (requiredError == false) { 53 $.ajax({
54 url: webFormAjaxDir + "?FORM_ID=" + formId + "&SITE_ID=" + webFormSiteId, 55 data: formData, 56 cache: false, 57 contentType: false, 58 processData: false, 59 enctype: "multipart/form-data", 60 type: "POST", 61 dataType: "json", 62 success: function (response) { 63 64 //remove error labels 65 $thisFormErrors.empty().removeClass("visible"); 66 $webFormError.empty().removeClass("visible"); 67 68 if (response["SUCCESS"] != "Y") { 69 70 //set errors 71 $.each(response["ERROR"], function (nextId, nextValue) { 72 var $errorItemContainer = $("#WEB_FORM_ITEM_" + nextId); 73 if (nextId != 0 && $errorItemContainer) { 74 $errorItemContainer.find(".webFormItemError").html(nextValue).addClass("visible"); 75 } else { 76 $webFormError.append(nextValue).addClass("visible"); 77 } 78 }); 79 80 // reload captcha 81 if (response["CAPTCHA"]) { 82 $webFormCaptchaSid.val(response["CAPTCHA"]["CODE"]); 83 $webFormCaptchaImage.attr("src", response["CAPTCHA"]["PICTURE"]); 84 } 85 86 } else { 87 $("#webFormMessage_" + formId).css({ 88 display: "block" 89 });
90 $thisForm[0].reset(); 91 if (typeof ingEvents !== "undefined") { 92 ingEvents.init({}); 93 if (formId === 2) 94 ingEvents.Event({ 95 category: 'forms', 96 action: 'submit', 97 label: 'feedback', 98 ya_label: 'feedback' 99 }); 100 } 101 } 102 103 //remove loader 104 $thisForm.removeClass("loading"); 105 $submitButton.removeClass("loading"); 106 107 } 108 109 }); 110 } else { 111 112 if (requiredErrorPosition) { 113 $("html, body").animate({ 114 "scrollTop": requiredErrorPosition - $(window).height() / 2 115 }, 250); 116 } 117 118 $thisForm.removeClass("loading"); 119 $submitButton.removeClass("loading"); 120 } 121 }); 122 }); 123 return event.preventDefault(); 124 125 } 126 127 var removeErrors = function(event){ 128 $(this).removeClass("error"); 129 }; 130 131 var webFormExit = function(event){ 132 $(".webFormMessage").hide(); 133 return event.preventDefault(); 134 } 135 136 $(document).on("focus", ".webFormItemField input, .webFormItemField select, .webFormItemField textarea, .webFormItemField.error", removeErrors); 137 $(document).on("click", ".webFormMessageExit", webFormExit); 138 $(document).on("submit", ".webFormDw.default form", sendWebForm); 139 140});
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.