PageSourceSearch

https://yarcube.ru/local/templates/yarcube_new/js/common.js

js yarcube.ru collected 2026-10-01 08:51:58 UTC 19,959 bytes, 588 lines download raw bytes

1$(document).ready(function() {
2
3    (function($) {
4
5        // font
6        $(function() {
7            // begin of fonts loading
8            // if you need google fonts - use this function
9            const loadFont = (url) => {
10                var xhr = new XMLHttpRequest();
11                xhr.open("GET", url, true);
12                xhr.onreadystatechange = () => {
13                    if (xhr.readyState == 4 && xhr.status == 200) {
14                        let css = xhr.responseText;
15                        css = css.replace(/}/g, "font-display: swap; }");
16
17                        const head = document.getElementsByTagName("head")[0];
18                        const style = document.createElement("style");
19                        style.appendChild(document.createTextNode(css));
20                        head.appendChild(style);
21                    }
22                };
23                xhr.send();
24            };
25            loadFont(
26                "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700&display=swap"
27            );
28
29            // loadFont(
30            //     "https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700&display=swap"
31            // );
32
33        });
34
35
36
37        /* ФИКСЕД ШАПКА ДЕСКТОП */
38
39        $(window).on("scroll", function() {
40
41            if (window.innerWidth > 991) {
42
43                if ($(window).scrollTop() > 40) {
44                    var site_header = $('.site-header');
45                    $('.site-header__wrp').css('height', '131px');
46                    site_header.addClass('_fixed');
47                } else {
48                    var site_header = $('.site-header');
49                    $('.site-header__wrp').css('height', 'auto');
50                    site_header.removeClass('_fixed');
51                }
52
53            }
54
55        });
56
57        /* END ----- ФИКСЕД ШАПКА */
58
59        /* ПОИСК В ШАПКЕ НА ДЕСКТОПЕ */
60
61        /* Плавное выдвижение поиска в шапке  */
62        $('#js-site-header-search-container').on('click', function(e) {
63
64            if (window.innerWidth > 991) {
65
66                e.preventDefault();
67                $('.js-site-header-search').addClass('opened');
68                $('#shb-menu__search-first').hide();
69
70                var search_width = search_header_width_calc();
71
72                TweenMax.to(".js-site-header-search", .3, {
73                    width: search_width,
74                    opacity: '1'
75                });
76
77            }
78
79        });
80
81        /* Возврат ширины поисковой строки в шапке */
82        function search_header_width_calc() {
83
84            var menu_container_offset = $('.js-header-container').offset().left,
85                header_bar_search_cont_offset = $('#js-site-header-search-container').offset().left,
86                header_bar_search_cont_width = $('#js-site-header-search-container').outerWidth();
87
88            var search_width = header_bar_search_cont_offset - menu_container_offset + header_bar_search_cont_width - 17;
89
90            return search_width;
91
92        }
93
94        /* Закрыть что-то по клику во вне */
95        $(document).mouseup(function(e) { // событие клика по веб-документу
96
97            if (window.innerWidth > 991) {
98
99                var div = $(".js-site-header-search"); // тут указываем ID элемента
100
101                if (!div.is(e.target) // если клик был не по нашему блоку
102                    &&
103                    div.has(e.target).length === 0) { // и не по его дочерним элементам
104
105                    TweenMax.to(".js-site-header-search", .3, {
106                        width: '0',
107                        opacity: '0',
108                        onComplete: function() {
109                            div.removeClass('opened');
110                            $('#shb-menu__search-first').show();
111                        }
112                    });
113
114                }
115
116            }
117
118        });
119
120        /* END ----- ПОИСК В ШАПКЕ */
121
122
123        /* МОБИЛЬНЫЕ МЕНЮШКИ В ШАПКЕ */
124
125        /* МЕНЮ */
126
127        $(document).on('click', '.js-mobile-menu-toggler', function(e) {
128            e.preventDefault();
129            e.stopPropagation();
130
131            if (window.innerWidth < 992) {
132                $('#js-mobil-slide-social').removeClass('_opened');
133                $('#js-mobil-slide-search').removeClass('_opened');
134
135                $('#js-header-mobile-menu').toggleClass('_opened');
136            }
137        })
138
139        $(document).mouseup(function(e) { // событие клика по веб-документу
140
141            if (window.innerWidth < 992) {
142
143                var div = $("#js-header-mobile-menu");
143 // тут указываем ID элемента
144                var divToggler = $('.js-mobile-menu-toggler');
145
146                if (!div.is(e.target) &&
147                    div.has(e.target).length === 0 &&
148                    !divToggler.is(e.target) &&
149                    divToggler.has(e.target).length === 0) {
150
151                    div.removeClass('_opened');
152
153                }
154
155            }
156
157        });
158
159
160        /* ПОИСК */
161
162        $(document).on('click', '#js-site-header-search-container', function(e) {
163            e.preventDefault();
164            e.stopPropagation();
165
166            if (window.innerWidth < 992) {
167                $('#js-mobil-slide-social').removeClass('_opened');
168                $('#js-header-mobile-menu').removeClass('_opened');
169
170                $('#js-mobil-slide-search').toggleClass('_opened');
171            }
172        })
173
174        $(document).mouseup(function(e) { // событие клика по веб-документу
175
176            if (window.innerWidth < 992) {
177
178                var div2 = $("#js-mobil-slide-search"); // тут указываем ID элемента
179                var divToggler2 = $('#js-site-header-search-container');
180
181                if (!div2.is(e.target) &&
182                    div2.has(e.target).length === 0 &&
183                    !divToggler2.is(e.target) &&
184                    divToggler2.has(e.target).length === 0) {
185
186                    div2.removeClass('_opened');
187
188                }
189
190            }
191
192        });
193
194        /* СОЦИАЛКА */
195
196        $(document).on('click', '.js-shared-toggler', function(e) {
197            e.preventDefault();
198            e.stopPropagation();
199
200            if (window.innerWidth < 992) {
201                $('#js-mobil-slide-search').removeClass('_opened');
202                $('#js-header-mobile-menu').removeClass('_opened');
203
204                $('#js-mobil-slide-social').toggleClass('_opened');
205            }
206        })
207
208        $(document).mouseup(function(e) { // событие клика по веб-документу
209
210            if (window.innerWidth < 992) {
211
212                var div3 = $("#js-mobil-slide-social"); // тут указываем ID элемента
213                var divToggler3 = $('.js-shared-toggler');
214
215                if (!div3.is(e.target) &&
216                    div3.has(e.target).length === 0 &&
217                    !divToggler3.is(e.target) &&
218                    divToggler3.has(e.target).length === 0) {
219
220                    div3.removeClass('_opened');
221
222                }
223
224            }
225
226        });
227
228        /* END --------- МОБИЛЬНЫЕ МЕНЮШКИ */
229
230        /* Закрыть рекламу */
231
232        /* Появление возможости закрыть через 10 секунд */
233
234        $('.js-adv-close').each(function() {
235            var $this = $(this);
236            //console.log($this);
237            setTimeout(function() {
238                //console.log($this);
239                $this.show();
240            }, 10000);
241        })
242
243        $(document).on('click', '.js-adv-close', function(e) {
244            e.preventDefault();
245            e.stopPropagation();
246
247            $(this).closest('.js-adv-target').animate({
248                    opacity: 0,
249                    height: 0
250                },
251                300,
252                function() {
253                    $(this).closest('.js-adv-target').remove();
254                });
255
256        })
257
258        /* Кнопка наверх */
259
260        $(window).on("scroll", function() {
261
262            if (window.innerWidth > 991) {
263
264                if ($(window).scrollTop() > 500) {
265                    var to_up_btn = $('#js-to-up-btn');
266                    to_up_btn.addClass('_showed');
267                } else {
268                    var to_up_btn = $('#js-to-up-btn');
269                    to_up_btn.removeClass('_showed');
270                }
271
272            }
273
274        });
275
276        $(document).on("click", "#js-to-up-btn", function(event) {
277
278            event.preventDefault();
279            $('html,body').animate({ scrollTop: 0 }, 500);
280
281        });
282
283        // Слайдер на главной
284
285        $('.js-slider-on-main').slick({
286            infinite: true,
287            dots: false,
288            arrows: true,
289            slidesPerRow: 1,
290            slidesToShow: 1,
291            slidesToScroll: 1,
292            autoplay: true,
293            autoplaySpeed: 5000,
294            autoplayHoverPause: true,
295            fade: true,
296            swipeToSlide: true,
297
298            prevArrow: '<span><i class="slick-prev fas fa-angle-left fa-3x"> </i></span>',
299            nextArrow: '<span><i class="slick-next fas fa-angle-right fa-3x"> </i></span>'
300
301        });
302
303
304        /* Галерея мероприятий */
305
306        $('.js-event-slider-main').slick({
307            arrows: true,
308            speed: 500,
309            // infinite: false,
310            slidesToShow: 3,
311            slidesToScroll: 1,
312            centerMode: true,
313            centerPadding: '0px',
314            // initialSlide: 1,
315            touchThreshold: 400,
316            responsive: [{
317                    breakpoint: 992,
318                    settings: {
319                        slidesToShow: 2,
320                        slidesToScroll: 1,
321                    }
322                },
323                {
324                    breakpoint: 600,
325                    settings: {
326                        slidesToShow: 2,
327                        slidesToScroll: 1,
328                        dots: true,
329                        arrows: false
330                    }
331                },
332                {
333                    breakpoint: 480,
334                    settings: {
335                        slidesToShow: 1,
336                        slidesToScroll: 1,
337                        dots: true,
338                        arrows: false
339                    }
340                }
341            ]
342        });
343
344        $('.js-event-slider-playbill').slick({
345            arrows: true,
346            speed: 500,
347            // infinite: false,
348            slidesToShow: 3,
349            slidesToScroll: 1,
350            //centerMode: true,
351            centerPadding: '0px',
352            // initialSlide: 1,
353            touchThreshold: 400,
354            responsive: [{
355                    breakpoint: 780,
356                    settings: {
357                        slidesToShow: 2,
358                        slidesToScroll: 1,
359                        dots: true,
360                        arrows: false
361                    }
362                },
363                {
364                    breakpoint: 480,
365                    settings: {
366                        slidesToShow: 1,
367                        slidesToScroll: 1,
368                        dots: true,
369                        arrows: false
370                    }
371                }
372            ]
373        });
374
375
376        /*  НОВОСТНАЯ ЛЕНТА */
377
378        /* Раскрыть новость */
379
380        $(document).on('click', '.js-newsletter-soc__toggler', function(e) {
381            e.preventDefault();
382            e.stopPropagation();
383            $(this).closest('.js-newsletter-soc__cont').find('.js-newsletter-soc__btns').toggleClass('_opened');
384        })
385
386        $(document).mouseup(function(e) { // событие клика по веб-документу
387
388            var div2 = $(".js-newsletter-soc__btns"); // тут указываем ID элемента
389            var divToggler2 = $('.js-newsletter-soc__toggler');
390
391            if (!div2.is(e.target) &&
392                div2.has(e.target).length === 0 &&
393                !divToggler2.is(e.target) &&
394                divToggler2.has(e.target).length === 0) {
395
396                div2.removeClass('_opened');
397
398            }
399
400        });
401
402
403        /* Узнаем реальную высоту элемента, записываем в data, утсанавливаем всем элементам высоту 190пкс */
404
405        // $('.js-reduced-height').each(function(){
406
407        // 	var hidden_height = $(this).outerHeight() < 190 ? 190 : $(this).outerHeight()
408
409        // 	$(this).data('hidden-height', hidden_height);
410        // 	$(this).outerHeight('190px');
411        // 	//console.log(hidden_height);
412        // 	if (hidden_height <= 190) {
413        // 		$(this).closest('.feed-news').find('.js-feed-news-opener').addClass('hidden');
414        // 	}
415        // })
416
417        // $(document).on('click', '.js-feed-news-opener', function(e){
418        // 	e.preventDefault();
419        // 	e.stopPropagation();
420
421        // 	var $this = $(this);
422        // 	var oneNews = $(this).closest('.feed-news').find('.feed-news__inner');
423        // 	var otherNews = $(this).closest('.feed-news__all-wrp').find('.feed-news__inner').not(oneNews);
424        // 	oneNews.addClass('opened');
425
426        //        TweenMax.to(oneNews, .3,
427        //                {
428        //                    height: oneNews.data('hidden-height'),
429        //                    onComplete: function(){
430        //                       	$this.addClass('hidden');
431        //                       	$this.siblings('.feed-news__toggler').removeClass('hidden');
432        //                       }
433        //                }
434        //        );
435
436        //        otherNews.each(function(){
437        //        	var $this= $(this);
438        //         TweenMax.to($this, .3,
439        //                 {
440        //                     height: '190',
441        //                     onComplete: function(){
442        //                        	$this.removeClass('opened');
443        //                        	$this.closest('.feed-news').find('.js-feed-news-opener').removeClass('hidden');
444        //                        	$this.closest('.feed-news').find('.js-feed-news-closer').addClass('hidden');
445        //                        }
446        //                 }
447        //         );
448        //        })
449        // })
450        $(document).on('click', '.js-feed-news-opener', function(e) {
451            e.preventDefault();
452            e.stopPropagation();
453
454            var $this = $(this);
455            var oneNews = $(this).closest('.feed-news').find('.feed-news__inner');
456            var otherNews = $(this).closest('.feed-news__all-wrp').find('.feed-news__inner').not(oneNews);
457            oneNews.addClass('opened');
458            $this.addClass('hidden');
459            $this.siblings('.feed-news__toggler').removeClass('hidden');
460            oneNews.find("._left").attr("style", "display:none;");
461            oneNews.find("._right").attr("style", "width:100%;");
462            // $this.find('._left').attr('style', 'display: none;');
463
464            otherNews.each(function() {
465                var $this = $(this);
466                $this.removeClass('opened');
467                $this.closest('.feed-news').find('.js-feed-news-opener').removeClass('hidden');
468                $this.closest('.feed-news').find('.js-feed-news-closer').addClass('hidden');
469            })
470        })
471
472        // $(document).on('click', '.js-feed-news-closer', function(e){
473        // 	e.preventDefault();
474        // 	e.stopPropagation();
475
476        // 	var $this = $(this);
477        // 	var oneNews = $(this).closest('.feed-news').find('.feed-news__inner');
478        //        TweenMax.to(oneNews, .3,
479        //                {
480        //                    height: '190',
481        //                    onComplete: function(){
482        //                       	$this.addClass('hidden');
483        //                       	oneNews.removeClass('opened');
484        //                       	$this.siblings('.feed-news__toggler').removeClass('hidden');
485        //                       }
486        //                }
487        //        );
488        // })
489
490        $(document).on('click', '.js-feed-news-closer', function(e) {
491            e.preventDefault();
492            e.stopPropagation();
493
494            var $this = $(this);
495            var oneNews = $(this).closest('.feed-news').find('.feed-news__inner');
496            $this.addClass('hidden');
497            oneNews.removeClass('opened');
498            $this.siblings('.feed-news__toggler').removeClass('hidden');
499            oneNews.find("._left").removeAttr("style");
500            oneNews.find("._right").removeAttr("style");
501
502        })
503
504        /* Слайдер внутри новости */
505
506        $('.news-slider').each(function() {
507
508            var sliderWrp = $(this).closest('.news-slider__wrp');
509
510            $(this).slick({
511                arrows: true,
512                speed: 500,
513                slidesToShow: 1,
514                slidesToScroll: 1,
515                touchThreshold: 400,
516                appendArrows: sliderWrp
517            });
518        })
519
520
521        /* Выбор даты на странице поиска */
522
523        // инициализация
524
525        $(".js-date-picker").datepicker({
526            changeMonth: true,
527            changeYear: true
528        });
529
530        // локализация
531
532        $.datepicker.setDefaults({
533            closeText: 'Закрыть',
534            prevText: '',
535            currentText: 'Сегодня',
536            monthNames: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь',
537                'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
538            ],
539            monthNamesShort: ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн',
540                'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'
541            ],
542            dayNames: ['воскресенье', 'понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота'],
543            dayNamesShort: ['вск', 'пнд', 'втр', 'срд', 'чтв', 'птн', 'сбт'],
544            dayNamesMin: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
545            weekHeader: 'Не',
546            dateFormat: 'dd.mm.yy',
547            firstDay: 1,
548            isRTL: false,
549            showMonthAfterYear: false,
550            yearSuffix: ''
551        });
552
553
554        // Новости в виде табов, активность по ховеру
555
556        $('.js-alt-news .prw-news-list__item').on('mouseenter', function(event) {
557
558            if (window.innerWidth > 1199) {
559                var curPreview = $(this),
560                    curPreviewIndex = curPreview.index();
561
562                curPreview.closest('.js-alt-news').find('.prw-big-news').removeClass('_active').eq(curPreviewIndex).addClass('_active');
563            }
564
565        });
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580    })(jQuery);
581
582
583
584
585
586
587
588});

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.