PageSourceSearch

https://www.bn.ru/assets/minify/c03e5f066c34f76fa4c7c2c6728b73b41d4937c6.js?v=1785952537

js bn.ru collected 2026-09-24 08:45:22 UTC 13,380 bytes, 289 lines download raw bytes

1// фиксация баннеров справо
2$(function () {
3
4    var selRow = '';
5    var settingScrollBan = '';
6    if ($('.catalog_result-wrapper').length) {
7        selRow = '.catalog_result-wrapper';
8        var b = null, K = null, Z = 0, P = 0, N = 40;
9    } else if ($('.object-page-right').length) {
10        selRow = '.object-page-right';
11        var b = null, K = null, Z = 0, P = 0, N = 40;
12    } else if ($('.object-2019-container').length) {
13        selRow = '.object-2019-container';
14        var b = null, K = null, Z = 0, P = 0, N = 40;
15    }
16
17    // BNRU-2692
18    var hWindow = $(window);
19    var hBlockRecommend = $('#block-recommendation');
20    var hBlockRecommendContainer = $('#block-recommendation-container');
21    var hBlockNewbuild = $('#block-newbuildsearch');
22    var hBlockLinks = $('.index--block-links');
23    var hBlockLinksPadding = 46;
24    if (!hBlockLinks.length) {
25        hBlockLinks = $('#bn-footer');
26        if ($('.mask_scroll').length) {
27            hBlockLinksPadding = 76;
28        } else {
29            hBlockLinksPadding = 30;
30        }
31    }
32    var hBlockRecommendTop = 0;
33    if (hBlockRecommend.length) {
34        hBlockRecommend.css('width', hBlockRecommend.outerWidth());
35        hBlockRecommendTop = hBlockRecommend.offset().top;
36    }
37
38    // BNRU-3065
39    var hBlockVideo = $('#gazeta-last-video__container');
40    var hBlockVideoTopLast = 0;
41    var hBlockVideoStub = $('#gazeta-last-video__stub');
42    if (!hBlockVideoIsClosedByUser) {
43        var hBlockVideoIsClosedByUser = 0;
44    }
45    $('.gazeta-last-video__button-close').bind('click', function () {
46        $(this).addClass('gazeta-last-video__button-close-hidden');
47        hBlockVideo.removeClass('gazeta-last-video__container-fixed');
48        hBlockVideoStub.css('weight', 0);
49        hBlockVideoStub.css('height', 0);
50        hBlockVideoStub.css('margin-bottom', 0);
51        hBlockVideoIsClosedByUser = 1;
52    });
53
54    // BNRU-3223
55    var hBlockBanner = $('#right-sidedar-banners_row');
56    var hBlockBannerLimit = $('.object-page-container');
57    if (!hBlockBannerLimit.length) {
58        var hBlockBannerLimit = $('.page--index-new_main');
59    }
60
61    var a = document.querySelector('#right-sidedar-banners_row');  // если у P ноль заменить на число, то блок будет прилипать до того, как верхний край окна браузера дойдёт до верхнего края элемента, если у N — нижний край дойдёт до нижнего края элемента. Может быть отрицательным числом
62    window.addEventListener('scroll', Ascroll, false);
63
64    let scrollPrevios = 0;
65    let fixed = 0;
66
67    function Ascroll() {
68        /*
69        if (a && selRow) {
70            var Ra = a.getBoundingClientRect(),
71                R1bottom = document.querySelector(selRow).getBoundingClientRect().bottom;
72            if (Ra.bottom < R1bottom) {
73                if (b == null) {
74                    var Sa = getComputedStyle(a, ''), s = '';
75                    for (var i = 0; i < Sa.length; i++) {
76                        if (Sa[i].indexOf('overflow') == 0 || Sa[i].indexOf('padding') == 0 || Sa[i].indexOf('border') == 0 || Sa[i].indexOf('outline') == 0 || Sa[i].indexOf('box-shadow') == 0 || Sa[i].indexOf('background') == 0) {
77                            s += Sa[i] + ': ' + Sa.getPropertyValue(Sa[i]) + '; '
78                        }
79                    }
80                    b = document.createElement('div');
81                    b.className = "stop";
82                    b.style.cssText = s + ' box-sizing: border-box; width: ' + a.offsetWidth + 'px;';
83                    a.insertBefore(b, a.firstChild);
84                    var l = a.childNodes.length;
85                    for (var i = 1; i < l; i++) {
86                        b.appendChild(a.childNodes[1]);
87                    }
88                    a.style.height = b.getBoundingClientRect().height + 'px';
89                    a.style.padding = '0';
90                    a.style.border = '0';
91                }
92                var Rb = b.getBoundingClientRect(),
93                    Rh = Ra.top + Rb.height,
94                    W = document.documentElement.clientHeight,
95                    R1 = Math.round(Rh - R1bottom),
96                    R2 = Math.round(Rh - W);
97                if (Rb.height > W) {
98                    if (Ra.top < K) {  // скролл вниз
99                        if (R2 + N > R1) {  // не дойти до низа
100                            if (Rb.bottom - W + N <= 1) {  // подцепиться
101                                b.className = 'right-sidedar-banners_lists';
102                                b.style.top = W - Rb.height - N + 'px';
103                                Z = N + Ra.top + Rb.height - W;
104                            } else {
105                                b.className = 'stop';
106                                b.style.top = -Z + 'px';
107                            }
108
109                        } else {
110                            b.className = 'stop';
111                            b.style.top = -R1 + 'px';
112                            Z = R1;
113                        }
114                    } else {  // скролл вверх
115                        if (Ra.top - P < 0) {  // не дойти до верха
116                            if (Rb.top - P >= 0) {  // подцепиться
117                                b.className = 'right-sidedar-banners_lists';
118                                b.style.top = P + 'px';
119                                Z = Ra.top - P;
120                            } else {
121                                b.className = 'stop';
122                                b.style.top = -Z + 'px';
123                            }
124                        } else {
125                            b.className = '';
126                            b.style.top = '';
127                            Z = 0;
128                        }
129                    }
130                    K = Ra.top;
131                } else {
132                    if ((Ra.top - P) <= 0) {
133                        if ((Ra.top - P) <= R1) {
134                            b.className = 'stop';
135                            b.style.top = -R1 + 'px';
136                        } else {
137                            b.className = 'right-sidedar-banners_lists';
138                            b.style.top = P + 'px';
139                        }
140                    } else {
141                        b.className = '';
142                        b.style.top = '';
143                    }
144                }
145                window.addEventListener('resize', function () {
146                    a.children[0].style.width = getComputedStyle(a, '').width
147                }, false);
148            }
149        }
150        */
151
152        // BNRU-2692
153        /*
154        if (hBlockRecommend.length) {
155            if (hWindow.scrollTop() > hBlockRecommendTop) {
156                hBlockRecommend.addClass('block-recommendation_fixed');
157                var hBlockRecommendTopCurrent = parseInt(hBlockRecommend.offset().top);
158                var hBlockRecommendHeight = parseInt(hBlockRecommendContainer.innerHe
158ight());
159                var hBlockNewbuildHeight = parseInt(hBlockNewbuild.innerHeight() ? hBlockNewbuild.innerHeight() : 0);
160                if (hBlockNewbuildHeight > 0) {
161                    hBlockNewbuildHeight += 20;
162                }
163                console.log(hBlockNewbuildHeight);
164                var hBlockLinksTopCurrent = parseInt(hBlockLinks.offset().top);
165                if ((hBlockRecommendTopCurrent + hBlockRecommendHeight + hBlockNewbuildHeight) > hBlockLinksTopCurrent - hBlockLinksPadding) {
166                    var diff = parseInt((hWindow.scrollTop() + hBlockRecommendHeight + hBlockNewbuildHeight) - hBlockLinksTopCurrent + hBlockLinksPadding);
167                    hBlockRecommendContainer.css('margin-top', '-' + diff + 'px');
168                }
169                else {
170                    hBlockRecommendContainer.css('margin-top', '0');
171                }
172            } else {
173                hBlockRecommend.removeClass('block-recommendation_fixed');
174            }
175        }
176        */
177
178        // BNRU-3223
179        let scroll = hWindow.scrollTop();
180        let height = hWindow.height();
181        let hBlockBannerTop = hBlockBanner.length ? Math.round(hBlockBanner.offset().top) : 0;
182        let hBlockBannerHeight = hBlockBanner.length ? Math.round(hBlockBanner.outerHeight()) : 0;
183        if (scroll > scrollPrevios) { // вниз
184            if ((fixed === 0) && (scroll + height > hBlockBannerTop + hBlockBannerHeight)) {
185                fixed = scroll + height;
186                hBlockBanner.addClass('right-sidedar-banners_row__fixed');
187            }
188        } else { // вверх
189            if ((fixed > 0) && (scroll + height < fixed)) {
190                fixed = 0;
191                hBlockBanner.removeClass('right-sidedar-banners_row__fixed');
192            }
193        }
194        scrollPrevios = scroll;
195
196        let hBlockBannerLimitTop = hBlockBannerLimit.length ? Math.round(hBlockBannerLimit.offset().top) : 0;
197        let hBlockBannerLimitHeight = hBlockBannerLimit.length ? Math.round(hBlockBannerLimit.outerHeight()) : 0;
198        if (scroll + height > hBlockBannerLimitTop + hBlockBannerLimitHeight) {
199            let bottom = height + scroll - hBlockBannerLimitTop - hBlockBannerLimitHeight + 10;
200            //console.log('hBlockBannerDown: ' + hBlockBannerLimitHeight);
201            //console.log('height: ' + hWindow.height() + ', scroll: ' + scroll + ', top: ' + hBlockBannerTop + ', height: ' + hBlockBannerHeight);
202            hBlockBanner.css('bottom', bottom + 'px');
203        } else {
204            hBlockBanner.css('bottom', '10px');
205        }
206
207        // BNRU-3065
208        if (hBlockVideo.length) {
209            var hBlockVideoTop = hBlockVideo.length ? Math.round(hBlockVideo.offset().top) : 0;
210            var hBlockVideoWidth = hBlockVideo.length ? Math.round(hBlockVideo.outerWidth()) : 0;
211            var hBlockVideoHeight = hBlockVideo.length ? Math.round(hBlockVideo.outerHeight()) : 0;
212            var intScroll = hWindow.scrollTop();
213            if ((intScroll > hBlockVideoTop + hBlockVideoHeight) && (hBlockVideoIsClosedByUser == 0)) {
214                if (!hBlockVideo.hasClass('gazeta-last-video__container-fixed')) {
215                    hBlockVideo.addClass('gazeta-last-video__container-fixed');
216                    hBlockVideoTopLast = intScroll;
217                    hBlockVideoStub.css('weight', hBlockVideoWidth);
218                    hBlockVideoStub.css('height', hBlockVideoHeight);
219                    hBlockVideoStub.css('margin-bottom', '10px');
220                    $('.gazeta-last-video__button-close').removeClass('gazeta-last-video__button-close-hidden');
221                }
222            }
223            if (intScroll < hBlockVideoTopLast) {
224                if (hBlockVideo.hasClass('gazeta-last-video__container-fixed')) {
225                    hBlockVideo.removeClass('gazeta-last-video__container-fixed');
226                    hBlockVideoStub.css('weight', 0);
227                    hBlockVideoStub.css('height', 0);
228                    hBlockVideoStub.css('margin-bottom', 0);
229                    $('.gazeta-last-video__button-close').addClass('gazeta-last-video__button-close-hidden');
230                }
231                //hBlockVideoIsClosedByUser = 0;
232            }
233        }
234    }
235
236    function tooltipPrice(input, tooltip) {
237        $(input).keyup(function () {
238            if ($(this).val() != "") {
239                $(tooltip).fadeIn(100);
240            } else {
241                $(tooltip).fadeOut(100);
242            }
243            if (parseInt($(this).val()) > 999) {
244                $(tooltip).find('span').text(($(this).val() / 1000) + ' млн ₽');
245            } else {
246                $(tooltip).find('span').text($(this).val() + ' тыс ₽');
247            }
248        })
249    }
250
251    if (location.href.indexOf('arenda-kvartiry') === -1 && location.href.indexOf('arenda-komnaty') === -1) {
252        tooltipPrice('.input-price-from', '.first-tooltip');
253        tooltipPrice('.input-price-to', '.second-tooltip');
254    }
255
256    $('.click-filter-mobile').click(function () {
257        if ($(this).hasClass('active')) {
258            $(this).removeClass('active');
259            $('.catalog_filter_hide').removeClass('active');
260        } else {
261            $('.catalog_control-panel_item').removeClass('active');
262            $(this).addClass('active');
263            $('.catalog_filter_hide').addClass('active');
264            $('.display-map').removeClass('active');
265            $('.display-list').addClass('active');
266            $('.catalog_backgroud').removeClass('active');
267            $('.catalog_result').removeClass('active');
268        }
269    });
270
271    $('.click-maps-mobile').click(function () {
272        $('.catalog_control-panel_item').removeClass('active');
273        $(this).addClass('active');
274        $('.catalog_filter_hide').removeClass('active');
275        $('.catalog_result').removeClass('active');
276        $('.display-list').addClass('active');
277        $('.catalog_backgroud').addClass('active');
278    });
279
280    $('.catalog_filter_hide-close').click(function () {
281        $('.catalog_filter_hide').removeClass('active');
282    });
283
284    $('.object--today').click(function () {
285        yaCounter481062.reachGoal('obj_day');
286        return true;
287    });
288});
289;

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.