PageSourceSearch

https://labburo.ru/bitrix/templates/alpha_s1/js/application.js

js labburo.ru collected 2026-10-06 11:21:48 UTC 24,935 bytes, 611 lines download raw bytes

1(function (window){
2	'use strict';
3        
4    if (window.Alpha)
5        return;
6
7    window.Alpha = {};
8    
9    window.Alpha.Application = function (params)
10    {
11        this.params = {};
12        this.init();
13        
14    };
15    
16    window.Alpha.Application.prototype = {
17        
18        init: function () {
19            
20            BX.addCustomEvent('onAjaxSuccess', BX.delegate(this.refreshEvents, this)); 
21            $(document).ajaxSuccess(BX.delegate(this.refreshEvents, this));
22            
23            this.initEvents();
24            this.refreshEvents();
25            this.lazyEvents();
26        },
27        
28        initEvents: function () {
29            
30            var _ = this;
31
32            let vh = window.innerHeight * 0.01;
33            document.documentElement.style.setProperty('--vh', `${vh}px`);
34
35            window.addEventListener('resize', () => {
36                let vh = window.innerHeight * 0.01;
37                document.documentElement.style.setProperty('--vh', `${vh}px`);
38            });
39
40            $(document).click(function(event) {
41                if ($(event.target).closest("[data-dropdown-links-id]").length) return;
42                if ($(event.target).closest('[data-role="sort-dropdown"]').length) return;
43                if ($(event.target).closest(".search-header").length) return;
44                if ($(event.target).closest(".search-fast-result").length) return;
45                if ($(event.target).closest(".search-line").length) return;
46                if ($(event.target).closest(".filter-container-horizontal").length) return;
47                if ($(event.target).closest(".auth-popup").length) return;
48                if ($(event.target).closest('[data-role="horizontal-filter-block"]').length) return;
49
50
51                $("[data-dropdown-links-id], [data-dropdown-links], .search-header, [data-role='sort-dropdown'], .auth-popup, [data-role='horizontal-filter-block']").removeClass("open");
52                $(".search-fast-result > .scrollbar-inner").empty();
53                $("[data-dropdown-links]").parent().removeClass("open");
54                $(".filter-container-horizontal, .filter-horizontal-btn").removeClass('active');
55
56                event.stopPropagation();
57            });
58
59            $(function() {
60                var $window = $(window),
61                    $body = $("body"),
62                    scrollDistance = 0;
63
64                $body.on('modalOpen', function () {
65                    scrollDistance = $window.scrollTop();
66                    $body.css("top", scrollDistance * -1);
67                });
68
69                $body.on('modalClose', function () {
70                    $body.css("top", "");
71                    $window.scrollTop(scrollDistance);
72                });
73            });
74
75            $(document).on('show.bs.modal', '.modal', function () {
76                $('body').trigger('modalOpen');
77            });
78            $(document).on('hidden.bs.modal', '.modal', function () {
79                $('body').trigger('modalClose');
80            });
81
82            $(document).on('scroll', function() {
83                if ($(window).scrollTop() > ($('.top-header-wrapper').outerHeight() + $('.main-header-wrapper').outerHeight() + $('.bottom-header-wrapper').outerHeight() + 290)) {
84                    $('.header.header-fixed.open-header').addClass('visible');
85                }
86                else {
87                    $('.header.header-fixed.open-header').removeClass('visible');
88                }
89            });
90            
91            $(document).on('click', '.modal-container .close-area', function (event) {
92                $(this).parent().addClass('hidden');
93                $('body').removeClass('modal-opened').trigger('modalClose');
94            });
95
96            $(document).on('click', '.modal-container .modal-content-container .close', function (event) {
97                $(this).parent().parent().addClass('hidden');
98                $('body').removeClass('modal-opened').trigger('modalClose');
99            });
100
101            $(document).on('click', '.brands-search .custom-input .clear-btn', function(){
102                $(this).siblings('input').val('').removeClass('filled');
103            })
104
105            $('body').on('input', '.city-choose-modal input', function () {
106                if ($(this).val() !== "") {
107                    $(this).parent().addClass('filled');
108                } else {
109                    $(this).parent().removeClass('filled');
110                }
111            })
112
113            $('body').on('click', '.city-choose-modal .clear-btn', function () {
114                $(this).siblings('input').val('');
115                $(this).parent().removeClass('filled');
116            })
117
118            $(document).on('click', '.btn.btn-primary', function (event) {
119                $(this).addClass('animating');
120                //$('body').toggleClass('fixed');
121                setTimeout(function(){
122                    $('.btn.btn-primary').removeClass('animating');
123                }, 280);
124            });
125            
126            $(document).on('click', function (e) {
127                if (!$(e.target).parents('.menu-container-wrapper.open').length && (!$(e.target).parents('.menu-button').length)) {
128                    $('.menu-container-wrapper.open').removeClass('open');
129                    $('.menu-button .btn').removeClass('opened');
130                    $('body').removeClass('fixed');
131                }
132            })
133
134            
135            $(document).on('click', '.close-menu', function (event) {
136                $(this).parents('.mobile-sidebar-menu').addClass('hidden');
137                $('body').removeClass('modal-opened').trigger('modalClose');
138            });
139            
140            $(document).on('click', '.menu-mobile-bottom-button', function (event) {
141                $('.mobile-sidebar-menu').removeClass('hidden');
142                $('body').trigger('modalOpen').addClass('modal-opened');
143            });
144
145            $(document).on('click', '.js-regions-modal', function (event) {
146                $(this).parents('.mobile-sidebar-menu').addClass('hidden');
147                $('body').removeClass('modal-opened').trigger('modalClose');
148            });
149            
150            $(document).on('click', '.main-header .menu-btn', function (event) {
151                $('.mobile-sidebar-menu').removeClass('hidden');
152                $('body').trigger('modalOpen').addClass('modal-opened');
153            });
154
155            $(document).on('click', '.js-sort-mobile .sorting-list a', function (event) {
156                $(".modal-container.mobile.js-sort-mobile").addClass('hidden');
157                $('body').removeClass('modal-opened').trigger('modalClose');
158            });
159
160            $(document).on('click', '.page-container .modal-container.mobile .menu-catalog-modal .menu-container a', function (event) {
161                $('body').removeClass('modal-opened').trigger('modalClose');
162            });
163
164            $("body").on('click', '[data-role="sort-dropdown"] [data-role="sort-dropdown-title"]', function () {
165                $(this).parents('[data-role="sort-dropdown"]').toggleClass('open');
166            });
167
168            $("body").on('click', '[data-role="sort-dropdown"] [data-role="sort-dropdown-item"]', function (event) {
169                if ($(this).data('value') !== undefined) {
170                    $(this).parents('[data-role="sort-dropdown"]').removeClass('open').find('[data-role="sort-dropdown-title"] span').text($(this).data('value'));
171
172                    $(this).closest('.link').siblings().find('[data-role="sort-dropdown-item"]').removeClass('active');
173
174
175                    $(this).addClass('active');
176                }
177            });
178
179            $("body").on('click', '.mobile-buttons .btn-show-catalog', function (event) {
180                $('body').trigger('modalOpen').addClass('modal-opened');
181                if($('.modal-container.js-catalog-mobile').hasClass('hidden')) {
182                    $('.modal-container.js-catalog-mobile').removeClass('hidden');
183
184                }
185
186            });
187            $("body").on('click', '.mobile-buttons .btn-show-sorting', function (event) {
188                $('body').trigger('modalOpen').addClass('modal-opened');
189                if($('.modal-container.js-sort-mobile').hasClass('hidden')) {
190                    $('.modal-container.js-sort-mobile').removeClass('hidden');
191
192                }
193
194            });
195            $("body").on('click', '.mobile-buttons .btn-show-filter', function (event) {
196                $('body').trigger('modalOpen').addClass('modal-opened');
197                if($('.modal-container.js-filter-mobile').hasClass('hidden')) {
198                    $('.modal-container.js-filter-mobile').removeClass('hidden');
199
200                }
201
202            });
203            $("body").on('click', '.horizontal-filter .btn-show-categories', function (event) {
204                $('body').trigger('modalOpen').addClass('modal-opened');
205                if($('.modal-container.js-catalog-categories').hasClass('hidden')) {
206                    $('.modal-container.js-catalog-categories').removeClass('hidden');
207
208                }
209
210            });
211
212            $("body").on('click', '.sidebar-filter .accordion-head > a', function () {
213                $(this).parent().toggleClass('open');
214            });
215            $("body").on('click', '.filter-modal .accordion-head > a', function () {
216                $(this).parent().toggleClass('open');
217            });
218            $("body").on('click', '.delivery-modal .accordion-head', function () {
219                $(this).parent().toggleClass('open');
220            });
221
222            $("body").on('click', '.horizontal-filter .accordion-head > a, .pickup-points .accordion-head > a', function () {
223                // $(this).parent().find(".accordion-body").toggleClass('active');
224                $(this).parent().toggleClass('open');
225
226
227                if($(this).parent().siblings().hasClass('open')) {
228                    $(this).parent().siblings().removeClass('open');
229                }
230
231            });
232
233
234            $("body").on('click', '.sidebar-menu li.has-sub > span .icon', function (event) {
235                $(this).closest('.has-sub').toggleClass('open');
236            });
237            
238            $('body').on('click', '[data-entity="button-search-modal"]', function (event) {
239                event.preventDefault();
240                $('.search-modal').addClass('opened');
241                $('body').trigger('modalOpen').addClass('modal-opened').addClass('search-opened');
242                return false;
243            });
244
245            $('body').on('click', function (event) {
246                if ($('body').hasClass('search-opened') && !$(event.target).parents().hasClass('search') && !$(event.target).parents().hasClass('search-modal') && !$(event.target).hasClass('search-modal')) {
247                    $('.search-modal').removeClass('opened');
248                    $('body').removeClass('modal-opened').removeClass('search-opened').trigger('modalClose');
249                }
250            });
251            
252            $('.item-detail .img-block .image-wrap').each(function() {
253                let height = $(this).children('.image').width();
254                $(this).css('height', height);
255            });
256
257            this.initScrollbar();
258
259            BX.onCustomEvent('OnCompareChange');
260
261            $(document).on('click', '.search-modal .clear', function() {
262                $(this).siblings('input').val('').removeClass('filled');
263                $('.search-modal').removeClass('opened');
264                $('body').removeClass('modal-opened').removeClass('search-opened').trigger('modalClose');
265            });
266
267            if ($('#panel').height() > 0) {
268                $('body').css('height', 'calc(100% + ' + $('#panel').height() + 'px)');
269            }
270            
271            if ($(window).width() > 768 && $('.interactive-image-section:not(.horizontal)').length) {
272                let interactiveImgHeight = 0;
273                if ($('.interactive-image-section+.item-wrap').height() >= $('.interactive-image-section+.item-wrap+.item-wrap').height()) {
274                    interactiveImgHeight = $('.interactive-image-section+.item-wrap').height() * 2 + 30 + 'px';
275                }
276                else {
277                    interactiveImgHeight = $('.interactive-image-section+.item-wrap+.item-wrap').height() * 2 + 30 + 'px';
278                }
279                $('.interactive-image-section').css('height', interactiveImgHeight);
280            }
281            
282            $('.labels .toggle-labels-btn').on('click', function() {
283                $(this).closest('.labels').toggleClass('open');
284            });
285            
286        },
287
288        refreshEvents: function () {
289
290            $('.custom-input input, .custom-input textarea').on('focusout', function () {
291                if ($(this).val() != '') $(this).addClass('filled')
292                else $(this).removeClass('filled');
293            });
294
295            $('.custom-input input, .custom-input textarea').each(function () {
296                if ($(this).val() != '') $(this).addClass('filled')
297                else $(this).removeClass('filled');
298            });
299            
300            if (BX.message('PHONE_NUMBER_MASK') != "")
301            {
302                $('input[data-field-type="phone"]').mask(BX.message('PHONE_NUMBER_MASK'));
303            }
304            
305            this.lazyEvents(true);
306            this.initScrollbar();
307        },
308
309        initScrollbar: function() {
310            $('.scrollbar-inner:not(.js-wheelPropagation):not(.gallery-thumbn
310ails)').each(function () {
311                if (!$(this).hasClass('ps')) {
312                    const ps = new PerfectScrollbar($(this)[0], {
313                        suppressScrollX: true,
314                    });
315                    $(this).on('ps-scroll-y', function() {
316                        ps.update();
317                    });
318                }
319            });
320            if ($(window).width() > 1024) {
321                $('.scrollbar-inner.js-wheelPropagation').each(function () {
322                    if (!$(this).hasClass('ps')) {
323                        const ps = new PerfectScrollbar($(this)[0], {
324                            wheelPropagation: false,
325                            suppressScrollX: true,
326                        });
327                        $(this).on('ps-scroll-y', function() {
328                            ps.update();
329                        });
330                    }
331                });
332            }
333            else {
334                $('.scrollbar-inner.js-wheelPropagation').each(function () {
335                    if (!$(this).hasClass('ps')) {
336                        const ps = new PerfectScrollbar($(this)[0], {
337                            wheelPropagation: true,
338                            suppressScrollX: true,
339                        });
340                        $(this).on('ps-scroll-y', function() {
341                            ps.update();
342                        });
343                    }
344                });
345                $('.scrollbar-inner.gallery-thumbnails:not(.js-wheelPropagation)').each(function () {
346                    if (!$(this).hasClass('ps')) {
347                        const ps = new PerfectScrollbar($(this)[0], {
348                            suppressScrollX: false,
349                        });
350                        $(this).on('ps-scroll-x', function() {
351                            ps.update();
352                        });
353                    }
354                });
355            }
356
357        },
358
359        lazyEvents: function ()
360        {
361           
362            $('[data-role="lazyload-background"]').Lazy({
363                effect: "fadeIn",
364                effectTime: 250,
365                threshold: 0,
366                
367                afterLoad: function(element) {
368                    element.find('.swiper-lazy-preloader').remove();
369                }
370            });
371
372            $('[data-role="lazyload-image"]').Lazy({
373                effect: "fadeIn",
374                effectTime: 250,
375                threshold: 0,
376                
377                afterLoad: function(element) {
378                    element.prev('.swiper-lazy-preloader').remove();
379                }
380            });
381
382            $('[data-role="lazyload-video"]').Lazy({
383                effect: "fadeIn",
384                effectTime: 250,
385                threshold: 0,
386
387                afterLoad: function(element) {
388                    element.prev('.swiper-lazy-preloader').remove();
389                }
390            });
391        },
392
393        refreshLazyEvents: function () {
394
395            $('[data-role="lazyload-background"]').Lazy();
396            $('[data-role="lazyload-image"]').Lazy();
397            $('[data-role="lazyload-video"]').Lazy();
398
399        }
400    };
401    
402    window.Alpha.LazyImage = function (params)
403    {
404        this.params = params;
405        return this.init();
406        
407    };
408    
409    window.Alpha.LazyImage.prototype = {
410        
411        init: function () {
412
413            if (this.params.type == "VIDEO")
414            {
415                return [
416                    BX.create('div', {
417                        props: {className: 'image-wrapper'},
418                        children: [
419                            BX.create('div', {
420                                props: {className: 'img-lazy-spinner'},
421                                html: '<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>'
422                            }),
423                            BX.create('div', {
424                                props: {className: 'video-wrapper js-video'},
425                                attrs: {
426                                    onclick: 'window.Alpha.VideoControl($(this));'
427                                },
428                                children: [
429                                    BX.create('div', {
430                                        props: {className: 'video-button'}
431                                    }),
432                                    BX.create('video', {
433                                        dataset: {role: 'lazyload-v
433ideo'},
434                                        attrs: {
435                                            preload: 'metadata',
436                                            loop: 'loop'
437                                        },
438                                        children: [
439                                            BX.create('data-src', {
440                                                attrs: {src: this.params.src}
441                                            })
442                                        ]
443                                    })
444                                ]
445                            })
446                        ]
447                    })
448                ];
449            }
450            else
451            {
452                return [
453                    BX.create('div', {
454                        props: {className: 'image-wrapper'},
455                        children: [
456                            BX.create('div', {
457                                props: {className: 'img-lazy-spinner'},
458                                html: '<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>'
459                            }),
460                            BX.create('img', {
461                                dataset: {role: 'lazyload-image', src: this.params.src},
462                                props: {className: !!this.params.className ? this.params.className : ''}
463                            })
464                        ]
465                    })
466                ];
467            }
468
469        }
470        
471    };
472
473    window.Alpha.LazyBackground = function (params)
474    {
475        this.params = params;
476        return this.init();
477        
478    };
479
480    window.Alpha.LazyBackgroundThumb = function (params)
481    {
482        this.params = params;
483        return this.init();
484
485    };
486
487    window.Alpha.VideoControl = function (videoContainer)
488    {
489        let playBtn = videoContainer.find('.video-button'),
490            video = videoContainer.find('video').get(0);
491
492        if (video.paused) {
493            video.play();
494            videoContainer.addClass('playing');
495            playBtn.addClass('pause');
496        } else {
497            video.pause();
498            videoContainer.removeClass('playing');
499            playBtn.removeClass('pause');
500        }
501    }
502    
503    window.Alpha.LazyBackground.prototype = {
504        
505        init: function () {
506            
507            return [
508                
509                BX.create('div', {
510                    props: {className: !!this.params.className ? this.params.className : ''},
511                    dataset: {role: "lazyload-background", src: this.params.src},
512                    html: '<div class="img-lazy-spinner"><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div></div>'
513                })
514                
515            ];
516            
517        }
518        
519    };
520
521    window.Alpha.LazyBackgroundThumb.prototype = {
522
523        init: function () {
524            if (this.params.type == "VIDEO")
525            {
526                return [
527                    BX.create('div', {
528                        props: {className: 'img-wrapper'},
529                        children: [
530                            BX.create('div', {
531                                props: {className: 'video-thumb-icon'},
532                            }),
533                            BX.create('div', {
534                                props: {className: (!!this.params.className ? this.params.className : '') + ' video-thumb'},
535                                dataset: {role: "lazyload-background", src: this.params.src},
536                                html: '<div class="img-lazy-spinner"><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div></div>'
537                            })
538                        ]
539                    })
540                ];
541            }
542            else
543            {
544                return [
545                    BX.create('div', {
546                        props: {className: 'img-wrapper'},
547                        children: [
548                            BX.create('div', {
549                                props: {className: !!this.params.className ? this.params.className : ''},
550                                dataset: {role: "lazyload-background", src: this.params.src},
551                                html: '<div class="img-lazy-spinner"><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div></div>'
552                            })
553                        ]
554                    })
555                ];
556            }
557
558        }
559
560    };
561
562    window.Alpha.LazyForceLoad = function (params)
563    {
564        this.params = params;
565        this.init();
566        
567    };
568
569    window.Alpha.ChangeRegionAjaxLink = function(link) 
570    {
571        var regionModals = document.querySelectorAll('.city-suggestion-container');
572        if (regionModals)
573        {
574            regionModals.forEach(regionModal => {
575                if (regionModal.classList.contains('open') || regionModal.classList.contains('mobile')) {
576                    let redirectButton = regionModal.querySelector('.city-suggestion-popup .buttons a.confirm');
577                    let redirectLink = redirectButton.href;
578                    redirectLink = redirectLink.split('&r=');
579                    if (link.includes('?bxajaxid='))
580                    {
581                        link = link.split('?bxajaxid=')[0];
582                    }
583                    redirectLink[1] = link;
584                    redirectLink = redirectLink.join('&r=');
585                    redirectButton.href= redirectLink;
586                }
587            });
588        }
589    }
590    
591    window.Alpha.LazyForceLoad.prototype = {
592        
593        init: function () {
594            
595            if (typeof(this.params) == 'object' && !!this.params.parentNode && typeof(this.params.parentNode) == 'object')
596            {
597                $(this.params.parentNode).find('[data-role="lazyload-background"]').each(function () {
598                    var instance = $(this).data("plugin_lazy");
599                    if (typeof(instance) == 'object') {
600                        instance.loadAll();
601                    }
602                });
603
604            }
605            
606        }
607        
608    };
609    
610    
611})(window);

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.