PageSourceSearch

https://ross-bel.ru/g/s3/misc/form/1.2.0/s3.form.js

js ross-bel.ru collected 2026-09-25 04:23:04 UTC 6,782 bytes, 232 lines download raw bytes

1function initFormCalendars($container) {
2	var formCalendars = $container.find('.s3wm-datepicker-calendar');
3	var formCalendarsInterval = $container.find('.s3wm-datepicker-calendar_interval');
4
5	if (!formCalendars.length && !formCalendarsInterval.length) {
6		var siteLang = $('html').attr('lang') !== 'ru' ? 'en' : 'ru';
7		// Init form calendars
8		$container.find('.init-calendar').each(function(){
9			new tcal({
10				'controlname':this.id,
11				'place':this.parentNode,
12				'lang': siteLang
13			});
14
15		});
16
17		// Init form calendar intervals
18		$container.find('.init-calendar-interval').each(function(){
19			for(var j=0; j<2; ++j){
20				var e = f_getElement(this.id + '['+j+']');
21				new tcal({
22					'controlname':e.id,
23					'place':e.parentNode,
24					'lang': siteLang,
25					'intervalpair':[
26						this.id + '[0]',
27						this.id + '[1]'
28					],
29					'intervalupdatecont' : this.id
30				});
31			}
32		});
33	}
34	if (formCalendars.length && $.datepicker) {
35		formCalendars.each(function(){
36			var thisInputCalendar = $(this);
37
38			if (thisInputCalendar.hasClass('hasDatepicker')) {return false;}
39
40			thisInputCalendar.datepicker({
41				changeMonth: true,
42				changeYear: true
43			});
44		});
45	}
46	if (formCalendarsInterval.length && $.datepicker) {
47		formCalendarsInterval.each(function(){
48			var thisCalendarInterval = $(this);
49
50			if (thisCalendarInterval.hasClass('calendar-init')) {return false;}
51
52			thisCalendarInterval.addClass('calendar-init');
53
54			var calendarWrap = thisCalendarInterval.closest('.form-calendar_interval,.form_calendar_interval');
55			var inputInterval = calendarWrap.find('[type="text"]');
56
57			inputInterval.eq(0).datepicker({
58				changeMonth: true,
59				changeYear: true,
60				onClose: function(selectedDate) {
61					inputInterval.eq(1).datepicker("option", "minDate", selectedDate);
62				}
63			});
64			inputInterval.eq(1).datepicker({
65				changeMonth: true,
66				changeYear: true,
67				onClose: function(selectedDate) {
68					inputInterval.eq(0).datepicker("option", "maxDate", selectedDate);
69					thisCalendarInterval.val(inputInterval.eq(0).val() + ' - ' + inputInterval.eq(1).val());
70				}
71			});
72		});
73	}
74}
75
76function fixFormId($container) {
77	if ((match = $container.data('api-url').match(/form_id[^=]?=(\d+)/)) && match != null && typeof match[1] !== undefined) {
78		$container.find('[name="form_id"]').val(match[1]);
79	};
80}
81
82var s3From = {
83	init: function() {
84		this.initForms();
85	},
86	initForms: function(parent, callback, from_response) {
87		var self = this;
88
89		if (!parent) parent = document;
90		if ($(parent)[0] === document || !$(parent).is('[data-api-url][data-api-type=form]')) {
91			parent = $(parent).find('[data-api-url][data-api-type=form]');
92		}
93
94		if (!callback) {
95			callback = typeof parent.data('callback') === 'function' ? parent.data('callback') : eval(parent.data('callback'));
96		}
97
98		$(parent).each(function() {
99			var $container = $(this);
100			var $form = $container.is("form") ? $container : $container.find("form");
101			fixFormId($container);
102			if ($container.data('s3form_inited')) {
103				return;
104			}
105			if ($form.length) {
106				$form.submit(function() {
107					$.post($container.data('api-url'), $form.serialize(), res);
108					return false;
109				});
110			} else if (!from_response) {
111				$.getJSON($container.data('api-url'), null, res);
112			}
113
114			initFormCalendars($form);
115
116			$container.data('s3form_inited', true);
117
118			function res(response) {
119				if (response.result.success && response.result.redirect_url) {
120					document.location = response.result.redirect_url;
121				} else if (response.result && response.result.html) {
122					var uploaders_inits = '';
123					var scripts = response.result.html.match(/<script[^>]*>[^<]*newSWFU[^<]*<\/script>/gm);
124					if (scripts) {
125						for (var i = 0; i < scripts.length; i++) {
126							uploaders_inits += scripts[i].replace(/<script[^>]*>([^<]+)<\/script>/, "$1");
127						}
128					}
129					var $replacement = $(response.result.html.replace(/[\r\n]/g, '').replace(/<script[^>]*>.*?<\/script>/g, ''));
130					if (!$($replacement).is('[data-api-url][data-api-type=form]')) {
131						$replacement = $($replacement).find('[data-api-url][data-api-type=form]');
132					}
133					$container.replaceWith($replacement);
134					$container = $replacement;
135					
136					if (response.result && response.result.success && typeof lpc_template !== 'undefined'){
137            				$container.closest(`.lpc-wrap`).find(`[class$=__title-wrap]`).remove();
138        			}
139					
140
141					var $uploads = $container.find('input[type="hidden"][id^="hidUploadField"]');
142
143					if ($uploads.length) {
144						if (typeof window['newSWFU'] !== 'function') {
145							$.getScript('/assets/site/s3/plupload/plupload.all.pack.js', function() {
146								inituploaders();
147							});
148						} else {
149							inituploaders();
150						}
151					}
152
153					function inituploaders() {
154						if (uploaders_inits) {
155							eval(uploaders_inits);
156						}
157					}
158
159					self.initForms($container, callback, true);
160
161					if (typeof callback === 'function') {
162						callback();
163					}
164				}
165			}
166		})
167	}
168}
168;
169
170var s3PopupForm = {
171	init: function() {
172		this.initPopupForms();
173	},
174	initPopupForms: function(parent, callback) {
175		if (typeof myo) {
176			if (!parent) parent = document;
177			if ($(parent)[0] === document || !$(parent).is('[data-api-url][data-api-type=popup-form]')) {
178				parent = $(parent).find('[data-api-url][data-api-type=popup-form]');
179			}
180			if (parent.data('api-url')) {
181				fixFormId(parent);
182				parent = parent.filter(function() {
183					return !$(this).data('s3form_inited');
184				});
185				if (!callback) {
186					callback = typeof parent.data('callback') === 'function' ? parent.data('callback') : eval(parent.data('callback'));
187				}
188				parent.data('s3form_inited', true).click(function(e) {
189					var $this = $(this);
190					if (myo.show) {
191						myo.show({
192							html: '<div data-api-url="' + $this.data('api-url') + '" data-api-type="form"></div>',
193							clas: $(this).data('wr-class'),
194							afterOpen: function() {
195								var win = this;
196								win.loadDiv.show();
197								s3From.initForms(win.bodyDiv.find('>div[data-api-type]'), function() {
198									win.loadDiv.hide();
199									if (typeof callback === 'function') {
200										callback();
201									}
202								});
203							}
204						});
205					} else if (myo.open) {
206						myo.open({
207							html: '<div data-api-url="' + $this.data('api-url') + '" data-api-type="form"></div>',
208							clas: $(this).data('wr-class'),
209							afterOpen: function() {
210								var win = this;
211								win.loadDiv.show();
212								s3From.initForms(win.bodyDiv.find('>div[data-api-type]'), function() {
213									win.loadDiv.hide();
214									if (typeof callback === 'function') {
215										callback();
216									}
217								});
218							}
219						});
220					}
221					e.preventDefault();
222					return false;
223				})
224			}
225		}
226	}
227};
228
229$(function() {
230	s3PopupForm.init();
231	s3From.init();
232});

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.