PageSourceSearch

https://barn-estate.ru/local/templates/barnes/components/bitrix/ca…/main/script.js?178982007535136

js barn-estate.ru collected 2026-10-09 21:35:27 UTC 35,136 bytes, 960 lines download raw bytes

1function JCSmartFilter(ajaxURL, viewMode, params) {
2    this.ajaxURL = ajaxURL;
3    this.form = null;
4    this.timer = null;
5    this.timer_search = null;
6    this.cacheKey = '';
7    this.cache = [];
8    this.popups = [];
9    this.viewMode = viewMode;
10    if (params && params.SEF_SET_FILTER_URL) {
11        this.bindUrlToButton('set_filter', params.SEF_SET_FILTER_URL);
12        this.sef = true;
13    }
14    if (params && params.SEF_DEL_FILTER_URL) {
15        this.bindUrlToButton('del_filter', params.SEF_DEL_FILTER_URL);
16    } else {
17        this.bindResetButton('del_filter');
18    }
19}
20
21JCSmartFilter.prototype.keyup = function (input) {
22    if (!!this.timer) {
23        clearTimeout(this.timer);
24    }
25
26    this.timer = setTimeout(BX.delegate(function () {
27        this.reload(input);
28    }, this), 500);
29};
30JCSmartFilter.prototype.keyup_search = function (input) {
31    if (!!this.timer_search) {
32        clearTimeout(this.timer_search);
33    }
34
35    this.timer_search = setTimeout(BX.delegate(function () {
36        this.reload(input);
37        if (input.value.length > 2) {
38            BX.ajax.runAction('barnes:core.api.search.find', {data: {q: input.value}}).then(function (res) {
39                if (res.data.html) {
40                    let block_items = $('#sb_result_search_items');
41                    block_items.html(res.data.html);
42                    $('.all_result').show();
43                } else {
44                    let block_items = $('#sb_result_search_items');
45                    block_items.html('Нет результата');
46                    $('.all_result').hide();
47                }
48
49                $('.sb_search_block').show();
50            });
51        } else {
52            $('.sb_search_block').hide();
53        }
54
55
56    }, this), 500);
57};
58
59JCSmartFilter.prototype.addNumSpan = function (checkbox, parent = '') {
60    let subNum;
61
62    if (!parent) {
63        parent = $(checkbox).parents('.sb_modal').data('parent')
64    }
65
66    let count = $(checkbox).parents('.sb_modal').find('.modal-footer .f_item').length
67    if (parent == 'sb_areas') {
68        count = $('[data-parent="sb_areas"]').find('.sb_step_2').find('.modal-footer .f_item').length
69    } else {
70        count = $('[data-parent="' + parent + '"]').find('.modal-footer .f_item').length
71    }
72
73    if (count) {
74        if (parent != '') {
75            $($('.' + parent).find('.filter__header .sb_count')).html('(<span class="sb_num">' + count + '</span>)')
76        } else {
77            $($(checkbox).parents('.search-panel__input-wrapper').find('.filter__header .sb_count')).html('(<span class="sb_num">' + count + '</span>)')
78        }
79    } else {
80        if (parent != '') {
81            $($('.' + parent).find('.filter__header .sb_count')).html('')
82        } else {
83            $($(checkbox).parents('.search-panel__input-wrapper').find('.filter__header .sb_count')).html('')
84        }
85    }
86
87    return
88}
89JCSmartFilter.prototype.click = function (checkbox) {
90    if (!!this.timer) {
91        clearTimeout(this.timer);
92    }
93    JCSmartFilter.prototype.addNumSpan(checkbox);
94
95
96    this.timer = setTimeout(BX.delegate(function () {
97        this.reload(checkbox);
98    }, this), 500);
99};
100
101JCSmartFilter.prototype.reload = function (input) {
102    if (this.cacheKey !== '') {
103        //Postprone backend query
104        if (!!this.timer) {
105            clearTimeout(this.timer);
106        }
107        this.timer = setTimeout(BX.delegate(function () {
108            this.reload(input);
109        }, this), 1000);
110        return;
111    }
112    this.cacheKey = '|';
113
114    this.position = BX.pos(input, true);
115    this.form = BX.findParent(input, {'tag': 'form'});
116    if (this.form) {
117        var values = [];
118        values[0] = {name: 'ajax', value: 'y'};
119        this.gatherInputsValues(values, BX.findChildren(this.form, {'tag': new RegExp('^(input|select)$', 'i')}, true));
120
121        for (var i = 0; i < values.length; i++)
122            this.cacheKey += values[i].name + ':' + values[i].value + '|';
123
124        if (this.cache[this.cacheKey]) {
125            this.curFilterinput = input;
126            this.postHandler(this.cache[this.cacheKey], true);
127        } else {
128            if (this.sef) {
129                // var set_filter = BX('set_filter');
130                // set_filter.disabled = true;
131            }
132
133            this.curFilterinput = input;
134            BX.ajax.loadJSON(
135                this.ajaxURL,
136                this.values2post(values),
137                BX.delegate(this.postHandler, this)
138            );
139        }
140    }
141};
142
143JCSmartFilter.prototype.updateItem = function (PID, arItem) {
144    if (arItem.PROPERTY_TYPE === 'N' || arItem.PRICE) {
145        var trackBar = window['trackBar' + PID];
146        if (!trackBar && arItem.ENCODED_ID)
147            trackBar = window['trackBar' + arItem.ENCODED_ID];
148
149        if (trackBar && arItem.VALUES) {
150            if (arItem.VALUES.MIN) {
151                if (arItem.VALUES.MIN.FILTERED_VALUE)
152                    trackBar.setMinFilteredValue(arItem.VALUES.MIN.FILTERED_VALUE);
153                else
154                    trackBar.setMinFilteredValue(arItem.VALUES.MIN.VALUE);
155            }
156
157            if (arItem.VALUES.MAX) {
158                if (arItem.VALUES.MAX.FILTERED_VALUE)
159                    trackBar.setMaxFilteredValue(arItem.VALUES.MAX.FILTERED_VALUE);
160                else
161                    trackBar.setMaxFilteredValue(arItem.VALUES.MAX.VALUE);
162            }
163        }
164    } else if (arItem.VALUES) {
165        for (var i in arItem.VALUES) {
166            if (arItem.VALUES.hasOwnProperty(i)) {
167                var value = arItem.VALUES[i];
168                var control = BX(value.CONTROL_ID);
169
170                if (!!control) {
171                    var label = document.querySelector('[data-role="label_' + value.CONTROL_ID + '"]');
172                    if (value.DISABLED) {
173
174                        if (label) {
175                            BX.addClass(label, 'disabled');
176                            $($(label).parents('.filter__check-item')).addClass('disabled');
177                        } else {
178                            BX.addClass(control.parentNode, 'disabled');
179                            $($(control.parentNode).parents('.filter__check-item')).addClass('disabled');
180                        }
181                    } else {
182                        if (label) {
183                            BX.removeClass(label, 'disabled');
184                            $($(label).parents('.filter__check-item')).removeClass('disabled');
185                        } else {
186                            BX.removeClass(control.parentNode, 'disabled');
187                            $($(control.parentNode).parents('.filter__check-item')).removeClass('disabled');
188                        }
189
190                    }
191
192                    if (value.hasOwnProperty('ELEMENT_COUNT')) {
193                        label = document.querySelector('[data-role="count_' + value.CONTROL_ID + '"]');
194                        if (label)
195                            label.innerHTML = value.ELEMENT_COUNT;
196                    }
197                }
198            }
199        }
200    }
201};
202
203JCSmartFilter.prototype.postHandler = function (result, fromCache) {
204    var hrefFILTER, url, curProp;
205    var modef = BX('modef');
206    var modef_num = BX('modef_num');
207
208    if (!!result && !!result.ITEMS) {
209        for (var popupId in this.popups) {
210            if (this.popups.hasOwnProperty(popupId)) {
211                this.popups[popupId].destroy();
212            }
213        }
214        this.popups = [];
215
216        for (var PID in result.ITEMS) {
217            if (result.ITEMS.hasOwnProperty(PID)) {
218                this.updateItem(PID, result.ITEMS[PID]);
219            }
220        }
221
222        // if (!!modef && !!modef_num)
223        // {
224        // 	modef_num.innerHTML = result.ELEMENT_COUNT;
225        // 	hrefFILTER = BX.findChildren(modef, {tag: 'A'}, true);
226
227        if (result.FILTER_URL && hrefFILTER) {
228            hrefFILTER[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL);
229        }
230
231        if (result.FILTER_AJAX_URL && result.COMPONENT_CONTAINER_ID) {
232            BX.unbindAll(hrefFILTER[0]);
233            BX.bind(hrefFILTER[0], 'click', function (e) {
234                url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
235                BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
236                return BX.PreventDefault(e);
237            });
238        }
239
240        if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID) {
241            url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
242            BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
243            //$('.block_clear').parent().removeClass('sb_hide');
244        } else {
245
246            //$('.block_clear').parent().removeClass('sb_hide');
247            // if (modef.style.display === 'none')
248            // {
249            // 	modef.style.display = 'inline-block';
250            // }
251
252            // if (this.viewMode == "VERTICAL")
253            // {
254            // 	curProp = BX.findChild(BX.findParent(this.curFilterinput, {'class':'bx-filter-parameters-box'}), {'class':'bx-filter-container-modef'}, true, false);
255            // 	curProp.appendChild(modef);
256            // }
257
258            if (result.SEF_SET_FILTER_URL) {
259                let url = result.SEF_SET_FILTER_URL;
260
261                if ($('#arrFilterBuy_272_1782049246:checked').val() === '1782049246' && $('#arrFilterBuy_271_1669441013:checked').val() === '1669441013') {
262                    url = url.replace('/search/', '/vtorichnaya-nedvizhimost/');
263                } else if ($('#arrFilterBuy_272_1554696125:checked').val() === '1554696125' && $('#arrFilterBuy_271_1669441013:checked').val() === '1669441013') {
264                    url = url.replace('/search/', '/arendovat/');
265                } else if ($('#arrFilterBuy_272_1782049246:checked').val() === '1782049246' && $('#arrFilterBuy_271_4203279439:checked').val() === '4203279439') {
266                    url = url.replace('/search/', '/zagorodnaya-nedvizhimost/');
267                } else if ($('#arrFilterBuy_272_1554696125:checked').val() === '1554696125' && $('#arrFilterBuy_271_4203279439:checked').val() === '4203279439') {
268                    url = url.replace('/search/', '/zagorodnaya-nedvizhimost/');
269                } else if ($('#arrFilterBuy_272_1782049246:checked').val() === '1782049246' && $('#arrFilterBuy_271_489740616:checked').val() === '489740616') {
270                    url = url.replace('/search/', '/kommercheskaya-nedvizhimost/');
271                } else if ($('#arrFilterBuy_272_1554696125:checked').val() === '1554696125' && $('#arrFilterBuy_271_489740616:checked').val() === '489740616') {
272                    url = url.replace('/search/', '/kommercheskaya-nedvizhimost/arendovat/');
273                } else if ($('#arrFilterBuy_272_1782049246:checked').val() === '1782049246' && $('#arrFilterBuy_271_2375009497:checked').val() === '2375009497') {
274                    url = url.replace('/search/', '/mezhdunarodnaya-nedvizhimost/');
275                } else {
276                   // url = url.replace('/search/'); 
277                }
278
279                this.bindUrlToButton('set_filter', url);
280            }
281        }
282        // }
283    }
284
285    if (this.sef) {
286        var set_filter = BX('set_filter');
287        set_filter.disabled = false;
288    }
289
290    if (!fromCache && this.cacheKey !== '') {
291        this.cache[this.cacheKey] = result;
292    }
293    this.cacheKey = '';
294};
295
296JCSmartFilter.prototype.bindUrlToButton = function (buttonId, url) {
297    var button = BX(buttonId);
298    if (button) {
299        var proxy = function (j, func) {
300            return function () {
301                return func(j);
302            }
303        };
304
305        if (button.type == 'submit')
306            button.type = 'button';
307
308        BX.bind(button, 'click', proxy(url, function (url) {
309            window.location.href = url;
310            return false;
311        }));
312    }
313};
314
315JCSmartFilter.prototype.bindResetButton = function (buttonId) {
316    var button = BX(buttonId);
317    if (!button) {
318        return;
319    }
320
321    BX.bind(button, 'click', BX.proxy(function () {
322        var resetUrl = this.ajaxURL;
323        if (typeof resetUrl === 'string') {
324            resetUrl = resetUrl.split('?')[0];
325        }
326        window.location.href = resetUrl || window.location.pathname;
327        return false;
328    }, this));
329};
330
331JCSmartFilter.prototype.gatherInputsValues = function (values, elements) {
332    if (elements) {
333        for (var i = 0; i < elements.length; i++) {
334            var el = elements[i];
335            if (el.disabled || !el.type)
336                continue;
337
338            switch (el.type.toLowerCase()) {
339                case 'text':
340                case 'textarea':
341                case 'password':
342                case 'hidden':
343                case 'select-one':
344                    if (el.value.length)
345                        values[values.length] = {name: el.name, value: el.value};
346                    break;
347                case 'radio':
348                case 'checkbox':
349                    if (el.checked)
350                        values[values.length] = {name: el.name, value: el.value};
351                    break;
352                case 'select-multiple':
353                    for (var j = 0; j < el.options.length; j++) {
354                        if (el.options[j].selected)
355                            values[values.length] = {name: el.name, value: el.options[j].value};
356                    }
357                    break;
358                default:
359                    break;
360            }
361        }
362    }
363};
364
365JCSmartFilter.prototype.values2post = function (values) {
366    var post = [];
367    var current = post;
368    var i = 0;
369
370    while (i < values.length) {
371        var p = values[i].name.indexOf('[');
372        if (p == -1) {
373            current[values[i].name] = values[i].value;
374            current = post;
375            i++;
376        } else {
377            var name = values[i].name.substring(0, p);
378            var rest = values[i].name.substring(p + 1);
379            if (!current[name])
380                current[name] = [];
381
382            var pp = rest.indexOf(']');
383            if (pp == -1) {
384                //Error - not balanced brackets
385                current = post;
386                i++;
387            } else if (pp == 0) {
388                //No index specified - so take the next integer
389                current = current[name];
390                values[i].name = '' + current.length;
391            } else {
392                //Now index name becomes and name and we go deeper into the array
393                current = current[name];
394                values[i].name = rest.substring(0, pp) + rest.substring(pp + 1);
395            }
396        }
397    }
398    return post;
399};
400
401JCSmartFilter.prototype.hideFilterProps = function (element) {
402    var obj = element.parentNode,
403        filterBlock = obj.querySelector("[data-role='bx_filter_block']"),
404        propAngle = obj.querySelector("[data-role='prop_angle']");
405
406    if (BX.hasClass(obj, "bx-active")) {
407        new BX.easing({
408            duration: 300,
409            start: {opacity: 1, height: filterBlock.offsetHeight},
410            finish: {opacity: 0, height: 0},
411            transition: BX.easing.transitions.quart,
412            step: function (state) {
413                filterBlock.style.opacity = state.opacity;
414                filterBlock.style.height = state.height + "px";
415            },
416            complete: function () {
417                filterBlock.setAttribute("style", "");
418                BX.removeClass(obj, "bx-active");
419            }
420        }).animate();
421
422        BX.addClass(propAngle, "fa-angle-down");
423        BX.removeClass(propAngle, "fa-angle-up");
424    } else {
425        filterBlock.style.display = "block";
426        filterBlock.style.opacity = 0;
427        filterBlock.style.height = "auto";
428
429        var obj_children_height = filterBlock.offsetHeight;
430        filterBlock.style.height = 0;
431
432        new BX.easing({
433            duration: 300,
434            start: {opacity: 0, height: 0},
435            finish: {opacity: 1, height: obj_children_height},
436            transition: BX.easing.transitions.quart,
437            step: function (state) {
438                filterBlock.style.opacity = state.opacity;
439                filterBlock.style.height = state.height + "px";
440            },
441            complete: function () {
442            }
443        }).animate();
444
445        BX.addClass(obj, "bx-active");
446        BX.removeClass(propAngle, "fa-angle-down");
447        BX.addClass(propAngle, "fa-angle-up");
448    }
449};
450
451JCSmartFilter.prototype.showDropDownPopup = function (element, popupId) {
452    var contentNode = element.querySelector('[data-role="dropdownContent"]');
453    this.popups["smartFilterDropDown" + popupId] = BX.PopupWindowManager.create("smartFilterDropDown" + popupId, element, {
454        autoHide: true,
455        offsetLeft: 0,
456        offsetTop: 3,
457        overlay: false,
458        draggable: {restrict: true},
459        closeByEsc: true,
460        content: BX.clone(contentNode)
461    });
462    this.popups["smartFilterDropDown" + popupId].show();
463};
464
465JCSmartFilter.prototype.selectDropDownItem = function (element, controlId) {
466    this.keyup(BX(controlId));
467
468    var wrapContainer = BX.findParent(BX(controlId), {className: "bx-filter-select-container"}, false);
469
470    var currentOption = wrapContainer.querySelector('[data-role="currentOption"]');
471    currentOption.innerHTML = element.innerHTML;
472    BX.PopupWindowManager.getCurrentPopup().close();
473};
474JCSmartFilter.prototype.region = function (element) {
475    let tmpInput = $(element).parent().find('input');
476    $($(element).parent().find('input')).each(function (index, elem) {
477
478        $(elem).attr('checked', true);
479        JCSmartFilter.prototype.click(elem);
480        sb_add_label('#sb_modal_areas .js_filter_item', elem.id, $(elem).parent().find('label').html().trim())
481        JCSmartFilter.prototype.addNumSpan(elem, 'sb_areas');
482    });
483};
484JCSmartFilter.prototype.city = function (element) {
485    let tmpInput = $(element).parent().find('input');
486
487    if ($(element).data('all') != 'Y') {
488        $(element).data('all', 'Y');
489
490        $(tmpInput).each(function (index, elem) {
491            $(elem).attr('checked', true);
492            JCSmartFilter.prototype.click(elem);
493            sb_add_label('#sb_modal_city .js_filter_item', elem.id, $(elem).parent().find('label').html().trim())
494            JCSmartFilter.prototype.addNumSpan(elem, 'sb_city');
495        });
496    } else {
497        $(element).data('all', '');
498
499
500        $(tmpInput).each(function (index, elem) {
501            $(elem).attr('checked', false);
502            JCSmartFilter.prototype.click(elem);
503            sb_add_label('#sb_modal_city .js_filter_item', elem.id, $(elem).parent().find('label').html().trim())
504            JCSmartFilter.prototype.addNumSpan(elem, 'sb_city');
505        });
506    }
507
508
509};
510
511BX.namespace("BX.Iblock.SmartFilter");
512BX.Iblock.SmartFilter = (function () {
513    /** @param {{
514     leftSlider: string,
515     rightSlider: string,
516     tracker: string,
517     trackerWrap: string,
518     minInputId: string,
519     maxInputId: string,
520     minPrice: float|int|string,
521     maxPrice: float|int|string,
522     curMinPrice: float|int|string,
523     curMaxPrice: float|int|string,
524     fltMinPrice: float|int|string|null,
525     fltMaxPrice: float|int|string|null,
526     precision: int|null,
527     colorUnavailableActive: string,
528     colorAvailableActive: string,
529     colorAvailableInactive: string
530     }} arParams
531     */
532    var SmartFilter = function (arParams) {
533        if (typeof arParams === 'object') {
534            this.leftSlider = BX(arParams.leftSlider);
535            this.rightSlider = BX(arParams.rightSlider);
536            this.tracker = BX(arParams.tracker);
537            this.trackerWrap = BX(arParams.trackerWrap);
538
539            this.minInput = BX(arParams.minInputId);
540            this.maxInput = BX(arParams.maxInputId);
541
542            this.minPrice = parseFloat(arParams.minPrice);
543            this.maxPrice = parseFloat(arParams.maxPrice);
544
545            this.curMinPrice = parseFloat(arParams.curMinPrice);
546            this.curMaxPrice = parseFloat(arParams.curMaxPrice);
547
548            this.fltMinPrice = arParams.fltMinPrice ? parseFloat(arParams.fltMinPrice) : parseFloat(arParams.curMinPrice);
549            this.fltMaxPrice = arParams.fltMaxPrice ? parseFloat(arParams.fltMaxPrice) : parseFloat(arParams.curMaxPrice);
550
551            this.precision = arParams.precision || 0;
552
553            this.priceDiff = this.maxPrice - this.minPrice;
554
555            this.leftPercent = 0;
556            this.rightPercent = 0;
557
558            this.fltMinPercent = 0;
559            this.fltMaxPercent = 0;
560
561            this.colorUnavailableActive = BX(arParams.colorUnavailableActive);//gray
562            this.colorAvailableActive = BX(arParams.colorAvailableActive);//blue
563            this.colorAvailableInactive = BX(arParams.colorAvailableInactive);//light blue
564
565            this.isTouch = false;
566
567            this.init();
568
569            if ('ontouchstart' in document.documentElement) {
570                this.isTouch = true;
571
572                BX.bind(this.leftSlider, "touchstart", BX.proxy(function (event) {
573                    this.onMoveLeftSlider(event)
574                }, this));
575
576                BX.bind(this.rightSlider, "touchstart", BX.proxy(function (event) {
577                    this.onMoveRightSlider(event)
578                }, this));
579            } else {
580                BX.bind(this.leftSlider, "mousedown", BX.proxy(function (event) {
581                    this.onMoveLeftSlider(event)
582                }, this));
583
584                BX.bind(this.rightSlider, "mousedown", BX.proxy(function (event) {
585                    this.onMoveRightSlider(event)
586                }, this));
587            }
588
589            BX.bind(this.minInput, "keyup", BX.proxy(function (event) {
590                this.onInputChange();
591            }, this));
592
593            BX.bind(this.maxInput, "keyup", BX.proxy(function (event) {
594                this.onInputChange();
595            }, this));
596        }
597    };
598
599    SmartFilter.prototype.init = function () {
600        var priceDiff;
601
602        if (this.curMinPrice > this.minPrice) {
603            priceDiff = this.curMinPrice - this.minPrice;
604            this.leftPercent = (priceDiff * 100) / this.priceDiff;
605
606            this.leftSlider.style.left = this.leftPercent + "%";
607            this.colorUnavailableActive.style.left = this.leftPercent + "%";
608        }
609
610        this.setMinFilteredValue(this.fltMinPrice);
611
612        if (this.curMaxPrice < this.maxPrice) {
613            priceDiff = this.maxPrice - this.curMaxPrice;
614            this.rightPercent = (priceDiff * 100) / this.priceDiff;
615
616            this.rightSlider.style.right = this.rightPercent + "%";
617            this.colorUnavailableActive.style.right = this.rightPercent + "%";
618        }
619
620        this.setMaxFilteredValue(this.fltMaxPrice);
621    };
622
623    SmartFilter.prototype.setMinFilteredValue = function (fltMinPrice) {
624        this.fltMinPrice = parseFloat(fltMinPrice);
625        if (this.fltMinPrice >= this.minPrice) {
626            var priceDiff = this.fltMinPrice - this.minPrice;
627            this.fltMinPercent = (priceDiff * 100) / this.priceDiff;
628
629            if (this.leftPercent > this.fltMinPercent)
630                this.colorAvailableActive.style.left = this.leftPercent + "%";
631            else
632                this.colorAvailableActive.style.left = this.fltMinPercent + "%";
633
634            this.colorAvailableInactive.style.left = this.fltMinPercent + "%";
635        } else {
636            this.colorAvailableActive.style.left = "0%";
637            this.colorAvailableInactive.style.left = "0%";
638        }
639    };
640
641    SmartFilter.prototype.setMaxFilteredValue = function (fltMaxPrice) {
642        this.fltMaxPrice = parseFloat(fltMaxPrice);
643        if (this.fltMaxPrice <= this.maxPrice) {
644            var priceDiff = this.maxPrice - this.fltMaxPrice;
645            this.fltMaxPercent = (priceDiff * 100) / this.priceDiff;
646
647            if (this.rightPercent > this.fltMaxPercent)
648                this.colorAvailableActive.style.right = this.rightPercent + "%";
649            else
650                this.colorAvailableActive.style.right = this.fltMaxPercent + "%";
651
652            this.colorAvailableInactive.style.right = this.fltMaxPercent + "%";
653        } else {
654            this.colorAvailableActive.style.right = "0%";
655            this.colorAvailableInactive.style.right = "0%";
656        }
657    };
658
659    SmartFilter.prototype.getXCoord = function (elem) {
660        var box = elem.getBoundingClientRect();
661        var body = document.body;
662        var docElem = document.documentElement;
663
664        var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
665        var clientLeft = docElem.clientLeft || body.clientLeft || 0;
666        var left = box.left + scrollLeft - clientLeft;
667
668        return Math.round(left);
669    };
670
671    SmartFilter.prototype.getPageX = function (e) {
672        e = e || window.event;
673        var pageX = null;
674
675        if (this.isTouch && event.targetTouches[0] != null) {
676            pageX = e.targetTouches[0].pageX;
677        } else if (e.pageX != null) {
678            pageX = e.pageX;
679        } else if (e.clientX != null) {
680            var html = document.documentElement;
681            var body = document.body;
682
683            pageX = e.clientX + (html.scrollLeft || body && body.scrollLeft || 0);
684            pageX -= html.clientLeft || 0;
685        }
686
687        return pageX;
688    };
689
690    SmartFilter.prototype.recountMinPrice = function () {
691        var newMinPrice = (this.priceDiff * this.leftPercent) / 100;
692        newMinPrice = (this.minPrice + newMinPrice).toFixed(this.precision);
693
694        if (newMinPrice != this.minPrice)
695            this.minInput.value = newMinPrice;
696        else
697            this.minInput.value = "";
698        /** @global JCSmartFilter smartFilter */
699        smartFilter.keyup(this.minInput);
700    };
701
702    SmartFilter.prototype.recountMaxPrice = function () {
703        var newMaxPrice = (this.priceDiff * this.rightPercent) / 100;
704        newMaxPrice = (this.maxPrice - newMaxPrice).toFixed(this.precision);
705
706        if (newMaxPrice != this.maxPrice)
707            this.maxInput.value = newMaxPrice;
708        else
709            this.maxInput.value = "";
710        /** @global JCSmartFilter smartFilter */
711        smartFilter.keyup(this.maxInput);
712    };
713
714    SmartFilter.prototype.onInputChange = function () {
715        var priceDiff;
716        if (this.minInput.value) {
717            var leftInputValue = this.minInput.value;
718            if (leftInputValue < this.minPrice)
719                leftInputValue = this.minPrice;
720
721            if (leftInputValue > this.maxPrice)
722                leftInputValue = this.maxPrice;
723
724            priceDiff = leftInputValue - this.minPrice;
725            this.leftPercent = (priceDiff * 100) / this.priceDiff;
726
727            this.makeLeftSliderMove(false);
728        }
729
730        if (this.maxInput.value) {
731            var rightInputValue = this.maxInput.value;
732            if (rightInputValue < this.minPrice)
733                rightInputValue = this.minPrice;
734
735            if (rightInputValue > this.maxPrice)
736                rightInputValue = this.maxPrice;
737
738            priceDiff = this.maxPrice - rightInputValue;
739            this.rightPercent = (priceDiff * 100) / this.priceDiff;
740
741            this.makeRightSliderMove(false);
742        }
743    };
744
745    SmartFilter.prototype.makeLeftSliderMove = function (recountPrice) {
746        recountPrice = (recountPrice !== false);
747
748        this.leftSlider.style.left = this.leftPercent + "%";
749        this.colorUnavailableActive.style.left = this.leftPercent + "%";
750
751        var areBothSlidersMoving = false;
752        if (this.leftPercent + this.rightPercent >= 100) {
753            areBothSlidersMoving = true;
754            this.rightPercent = 100 - this.leftPercent;
755            this.rightSlider.style.right = this.rightPercent + "%";
756            this.colorUnavailableActive.style.right = this.rightPercent + "%";
757        }
758
759        if (this.leftPercent >= this.fltMinPercent && this.leftPercent <= (100 - this.fltMaxPercent)) {
760            this.colorAvailableActive.style.left = this.leftPercent + "%";
761            if (areBothSlidersMoving) {
762                this.colorAvailableActive.style.right = 100 - this.leftPercent + "%";
763            }
764        } else if (this.leftPercent <= this.fltMinPercent) {
765            this.colorAvailableActive.style.left = this.fltMinPercent + "%";
766            if (areBothSlidersMoving) {
767                this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%";
768            }
769        } else if (this.leftPercent >= this.fltMaxPercent) {
770            this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%";
771            if (areBothSlidersMoving) {
772                this.colorAvailableActive.style.right = this.fltMaxPercent + "%";
773            }
774        }
775
776        if (recountPrice) {
777            this.recountMinPrice();
778            if (areBothSlidersMoving)
779                this.recountMaxPrice();
780        }
781    };
782
783    SmartFilter.prototype.countNewLeft = function (event) {
784        var pageX = this.getPageX(event);
785
786        var trackerXCoord = this.getXCoord(this.trackerWrap);
787        var rightEdge = this.trackerWrap.offsetWidth;
788
789        var newLeft = pageX - trackerXCoord;
790
791        if (newLeft < 0)
792            newLeft = 0;
793        else if (newLeft > rightEdge)
794            newLeft = rightEdge;
795
796        return newLeft;
797    };
798
799    SmartFilter.prototype.onMoveLeftSlider = function (e) {
800        if (!this.isTouch) {
801            this.leftSlider.ondragstart = function () {
802                return false;
803            };
804        }
805
806        if (!this.isTouch) {
807            document.onmousemove = BX.proxy(function (event) {
808                this.leftPercent = ((this.countNewLeft(event) * 100) / this.trackerWrap.offsetWidth);
809                this.makeLeftSliderMove();
810            }, this);
811
812            document.onmouseup = function () {
813                document.onmousemove = document.onmouseup = null;
814            };
815        } else {
816            document.ontouchmove = BX.proxy(function (event) {
817                this.leftPercent = ((this.countNewLeft(event) * 100) / this.trackerWrap.offsetWidth);
818                this.makeLeftSliderMove();
819            }, this);
820
821            document.ontouchend = function () {
822                document.ontouchmove = document.touchend = null;
823            };
824        }
825
826        return false;
827    };
828
829    SmartFilter.prototype.makeRightSliderMove = function (recountPrice) {
830        recountPrice = (recountPrice !== false);
831
832        this.rightSlider.style.right = this.rightPercent + "%";
833        this.colorUnavailableActive.style.right = this.rightPercent + "%";
834
835        var areBothSlidersMoving = false;
836        if (this.leftPercent + this.rightPercent >= 100) {
837            areBothSlidersMoving = true;
838            this.leftPercent = 100 - this.rightPercent;
839            this.leftSlider.style.left = this.leftPercent + "%";
840            this.colorUnavailableActive.style.left = this.leftPercent + "%";
841        }
842
843        if ((100 - this.rightPercent) >= this.fltMinPercent && this.rightPercent >= this.fltMaxPercent) {
844            this.colorAvailableActive.style.right = this.rightPercent + "%";
845            if (areBothSlidersMoving) {
846                this.colorAvailableActive.style.left = 100 - this.rightPercent + "%";
847            }
848        } else if (this.rightPercent <= this.fltMaxPercent) {
849            this.colorAvailableActive.style.right = this.fltMaxPercent + "%";
850            if (areBothSlidersMoving) {
851                this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%";
852            }
853        } else if ((100 - this.rightPercent) <= this.fltMinPercent) {
854            this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%";
855            if (areBothSlidersMoving) {
856                this.colorAvailableActive.style.left = this.fltMinPercent + "%";
857            }
858        }
859
860        if (recountPrice) {
861            this.recountMaxPrice();
862            if (areBothSlidersMoving)
863                this.recountMinPrice();
864        }
865    };
866
867    SmartFilter.prototype.onMoveRightSlider = function (e) {
868        if (!this.isTouch) {
869            this.rightSlider.ondragstart = function () {
870                return false;
871            };
872        }
873
874        if (!this.isTouch) {
875            document.onmousemove = BX.proxy(function (event) {
876                this.rightPercent = 100 - (((this.countNewLeft(event)) * 100) / (this.trackerWrap.offsetWidth));
877                this.makeRightSliderMove();
878            }, this);
879
880            document.onmouseup = function () {
881                document.onmousemove = document.onmouseup = null;
882            };
883        } else {
884            document.ontouchmove = BX.proxy(function (event) {
885                this.rightPercent = 100 - (((this.countNewLeft(event)) * 100) / (this.trackerWrap.offsetWidth));
886                this.makeRightSliderMove();
887            }, this);
888
889            document.ontouchend = function () {
890                document.ontouchmove = document.ontouchend = null;
891            };
892        }
893
894        return false;
895    };
896
897    return SmartFilter;
898})();
899
900
901$(document).ready(function () {
902    $(document).on('focus', '.search-form_type_search-panel input', function () {
903        if ($('#sb_result_search_items a').length) {
904            $('.sb_search_block').show();
905        }
906    });
907    $(document).on('click', function (e) {
908        let container = $(".smartfilter");
909        if (container.has(e.target).length === 0) {
910            $('.sb_search_block').hide();
911        }
912
913        e.stopPropagation();
914    });
915
916    $(document).on('click', '.block_search', function () {
917        sb_filter_hide_all();
918        $('.sb_search .sb_filter_all_prop').toggleClass('open')
919    });
920
921    $(document).on('focus', '#sb_modal_areas', function () {
922        if ($('#sb_result_search_items a').length) {
923            $('.sb_bg_overlay').show();
924            $('#sb_modal_areas').show();
925            if ($('#sb_modal_areas .sb_step_1').length > 0) {
926                $('#sb_modal_areas .sb_step_1').show();
927                $('#sb_modal_areas .sb_step_2').hide();
928            } else {
929                //$('#sb_modal_areas .sb_step_2').show();
930
931            }
932
933            $('.intro__main').css({'z-index': '401'})
934        }
935    });
936    $(document).on('blur', '#sb_modal_areas', function () {
937        $('#sb_modal_areas').hide();
938        $('.sb_bg_overlay').hide();
939        $('.intro__main').css({'z-index': '399'})
940    });
941
942    $(document).on('blur', '#sb_modal_highway', function () {
943        $('#sb_modal_highway').hide();
944        $('.sb_bg_overlay').hide();
945        $('.intro__main').css({'z-index': '399'})
946    });
947
948    $('#arrFilterBuy_271_1669441013').click();
949});
950
951$('#arrFilterBuy_271_1669441013').on('click', function () {
952    // let url = '/vtorichnaya-nedvizhimost/'
953
954    // smartFilter = new JCSmartFilter(url, 'horizontal', {
955    //     'SEF_SET_FILTER_URL': url + 'filter/clear',
956    //     'SEF_DEL_FILTER_URL': url + 'filter/clear'
957    // });
958    // JCSmartFilter.bindUrlToButton('set_filter', '/vtorichnaya-nedvizhimost/filter/clear');
959    // JCSmartFilter.bindUrlToButton('del_filter', '/vtorichnaya-nedvizhimost/filter/clear');
960})

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.