PageSourceSearch

https://soyuzmash.ru/local/templates/main/js/views/view.contact.js

js soyuzmash.ru collected 2026-10-02 07:07:53 UTC 3,180 bytes, 126 lines download raw bytes

1/*
2Name: 			View - Contact
3Written by: 	Okler Themes - (http://www.okler.net)
4Theme Version:	1.1.0
5*/
6
7(function($) {
8
9	'use strict';
10
11	/*
12	Custom Rules
13	*/
14	
15	// No White Space
16	$.validator.addMethod("noSpace", function(value, element) {
17    	if( $(element).attr('required') ) {
18    		return value.search(/[a-z0-9а-яА-Я]/i) == 0;
19    	}
20
21    	return true;
22	}, 'Заполните пустые поля.');
23
24	/*
25	Assign Custom Rules on Fields
26	*/
27	$.validator.addClassRules({
28	    'form-control': {
29	        noSpace: true
30	    }
31	});
32
33	/*
34	Contact Form: Basic
35	*/
36	$('.contact-form').each(function(){
37		$(this).validate({
38			submitHandler: function(form) {
39
40				var $form = $(form),
41					$messageSuccess = $form.find('.contact-form-success'),
42					$messageError = $form.find('.contact-form-error'),
43					$submitButton = $(this.submitButton),
44					$errorMessage = $form.find('.mail-error-message'),
45					submitButtonText = $submitButton.val();
46
47				$submitButton.val( $submitButton.data('loading-text') ? $submitButton.data('loading-text') : 'Loading...' ).attr('disabled', true);
48
49				// Fields Data
50				var formData = $form.serializeArray(),
51					data = {};
52
53				$(formData).each(function(index, obj){
54				    data[obj.name] = obj.value;
55				});
56
57				// Google Recaptcha
58				if( data["g-recaptcha-response"] != undefined ) {
59					data["g-recaptcha-response"] = $form.find('#g-recaptcha-response').val();
60				}
61
62				// Ajax Submit
63				$.ajax({
64					type: 'POST',
65					url: $form.attr('action'),
66					data: data
67				}).always(function(data, textStatus, jqXHR) {
68
69					$errorMessage.empty().hide();
70
71					if (data.response == 'success') {
72
73						// Uncomment the code below to redirect for a thank you page
74						// self.location = 'thank-you.html';
75
76						$messageSuccess.removeClass('d-none');
77						$messageError.addClass('d-none');
78
79						// Reset Form
80						$form.find('.form-control')
81							.val('')
82							.blur()
83							.parent()
84							.removeClass('has-success')
85							.removeClass('has-danger')
86							.find('label.error')
87							.remove();
88
89						if (($messageSuccess.offset().top - 80) < $(window).scrollTop()) {
90							$('html, body').animate({
91								scrollTop: $messageSuccess.offset().top - 80
92							}, 300);
93						}
94
95						$form.find('.form-control').removeClass('error');
96
97						$submitButton.val( submitButtonText ).attr('disabled', false);
98						
99						return;
100
101					} else if (data.response == 'error' && typeof data.errorMessage !== 'undefined') {
102						$errorMessage.html(data.errorMessage).show();
103					} else {
104						$errorMessage.html(data.responseText).show();
105					}
106
107					$messageError.removeClass('d-none');
108					$messageSuccess.addClass('d-none');
109
110					if (($messageError.offset().top - 80) < $(window).scrollTop()) {
111						$('html, body').animate({
112							scrollTop: $messageError.offset().top - 80
113						}, 300);
114					}
115
116					$form.find('.has-success')
117						.removeClass('has-success');
118						
119					$submitButton.val( submitButtonText ).attr('disabled', false);
120
121				});
122			}
123		});
124	});
125
126}).apply(this, [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.