PageSourceSearch

https://xn--h1aaeccek.xn--p1ai/g/s3/lp/js/lp.core.content.js

js xn--h1aaeccek.xn--p1ai collected 2026-09-28 19:02:46 UTC 15,388 bytes, 486 lines download raw bytes

1var s3LP = {
2	init: function(options) {
3		var self = this;
4		
5		if (options){
6			this.is_cms = options.is_cms ? true : false;
7		}
8		
9		this.initForms();
10
11		try {
12			lp_init($('body'));
13		} catch(e) {
14			console.log(e);
15		}
16		this.pageBlocking();
17		
18		self.popupForm();
19		
20		document.dispatchEvent(new Event('lpcPopupFormInitDone', {bubbles: true}));
21		
22		if ($('body').find('._lp-image-container').length) {
23			if (!window.hasOwnProperty('img_convert_cache')) {
24                window.img_convert_cache = {};
25            }
26			var debounce = (function () {
27				return function (fn, time) {
28					var timer, func;
29					func = function() {
30						var args = [].slice.call(arguments, 0);
31						window.clearTimeout(timer);
32						timer = window.setTimeout(function () {
33							window.requestAnimationFrame && window.requestAnimationFrame(function() {
34								fn.apply(null, args);
35							}) || fn.apply(null, args);
36						}, time)
37					};
38					return func;
39				}
40			}());
41			self.convertImages($('body'));
42			$(window).on('resize', debounce(function() {
43				self.convertImages($('body'));
44			}, 200));
45		}	
46	},
47	pageBlocking: function() {
48		if (s3LP.page_blocking) {
49			$('html, body').css({
50				'overflow': 'hidden',
51				'height': '100%'
52			});
53			$('<div />', {
54				'class' : 'page-blocked'
55			}).appendTo($('body'));
56			
57			$('.page-blocked').css({
58				'background': 'rgba(0,0,0,.8)',
59				'position': 'absolute',
60				'left': 0,
61				'right': 0,
62				'bottom': 0,
63				'top': 0,
64				'z-index': 100000,
65				'color': '#fff',
66				'font-size': '28px',
67				'display': 'flex',
68				'align-items': 'center',
69				'flex-direction': 'column',
70				'padding': '10px',
71				'text-align': 'center',
72				'line-height':'1.5',
73				'align-items': 'center',
74				'justify-content': 'center'
75			}).append('<b>Страница заблокирована</b><div style="font-size: 18px;">обратитесь в техническую поддержку</div>');
76		}
77	},
78	initForms: function(parent) {
79		var self = this;
80		if (!parent) parent = document;
81		if (!$(parent).is('[data-api-url][data-api-type=form], [data-lpc-api-url][data-api-type=form]')) {
82			parent = $(parent).find('[data-api-url][data-api-type=form], [data-lpc-api-url][data-api-type=form]');
83		}
84
85		$(parent).each(function() {
86			var obj = $(this);
87			var form = obj.is("form") ? obj : obj.find("form");
88			
89			if (obj.data('s3form_inited')) {
90				return;
91			}
92
93			if (self.is_cms) {
94				const title = typeof JS_LP_FORM_NOTE !== 'undefined' ? JS_LP_FORM_NOTE : '';
95				const attr = form.attr('title', title);
96				if (typeof attr.tooltip === "function") { 
97			         attr.tooltip();
98				}
99				form.submit(function() {
100					return false;
101				});
102			} else {
103				form.submit(function() {
104					
105					var apiUrl = obj.data('lpc-api-url') || obj.data('api-url');
106					
107					$.post(apiUrl, form.serialize(), function(response) {
108						
109						if (response.result.success && response.result.redirect_url) {
110							document.location = response.result.redirect_url;
111						} else {
112							if (response.result.html) {
113								var replacement = $(response.result.html.replace(/[\r\n]/g, '').replace(/<script[^>]*>.*?<\/script>/g, ''));
114								if (!$(replacement).is('[data-api-url][data-api-type=form], [data-lpc-api-url][data-api-type=form]')) {
115									replacement = $(replacement).find('[data-api-url][data-api-type=form], [data-lpc-api-url][data-api-type=form]');
116								}
117								obj.replaceWith(replacement);
118								
119	
120								// Init form calendars
121								obj.find('.init-calendar').each(function(i){
122									new tcal({
123										'controlname':this.id,
124										'place':this.parentNode,
125										'lang':'ru'
126									});
127	
128								});
129	
130								// Init form calendar intervals
131								obj.find('.init-calendar-interval').each(function(i){
132									for(var j=0; j<2; ++j){
133										var e = f_getElement(this.id + '['+j+']');
134										new tcal({
135											'controlname':e.id,
136											'place':e.parentNode,
137											'lang':'ru',
138											'intervalpair':[
139												this.id + '[0]',
140												this.id + '[1]'
141											],
142											'intervalupdatecont' : this.id
143										});
144									}
145								});
146								
147								if (response.result && response.result.success && lpc_template){
148        							 replacement.closest(`.lpc-wrap`).find('.hide-on-success').remove();
149          						}
150								
151								var $captcha = replacement.find('input[name=_cn]');
152								if ($captcha.length) {
153									$.getScript('http://captcha.oml.ru/static/captcha.js?2', function() {
154										var $d = replacement.find("[id^=s3_captcha_cn]");
155										mgCaptcha.draw("/my/s3/captcha/get.php", ($d.length ? $d.get(0) : null));
156									});
157								}
158								self.initForms(replacement);
159							}
160						}
161					});
162					return false;
163				});
164			}
165			obj.data('s3form_inited', true);
166		})
167	},
168
169	convertImages: function ($container) {
170        var self = this;
171
172        $container.find('._lp-image-container').each(function() {
173            var $img = $(this).find('img');
174
175            if ($img.length) {
176                var img_src = $img.attr('src');
177                if (!window.img_convert_cache.hasOwnProperty(img_src)) window.img_convert_cache[img_src] = {};
178                self.convertImg(window.img_convert_cache[img_src], $img);
179            }
180        });
181    },
182    
183
184    popupForm: function() {
185	    var $body = $('body'),
186	        $html = $('html'),
187	        self = this;
188	
189	    $('<div class="lp-popup-wrapper js-popup-wrapper"><div class="lp-popup-overlay"></div><div class="lp-popup-inner js-popup-inner"></div></div>').appendTo($body);
190	
191	    var $wrapper = $('.js-popup-wrapper'),
192	        $newBlock,
193	        $container = $wrapper.find('.js-popup-inner'),
194	        $readyPopup = $body.find('[data-popup-type="ready"]'),
195	        $finishPopup = $body.find('[data-popup-type="finish"]'),
196	        $inactionPopup = $body.find('[data-popup-type="inaction"]'),
197	        openedClass = '_opened',
198	        $popupCookieTime = $body.find('[data-hide-time]').data('hide-time');
199	
200	    var isFramed = false;
201	    try {
202	        isFramed = window != window.top || document != top.document || self.location != top.location;
203	    } catch (e) {
204	        isFramed = true;
205	    }
206	
207	    if ($finishPopup.length) {
208	        $finishPopup.each(function () {
209	            var $this = $(this);
210	            $('html').one('mouseleave', function () {
211	                if (!$wrapper.hasClass(openedClass) && !self.is_cms) {
212	                    $newBlock = self.appendPopupForm($this, $container, $wrapper);
213	                    if ($this.parent('.lpc-popup-decor').length === 1) {
214	                        document.dispatchEvent(new Event('lpcTriggerPopupInitDone', {
215	                            bubbles: true
216	                        }));
217	                    }
218	                }
219	            });
220	        });
221	    }
222	
223	    function popupTimer() {
224	        if ($readyPopup.length && document.location.search != "?no_panel=1") {
225	
226	            $readyPopup.each(function () {
227	
228	                var $this = $(this);
229	                
230	                setTimeout(function () {
231	                    if (!$wrapper.hasClass(openedClass)) {
232	                    	
233	                        $newBlock = self.appendPopupForm($this, $container, $wrapper);
234
235	                        if ($this.parent('.lpc-popup-decor').length === 1 || $this.hasClass('lpc-popup-decor')) {
236	                        
237	                            document.dispatchEvent(new Event('lpcTriggerPopupInitDone', {
238	                                bubbles: true
239	                            }));
240	                        }
241	                    }
242	
243	                }, +$this.data('popup-time'))
244	                
245	            });
246	        }
247	    };
248	
249	    popupTimer();
250	
251	    if ($inactionPopup.length && document.location.search != "?no_panel=1") {
252	        $inactionPopup.each(function () {
253	            var $this = $(this),
254	                thisTime = +$this.data('popup-time'),
255	                idleTimer = null,
256	                idleState = false;
257	
258	            if ($this.parent('.lpc-popup-decor').length === 1) {
259	                var $this = $this.closest('.lpc-popup-decor');
260	            }
261	
262	            $(document).on('keydown scroll', function () {
263	
264	                clearTimeout(idleTimer);
265	
266	                if (idleState == true) return;
267	
268	                idleState = false;
269	
270	                idleTimer = setTimeout(function () {
271	                    if (!$wrapper.hasClass(openedClass)) {
272	                        $newBlock = self.appendPopupForm($this, $container, $wrapper);
273	                        idleState = true;
274	                        if ($this.parent('.lpc-popup-decor').length === 1) {
275	                            document.dispatchEvent(new Event('lpcTriggerPopupInitDone', {
276	                                bubbles: true
277	                            }));
278	                        }
279	                    }
280	                }, thisTime);
281	            });
282	
283	            $(document).trigger('mousemove');
284	        });
285	    }
286	
287	    $body.on('click', 'a[href^="popup:"]', function (e) {
288	        e.preventDefault();
289			
290	        var $thisBlock = $('#' + this.href.replace(':', ''));
291	        
292	        if ($(this).closest('.lp-popup-wrapper').length != 0) {
293	            $newBlock.appendTo($('body'));
294	            $container.html('');
295	            $newBlock = self.appendPopupForm($thisBlock, $container, $wrapper);
296	        }
297	
298	        if ($thisBlock.length == 1) {
299	            if (!$wrapper.hasClass(openedClass)) {
300	                $newBlock = self.appendPopupForm($thisBlock, $container, $wrapper);
301	            }
302	        }
303	    });
304	
305	    $container.on('click', '.js-close-popup', function (e) {
306	        e.preventDefault();
307	
308	        if ($newBlock.find('[data-popup-trigger-type]').length) {
309	            if ($popupCookieTime == 30 || $popupCookieTime == 60) {
310	                var $new_minut = $popupCookieTime / 1440;
311	                createCookie("lpctrigger", "1", $new_minut);
312	            } else {
313	                createCookie("lpctrigger", "1", $popupCookieTime);
314	            }
315	            $newBlock.hide();
316	        }
317	
318	        $newBlock.appendTo($('body'));
319	
320	        $container.html('');
321	        $wrapper.removeClass(openedClass);
322	
323	        $html.css({
324	            overflow: ''
325	        });
326	        
327	        document.dispatchEvent(new Event('lpcPopupClosing'));
328	
329	        let hasLpctriggerCookie = readCookie('lpctrigger');
330	
331	        if (!hasLpctriggerCookie && !$wrapper.hasClass(openedClass)) {
332	            popupTimer();
333	        }
334	    });
335	    
336	    $container.on('click', function (e) {
337		    if ($(e.target).closest('.progressCancel').length) {
338		        return;
339		    }
340		
341		    if (s3LP.templateID == 706 && !$(e.target).closest('.lpc-popup-body').length) {
342		        e.preventDefault();
343		
344		        if ($newBlock.find('[data-popup-trigger-type]').length) {
345		            if ($popupCookieTime == 30 || $popupCookieTime == 60) {
346		                var $new_minut = $popupCookieTime / 1440;
347		                createCookie("lpctrigger", "1", $new_minut);
348		            } else {
349		                createCookie("lpctrigger", "1", $popupCookieTime);
350		            }
351		            $newBlock.hide();
352		        }
353		
354		        $newBlock.appendTo($('body'));
355		
356		        $container.html('');
357		        $wrapper.removeClass(openedClass);
358		
359		        $html.css({
360		            overflow: ''
361		        });
362		
363		        document.dispatchEvent(new Event('lpcPopupClosing'));
364		
365		        let hasLpctriggerCookie = readCookie('lpctrigger');
366		
367		        if (!hasLpctriggerCookie && !$wrapper.hasClass(openedClass)) {
368		            popupTimer();
369		        }
370		    }
371		});
372	
373	    $(document).on('keyup', function (e) {
374	        if (e.keyCode != 27) return;
375	
376	        if ($newBlock) {
377	            if ($newBlock.find('[data-popup-trigger-type]').length && !$wrapper.hasClass(openedClass)) {
378	                if ($popupCookieTime == 30 || $popupCookieTime == 60) {
379	                    var $new_minut = $popupCookieTime / 1440;
380	                    createCookie("lpctrigger", "1", $new_minut);
381	                } else {
382	                    createCookie("lpctrigger", "1", $popupCookieTime);
383	                }
384	                $newBlock.hide();
385	            }
386	
387	            $newBlock.appendTo($('body'));
388	        }
389	        $container.html('');
390	        $wrapper.removeClass(openedClass);
391	
392	        $html.css({
393	            overflow: ''
394	        });
395	        
396	        document.dispatchEvent(new Event('lpcPopupClosing'));
397	
398	        let hasLpctriggerCookie = readCookie('lpctrigger');
399	
400	        if (!hasLpctriggerCookie && !$wrapper.hasClass(openedClass)) {
401	            popupTimer();
402	        }
403	    });
404	},
405
406
407	appendPopupForm: function($block, $container, $wrap) {
408		var $newBlock = $block.prependTo($container),
409			$html = $('html'),
410			openedClass = '_opened';
411			
412		if (!$wrap.find('.lp-form-step-popup-inner').length) {
413			var $uploads = $container.find('input[type="hidden"][id^="hidUploadField"]');
414
415			if ($uploads.length) {
416				$uploads.each(function(){
417					var thisAttr = $(this).data('init-upload');
418					newSWFU(void 0, thisAttr);
419				});
420			}
421			
422		} else {
423			var $block = $wrap.find('.js-lp-steps-form');
424			$block.html('');
425			$block.formsteps();
426		}
427		
428		$html.css({
429			overflow: 'hidden'
430		});
431		
432		document.dispatchEvent(new Event('lpcPopupOpening'));
433
434		$wrap.addClass(openedClass);
435		
436		return $newBlock;
437	},
438
439    convertImg : function (cache_img, $img) {
440        var self = this;
441        $img.css({"max-width": "100%", "max-height": "100%"});
442
443        if (!$img.parent().hasClass('lp-img-contain')) {
444            var img_width,
445                img_height;
446
447            if (!cache_img.hasOwnProperty('width') || !cache_img.hasOwnProperty('height')) {
448                if ($img.is('svg') || ($img.attr('src') && $img.attr('src').slice(-3) == 'svg')) {
449                    img_width = $img.parent().width();
450                    img_height = $img.parent().height();
451                } else {
452                    img_width = $img[0].naturalWidth;
453                    img_height = $img[0].naturalHeight;
454                }
455            } else {
456                img_width = cache_img.width;
457                img_height = cache_img.height;
458            }
459
460            self.setImgStyles($img, img_width, img_height, null);
461        }
462    },
463
464    setImgStyles: function ($img, img_width, img_height, svg) {
465        var $wrap = $img.parent();
466        var wrap_width = parseInt($wrap.width()),
467            wrap_height = parseInt($wrap.height()),
468            wrap_prop = wrap_width/wrap_height;
469
470        var min_width = wrap_height/img_height * img_width;
471
472        if(img_width && img_height) {
473            var img_prop = img_width/img_height;
474
475            if (wrap_prop > img_prop) {
476                $img.css({"max-width": "100%", "width": img_width > wrap_width ? wrap_width : img_width, "min-width": "0", "max-height": "none", "height": "auto"});
477            } else {
478                $img.css({"max-width": "none", "width": "auto", "min-width": min_width > img_width ? img_width : min_width, /*"min-height": "100%",*/  "max-height": "100%", "height": img_height > wrap_height ? wrap_height : img_height});
479
480                if (svg) {
481                    $img.css('min-height', '100%');
482                }
483            }
484        }
485    }
486}

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.