PageSourceSearch

https://horoshie-kraski.ru/bitrix/templates/dresscode/components/b…/modal/script.js?17736646715035

js horoshie-kraski.ru collected 2026-10-07 16:46:04 UTC 5,035 bytes, 178 lines download raw bytes

1$(function(){
2
3	var $modalForms = $(".webformModal");
4
5	var sendWebForm = function(event, data){
6
7		var requiredErrorPosition = false;
8		var requiredError = false;
9
10		var $thisForm = $(this).addClass("loading");
11		var $parentThis = $thisForm.parents(".webFormDwModal");
12		var $thisFormFields = $thisForm.find(".webFormItemField");
13		var $thisFormErrors = $thisForm.find(".webFormItemError");
14		var $submitButton = $thisForm.find('input[type="submit"]').addClass("loading");
15		var $webFormError = $thisForm.find(".webFormError");
16		var $webFormCaptchaSid = $thisForm.find(".webFormCaptchaSid");
17		var $webFormCaptchaImage = $thisForm.find(".webFormCaptchaImage");
18
19		var formId = $parentThis.data("id");
20
21		$thisFormFields.each(function(i, nextField){
22
23			var $nextField = $(nextField);
24			if($nextField.data("required") == "Y"){
25				var $nextFieldEx = $nextField.find('input[type="text"], input[type="password"], input[type="file"], select, textarea');
26				if($nextFieldEx.attr("name")){
27					if(!$nextFieldEx.val() || $nextFieldEx.val().length == 0){
28						$nextFieldEx.addClass("error");
29						if(!requiredError){
30							requiredErrorPosition = $nextFieldEx.offset().top;
31							requiredError = true;
32						}
33					}
34				}
35
36			}
37		});
38
39		//get form data
40		var formData = new FormData(this);
41
42		//set control
43		formData.append("control", Math.floor((new Date()).getTime() / 1000));
44
45		var $personalInfo = $thisForm.find(".personalInfoField");
46		if(!$personalInfo.prop("checked")){
47			$personalInfo.addClass("error");
48			requiredError = true;
49		}
50
51		//check errors
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						$(".webformModal").removeClass("visible");
91						$thisForm[0].reset();
92					}
93
94		  			//remove loader
95		  			$thisForm.removeClass("loading");
96		  			$submitButton.removeClass("loading");
97
98		  		}
99
100	  		});
101	  	}else{
102	  		
103	  		// if(requiredErrorPosition){
104	  		// 	$("html, body").animate({
105	  		// 		"scrollTop": requiredErrorPosition - $(window).height() / 2
106	  		// 	}, 250);
107	  		// }
108
109	  		$thisForm.removeClass("loading");
110	  		$submitButton.removeClass("loading");
111	  	}
112
113		return event.preventDefault();
114
115	}
116
117	var removeErrors = function(event){
118		$(this).removeClass("error");
119	};
120
121	var webFormExit = function(event){
122		$(".webFormMessage").hide();
123		return event.preventDefault();
124	}
125
126	var openWebFormModal = function(event){
127
128		var $thisForm = $("#webFormDwModal_" + $(this).data("id"));
129		var $thisFormCn = $thisForm.find(".webformModalContainer");
130
131		$thisForm.addClass("visible");
132
133		if($thisFormCn.height() < $(window).height()){
134			$thisForm.addClass("small");
135		}
136
137		return event.preventDefault();
138
139	}
140
141	var closeWebFormModal = function(event){
142		$(this).parents(".webformModal").removeClass("visible");
143		return event.preventDefault();
144	};
145
146	var checkFormsHeight = function(event){
147
148		//get window height now
149		var windowHeightNow = $(this).height();
150
151		//get web forms
152		$modalForms.each(function(i, nextForm){
153
154			//vars
155			var $nextForm = $(nextForm);
156			var $nextFormCn = $nextForm.find(".webformModalContainer");
157
158			//class change
159			if($nextFormCn.height() < windowHeightNow){
160				$nextForm.addClass("small");
161			}else{
162				$nextForm.removeClass("small");
163			}
164
165		});
166	}
167
168	$(document).on("focus", ".webFormItemField input, .webFormItemField select, .webFormItemField textarea", removeErrors);
169	$(document).on("click", ".webFormModalHeadingExit", closeWebFormModal);
170	$(document).on("click", ".openWebFormModal", openWebFormModal);
171	$(document).on("click", ".webFormMessageExit", webFormExit);
172	$(document).on("submit", ".webFormDwModal form", sendWebForm);
173
174	if($modalForms.length > 0){
175		$(window).on("resize", checkFormsHeight);	
176	}
177
178});

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.