PageSourceSearch

https://www.rfs.ru/js/widgets/media/media.js?v=1773831949

js rfs.ru collected 2026-10-02 03:57:17 UTC 42,095 bytes, 1,087 lines download raw bytes

1rfs.medialoads = {
2    'params'            : {},
3    'init'              : function(params) {
4        rfs.medialoads.initTitles();
5        rfs.medialoads.params = params;
6        rfs.medialoads.params.list = $(params.listSelector);
7        rfs.medialoads.params.allTimeClick = false;
8        rfs.medialoads.params.context = $(params.btnParentSelector).find('.context').data();
9        $(params.btnParentSelector).find('.context').remove();
10        $('.' + params.loadmoreClass + ', .' + params.loadallClass).click(function() {
11            rfs.medialoads.ajaxQuery(rfs.medialoads.params.context.day, rfs.medialoads.params.context.month, rfs.medialoads.params.context.year, $(this));
12        });
13        $('ul.js-days li').click(function() {
14            if (!rfs.medialoads.params.allTimeClick) {
15                rfs.medialoads.ajaxQuery($(this).val(), rfs.medialoads.params.context.month, rfs.medialoads.params.context.year, false);
16            }
17        });
18        $('ul.js-months li').click(function() {
19            if (!rfs.medialoads.params.allTimeClick) {
20                rfs.medialoads.ajaxQuery(rfs.medialoads.params.context.day, $(this).val(), rfs.medialoads.params.context.year, false);
21            }
22        });
23        $('ul.js-years li').click(function() {
24            if (!rfs.medialoads.params.allTimeClick) {
25                rfs.medialoads.ajaxQuery(rfs.medialoads.params.context.day, rfs.medialoads.params.context.month, $(this).val(), false);
26            }
27        });
28        $('.for-all-time').click(function() {
29            $(this).toggleClass('active');
30            if ($(this).hasClass('active')) {
31                $('ul.js-days, ul.js-months, ul.js-years').parents('.rfs-dropdown').addClass('disabled');
32                rfs.medialoads.params.allTimeClick = true;
33                rfs.medialoads.ajaxQuery(0, 0, 0, false);
34            } else {
35                $('ul.js-days, ul.js-months, ul.js-years').parents('.rfs-dropdown').removeClass('disabled');
36                rfs.medialoads.params.allTimeClick = false;
37                rfs.medialoads.ajaxQuery($('ul.js-days li.active').val(), $('ul.js-months li.active').val(), $('ul.js-years li.active').val(), false);
38            }
39        });
40    },
41    'generateSendData'  : function(loadmore, day, month, year) {
42        var sendData = {
43            small  : rfs.medialoads.params.context.small,
44            limit  : rfs.medialoads.params.context.limit,
45            is_main: rfs.medialoads.params.context.is_main,
46            day    : day,
47            month  : month,
48            year   : year
49        };
50        if (rfs.medialoads.params.context.type != null) {
51            sendData.type = rfs.medialoads.params.context.type;
52        }
53        if (rfs.medialoads.params.context.id != null) {
54            sendData.id = rfs.medialoads.params.context.id;
55        }
56        if (rfs.medialoads.params.context.tags != null) {
57            sendData.tags = rfs.medialoads.params.context.tags;
58        }
59        if (rfs.medialoads.params.context.excludedVideoId) {
60            sendData.excludedVideoId = rfs.medialoads.params.context.excludedVideoId;
61        }
62        if (rfs.medialoads.params.context.mobile != null) {
63            sendData.mobile = rfs.medialoads.params.context.mobile;
64        }
65        if (sendData.mobile) {
66            sendData.module = rfs.medialoads.params.context.module;
67            sendData.moduleId = rfs.medialoads.params.context.moduleId;
68        }
69        if (loadmore) {
70            sendData.last_datetime = rfs.medialoads.params.context.last_datetime;
71            sendData.offset = rfs.medialoads.params.context.offset;
72        }
73        if (rfs.medialoads.params.context.unlimited) {
74            sendData.unlimited = true;
75        }
76
77        return sendData;
78    },
79    'ajaxQuery'         : function(day, month, year, loadmore) {
80        var urlLoadAlbums = rfs.medialoads.params.ajaxUrl;
81
82        if (loadmore) {
83            rfs.locker.lock($('.' + rfs.medialoads.params.loadmoreClass));
84        }
85
86        var sendData = rfs.medialoads.generateSendData(loadmore, day, month, year);
87        if (loadmore && loadmore.data('hideProjectMedia')) {
88            sendData.hideProjectMedia = true;
89        }
90
91        $.ajax({
92            url : urlLoadAlbums,
93            data: sendData
94        }).done(function(data) {
95            rfs.medialoads.params.context.last_datetime = data.lastDateTime;
96            rfs.medialoads.params.context.count = data.count;
97            rfs.medialoads.params.context.day = day;
98            rfs.medialoads.params.context.month = month;
99            rfs.medialoads.params.context.year = year;
100            rfs.medialoads.params.context.offset = ((loadmore) ? (rfs.medialoads.params.context.offset + 1) : 1);
101            if (loadmore) {
102                $(rfs.medialoads.params.list).find('div.clear').remove();
103                $(rfs.medialoads.params.list).append(data.body);
104                if ((rfs.medialoads.params.context.count < rfs.medialoads.params.context.limit) || sendData.unlimited) {
105                    $(loadmore).remove();
106                } else {
107                    rfs.locker.unlock('.' + rfs.medialoads.params.loadmoreClass);
108                }
109                if ($(rfs.medialoads.params.list).hasClass('js-videos-list')) {
110                    rfs.videogallery.loadmoreVideos();
111                }
112            } else {
113                $('.' + rfs.medialoads.params.loadmoreClass + ', .' + rfs.medialoads.params.loadallClass).parent().remove();
114                $(rfs.medialoads.params.list).html(data.body);
115                if (rfs.medialoads.params.context.count >= rfs.medialoads.params.context.limit) {
116                    var btn = sendData.unlimited ? rfs.medialoads.createUnlimitedBtn() : rfs.medialoads.createLoadmoreBtn();
117                    if (btn) {
118                        $(btn).click(function() {
119                            rfs.medialoads.ajaxQuery(rfs.medialoads.params.context.day, rfs.medialoads.params.context.month, rfs.medialoads.params.context.year, $(this));
120                        });
121                        $(rfs.medialoads.params.btnParentSelector).append(btn);
122                    }
123                }
124            }
125            rfs.medialoads.initTitles();
126        });
127    },
128    'createUnlimitedBtn': function() {
129        if ($('.' + rfs.medialoads.params.loadallClass).length) {
130            return false;
131        }
132        return $('<div>', {'class': 'broadcasts-to-all-btn'}).append($('<button>', {'class': rfs.medialoads.params.loadallClass}).text(rfs.medialoads.params.loadallText));
133    },
134    'createLoadmoreBtn' : function() {
135        if ($('.' + rfs.medialoads.params.loadmoreClass).length) {
136            return false;
137        }
138        return $('<div>', {'class': 'loadmore-cont'}).append($('<button>', {'class': rfs.medialoads.params.loadmoreClass + ' loadmore'}).text(rfs.medialoads.params.loadmoreText).css('width', '100%'));
139    },
140    'initTitles'        : function() {
141        $('.js-media-item-title:visible').each(function() {
142            var height = $(this).height(), small = $(this).parents('.media-slider').length;
143            $(this).css({
144                'top'   : 'auto',
145                'bottom': $(this).parent().height() - height - (small ? 145 : 168)
146            });
147        });
148    }
149};
150
151rfs.photogallery = new function() {
152    var that = this;
153
154    this.labels = {
155        'author' : '', 'address': '', 'confirm': ''
156    };
157
158    var classes = {
159        'mediaGallery'        : 'rfs-media-gallery',
160        'gallery'             : 'rfs-gallery',
161        'close'               : 'rfs-gallery-close',
162        'leftArrow'           : 'rfs-gallery-left-arrow',
163        'rightArrow'          : 'rfs-gallery-right-arrow',
164        'slider'              : 'rfs-gallery-slider',
165        'sliderCont'          : 'rfs-gallery-slider-cont',
166        'slides'              : 'rfs-gallery-slider-slides',
167        'slide'               : 'rfs-gallery-slide',
168        'slideCont'           : 'rfs-gallery-slide-cont',
169        'dontOpen'            : 'rfs-gallery-dont-open',
170        'image'               : 'rfs-gallery-image',
171        'imageDesc'           : 'rfs-gallery-image-desc',
172        'imageTags'           : 'rfs-gallery-image-tags',
173        'imageTitle'          : 'rfs-gallery-image-title',
174        'imageLink'           : 'rfs-gallery-image-link',
175        'imageAuthor'         : 'rfs-gallery-image-author',
176        'imageCounter'        : 'rfs-gallery-image-counter',
177        'imageLoader'         : 'rfs-gallery-image-loader',
178        'indicators'          : 'rfs-gallery-indicators',
179        'indicatorsLeftArrow' : 'rfs-gallery-indicators-left-arrow',
180        'indicatorsRightArrow': 'rfs-gallery-indicators-right-arrow',
181        'indicatorsCont'      : 'rfs-gallery-indicators-cont',
182        'indicatorsSlides'    : 'rfs-gallery-indicators-slides',
183        'indicatorSlide'      : 'rfs-gallery-indicators-slide'
184    };
185
186    var selectors = {
187        'mediaGallery'        : '.' + classes.mediaGallery,
188        'gallery'             : '.' + classes.gallery,
189        'close'               : '.' + classes.close,
190        'leftArrow'           : '.' + classes.leftArrow,
191        'rightArrow'          : '.' + classes.rightArrow,
192        'slider'              : '.' + classes.slider,
193        'sliderCont'          : '.' + classes.sliderCont,
194        'slides'              : '.' + classes.slides,
195        'slide'               : '.' + classes.slide,
196        'dontOpen'            : '.' + classes.dontOpen,
197        'image'               : '.' + classes.image,
198        'imageDesc'           : '.' + classes.imageDesc,
199        'imageTags'           : '.' + classes.imageTags,
200        'imageTitle'          : '.' + classes.imageTitle,
201        'imageLink'           : '.' + classes.imageLink,
202        'imageAuthor'         : '.' + classes.imageAuthor,
203        'imageCounter'        : '.' + classes.imageCounter,
204        'imageLoader'         : '.' + classes.imageLoader,
205        'indicators'          : '.' + classes.indicators,
206        'indicatorsLeftArrow' : '.' + classes.indicatorsLeftArrow,
207        'indicatorsRightArrow': '.' + classes.indicatorsRightArrow,
208        'indicatorsCont'      : '.' + classes.indicatorsCont,
209        'indicatorsSlides'    : '.' + classes.indicatorsSlides,
210        'indicatorSlide'      : '.' + classes.indicatorSlide
211    };
212    var betcityWrapper = $('.js-bet-city');
213    var isTablet = false
214    if (betcityWrapper && betcityWrapper.outerWidth() < 1280 && betcityWrapper.outerWidth() > 480) {
215        isTablet = true
216    }
217
218    var isMobile = false
219    if (betcityWrapper) {
220        isMobile = betcityWrapper.outerWidth() < 481;
221    } else {
222        isMobile = $('.wrapper').outerWidth() < 481;
223    }
224
225    var openState = false;
226
227    var params = {
228        sliderSidePadding: isMobile ? 0 : 36 + 36 + 32,
229        indicatorHeight  : 128,
230        slideWideWidth   : 800,
231        mouseHolder      : false
232    };
233
234    this.gallery = null;
235
236    this.images = [];
237
238    this.init = function() {
239        var mediaGallery = $(selectors.mediaGallery);
240        if (!$(mediaGallery).length) {
241            return false;
242        }
243
244        params['maxSlideHeight']    = $(window).height() - params.indicatorHeight - params.indicatorHeight / (isMobile ? 3 : 4);
245        if(isTablet) {
246            params['maxSlideWidth'] = $(window).outerWidth()
247        } else {
248            params['maxSlideWidth']     = isMobile ? (window.orientation == 0 ? 480 : $(window).outerWidth()) : ($(window).outerWidth() < 1232 ? 1232 : $(window).outerWidth());
249        }
250        params['widthIndicator']    = 155;
251        params['maxViewIndicators'] = Math.floor($(window).width() / params.widthIndicator) - 2;
252
253
254        that.$gallery    = null;
255        that.$controls   = null;
256        that.$slider     = null;
257        that.$indicators = null;
258
259        that.images = $($(mediaGallery).find('.rfs-photo'));
260
261        //Создание галереи изображений
262        if (that.images.length && that.$gallery === null) {
263            that.create();
264        }
265    };
266
267    this.destroy = function() {
268        if (that.$gallery !== null) {
269            if (openState) {
270                $(that.images[that.slider.getActiveIndex()]).addClass('auto-open');
271            }
272
273            that.close();
274
275            $(that.$gallery).remove();
276            rfs.slider.widgets.splice(params.gallerySliderIndex);
277            rfs.slider.widgets.splice(params.galleryIndicatorSliderIndex);
278        }
279    };
280
281    this.create = function() {
282        that.$gallery    = $('<div>', {'class': 'rfs-gallery'}).hide();
283        that.$controls   = that.createControls();
284        that.$slider     = that.createSlider();
285        that.$indicators = that.createIndicators();
286
287        $(that.$gallery).append(
288            that.$slider,
289            that.$indicators,
290            that.$controls.close
291        );
292
293        $('body').append(that.$gallery);
294
295        that.slider.init();
296        that.indicatorsSlider.init();
297        rfs.slider.init();
298
299        $('body').find('.rfs-slider').each(function(k) {
300            if ($(this).hasClass(classes.slider)) {
301                params['gallerySliderIndex'] = k;
302            }
303            if ($(this).hasClass(classes.indicators)) {
304                params['galleryIndicatorSliderIndex'] = k;
305            }
306        });
307
308        //Автооткрытие галереи
309        that.images.each(function() {
310            if ($(this).hasClass('auto-open')) {
311                $(this).removeClass('auto-open').click();
312            }
313        });
314    };
315
316    this.open = function(index) {
317        rfs.overlay.open();
318        $(that.$gallery).show();
319        that.lazy.init(index);
320        that.slider.to(index, {'delay': 0});
321        this.keymap.start();
322        openState = true;
323    };
324
325    this.close = function() {
326        rfs.overlay.close();
327        $(that.$gallery).hide();
328        rfs.mediagallery.link.changeLink();
329        this.keymap.end();
330        openState = false;
331    };
332
333    this.createControls = function() {
334        //Кнопка закрытия
335        var close = $('<a>', {'class': classes.close}).click(function() {
336            that.close();
337        });
338
339        //Левая стрелка
340        var leftArrow = $('<a>', {'class': classes.leftArrow}).hide().click(function() {
341            that.slider.prev(true);
342        });
343
344        //Правая стрелка
345        var rightArrow = $('<a>', {'class': classes.rightArrow}).click(function() {
346            that.slider.next(true);
347        });
348
349        //Скрываем правую стрелу, если изображений меньше 2-ух
350        if (that.images.length < 2) {
351            $(rightArrow).hide();
352        }
353
354        return {
355            'close'     : close,
356            'leftArrow' : leftArrow,
357            'rightArrow': rightArrow
358        };
359    };
360
361    this.createSlider = function() {
362        var slider = $('<div>', {'class': classes.slider}),
363            sliderCont = $('<div>', {'class': classes.sliderCont}),
364            slides = $('<div>', {'class': classes.slides});
365
366        $(that.images).each(function(index) {
367            $(slides).append(that.createSlide(this, index));
368        });
369
370        $(sliderCont).append(slides);
371        $(slider).append(sliderCont, that.$controls.leftArrow, that.$controls.rightArrow).css({
372            'marginTop': params.indicatorHeight / (isMobile ? 2 : 4),
373            'height'   : params.maxSlideHeight
374        });
375
376        return slider;
377    };
378
379    this.createSlide = function(image, index) {
380        $(image).off('click').click(function() {
381            that.open(index);
382            rfs.mediagallery.link.changeLink($(that.images[index]).attr('href'));
383            //Запрещаем переход по ссылке
384            return false;
385        });
386        var slide = $('<div>', {'class': classes.slide}).css({
387            'width' : params.maxSlideWidth,
388            'height': params.maxSlideHeight
389        });
390        var slideCont = $('<div>', {'class': classes.slideCont}).css({
391            'maxWidth': params.maxSlideWidth - params.sliderSidePadding * 2,
392            'width'   : params.maxSlideWidth - params.sliderSidePadding * 2,
393            'height'  : params.maxSlideHeight
394        });
395        var img = $('<img>', {
396                'class'        : classes.image,
397                'data-original': $(image).data('imageUrl')
398            })
399            .hide()
400            .lazyload({'event': 'lazy'})
401            .click(function() {
402                that.slider.next(true);
403            });
404        var description = that.description.create(image, index);
405        var loader = $('<div>', {'class': classes.imageLoader});
406
407        $(slideCont).append(loader, img, description);
408        $(slide).append(slideCont);
409
410        //Появление описание при наведении мыши на изображение
411        $(slideCont).hover(
412           function() {
413                params.mouseHolder = true;
414                setTimeout(function() {
415                    if (params.mouseHolder) {
416                        that.description.show(description, 300);
417                    }
418                }, 700);
419            },
420            function() {
421                that.description.hide(description, 0);
422                params.mouseHolder = false;
423            }
424        );
425
426        return slide;
427    };
428
429    this.description = {
430        create: function(image, index) {
431            var data = $(image).data();
432            var description = $('<div>', {'class': classes.imageDesc}),
433                title = $('<div>', {'class': classes.imageTitle}).text(data['title'] ? data['title'] : ''),
434                link = $('<a>', {'class': classes.imageLink}).text(that.labels.address),
435                author = $('<div>', {'class': classes.imageAuthor}).text(data['author'] ? that.labels.author + ': ' + data['author'] : ''),
436                counter = $('<div>', {'class': classes.imageCounter}).text([index + 1, '/', that.images.length].join(' '));
437            if (data['tags']) {
438                var tags = $('<div>', {'class': classes.imageTags});
439                $.each(data['tags'], function(name, url) {
440                    $(tags).append($('<a>', {
441                        'href' : url,
442                        'class': 'article-tag'
443                    }).html(name));
444                });
445                $(description).append(tags);
446            }
447            $(description).append(
448                $('<div>').append(title, link, $('<div>', {'class': 'clear'})),
449                $('<div>').append(author, counter, $('<div>', {'class': 'clear'}))
450            );
451
452            //Устанавливанем копирование по клику
453            rfs.mediagallery.link.copyLink(link, 'photo', that.labels.confirm);
454
455            return description;
456        },
457        show: function(description) {
458            var container = $(description).parent(),
459                originalWidth = parseInt($(container).data('originalWidth'));
460            $(container).queue("fx", []);
461
462            if (originalWidth < params.slideWideWidth) {
463                $(container).addClass('wide').animate({'width': params.slideWideWidth}, 100, function() {
464                    if ($(this).hasClass('wide')) {
465                        $(description).addClass('visible');
466                    }
467                });
468            } else {
469                $(description).addClass('visible');
470            }
471        },
472        hide: function (description) {
473            var container = $(description).parent();
474            $(container).queue("fx", []);
475
476            $(description).removeClass('visible');
477            if ($(container).data('originalWidth')) {
478                var originalWidth = $(container).data('originalWidth');
479                $(container).removeClass('wide').animate({'width': originalWidth}, 300);
480            }
481        }
482    };
483
484    this.createIndicators = function() {
485        var width = params.widthIndicator * ((that.images.length > params['maxViewIndicators']) ? params['maxViewIndicators'] : that.images.length) + params.widthIndicator * 2; //вычисление максимального количество видимых индикаторов
486
487        var indicators = $('<div>', {'class': classes.indicators}).css({
488                'width': width
489            }),
490            indicatorsLeftArrow = $('<a>', {'class': classes.indicatorsLeftArrow}).hide(),
491            indicatorsRightArrow = $('<a>', {'class': classes.indicatorsRightArrow}),
492            indicatorsCont = $('<div>', {'class': classes.indicatorsCont}),
493            indicatorsSlides = $('<div>', {'class': classes.indicatorsSlides});
494        $(that.images).each(function(index) {
495            $(indicatorsSlides).append(that.createIndicator(this, index));
496        });
497
498        $(indicatorsCont).append(indicatorsSlides);
499        if (that.images.length > params.maxViewIndicators) {
500            $(indicators).append(indicatorsLeftArrow);
501        }
502        $(indicators).append(indicatorsCont);
503        if (that.images.length > params.maxViewIndicators) {
504            $(indicators).append(indicatorsRightArrow);
505        }
506
507        return indicators;
508    };
509
510    this.createIndicator = function(image, index) {
511        var img = $('<img>', {'src': $(image).data('image'), 'loading': 'lazy'});
512        var indicator = $('<a>', {
513            'class'        : classes.indicatorSlide,
514            'data-photo-id': $(image).data('photoId')
515        }).click(function() {
516            that.lazy.init(index);
517            that.slider.to(index, {'delay': 0});
518        });
519        $(indicator).append(img);
520
521        return indicator;
522    };
523
524    this.slider = {
525        init: function() {
526            $(that.$slider).addClass('rfs-slider').data({
527                'slideStep' : 1,
528                'slideViews': 1
529            });
530
531            $(that.$slider).find(selectors.sliderCont).addClass('rfs-slider-cont');
532            $(that.$slider).find(selectors.slide).addClass('rfs-slider-slide');
533            $(that.$slider).find(selectors.leftArrow).addClass('rfs-slider-left');
534            $(that.$slider).find(selectors.rightArrow).addClass('rfs-slider-right');
535        },
536        next: function(animation) {
537            var active = that.slider.getActiveIndex() + 1;
538            that.lazy.init(active);
539            that.slider.to(active, animation ? {'delay': 600} : {'delay': 0});
540        },
541        prev: function(animation) {
542            var active = that.slider.getActiveIndex() - 1;
543            that.lazy.init(active);
544            that.slider.to(active, animation ? {'delay': 600} : {'delay': 0});
545        },
546        to: function(index, options) {
547            var i, active = that.slider.getActiveIndex();
548
549            that.indicatorsSlider.setActive(index);
550            rfs.mediagallery.link.changeLink($(that.images[index]).attr('href'));
551
552            if (index > active) {
553                for (i = active; i < index; i++) {
554                    rfs.slider.slide(that.$controls.rightArrow, 'next', params.gallerySliderIndex, options);
555                    that.indicatorsSlider.to(index, 'next', options);
556                }
557            } else {
558                for (i = active; i > index; i--) {
559                    rfs.slider.slide(that.$controls.leftArrow, 'prev', params.gallerySliderIndex, options);
560                    that.indicatorsSlider.to(index, 'prev', options);
561                }
562            }
563        },
564        getActiveIndex : function() {
565            var detect = false, active = 0;
566            $(selectors.slide).each(function(k) {
567                if (!detect && !$(this).hasClass('rfs-sliding')) {
568                    detect = true;
569                    active = k;
570                }
571            });
572
573            return active;
574        }
575    };
576
577    this.indicatorsSlider = {
578        init: function() {
579            $(that.$indicators).addClass('rfs-slider').data({
580                'slideStep' : params.maxViewIndicators,
581                'slideViews': params.maxViewIndicators
582            });
583
584            $(that.$indicators).find(selectors.indicatorsCont).addClass('rfs-slider-cont');
585            $(that.$indicators).find(selectors.indicatorSlide).addClass('rfs-slider-slide');
586            $(that.$indicators).find(selectors.indicatorsLeftArrow).addClass('rfs-slider-left');
587            $(that.$indicators).find(selectors.indicatorsRightArrow).addClass('rfs-slider-right');
588        },
589        setActive: function(active) {
590            var slides = $(that.$indicators).find(selectors.indicatorSlide);
591            if (slides[active]) {
592                $(slides).removeClass('active');
593                $(slides[active]).addClass('active');
594            }
595        },
596        to: function(index, side, options) {
597            if (!options) {
598                options = {'delay': 600};
599            }
600
601            var active = that.indicatorsSlider.getActiveIndex();
602            switch (side) {
603                case 'next': {
604                    active = active % params.maxViewIndicators - 1 == 0 ? active : active + params.maxViewIndicators - 1;
605                    if (index > active) {
606                        rfs.slider.slide($(that.$indicators).find(selectors.indicatorsRightArrow), 'next', params.galleryIndicatorSliderIndex, options);
607                    }
608                    break;
609                }
610                case 'prev': {
611                    active = active % params.maxViewIndicators - 1 == 0 ? active + params.maxViewIndicators - 1 : active;
612                    if (index < active) {
613                        rfs.slider.slide($(that.$indicators).find(selectors.indicatorsLeftArrow), 'prev', params.galleryIndicatorSliderIndex, options);
614                    }
615                    break;
616                }
617            }
618        },
619        getActiveIndex : function() {
620            var detect = false, active = 0;
621            $(selectors.indicatorSlide).each(function(k) {
622                if (!detect && !$(this).hasClass('rfs-sliding')) {
623                    detect = true;
624                    active = k;
625                }
626            });
627
628            return active;
629        }
630    };
631
632    this.lazy = {
633        'init': function(k) {
634            var images = $(that.$gallery).find(selectors.image);
635            $(images).each(function(i) {
636                if (i == k) {
637                    if (i == 0 && images[1]) {
638                        that.lazy.load(images[1]);
639                    } else {
640                        that.lazy.load(images[i - 1]);
641                        if (images[i + 1]) {
642                            that.lazy.load(images[i + 1]);
643                        }
644                    }
645                    that.lazy.load(this)
646                }
647            });
648        },
649        'load'     : function(image) {
650            $(image)
651                .trigger('lazy')
652                .load(function() {
653                    $(this).addClass('img-loaded');
654                    var width = $(this).width(), height = $(this).height(), parent = $(this).parent();
655
656                    //Добавляем родителю размер картинки, для интуитивного интерфейса контролов и наведения
657                    if (width > 1 && height > 1) {
658                        $(parent).find(selectors.imageLoader).remove();
659                        $(parent)
660                            .css({
661                                'width' : width,
662                                'height': height
663                            })
664                            .data('originalWidth', width);
665                    }
666                });
667        }
668    };
669
670    this.keymap = {
671        start: function() {
672            document.onkeydown = function(e) {
673                e = e || window.event;
674                if (e.keyCode === 37) { //влево
675                    that.slider.prev(true);
676                }
677                if (e.keyCode === 39) { //вправо
678                    that.slider.next(true);
679                }
680                if (e.keyCode === 27) { //escape
681                    that.close();
682                }
683            }
684        },
685        end: function() {
686            document.onkeydown = function(e) {
687                e = e || window.event;
688                if (e.keyCode === 37) { //влево
689                    return false;
690                }
691                if (e.keyCode === 39) { //вправо
692                    return false;
693                }
694                if (e.keyCode === 27) { //escape
695                    return false;
696                }
697            }
698        }
699    };
700};
701
702rfs.videogallery = new function() {
703    var that = this;
704
705    this.labels = {
706        'author' : '', 'address': '', 'confirm': ''
707    };
708
709    var classes = {
710        'mediaGallery'     : 'rfs-media-gallery',
711        'gallery'          : 'rfs-gallery',
712        'close'            : 'rfs-gallery-close',
713        'videogallery'     : 'rfs-videogallery',
714        'videogalleryInner': 'rfs-videogallery-inner',
715        'video'            : 'rfs-videogallery-video-',
716        'videoPlayer'      : 'rfs-videogallery-videoplayer',
717        'videoDesc'        : 'rfs-videogallery-desc',
718        'videoTitle'       : 'rfs-videogallery-desc-title',
719        'videoLink'        : 'rfs-videogallery-desc-link',
720        'videoTagsCont'    : 'rfs-videogallery-desc-tags-cont',
721        'videoTagsAuthor'  : 'rfs-videogallery-desc-tags-author'
722    };
723
724    var selectors = {
725        'mediaGallery'     : '.' + classes.mediaGallery,
726        'gallery'          : '.' + classes.gallery,
727        'close'            : '.' + classes.close,
728        'videogallery'     : '.' + classes.videogallery,
729        'videogalleryInner': '.' + classes.videogalleryInner,
730        'video'            : '#' + classes.video,
731        'videoPlayer'      : '.' + classes.videoPlayer,
732        'videoDesc'        : '.' + classes.videoDesc,
733        'videoTitle'       : '.' + classes.videoTitle,
734        'videoLink'        : '.' + classes.videoLink,
735        'videoTagsCont'    : '.' + classes.videoTagsCont,
736        'videoTagsAuthor'  : '.' + classes.videoTagsAuthor
737    };
738
739    var params = {};
740
741    var isMobile = $('.wrapper').outerWidth() < 481;
742
743    var openState = false;
744
745    var openVideoIndex;
746
747    this.gallery = null;
748
749    this.videos = [];
750
751    this.init = function() {
752        var mediaGallery = $(selectors.mediaGallery);
753        if (!$(mediaGallery).length) {
754            return false;
755        }
756
757        params['maxVideoHeight'] = $(window).height() - 60 - 60; //вычисление максимальной высоты для видео
758
759        that.$gallery  = null;
760        that.$controls = null;
761
762        that.videos = $(mediaGallery).find('.rfs-video');
763
764        //Создание галереи изображений
765        if (that.videos.length && that.$gallery === null) {
766            that.create();
767        }
768    };
769
770    this.destroy = function() {
771        if (that.$gallery !== null) {
772            if (openState) {
773                $(that.videos[openVideoIndex]).addClass('auto-open');
774            }
775
776            that.close();
777            $(that.$gallery).remove();
778        }
779    };
780
781    this.create = function() {
782        that.$gallery  = $('<div>', {'class': 'rfs-videogallery'}).hide();
783        that.$controls = that.createControls();
784
785        $(that.$gallery).append(
786            that.$controls.close
787        );
788
789        $('body').append(that.$gallery);
790
791        that.clickVideos();
792
793        //Автооткрытие видео
794        that.videos.each(function() {
795            if ($(this).hasClass('auto-open')) {
796                $(this).removeClass('auto-open').click();
797            }
798        });
799    };
800
801    this.loadmoreVideos = function() {
802        var mediaGallery = $(selectors.mediaGallery);
803        that.videos = $(mediaGallery).find('.rfs-video');
804        that.clickVideos();
805    };
806
807    this.clickVideos = function() {
808        that.videos.each(function(index) {
809            $(this).off('click').click(function(event) {
810                event.preventDefault();
811                that.open(index);
812                //Запрещаем переход по ссылке
813                return false;
814            });
815        });
816    };
817
818    this.createControls = function() {
819        //Кнопка закрытия
820        var close = $('<a>', {'class': classes.close}).click(function() {
821            that.close($(this));
822            if ($('.js-bet-city').find('.jwplayer').length) {
823                jwplayer($('.js-bet-city').find('.jwplayer').attr('id')).setVolume(0);
824            }
825        });
826
827        return {
828            'close': close
829        };
830    };
831
832    this.open = function(index) {
833        var isCreated = false;
834        if (!$(selectors.video + index).length) {
835            that.createVideo(index);
836            isCreated = true;
837        }
838        var $startVideo =  $(selectors.video + index);
839        rfs.overlay.open();
840        $(selectors.video + index).show();
841        $(that.$gallery).show();
842
843        rfs.mediagallery.link.changeLink($(that.videos[index]).attr('href'));
844
845        that.keymap.start();
846
847        openVideoIndex = index;
848        openState = true;
849        if ($startVideo.find('.js-video-wrapper').data('is-vk')) {
850            return;
851        }
852        if(!isCreated) {
853            jwplayer('JWPlayerCont_' + index).play();
854        }
855    };
856
857    this.close = function(element) {
858        rfs.overlay.close();
859        $(selectors.videogalleryInner).hide();
860        $(that.$gallery).hide();
861
862        rfs.mediagallery.link.changeLink();
863
864        that.keymap.end();
865
866        $('.jwplayer').each(function() {
867            if (in_array(jwplayer($(this).attr('id')).getState(), ['buffering', 'playing'])) {
868                jwplayer($(this).attr('id')).stop();
869            }
870        });
871
872        openVideoIndex = null;
873        openState = false;
874        var $videoWrapper = $(element).closest('.rfs-videogallery').find('.js-video-wrapper');
875        var $iframeVK = $(element).closest('.rfs-videogallery').find('.js-video-wrapper').find('iframe');
876        if ($iframeVK && $iframeVK.length > 0) {
877            $videoWrapper.empty();
878            $videoWrapper.append($iframeVK);
879        }
880    };
881
882    this.createVideo = function(index) {
883        var video = $(that.videos[index]);
884
885        //Создание главного контейнера
886        var cont = $('<div>', {'class': classes.videogalleryInner, 'id': classes.video + index});
887        var src = $(video).data('video-url-vk') || $(video).data('video-url');
888        var url = new URL(src);
889        var vkHost = 'vk.com';
890        var JWCont;
891        if (url.host === vkHost) {
892            var style = 'max-height: ' + params.maxVideoHeight + 'px; height: 400px';
893                if (window.innerWidth < 800) {
894                    style = 'max-height: ' + params.maxVideoHeight + 'px; height: 189px; min-height: auto';
895                }
896            JWCont = $('<div>', {
897                'class': classes.videoPlayer + ' js-video-wrapper',
898                'src'  : $(video).attr('href'),
899                'style': style,
900            });
901            var iframe = $('<iframe>', {
902                'src'  : src,
903                'style': 'height: 100%; width: 100%',
904                'allow': 'fullscreen',
905            });
906            JWCont.append(iframe);
907            JWCont.attr('data-is-vk', 'true');
908        } else {
909            JWCont = $('<div>', {
910                'id' : 'JWPlayerCont_' + index,
911                'data-index' : index,
912                'class' : classes.videoPlayer,
913                'src' : $(video).data('videoUrl'),
914                'style' : 'max-height: ' + params.maxVideoHeight + 'px;'
915            });
916        }
917
918        //Создание блока описания
919        var description = $('<div>', {'class': classes.videoDesc}),
920            title       = $('<div>', {'class': classes.videoTitle}).html($(video).data('title') ? $(video).data('title') : ''),
921            link        = $('<a>', {'class': classes.videoLink}
921).html(that.labels.address),
922            author      = $('<div>', {'class': classes.videoTagsAuthor}).html($(video).data('author') ? that.labels.author + ': ' + $(video).data('author') : '');
923
924        //Устанавливанем копирование по клику
925        rfs.mediagallery.link.copyLink(link, 'video', that.labels.confirm);
926
927        $(description).append(title, link, rfs.mediagallery.clear());
928        if ($(video).data('tags')) {
929            var tags = $('<div>', {'class': classes.videoTagsCont});
930            $.each($(video).data('tags'), function(name, url) {
931                $(tags).append($('<a>', {
932                    'href' : url,
933                    'class': 'article-tag'
934                }).html(name));
935            });
936            $(description).append(tags, rfs.mediagallery.clear());
937        }
938        $(description).append(author);
939        $(that.$gallery).append($(cont).append(JWCont, description));
940        if (url.host === vkHost) {
941            return;
942        }
943        //Инициализируем JWPlayer
944        jwplayer('JWPlayerCont_' + index).setup({
945            "aspectratio": "16:9",
946            "stretching": "uniform",
947            "width": "100%",
948            "file" : $(video).data('videoUrl'), //ссылка на видео
949            "image": $(video).data('image') //ссылка на превью
950        }).on('ready', function() {
951            jwplayer('JWPlayerCont_' + index).play(); //автостарт видео
952        });
953    };
954
955    this.keymap = {
956        start: function() {
957            document.onkeydown = function(e) {
958                e = e || window.event;
959
960                if ($('.js-bet-city').find('.jwplayer').length) {
961                    jwplayer($('.js-bet-city').find('.jwplayer').attr('id')).setVolume(0);
962                }
963                if (e.keyCode === 27) { //escape
964                    that.close();
965                }
966            }
967        },
968        end: function() {
969            document.onkeydown = function(e) {
970                e = e || window.event;
971                if (e.keyCode === 27) { //escape
972                    return false;
973                }
974            }
975        }
976    };
977};
978
979rfs.mediagallery = new function() {
980    var that = this;
981
982    this.init = function(config) {
983        //Создание оверлея
984        rfs.overlay.create();
985
986        //Устанавливаем ссылку на страницу
987        that.link.default = config.defaultLink;
988
989        rfs.photogallery.init();
990        rfs.videogallery.init();
991        $(window).afterResize(function() {
992            that.destroy();
993            that.link.default = config.defaultLink;
994            rfs.photogallery.init();
995        }, false, 100);
996    };
997
998    that.destroy = function() {
999        rfs.photogallery.destroy();
1000    };
1001
1002    this.link = {
1003        'default'   : null,
1004        'changeLink': function(link) {
1005            if (link) {
1006                history.pushState(null, null, link);
1007            } else {
1008                $('.rfs-gallery-image-link.success').html(rfs.photogallery.labels.address).removeClass('success');
1009                $('.rfs-gallery-video-link.success').html(rfs.photogallery.address).removeClass('success');
1010
1011                history.pushState(null, null, that.link.default);
1012            }
1013        },
1014        'copyLink'      : function(el, type, confirm) {
1015            $(el).click(function() {
1016                var id = 'rfs-gallery-copy-media-link';
1017                var textarea = $('<textarea>', {'id': id}).text(window.location.href);
1018                $(el).after(textarea);
1019
1020                var ta = document.getElementById(id);
1021                ta.select();
1022
1023                var range = document.createRange();
1024                range.selectNode(ta);
1025                window.getSelection().addRange(range);
1026                var complete = document.execCommand('copy');
1027
1028                window.getSelection().removeAllRanges();
1029                $(textarea).remove();
1030
1031                if (complete) {
1032                    $(el).html(confirm).addClass('success');
1033                } else {
1034                    $(el).remove();
1035                }
1036            });
1037        }
1038    };
1039
1040    this.clear = function() {
1041        return $('<div>', {'class': 'clear'});
1042    };
1043};
1044
1045rfs.albumSlider = new function() {
1046    var that = this;
1047    var $body = $('.js-bet-city');
1048
1049    var classes = {
1050        'albumSlider' : 'js-album-slider',
1051        'sliderCont'  : 'js-album-slider-cont',
1052        'arrowsCont'  : 'js-album-slider-arrows',
1053        'currentSlide': 'js-album-slider-current'
1054    };
1055
1056    var selectors = {
1057        'albumSlider' : '.' + classes.albumSlider,
1058        'sliderCont'  : '.' + classes.sliderCont,
1059        'arrowsCont'  : '.' + classes.arrowsCont,
1060        'currentSlide': '.' + classes.currentSlide
1061    };
1062    this.init = function() {
1063        var activate = function (element) {
1064            element.addClass('js-already-init')
1065                .slick({
1066                    'lazyLoad': 'ondemand',
1067                    'appendArrows': $(selectors.arrowsCont),
1068                    'prevArrow'     : '<a class="broadcast-album-slider-arrow broadcast-album-slider-arrow-back"></a>',
1069                    'nextArrow'     : '<a class="broadcast-album-slider-arrow broadcast-album-slider-arrow-forward"></a>'
1070                })
1071                .on('beforeChange', function(e, slick, currentSlideIndex, nextSlideIndex) {
1072                    $(this).parents(selectors.sliderCont).find(selectors.currentSlide).text(nextSlideIndex + 1);
1073                });
1074        }
1075        $(selectors.albumSlider).each(function() {
1076            if($body.length > 0) {
1077                if (!$(this).hasClass('js-already-init') && $(this).parents('#MatchTabsContPhotos').css('display') !== 'none') {
1078                    activate($(this))
1079                }
1080            } else {
1081                if (!$(this).hasClass('js-already-init') && $(this).parents('#broadcastAlbums').css('display') !== 'none') {
1082                    activate($(this))
1083                }
1084            }
1085        });
1086    };
1087};

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.