PageSourceSearch

https://itaita.ru/local/templates/itaita2020/components/bitrix/catalog.element/universal/script.js

js itaita.ru collected 2026-10-02 18:15:38 UTC 128,530 bytes, 3,170 lines download raw bytes

1var hrefGetDisc = "/local/templates/itaita2020/ajax/formgetdiscount.php";
2
3
4(function (window) {
5
6    if (!!window.JCCatalogElement) {
7        return;
8    }
9
10    var BasketButton = function (params) {
11        BasketButton.superclass.constructor.apply(this, arguments);
12        this.nameNode = BX.create('span', {
13            props: {className: 'bx_medium bx_bt_button', id: this.id},
14            style: typeof (params.style) === 'object' ? params.style : {},
15            text: params.text
16        });
17        this.buttonNode = BX.create('span', {
18            attrs: {className: params.ownerClass},
19            children: [this.nameNode],
20            events: this.contextEvents
21        });
22        if (BX.browser.IsIE()) {
23            this.buttonNode.setAttribute("hideFocus", "hidefocus");
24        }
25    };
26    BX.extend(BasketButton, BX.PopupWindowButton);
27
28    window.JCCatalogElement = function (arParams) {
29        // console.dir(arParams);
30        this.productType = 0;
31
32        this.config = {
33            useCatalog: true,
34            showQuantity: true,
35            showPrice: true,
36            showAbsent: true,
37            showOldPrice: false,
38            showPercent: false,
39            showSkuProps: false,
40            showOfferGroup: false,
41            useCompare: false,
42            mainPictureMode: 'IMG',
43            showBasisPrice: false,
44            basketAction: ['BUY'],
45            showClosePopup: false
46        };
47
48        this.checkQuantity = false;
49        this.maxQuantity = 0;
50        this.stepQuantity = 1;
51        this.isDblQuantity = false;
52        this.canBuy = true;
53        this.currentBasisPrice = {};
54        this.canSubscription = true;
55        this.currentIsSet = false;
56        this.updateViewedCount = false;
57
58        this.precision = 6;
59        this.precisionFactor = Math.pow(10, this.precision);
60
61        this.listID = {
62            main: ['PICT_ID', 'BIG_SLIDER_ID', 'BIG_IMG_CONT_ID'],
63            stickers: ['STICKER_ID'],
64            productSlider: ['SLIDER_CONT', 'SLIDER_LIST', 'SLIDER_LEFT', 'SLIDER_RIGHT'],
65            offerSlider: ['SLIDER_CONT_OF_ID', 'SLIDER_LIST_OF_ID', 'SLIDER_LEFT_OF_ID', 'SLIDER_RIGHT_OF_ID'],
66            offers: ['TREE_ID', 'TREE_ITEM_ID', 'DISPLAY_PROP_DIV', 'OFFER_GROUP'],
67            quantity: ['QUANTITY_ID', 'QUANTITY_UP_ID', 'QUANTITY_DOWN_ID', 'QUANTITY_MEASURE', 'QUANTITY_LIMIT', 'BASIS_PRICE'],
68            price: ['PRICE_ID'],
69            oldPrice: ['OLD_PRICE_ID', 'DISCOUNT_VALUE_ID'],
70            discountPerc: ['DISCOUNT_PERC_ID'],
71            basket: ['BASKET_PROP_DIV', 'BUY_ID', 'ADD_BASKET_ID', 'BASKET_ACTIONS_ID', 'NOT_AVAILABLE_MESS'],
72            magnifier: ['MAGNIFIER_ID', 'MAGNIFIER_AREA_ID'],
73            compare: ['COMPARE_LINK_ID']
74        };
75
76        this.visualPostfix = {
77            // main pict
78            PICT_ID: '_pict',
79            BIG_SLIDER_ID: '_big_slider',
80            BIG_IMG_CONT_ID: '_bigimg_cont',
81            // stickers
82            STICKER_ID: '_sticker',
83            // product pict slider
84            SLIDER_CONT: '_slider_cont',
85            SLIDER_LIST: '_slider_list',
86            SLIDER_LEFT: '_slider_left',
87            SLIDER_RIGHT: '_slider_right',
88            // offers sliders
89            SLIDER_CONT_OF_ID: '_slider_cont_',
90            SLIDER_LIST_OF_ID: '_slider_list_',
91            SLIDER_LEFT_OF_ID: '_slider_left_',
92            SLIDER_RIGHT_OF_ID: '_slider_right_',
93            // offers
94            TREE_ID: '_skudiv',
95            TREE_ITEM_ID: '_prop_',
96            DISPLAY_PROP_DIV: '_sku_prop',
97            // quantity
98            QUANTITY_ID: '_quantity',
99            QUANTITY_UP_ID: '_quant_up',
100            QUANTITY_DOWN_ID: '_quant_down',
101            QUANTITY_MEASURE: '_quant_measure',
102            QUANTITY_LIMIT: '_quant_limit',
103            BASIS_PRICE: '_basis_price',
104            // price and discount
105            PRICE_ID: '_price',
106            OLD_PRICE_ID: '_old_price',
107            DISCOUNT_VALUE_ID: '_price_discount',
108            DISCOUNT_PERC_ID: '_dsc_pict',
109            // basket
110            BASKET_PROP_DIV: '_basket_prop',
111            BUY_ID: '_buy_link',
112            ADD_BASKET_ID: '_add_basket_link',
113            BASKET_ACTIONS_ID: '_basket_actions',
114            NOT_AVAILABLE_MESS: '_not_avail',
115            // magnifier
116            MAGNIFIER_ID: '_magnifier',
117            MAGNIFIER_AREA_ID: '_magnifier_area',
118            // offer groups
119            OFFER_GROUP: '_set_group_',
120            // compare
121            COMPARE_LINK_ID: '_compare_link'
122        };
123
124        this.visual = {};
125
126        this.basketMode = '';
127        this.product = {
128            checkQuantity: false,
129            maxQuantity: 0,
130            stepQuantity: 1,
131            startQuantity: 1,
132            isDblQuantity: false,
133            canBuy: true,
134            canSubscription: true,
135            name: '',
136            pict: {},
137            id: 0,
138            addUrl: '',
139            buyUrl: '',
140            slider: {},
141            sliderCount: 0,
142            useSlider: false,
143            sliderPict: []
144        };
145        this.mess = {};
146
147        this.basketData = {
148            useProps: false,
149            emptyProps: false,
150            quantity: 'quantity',
151            props: 'prop',
152            basketUrl: '',
153            sku_props: '',
154            sku_props_var: 'basket_props',
155            add_url: '',
156            buy_url: ''
157        };
158        this.compareData = {
159            compareUrl: '',
160            comparePath: ''
161        };
162
163        this.defaultPict = {
164            preview: null,
165            detail: null
166        };
167
168        this.offers = [];
169        this.offerNum = 0;
170        this.treeProps = [];
171        this.obTreeRows = [];
172        this.showCount = [];
173        this.showStart = [];
174        this.selectedValues = {};
175        this.sliders = [];
176
177        this.obProduct = null;
178        this.obQuantity = null;
179        this.obQuantityUp = null;
180        this.obQuantityDown = null;
181        this.obBasisPrice = null;
182        this.obPict = null;
183        this.obPictAligner = null;
184        this.obPrice = {
185            price: null,
186            full: null,
187            discount: null,
188            percent: null
189        };
190        this.obTree = null;
191        this.obBuyBtn = null;
192        this.obAddToBasketBtn = null;
193        this.obAddToBasketInSaloonBtn = null;
194        this.obBasketActions = null;
195        this.obNotAvail = null;
196        this.obSkuProps = null;
197        this.obSlider = null;
198        this.obMeasure = null;
199        this.obQuantityLimit = {
200            all: null,
201            value: null
202        };
203        this.obCompare = null;
204
205        this.viewedCounter = {
206            path: '/bitrix/components/bitrix/catalog.element/ajax.php',
207            params: {
208                AJAX: 'Y',
209                SITE_ID: '',
210                PRODUCT_ID: 0,
211                PARENT_ID: 0
212            }
213        };
214
215        this.currentImg = {
216            src: '',
217            width: 0,
218            height: 0,
219            screenWidth: 0,
220            screenHeight: 0,
221            screenOffsetX: 0,
222            screenOffsetY: 0,
223            scale: 1
224        };
225
226        this.obPopupWin = null;
227        this.basketUrl = '';
228        this.basketParams = {};
229        this.basketParamsInSaloon = false;
230
231        this.obPopupPict = null;
232        this.magnify = {
233            obMagnifier: null,
234            obMagnifyPict: null,
235            obMagnifyArea: null,
236            obBigImg: null,
237            obBigSlider: null,
238            magnifyShow: false,
239            areaParams: {
240                width: 100,
241                height: 130,
242                left: 0,
243                top: 0,
244                scaleFactor: 1,
245                globalLeft: 0,
246                globalTop: 0,
247                globalRight: 0,
248                globalBottom: 0
249            },
250            magnifierParams: {
251                top: 0,
252                left: 0,
253                width: 0,
254                height: 0,
255                ratioX: 10,
256                ratioY: 13,
257                defaultScale: 1
258            },
259            magnifyPictParams: {
260                marginTop: 0,
261                marginLeft: 0,
262                width: 0,
263                height: 0
264            }
265        };
266
267        this.treeRowShowSize = 5;
268        this.treeEnableArrow = {display: '', cursor: 'pointer', opacity: 1};
269        this.treeDisableArrow = {display: '', cursor: 'default', opacity: 0.2};
270        this.sliderRowShowSize = 5;
271        this.sliderEnableArrow = {display: '', cursor: 'pointer', opacity: 1};
272        this.sliderDisableArrow = {display: '', cursor: 'default', opacity: 0.2};
273
274        this.errorCode = 0;
275
276        if (typeof arParams === 'object') {
277            this.params = arParams;
278            this.initConfig();
279
280            if (!!this.params.MESS) {
281                this.mess = this.params.MESS;
282            }
283            switch (this.productType) {
284                case 0:// no catalog
285                case 1://product
286                case 2://set
287                    this.initProductData();
288                    break;
289                case 3://sku
290                    this.initOffersData();
291                    break;
292                default:
293                    this.errorCode = -1;
294            }
295            this.initBasketData();
296            this.initCompareData();
297        }
298        if (0 === this.errorCode) {
299            BX.ready(BX.delegate(this.Init, this));
300        }
301        this.params = {};
302    };
303
304    window.JCCatalogElement.prototype.Init = function () {
305        var i = 0,
306            j = 0,
307            strPrefix = '',
308            SliderImgs = null,
309            TreeItems = null;
310
311        this.obProduct = BX(this.visual.ID);
312        if (!this.obProduct) {
313            this.errorCode = -1;
314        }
315        this.obPict = BX(this.visual.PICT_ID);
316        if (!this.obPict) {
317            this.errorCode = -2;
318        } else {
319            this.obPictAligner = this.obPict.parentNode;
320        }
321
322        if (this.config.showPrice) {
323            this.obPrice.price = BX(this.visual.PRICE_ID);
324            if (!this.obPrice.price && this.config.useCatalog) {
325                this.errorCode = -16;
326            } else {
327                if (this.config.showOldPrice) {
328                    this.obPrice.full = BX(this.visual.OLD_PRICE_ID);
329                    this.obPrice.discount = BX(this.visual.DISCOUNT_VALUE_ID);
330                    if (!this.obPrice.full || !this.obPrice.discount) {
331                        this.config.showOldPrice = false;
332                    }
333                }
334                if (this.config.showPercent) {
335                    this.obPrice.percent = BX(this.visual.DISCOUNT_PERC_ID);
336                    if (!this.obPrice.percent) {
337                        this.config.showPercent = false;
338                    }
339                }
340            }
341            this.obBasketActions = BX(this.visual.BASKET_ACTIONS_ID);
342            if (!!this.obBasketActions) {
343                if (BX.util.in_array('BUY', this.config.basketAction)) {
344                    this.obBuyBtn = BX(this.visual.BUY_ID);
345                }
346                if (BX.util.in_array('ADD', this.config.basketAction)) {
347                    this.obAddToBasketBtn = BX(this.visual.ADD_BASKET_ID);
348
349                    this.obAddToBasketInSaloonBtn = BX(this.visual.ADD_BASKET_ID + "_in_saloon");
350
351                    this.obSaloonBtn = BX(this.visual.ADD_BASKET_ID + "_add_in_saloon");
352                }
353            }
354            this.obNotAvail = BX(this.visual.NOT_AVAILABLE_MESS);
355        }
356
357        if (this.config.showQuantity) {
358            this.obQuantity = BX(this.visual.QUANTITY_ID);
359            if (!!this.visual.QUANTITY_UP_ID) {
360                this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID);
361            }
362            if (!!this.visual.QUANTITY_DOWN_ID) {
363                this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID);
364            }
365            if (this.config.showBasisPrice) {
366                this.obBasisPrice = BX(this.visual.BASIS_PRICE);
367            }
368        }
369        if (3 === this.productType) {
370            //console.log(this.visual.TREE_ID);
371            if (!!this.visual.TREE_ID) {
372                this.obTree = BX(this.visual.TREE_ID);
373                //console.log(this.obTree);
374                if (!this.obTree) {
375                    this.errorCode = -256;
376                }
377                strPrefix = this.visual.TREE_ITEM_ID;
378                for (i = 0; i < this.treeProps.length; i++) {
379                    this.obTreeRows[i] = {
380                        LEFT: BX(strPrefix + this.treeProps[i].ID + '_left'),
381                        RIGHT: BX(strPrefix + this.treeProps[i].ID + '_right'),
382                        LIST: BX(strPrefix + this.treeProps[i].ID + '_list'),
383                        CONT: BX(strPrefix + this.treeProps[i].ID + '_cont')
384                    };
385                    if (!this.obTreeRows[i].LEFT || !this.obTreeRows[i].RIGHT || !this.obTreeRows[i].LIST || !this.obTreeRows[i].CONT) {
386                        this.errorCode = -512;
387                        break;
388                    }
389                }
390            }
391            if (!!this.visual.QUANTITY_MEASURE) {
392                this.obMeasure = BX(this.visual.QUANTITY_MEASURE);
393            }
394            if (!!this.visual.QUANTITY_LIMIT) {
395                this.obQuantityLimit.all = BX(this.visual.QUANTITY_LIMIT);
396                if (!!this.obQuantityLimit.all) {
397                    this.obQuantityLimit.value = BX.findChild(this.obQuantityLimit.all, {tagName: 'span'}, false, false);
398                    if (!this.obQuantityLimit.value) {
399                        this.obQuantityLimit.all = null;
400                    }
401                }
402            }
403        }
404
405        if (this.config.showSkuProps) {
406            if (!!this.visual.DISPLAY_PROP_DIV) {
407                this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV);
408            }
409        }
410
411        if (this.config.useCompare) {
412            this.obCompare = BX(this.visual.COMPARE_LINK_ID);
413        }
414
415        let eventParamsCard = this.eventParamsCard;
416
417        /* Marketing */
418        VK.Retargeting.ProductEvent(3158, "view_product", eventParamsCard);
419        window.dataLayer.push({
420            "ecommerce": {
421                "detail": {
422                    "products": [
423                        {
424                            'id': this.productId,
425                            'name': this.product.name,
426                            'price': this.productPrice
427                        },
428
429                    ]
430                }
431            }
432        });
433
434        var _tmr = _tmr || [];
435        _tmr.push({
436            type: 'itemView',
437            productid: this.productId,
438            pagetype: 'product',
439            totalvalue: this.productMinPrice,
440            list: '1'
441        });
442        ga('set', 'dimension1', this.productId);
443        ga('set', 'dimension2', 'product');
444        ga('set', 'dimension3', this.productMinPrice);
445
446        let prodId = this.productId;
447        let rnd = this.makeRnd(12);
448
449        //(function (d, w) {
450            //var n = d.getElementsByTagName("script")[0],
451                //s = d.createElement("script"),
452                //f = function () {
453                    //n.parentNode.insertBefore(s, n);
454                //};
455            //s.type = "text/javascript";
456            //s.async = true;
457            //s.src = "//track.recreativ.ru/trck.php?shop=1971&ttl=30&offer=" + prodId + "&rnd=" + rnd;
458            //if (window.opera == "[object Opera]") {
459                //d.addEventListener("DOMContentLoaded", f, false);
460            //} else {
461                //f();
462            //}
463        //})(document, window);
464
465        var toConvid = function () {
466            var mailAddr = this.config.userEmail;
467            convead(
468                "event",
469                "custom",
470                {
471                    key: "insaloon"
472                },
473                {
474                    "email": mailAddr
475                }
476            );
477        };
478
479
480        // if (this.config.isModal != true) {
481        //     (function () {
482        //         if (window.pluso) if (typeof window.pluso.start == "function") return;
483        //         if (window.ifpluso == undefined) {
484        //             window.ifpluso = 1;
485        //             var d = document, s = d.createElement('script'), g = 'getElementsByTagName';
486        //             s.type = 'text/javascript';
487        //             s.charset = 'UTF-8';
488        //             s.async = true;
489        //             s.src = ('https:' == window.location.protocol ? 'https' : 'http') + '://share.pluso.ru/pluso-like.js';
490        //             var h = d[g]('body')[0];
491        //             h.appendChild(s);
492        //         }
493        //     })();
494        // }
495
496        if ((this.productSection == 232) || (this.productSection == 235)) {
497            //fbq('track', 'ViewContent');
498        }
499
500        if (this.config.userLoggedIn) {
501            $(".in-basket__like").click(function (e) {
502                e.preventDefault();
503                var elCount = parseInt($('#count_in_fav').text());
504
505                var idid = $('.in-basket__like').data('id');
506                var $this = $(this);
507
508
509                $.get("/ajax_favorite.php", {
510                    elid: $this.data('id')
511                }, function (data) {
512                    switch (data) {
513                        case 'done' :
514                            var response = 'Товар успешно добавлен в список "Моих желаний"';
515                            var textlink = 'Удалить из "Моих желаний"';
516                            VK.Retargeting.ProductEvent(3158, "add_to_wishlist", eventParamsCard);
517                            //fbq('track', 'AddToWishlist');
518                            $this.addClass("in-basket__like_active");
519                            if ($('*').is('#count_in_fav')) {
520                                $('#count_in_fav').text(elCount + 1);
521                            } else {
522                                $('.vb-favorites-link a span').html('Мои желания <b id="count_in_fav">1</b>');
523                            }
524                            break;
525
526                        case 'deleted' :
527                            var response = 'Товар успешно удален из списка "Моих желаний"';
528                            var textlink = 'Добавить в "Мои желания"';
529                            VK.Retargeting.ProductEvent(3158, "remove_from_wishlist", eventParam
529sCard);
530                            $this.removeClass("in-basket__like_active");
531
532                            if (elCount > 1) {
533                                $('#count_in_fav').text(elCount - 1);
534                            } else {
535                                $('#count_in_fav').remove();
536                            }
537                            break;
538
539                        case 'fail' :
540                            var response = 'Вы не авторизованы, либо Ваш запрос некорректен';
541                            var textlink = 'Добавить в "Мои желания"';
542                            $this.removeClass("in-basket__like_active");
543                            break;
544                    }
545                    $("#favorit_label").html(response).fadeIn(1000).delay(5000).fadeOut();
546                    $("#textlink").html(textlink).fadeIn(1000);
547                });
548            });
549        } else {
550            // $(".favorite_auth_need").click(function (e) {
551            //     alert("Для добавления товара в избранное необходимо авторизоваться")
552            // });
553
554            this.favBtnAuthNeed = this.obProduct.querySelector(".favorite_auth_need");
555            BX.bind(this.favBtnAuthNeed, 'click', BX.delegate(this.addToFavsAuthNeed, this));
556            this.checkFavsAuthNeed();
557        }
558
559        console.log(this.errorCode);
560
561        if (0 === this.errorCode) {
562            if (this.config.showQuantity) {
563                if (!!this.obQuantityUp) {
564                    BX.bind(this.obQuantityUp, 'click', BX.delegate(this.QuantityUp, this));
565                }
566                if (!!this.obQuantityDown) {
567                    BX.bind(this.obQuantityDown, 'click', BX.delegate(this.QuantityDown, this));
568                }
569                if (!!this.obQuantity) {
570                    BX.bind(this.obQuantity, 'change', BX.delegate(this.QuantityChange, this));
571                }
572            }
573            switch (this.productType) {
574                case 0://no catalog
575                case 1://product
576                case 2://set
577                    if (this.product.useSlider) {
578                        this.product.slider = {
579                            COUNT: this.product.sliderCount,
580                            ID: this.visual.SLIDER_CONT,
581                            CONT: BX(this.visual.SLIDER_CONT),
582                            LIST: BX(this.visual.SLIDER_LIST),
583                            LEFT: BX(this.visual.SLIDER_LEFT),
584                            RIGHT: BX(this.visual.SLIDER_RIGHT),
585                            START: 0
586                        };
587                        SliderImgs = BX.findChildren(this.product.slider.LIST, {tagName: 'li'}, true);
588                        if (!!SliderImgs && 0 < SliderImgs.length) {
589                            for (j = 0; j < SliderImgs.length; j++) {
590                                BX.bind(SliderImgs[j], 'click', BX.delegate(this.ProductSelectSliderImg, this));
591                            }
592                        }
593                        if (!!this.product.slider.LEFT) {
594                            BX.bind(this.product.slider.LEFT, 'click', BX.delegate(this.ProductSliderRowLeft, this));
595                            BX.adjust(this.product.slider.LEFT, {style: this.sliderDisableArrow});
596
597                        }
598                        if (!!this.product.slider.RIGHT) {
599                            BX.bind(this.product.slider.RIGHT, 'click', BX.delegate(this.ProductSliderRowRight, this));
600                            BX.adjust(this.product.slider.RIGHT, {style: this.sliderEnableArrow});
601                        }
602                        this.setCurrentImg(this.product.sliderPict[0], true);
603                    }
604                    break;
605                case 3://sku
606                    TreeItems = BX.findChildren(this.obTree, {tagName: 'li'}, true);
607                    if (!!TreeItems && 0 < TreeItems.length) {
608                        for (i = 0; i < TreeItems.length; i++) {
609                            BX.bind(TreeItems[i], 'click', BX.delegate(this.SelectOfferProp, this));
610                        }
611                    }
612                    for (i = 0; i < this.obTreeRows.length; i++) {
613                        BX.bind(this.obTreeRows[i].LEFT, 'click', BX.delegate(this.RowLeft, this));
614                        BX.bind(this.obTreeRows[i].RIGHT, 'click', BX.delegate(this.RowRight, this));
615                    }
616                    for (i = 0; i < this.offers.length; i++) {
617                        this.offers[i].SLIDER_COUNT = parseInt(this.offers[i].SLIDER_COUNT, 10);
618                        if (isNaN(this.offers[i].SLIDER_COUNT)) {
619                            this.offers[i].SLIDER_COUNT = 0;
620                        }
621                        if (0 === this.offers[i].SLIDER_COUNT) {
622                            this.sliders[i] = {
623                                COUNT: this.offers[i].SLIDER_COUNT,
624                                ID: ''
625                            };
626                        } else {
627                            for (j = 0; j < this.offers[i].SLIDER.length; j++) {
628                                this.offers[i].SLIDER[j].WIDTH = parseInt(this.offers[i].SLIDER[j].WIDTH, 10);
629                                this.offers[i].SLIDER[j].HEIGHT = parseInt(this.offers[i].SLIDER[j].HEIGHT, 10);
630                            }
631                            this.sliders[i] = {
632                                COUNT: this.offers[i].SLIDER_COUNT,
633                                OFFER_ID: this.offers[i].ID,
634                                ID: this.visual.SLIDER_CONT_OF_ID + this.offers[i].ID,
635                                CONT: BX(this.visual.SLIDER_CONT_OF_ID + this.offers[i].ID),
636                                LIST: BX(this.visual.SLIDER_LIST_OF_ID + this.offers[i].ID),
637                                LEFT: BX(this.visual.SLIDER_LEFT_OF_ID + this.offers[i].ID),
638                                RIGHT: BX(this.visual.SLIDER_RIGHT_OF_ID + this.offers[i].ID),
639                                START: 0
640                            };
641                            SliderImgs = BX.findChildren(this.sliders[i].LIST, {tagName: 'li'}, true);
642                            if (!!SliderImgs && 0 < SliderImgs.length) {
643                                for (j = 0; j < SliderImgs.length; j++) {
644                                    BX.bind(SliderImgs[j], 'click', BX.delegate(this.SelectSliderImg, this));
645                                }
646                            }
647                            if (!!this.sliders[i].LEFT) {
648                                BX.bind(this.sliders[i].LEFT, 'click', BX.delegate(this.SliderRowLeft, this));
649                            }
650                            if (!!this.sliders[i].RIGHT) {
651                                BX.bind(this.sliders[i].RIGHT, 'click', BX.delegate(this.SliderRowRight, this));
652                            }
653                        }
654                    }
655                    this.SetCurrent();
656                    break;
657            }
658
659            if (!!this.obBuyBtn) {
660                BX.bind(this.obBuyBtn, 'click', BX.proxy(this.BuyBasket, this));
661            }
662            if (!!this.obAddToBasketBtn) {
663                BX.bind(this.obAddToBasketBtn, 'click', BX.proxy(this.Add2Basket, this));
664            }
665            if (!!this.obAddToBasketInSaloonBtn) {
666                BX.bind(this.obAddToBasketInSaloonBtn, 'click', BX.proxy(this.Add2Basket, this));
667            }
668
669            if (!!this.obSaloonBtn) {
670                BX.bind(this.obSaloonBtn, 'click', BX.proxy(this.Add2Saloon, this));
671            }
672
673            if (!!this.obCompare) {
674                BX.bind(this.obCompare, 'click', BX.proxy(this.Compare, this));
675            }
676
677            this.setMainPictHandler();
678        }
679
680        offerID = this.offers[this.offerNum].ID;
681        newHref = hrefGetDisc + "?PRICE=" + this.currentBasisPrice.DISCOUNT_VALUE + "&PRODUCT_ID=" + offerID;
682        $(".get-discount").attr("href", newHref);
683
684        let getUrl = window.location.hash;
685        if (getUrl) {
686            let reviewTab = BX('reviewTab');
687            let tabsGroup = BX('tabsGroup');
688
689            if (getUrl == "#review") {
690                BX.fireEvent(reviewTab, 'click');
691
692                let pos = BX.pos(tabsGroup, false);
693
694                let easing = new BX.easing({
695                    duration: 500,
696                    start: {top: 0},
697                    finish: {top: pos.top},
698                    transition: BX.easing.transitions.quart,
699                    step: function (state) {
700                        window.scrollTo(0, state.top);
701                    }
702                });
703                easing.animate();
704            }
705        }
706    };
707
708
709    window.JCCatalogElement.prototype.checkFavsAuthNeed = function () {
710        let _this = this,
711            favArr = localStorage.getItem("favArr");
712
713        if (favArr == null) {
714            favArr = _this.getCookie("favArr");
715        }
716        if ((favArr !== null) && (favArr !== undefined)) {
717            favArr = favArr.split(",");
718            favArr.forEach(function (favId) {
719                let btn = document.querySelector(".favorite_auth_need[data-id='" + favId + "']");
720                if (btn !== null) {
721                    btn.classList.add("in-basket__like_active");
722                }
723            })
724        }
725    };
726
727    window.JCCatalogElement.prototype.addToFavsAuthNeed = function (e) {
728        e.preventDefault();
729        let _this = this;
730
731        if (_this.favBtnAuthNeed.classList.contains("in-basket__like_active")) {
732            _this.removeFromFavsAuthNeed();
733        } else {
734            let favId = _this.favBtnAuthNeed.dataset.id;
735            let favArr = localStorage.getItem("favArr");
736
737            if (favArr == null) {
738                favArr = _this.getCookie("favArr");
739            }
740            if ((favArr !== null) && (favArr !== undefined)) {
741                // favArr = favArr.replace(/%2C/g, ",");
742                favArr = favArr.split(",");
743            } else {
744                favArr = [];
745            }
746            favArr.push(favId);
747            localStorage.setItem("favArr", favArr);
748            _this.setCookie("favArr", favArr);
749
750            _this.favBtnAuthNeed.classList.add("in-basket__like_active");
751        }
752    };
753
754    window.JCCatalogElement.prototype.removeFromFavsAuthNeed = function () {
755        let _this = this,
756            favId = _this.favBtnAuthNeed.dataset.id,
757            favArr = localStorage.getItem("favArr");
758
759
760        if (favArr == null) {
761            favArr = _this.getCookie("favArr");
762        }
763        if ((favArr !== null) && (favArr !== undefined)) {
764            // favArr = favArr.replace(/%2C/g, ",");
765            favArr = favArr.split(",");
766        }
767
768        const index = favArr.indexOf(favId);
769        if (index > -1) {
770            favArr.splice(index, 1);
771        }
772
773        localStorage.setItem("favArr", favArr);
774        _this.setCookie("favArr", favArr);
775
776        _this.favBtnAuthNeed.classList.remove("in-basket__like_active");
777    };
778
779    window.JCCatalogElement.prototype.getCookie = function (name) {
780        let matches = document.cookie.match(new RegExp(
781            "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
782        ));
783        console.dir(matches);
784        return matches ? decodeURIComponent(matches[1]).replace(/%2C/g, ",") : undefined;
785    };
786
787    window.JCCatalogElement.prototype.deleteCookie = function (name) {
788        setCookie(name, "", {
789            'max-age': -1
790        })
791    };
792
793    window.JCCatalogElement.prototype.setCookie = function (name, value, options = {}) {
794
795        options = {
796            path: '/',
797            'max-age': 999999999999
798        };
799
800        if (options.expires instanceof Date) {
801            options.expires = options.expires.toUTCString();
802        }
803
804        let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value).replace(/%2C/g, ",");
805
806        for (let optionKey in options) {
807            updatedCookie += "; " + optionKey;
808            let optionValue = options[optionKey];
809            if (optionValue !== true) {
810                updatedCookie += "=" + optionValue;
811            }
812        }
813
814        document.cookie = updatedCookie;
815    };
816
817    window.JCCatalogElement.prototype.makeRnd = function (length) {
818        var result = '';
819        // var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
820        var characters = '0123456789';
821        var charactersLength = characters.length;
822        for (var i = 0; i < length; i++) {
823            result += characters.charAt(Math.floor(Math.random() * charactersLength));
824        }
825        return result;
826    };
827
828    window.JCCatalogElement.prototype.initConfig = function () {
829        this.productType = parseInt(this.params.PRODUCT_TYPE, 10);
830        this.productBrand = this.params.BRAND;
831        this.productId = this.params.PRODUCT.ID;
832        this.productPrice = this.params.PRODUCT.PRICE;
833        this.productSection = this.params.PRODUCT.SECTION;
834        this.productMinPrice = this.params.PRODUCT.MIN_PRICE;
835        this.productPriceOld = this.params.PRODUCT.PRICE_OLD;
836        this.config.userEmail = this.params.USER_EMAIL;
837        this.config.isModal = this.params.IS_MODAL;
838
839        this.eventParamsCard = {
840            "products": [{
841                "id": this.productId,
842                "group_id": this.productId,
843                "price": this.productPrice,
844                "price_old": this.productPriceOld
845            }],
846            "currency_code": "RUR"
847        };
848
849        if (!!this.params.CONFIG && typeof (this.params.CONFIG) === 'object') {
850            if (this.params.CONFIG.USE_CATALOG !== 'undefined' && BX.type.isBoolean(this.params.CONFIG.USE_CATALOG)) {
851                this.config.useCatalog = this.params.CONFIG.USE_CATALOG;
852            }
853            this.config.showQuantity = !!this.params.CONFIG.SHOW_QUANTITY;
854            this.config.showPrice = !!this.params.CONFIG.SHOW_PRICE;
855            this.config.showPercent = !!this.params.CONFIG.SHOW_DISCOUNT_PERCENT;
856            this.config.showOldPrice = !!this.params.CONFIG.SHOW_OLD_PRICE;
857            this.config.showSkuProps = !!this.params.CONFIG.SHOW_SKU_PROPS;
858            this.config.showOfferGroup = !!this.params.CONFIG.OFFER_GROUP;
859            this.config.useCompare = !!this.params.CONFIG.DISPLAY_COMPARE;
860            if (!!this.params.CONFIG.MAIN_PICTURE_MODE) {
861                this.config.mainPictureMode = this.params.CONFIG.MAIN_PICTURE_MODE;
862            }
863            this.config.showBasisPrice = !!this.params.CONFIG.SHOW_BASIS_PRICE;
864            if (!!this.params.CONFIG.ADD_TO_BASKET_ACTION) {
865                this.config.basketAction = this.params.CONFIG.ADD_TO_BASKET_ACTION;
866            }
867            this.config.showClosePopup = !!this.params.CONFIG.SHOW_CLOSE_POPUP;
868            this.config.userLoggedIn = !!this.params.USER_LOGGED_IN;
869        } else {
870            // old version
871            if (this.params.USE_CATALOG !== 'undefined' && BX.type.isBoolean(this.params.USE_CATALOG)) {
872                this.config.useCatalog = this.params.USE_CATALOG;
873            }
874            this.config.showQuantity = !!this.params.SHOW_QUANTITY;
875            this.config.showPrice = !!this.params.SHOW_PRICE;
876            this.config.showPercent = !!this.params.SHOW_DISCOUNT_PERCENT;
877            this.config.showOldPrice = !!this.params.SHOW_OLD_PRICE;
878            this.config.showSkuProps = !!this.params.SHOW_SKU_PROPS;
879            this.config.showOfferGroup = !!this.params.OFFER_GROUP;
880            this.config.useCompare = !!this.params.DISPLAY_COMPARE;
881            if (!!this.params.MAIN_PICTURE_MODE) {
882                this.config.mainPictureMode = this.params.MAIN_PICTURE_MODE;
883            }
884            this.config.showBasisPrice = !!this.params.SHOW_BASIS_PRICE;
885            if (!!this.params.ADD_TO_BASKET_ACTION) {
886                this.config.basketAction = this.params.ADD_TO_BASKET_ACTION;
887            }
888            this.config.showClosePopup = !!this.params.SHOW_CLOSE_POPUP;
889            this.config.userLoggedIn = !!this.params.USER_LOGGED_IN;
890        }
891
892        if (!this.params.VISUAL || typeof (this.params.VISUAL) !== 'object' || !this.params.VISUAL.ID) {
893            this.errorCode = -1;
894            return;
895        }
896        this.visual.ID = this.params.VISUAL.ID;
897        this.initVisualParams('main');
898        if (this.config.showQuantity) {
899            this.initVisualParams('quantity');
900        }
901        if (this.config.showPrice) {
902            this.initVisualParams('price');
903        }
904        if (this.config.showOldPrice) {
905            this.initVisualParams('oldPrice');
906        }
907        if (this.config.showPercent) {
908            this.initVisualParams('discountPerc');
909        }
910        this.initVisualParams('basket');
911        if (this.config.mainPictureMode === 'MAGNIFIER') {
912            this.initVisualParams('magnifier');
913        }
914        if (this.config.useCompare) {
915            this.initVisualParams('compare');
916        }
917    };
918
919    window.JCCatalogElement.prototype.initVisualParams = function (ID) {
920        var i = 0,
921            key = '';
922
923        if (!this.listID[ID]) {
924            this.errorCode = -1;
925            return;
926        }
927        for (i = 0; i < this.listID[ID].length; i++) {
928            key = this.listID[ID][i];
929            this.visual[key] = (!!this.params.VISUAL[key] ? this.params.VISUAL[key] : this.visual.ID + this.visualPostfix[key]);
930        }
931    };
932
933    window.JCCatalogElement.prototype.initProductData = function () {
934        var j = 0;
935        this.initVisualParams('productSlider');
936        if (!!this.params.PRODUCT && 'object' === typeof (this.params.PRODUCT)) {
937            if (this.config.showQuantity) {
938                this.product.checkQuantity = this.params.PRODUCT.CHECK_QUANTITY;
939                this.product.isDblQuantity = this.params.PRODUCT.QUANTITY_FLOAT;
940                if (this.product.checkQuantity) {
941                    this.product.maxQuantity = (this.product.isDblQuantity ? parseFloat(this.params.PRODUCT.MAX_QUANTITY) : parseInt(this.params.PRODUCT.MAX_QUANTITY, 10));
942                }
943                this.product.stepQuantity = (this.product.isDblQuantity ? parseFloat(this.params.PRODUCT.STEP_QUANTITY) : parseInt(this.params.PRODUCT.STEP_QUANTITY, 10));
944
945                this.checkQuantity = this.product.checkQuantity;
946                this.isDblQuantity = this.product.isDblQuantity;
947                this.maxQuantity = this.product.maxQuantity;
948                this.stepQuantity = this.product.stepQuantity;
949                if (this.isDblQuantity) {
950                    this.stepQuantity = Math.round(this.stepQuantity * this.precisionFactor) / this.precisionFactor;
951                }
952            }
953            this.product.canBuy = this.params.PRODUCT.CAN_BUY;
954            this.product.canSubscription = this.params.PRODUCT.SUBSCRIPTION;
955            if (this.config.showPrice) {
956                this.currentBasisPrice = this.params.PRODUCT.BASIS_PRICE;
957            }
958
959            this.canBuy = this.product.canBuy;
960            this.canSubscription = this.product.canSubscription;
961
962            this.product.name = this.params.PRODUCT.NAME;
963            this.product.pict = this.params.PRODUCT.PICT;
964            this.product.id = this.params.PRODUCT.ID;
965
966            if (!!this.params.PRODUCT.ADD_URL) {
967                this.product.addUrl = this.params.PRODUCT.ADD_URL;
968            }
969            if (!!this.params.PRODUCT.BUY_URL) {
970                this.product.buyUrl = this.params.PRODUCT.BUY_URL;
971            }
972
973            if (!!this.params.PRODUCT.SLIDER_COUNT) {
974                this.product.sliderCount = parseInt(this.params.PRODUCT.SLIDER_COUNT, 10);
975                if (isNaN(this.product.sliderCount)) {
976                    this.product.sliderCount = 0;
977                }
978                if (0 < this.product.sliderCount && !!this.params.PRODUCT.SLIDER.length && 0 < this.params.PRODUCT.SLIDER.length) {
979                    for (j = 0; j < this.params.PRODUCT.SLIDER.length; j++) {
980                        this.product.useSlider = true;
981                        this.params.PRODUCT.SLIDER[j].WIDTH = parseInt(this.params.PRODUCT.SLIDER[j].WIDTH, 10);
982                        this.params.PRODUCT.SLIDER[j].HEIGHT = parseInt(this.params.PRODUCT.SLIDER[j].HEIGHT, 10);
983                    }
984                    this.product.sliderPict = this.params.PRODUCT.SLIDER;
985                    this.setCurrentImg(this.product.sliderPict[0], false);
986                }
987            }
988            this.currentIsSet = true;
989        } else {
990            this.errorCode = -1;
991        }
992
993        /*
994        const eventParams = {
995            "products" : [{"id":this.product.id}, {"id":this.product.id, "group_id":this.group_id}],
996            "total_price" : this.price.full
997        };
998
999        VK.Retargeting.ProductEvent("view_product", eventParams);
1000        */
1001    };
1002
1003    window.JCCatalogElement.prototype.initOffersData = function () {
1004        this.initVisualParams('offerSlider');
1005        this.initVisualParams('offers');
1006        if (!!this.params.OFFERS && BX.type.isArray(this.params.OFFERS)) {
1007            this.offers = this.params.OFFERS;
1008            this.offerNum = 0;
1009            if (!!this.params.OFFER_SELECTED) {
1010                this.offerNum = parseInt(this.params.OFFER_SELECTED, 10);
1011            }
1012            if (isNaN(this.offerNum)) {
1013                this.offerNum = 0;
1014            }
1015            if (!!this.params.TREE_PROPS) {
1016                this.treeProps = this.params.TREE_PROPS;
1017            }
1018            if (!!this.params.DEFAULT_PICTURE) {
1019                this.defaultPict.preview = this.params.DEFAULT_PICTURE.PREVIEW_PICTIRE;
1020                this.defaultPict.detail = this.params.DEFAULT_PICTURE.DETAIL_PICTURE;
1021            }
1022            if (!!this.params.PRODUCT && typeof (this.params.PRODUCT) === 'object') {
1023                this.product.id = parseInt(this.params.PRODUCT.ID, 10);
1024                this.product.name = this.params.PRODUCT.NAME;
1025            }
1026        } else {
1027            this.errorCode = -1;
1028        }
1029    };
1030
1031    window.JCCatalogElement.prototype.initBasketData = function () {
1032        if (!!this.params.BASKET && 'object' === typeof (this.params.BASKET)) {
1033            if (1 === this.productType || 2 === this.productType) {
1034                this.basketData.useProps = !!this.params.BASKET.ADD_PROPS;
1035                this.basketData.emptyProps = !!this.params.BASKET.EMPTY_PROPS;
1036            }
1037
1038            if (!!this.params.BASKET.QUANTITY) {
1039                this.basketData.quantity = this.params.BASKET.QUANTITY;
1040            }
1041            if (!!this.params.BASKET.PROPS) {
1042                this.basketData.props = this.params.BASKET.PROPS;
1043            }
1044            if (!!this.params.BASKET.BASKET_URL) {
1045                this.basketData.basketUrl = this.params.BASKET.BASKET_URL;
1046            }
1047            if (3 === this.productType) {
1048                if (!!this.params.BASKET.SKU_PROPS) {
1049                    this.basketData.sku_props = this.params.BASKET.SKU_PROPS;
1050                }
1051            }
1052            if (!!this.params.BASKET.ADD_URL_TEMPLATE) {
1053                this.basketData.add_url = this.params.BASKET.ADD_URL_TEMPLATE;
1054            }
1055            if (!!this.params.BASKET.BUY_URL_TEMPLATE) {
1056                this.basketData.buy_url = this.params.BASKET.BUY_URL_TEMPLATE;
1057            }
1058            if (this.basketData.add_url === '' && this.basketData.buy_url === '') {
1059                this.errorCode = -1024;
1060            }
1061        }
1062    };
1063
1064    window.JCCatalogElement.prototype.initCompareData = function () {
1065        if (this.config.useCompare) {
1066            if (!!this.params.COMPARE && typeof (this.params.COMPARE) === 'object') {
1067                if (!!this.params.COMPARE.COMPARE_PATH) {
1068                    this.compareData.comparePath = this.params.COMPARE.COMPARE_PATH;
1069                }
1070                if (!!this.params.COMPARE.COMPARE_URL_TEMPLATE) {
1071                    this.compareData.compareUrl = this.params.COMPARE.COMPARE_URL_TEMPLATE;
1072                } else {
1073                    this.config.useCompare = false;
1074                }
1075            } else {
1076                this.config.useCompare = false;
1077            }
1078        }
1079    };
1080
1081    window.JCCatalogElement.prototype.setMainPictHandler = function () {
1082        switch (this.config.mainPictureMode) {
1083            case 'GALLERY':
1084                break;
1085            case 'MAGNIFIER':
1086                this.magnify.obBigImg = BX(this.visual.BIG_IMG_CONT_ID);
1087                this.magnify.obBigSlider = BX(this.visual.BIG_SLIDER_ID);
1088                if (!!this.magnify.obBigImg && !!this.magnify.obBigSlider) {
1089                    this.magnify.obMagnifyArea = this.obPictAligner.appendChild(BX.create(
1090                        'DIV',
1091                        {
1092                            props: {
1093                                id: this.visual.MAGNIFIER_AREA_ID,
1094                                className: 'bx_item_slider_lupe_small'
1095                            },
1096                            style: {
1097                                display: 'none',
1098                                top: 0,
1099                                left: 0,
1100                                width: '100px',
1101                                height: '130px'
1102                            },
1103                            events: {
1104                                mouseover: BX.delegate(this.onMagnifierArea, this),
1105                                mouseout: BX.delegate(function () {
1106                                    this.outMagnifierArea();
1107                                    this.hideMagnifier();
1108                                }, this)
1109                            }
1110                        }
1111                    ));
1112
1113                    this.magnify.obMagnifier = this.magnify.obBigSlider.appendChild(BX.create(
1114                        'DIV',
1115                        {
1116                            props: {
1117                                id: this.visual.MAGNIFIER_ID,
1118                                className: 'bx_item_slider_lupe'
1119                            },
1120                            style: {
1121                                display: 'none'
1122                            }
1123                        }
1124                    ));
1125                    this.magnify.obMagnifyPict = this.magnify.obMagnifier.appendChild(BX.create(
1126                        'IMG',
1127                        {
1128                            props: {
1129                                src: this.currentImg.src
1130                            }
1131                        }
1132                    ));
1133                    BX.bind(this.obPict, 'mouseover', BX.delegate(this.showMagnifier, this));
1134                }
1135                break;
1136            case 'POPUP':
1137                this.obPopupPict = new BX.PopupWindow('CatalogElementPopup_' + this.visual.ID, null, {
1138                    autoHide: false,
1139                    offsetLeft: 0,
1140                    offsetTop: 0,
1141                    overlay: false,
1142                    closeByEsc: true,
1143                    titleBar: true,
1144                    closeIcon: {top: '10px', right: '10px'}
1145                });
1146                BX.bind(this.obPict, 'click', BX.delegate(this.showMainPictPopup, this));
1147                BX.adjust(this.obPict, {style: {cursor: 'pointer'}});
1148                BX.addCustomEvent(this.obPopupPict, "onAfterPopupShow", BX.proxy(this.onPopupWindowShow, this));
1149                BX.addCustomEvent(this.obPopupPict, "onPopupClose", BX.proxy(this.onPopupWindowClose, this));
1150                break;
1151            default:
1152                break;
1153        }
1154    };
1155
1156    window.JCCatalogElement.prototype.setCurrentImg = function (img, showImage) {
1157        showImage = !!showImage;
1158        this.currentImg.src = img.SRC;
1159        this.currentImg.width = img.WIDTH;
1160        this.currentImg.height = img.HEIGHT;
1161        if (showImage && !!this.obPict) {
1162            if (this.config.mainPictureMode === 'MAGNIFIER') {
1163                this.outMagnifierArea();
1164                this.hideMagnifier();
1165            }
1166            BX.adjust(this.obPict, {props: {src: this.currentImg.src}});
1167            var dest = {
1168                    width: parseInt(this.obPictAligner.offsetWidth, 10),
1169                    height: parseInt(this.obPictAligner.offsetHeight, 10)
1170                },
1171                result,
1172                newMarginTop;
1173            result = this.scaleImg(this.currentImg, dest);
1174
1175            newMarginTop = (result.height < dest.height ? (dest.height - result.height) >>> 1 : 0);
1176            if (newMarginTop !== this.currentImg.screenOffsetY) {
1177                BX.style(this.obPictAligner, 'marginTop', newMarginTop + 'px');
1178                this.currentImg.screenOffsetY = newMarginTop;
1179            }
1180            this.currentImg.screenOffsetX = (result.width < dest.width ? (dest.width - result.width) >>> 1 : 0);
1181            this.currentImg.screenWidth = result.width;
1182            this.currentImg.screenHeight = result.height;
1183        }
1184    };
1185
1186    window.JCCatalogElement.prototype.scaleImg = function (src, dest) {
1187        var
1188            scaleX,
1189            scaleY,
1190            scale,
1191            result = {};
1192
1193        if (dest.width >= src.width && dest.height >= src.height) {
1194            result.width = src.width;
1195            result.height = src.height;
1196        } else {
1197            scaleX = dest.width / src.width;
1198            scaleY = dest.height / src.height;
1199            scale = Math.min(scaleX, scaleY);
1200            result.width = Math.max(1, parseInt(scale * src.width, 10));
1201            result.height = Math.max(1, parseInt(scale * src.height, 10));
1202        }
1203        return result;
1204    };
1205
1206    window.JCCatalogElement.prototype.showMagnifier = function (e) {
1207        if (e.view.outerWidth > 900) {
1208            if (!this.magnify.magnifyShow) {
1209                this.calcMagnifierParams();
1210                this.calcMagnifyAreaSize();
1211                this.calcMagnifyAreaPos(e);
1212                this.calcMagnifyPictSize();
1213                this.calcMagnifyPictPos();
1214                this.setMagnifyAreaParams(true);
1215                this.setMagnifyPictParams(true);
1216                this.setMagnifierParams(true);
1217                BX.bind(document, 'mousemove', BX.proxy(this.moveMagnifierArea, this));
1218            }
1219        }
1220    };
1221
1222    window.JCCatalogElement.prototype.hideMagnifier = function () {
1223        if (!this.magnify.magnifyShow) {
1224            if (!!this.magnify.obMagnifier) {
1225                BX.adjust(this.magnify.obMagnifier, {style: {display: 'none'}});
1226            }
1227            if (!!this.magnify.obMagnifyArea) {
1228                BX.adjust(this.magnify.obMagnifyArea, {style: {display: 'none'}});
1229            }
1230            BX.unbind(document, 'mousemove', BX.proxy(this.moveMagnifierArea, this));
1231        }
1232    };
1233
1234    window.JCCatalogElement.prototype.moveMagnifierArea = function (e) {
1235        var
1236            currentPos = {
1237                X: 0,
1238                Y: 0
1239            },
1240            posBigImg = BX.pos(this.obPict),
1241            intersect = {},
1242            params = {},
1243            paramsPict = {};
1244
1245        currentPos = this.inRect(e, posBigImg);
1246        if (this.inBound(posBigImg, currentPos)) {
1247            intersect = this.intersectArea(currentPos, posBigImg);
1248            switch (intersect.X) {
1249                case -1:
1250                    this.magnify.areaParams.left = this.currentImg.screenOffsetX;
1251                    break;
1252                case 0:
1253                    this.magnify.areaParams.left = this.currentImg.screenOffsetX + currentPos.X - (this.magnify.areaParams.width >>> 1);
1254                    break;
1255                case 1:
1256                    this.magnify.areaParams.left = this.currentImg.screenOffsetX + posBigImg.width - this.magnify.areaParams.width;
1257                    break;
1258            }
1259            switch (intersect.Y) {
1260                case -1:
1261                    this.magnify.areaParams.top = 0;
1262                    break;
1263                case 0:
1264                    this.magnify.areaParams.top = currentPos.Y - (this.magnify.areaParams.height >>> 1);
1265                    break;
1266                case 1:
1267                    this.magnify.areaParams.top = posBigImg.height - this.magnify.areaParams.height;
1268                    break;
1269            }
1270            this.magnify.magnifyPictParams.marginLeft = -parseInt(((this.magnify.areaParams.left - this.currentImg.screenOffsetX) * this.currentImg.scale), 10);
1271            this.magnify.magnifyPictParams.marginTop = -parseInt(((this.magnify.areaParams.top) * this.currentImg.scale), 10);
1272            params.left = this.magnify.areaParams.left + 'px';
1273            params.top = this.magnify.areaParams.top + 'px';
1274            BX.adjust(this.magnify.obMagnifyArea, {style: params});
1275            paramsPict.marginLeft = this.magnify.magnifyPictParams.marginLeft + 'px';
1276            paramsPict.marginTop = this.magnify.magnifyPictParams.marginTop + 'px';
1277            BX.adjust(this.magnify.obMagnifyPict, {style: paramsPict});
1278        } else {
1279            this.outMagnifierArea();
1280            this.hideMagnifier();
1281        }
1282    };
1283
1284    window.JCCatalogElement.prototype.onMagnifierArea = function () {
1285        this.magnify.magnifyShow = true;
1286    };
1287
1288    window.JCCatalogElement.prototype.outMagnifierArea = function () {
1289        this.magnify.magnifyShow = false;
1290    };
1291
1292    window.JCCatalogElement.prototype.calcMagnifierParams = function () {
1293        if (!!this.magnify.obBigImg) {
1294            var pos = BX.pos(this.magnify.obBigImg, true);
1295
1296            this.magnify.magnifierParams.width = pos.width;
1297            this.magnify.magnifierParams.height = pos.height;
1298            this.magnify.magnifierParams.top = pos.top;
1299            this.magnify.magnifierParams.left = pos.left + pos.width + 2;
1300        }
1301    };
1302
1303    window.JCCatalogElement.prototype.setMagnifierParams = function (show) {
1304        if (!!this.magnify.obMagnifier) {
1305            show = !!show;
1306            var params = {
1307                top: this.magnify.magnifierParams.top + 'px',
1308                left: this.magnify.magnifierParams.left + 'px',
1309                width: "550px", /* this.magnify.magnifierParams.width+'px' */
1310                height: "550px",
1311            };
1312            if (show) {
1313                params.display = '';
1314            }
1315            BX.adjust(this.magnify.obMagnifier, {style: params});
1316        }
1317    };
1318
1319    window.JCCatalogElement.prototype.setMagnifyAreaParams = function (show) {
1320        if (!!this.magnify.obMagnifier) {
1321            show = !!show;
1322            var params = {
1323                top: this.magnify.areaParams.top + 'px',
1324                left: this.magnify.areaParams.left + 'px',
1325                width: this.magnify.areaParams.width + 'px',
1326                height: this.magnify.areaParams.height + 'px'
1327            };
1328            if (show) {
1329                params.display = '';
1330            }
1331            BX.adjust(this.magnify.obMagnifyArea, {style: params});
1332        }
1333    };
1334
1335    window.JCCatalogElement.prototype.calcMagnifyAreaPos = function (e) {
1336        var currentPos,
1337            posBigImg,
1338            intersect;
1339
1340        posBigImg = BX.pos(this.obPict);
1341        currentPos = this.inRect(e, posBigImg);
1342        if (this.inBound(posBigImg, currentPos)) {
1343            intersect = this.intersectArea(currentPos, posBigImg);
1344            switch (intersect.X) {
1345                case -1:
1346                    this.magnify.areaParams.left = this.currentImg.screenOffsetX;
1347                    break;
1348                case 0:
1349                    this.magnify.areaParams.left = this.currentImg.screenOffsetX + currentPos.X - (this.magnify.areaParams.width >>> 1);
1350                    break;
1351                case 1:
1352                    this.magnify.areaParams.left = this.currentImg.screenOffsetX + posBigImg.width - this.magnify.areaParams.width;
1353                    break;
1354            }
1355            switch (intersect.Y) {
1356                case -1:
1357                    this.magnify.areaParams.top = 0;
1358                    break;
1359                case 0:
1360                    this.magnify.areaParams.top = currentPos.Y - (this.magnify.areaParams.height >>> 1);
1361                    break;
1362                case 1:
1363                    this.magnify.areaParams.top = posBigImg.height - this.magnify.areaParams.height;
1364                    break;
1365            }
1366        }
1367    };
1368
1369    window.JCCatalogElement.prototype.inBound = function (rect, point) {
1370        return ((0 <= point.Y && rect.height >= point.Y) && (0 <= point.X && rect.width >= point.X));
1371    };
1372
1373    window.JCCatalogElement.prototype.inRect = function (e, rect) {
1374        var wndSize = BX.GetWindowSize(),
1375            currentPos = {
1376                X: 0,
1377                Y: 0,
1378                globalX: 0,
1379                globalY: 0
1380            };
1381
1382        currentPos.globalX = e.clientX + wndSize.scrollLeft;
1383        currentPos.X = currentPos.globalX - rect.left;
1384        currentPos.globalY = e.clientY + wndSize.scrollTop;
1385        currentPos.Y = currentPos.globalY - rect.top;
1386        return currentPos;
1387    };
1388
1389    window.JCCatalogElement.prototype.intersectArea = function (currentPos, rect) {
1390        var intersect = {
1391                X: 0,
1392                Y: 0
1393            },
1394            halfX = this.magnify.areaParams.width >>> 1,
1395            halfY = this.magnify.areaParams.height >>> 1;
1396
1397        if (currentPos.X <= halfX) {
1398            intersect.X = -1;
1399        } else if (currentPos.X >= (rect.width - halfX)) {
1400            intersect.X = 1;
1401        } else {
1402            intersect.X = 0;
1403        }
1404        if (currentPos.Y <= halfY) {
1405            intersect.Y = -1;
1406        } else if (currentPos.Y >= (rect.height - halfY)) {
1407            intersect.Y = 1;
1408        } else {
1409            intersect.Y = 0;
1410        }
1411
1412        return intersect;
1413    };
1414
1415    window.JCCatalogElement.prototype.calcMagnifyAreaSize = function () {
1416        var scaleX,
1417            scaleY,
1418            scale;
1419
1420        if (
1421            this.magnify.magnifierParams.width < this.currentImg.width &&
1422            this.magnify.magnifierParams.height < this.currentImg.height
1423        ) {
1424            scaleX = this.magnify.obBigImg.offsetWidth / this.currentImg.width;
1425            scaleY = this.magnify.obBigImg.offsetHeight / this.currentImg.height;
1426            scale = Math.min(scaleX, scaleY);
1427            this.currentImg.scale = 1 / scale;
1428            this.magnify.areaParams.width = Math.max(1, parseInt(scale * this.magnify.magnifierParams.width, 10));
1429            this.magnify.areaParams.height = Math.max(1, parseInt(scale * this.magnify.magnifierParams.height, 10));
1430            this.magnify.areaParams.scaleFactor = this.magnify.magnifierParams.defaultScale;
1431        } else {
1432            scaleX = this.obPict.offsetWidth / this.magnify.obBigImg.offsetWidth;
1433            scaleY = this.obPict.offsetHeight / this.magnify.obBigImg.offsetHeight;
1434            scale = Math.min(scaleX, scaleY);
1435            this.currentImg.scale = 1 / scale;
1436            this.magnify.areaParams.width = Math.max(1, parseInt(scale * this.magnify.magnifierParams.width, 10));
1437            this.magnify.areaParams.height = Math.max(1, parseInt(scale * this.magnify.magnifierParams.height, 10));
1438
1439            scaleX = this.magnify.magnifierParams.width / this.currentImg.width;
1440            scaleY = this.magnify.magnifierParams.height / this.currentImg.height;
1441            scale = Math.max(scaleX, scaleY);
1442            this.magnify.areaParams.scaleFactor = scale;
1443        }
1444    };
1445
1446    window.JCCatalogElement.prototype.calcMagnifyPictSize = function () {
1447        this.magnify.magnifyPictParams.width = this.currentImg.width * this.magnify.areaParams.scaleFactor;
1448        this.magnify.magnifyPictParams.height = this.currentImg.height * this.magnify.areaParams.scaleFactor;
1449    };
1450
1451    window.JCCatalogElement.prototype.calcMagnifyPictPos = function () {
1452        this.magnify.magnifyPictParams.marginLeft = -parseInt(((this.magnify.areaParams.left - this.currentImg.screenOffsetX) * this.currentImg.scale), 10);
1453        this.magnify.magnifyPictParams.marginTop = -parseInt(((this.magnify.areaParams.top) * this.currentImg.scale), 10);
1454    };
1455
1456    window.JCCatalogElement.prototype.setMagnifyPictParams = function (show) {
1457        if (!!this.magnify.obMagnifier) {
1458            show = !!show;
1459            var params = {
1460                width: this.magnify.magnifyPictParams.width + 'px',
1461                height: this.magnify.magnifyPictParams.height + 'px',
1462                marginTop: this.magnify.magnifyPictParams.marginTop + 'px',
1463                marginLeft: this.magnify.magnifyPictParams.marginLeft + 'px'
1464            };
1465            if (show) {
1466                params.display = '';
1467            }
1468            BX.adjust(this.magnify.obMagnifyPict, {style: params, props: {src: this.currentImg.src}});
1469        }
1470    };
1471
1472    window.JCCatalogElement.prototype.ProductSliderRowLeft = function () {
1473        var target = BX.proxy_context;
1474        if (!!target) {
1475            if (this.sliderRowShowSize < this.product.slider.COUNT) {
1476                if (0 > this.product.slider.START) {
1477                    this.product.slider.START++;
1478                    BX.adjust(this.product.slider.LIST, {style: {marginLeft: this.product.slider.START * 20 + '%'}});
1479                    BX.adjust(this.product.slider.RIGHT, {style: this.sliderEnableArrow});
1480                }
1481
1482                if (0 <= this.product.slider.START) {
1483                    BX.adjust(this.product.slider.LEFT, {style: this.sliderDisableArrow});
1484                }
1485            }
1486        }
1487    };
1488
1489    window.JCCatalogElement.prototype.ProductSliderRowRight = function () {
1490        var target = BX.proxy_context;
1491        if (!!target) {
1492            if (this.sliderRowShowSize < this.product.slider.COUNT) {
1493                if ((this.sliderRowShowSize - this.product.slider.START) < this.product.slider.COUNT) {
1494                    this.product.slider.START--;
1495                    BX.adjust(this.product.slider.LIST, {style: {marginLeft: this.product.slider.START * 20 + '%'}});
1496                    BX.adjust(this.product.slider.LEFT, {style: this.sliderEnableArrow});
1497                }
1498
1499                if ((this.sliderRowShowSize - this.product.slider.START) >= this.product.slider.COUNT) {
1500                    BX.adjust(this.product.slider.RIGHT, {style: this.sliderDisableArrow});
1501                }
1502            }
1503        }
1504    };
1505
1506    window.JCCatalogElement.prototype.ProductSelectSliderImg = function () {
1507        var strValue = '',
1508            target = BX.proxy_context;
1509        if (!!target && target.hasAttribute('data-value')) {
1510            strValue = target.getAttribute('data-value');
1511            this.SetProductMainPict(strValue);
1512        }
1513    };
1514
1515    window.JCCatalogElement.prototype.SetProductMainPict = function (intPict) {
1516        var indexPict = -1,
1517            i = 0,
1518            j = 0,
1519            value = '',
1520            strValue = '',
1521            RowItems = null;
1522
1523        if (0 < this.product.sliderCount) {
1524            for (j = 0; j < this.product.sliderPict.length; j++) {
1525                if (intPict === this.product.sliderPict[j].ID) {
1526                    indexPict = j;
1527                    break;
1528                }
1529            }
1530            if (-1 < indexPict) {
1531                if (!!this.product.sliderPict[indexPict]) {
1532                    this.setCurrentImg(this.product.sliderPict[indexPict], true);
1533                }
1534                RowItems = BX.findChildren(this.product.slider.LIST, {tagName: 'li'}, false);
1535                if (!!RowItems && 0 < RowItems.length) {
1536                    strValue = intPict;
1537                    for (i = 0; i < RowItems.length; i++) {
1538                        value = RowItems[i].getAttribute('data-value');
1539                        if (value === strValue) {
1540                            BX.addClass(RowItems[i], 'bx_active');
1541                        } else {
1542                            BX.removeClass(RowItems[i], 'bx_active');
1543                        }
1544                    }
1545                }
1546            }
1547        }
1548    };
1549
1550    window.JCCatalogElement.prototype.SliderRowLeft = function () {
1551        var strValue = '',
1552            index = -1,
1553            i,
1554            target = BX.proxy_context;
1555        if (!!target && target.hasAttribute('data-value')) {
1556            strValue = target.getAttribute('data-value');
1557            for (i = 0; i < this.sliders.length; i++) {
1558                if (this.sliders[i].OFFER_ID === strValue) {
1559                    index = i;
1560                    break;
1561                }
1562            }
1563            if (-1 < index && this.sliderRowShowSize < this.sliders[index].COUNT) {
1564                if (0 > this.sliders[index].START) {
1565                    this.sliders[index].START++;
1566                    BX.adjust(this.sliders[index].LIST, {style: {marginLeft: this.sliders[index].START * 20 + '%'}});
1567                    BX.adjust(this.sliders[index].RIGHT, {style: this.sliderEnableArrow});
1568                }
1569
1570                if (0 <= this.sliders[index].START) {
1571                    BX.adjust(this.sliders[index].LEFT, {style: this.sliderDisableArrow});
1572                }
1573            }
1574        }
1575    };
1576
1577    window.JCCatalogElement.prototype.SliderRowRight = function () {
1578        var strValue = '',
1579            index = -1,
1580            i,
1581            target = BX.proxy_context;
1582        if (!!target && target.hasAttribute('data-value')) {
1583            strValue = target.getAttribute('data-value');
1584            for (i = 0; i < this.sliders.length; i++) {
1585                if (this.sliders[i].OFFER_ID === strValue) {
1586                    index = i;
1587                    break;
1588                }
1589            }
1590            if (-1 < index && this.sliderRowShowSize < this.sliders[index].COUNT) {
1591                if ((this.sliderRowShowSize - this.sliders[index].START) < this.sliders[index].COUNT) {
1592                    this.sliders[index].START--;
1593                    BX.adjust(this.sliders[index].LIST, {style: {marginLeft: this.sliders[index].START * 20 + '%'}});
1594                    BX.adjust(this.sliders[index].LEFT, {style: this.sliderEnableArrow});
1595                }
1596
1597                if ((this.sliderRowShowSize - this.sliders[index].START) >= this.sliders[index].COUNT) {
1598                    BX.adjust(this.sliders[index].RIGHT, {style: this.sliderDisableArrow});
1599                }
1600            }
1601        }
1602    };
1603
1604    window.JCCatalogElement.prototype.SelectSliderImg = function () {
1605        var strValue = '',
1606            arItem = [],
1607            target = BX.proxy_context;
1608        if (!!target && target.hasAttribute('data-value')) {
1609            strValue = target.getAttribute('data-value');
1610            arItem = strValue.split('_');
1611            this.SetMainPict(arItem[0], arItem[1]);
1612        }
1613    };
1614
1615    window.JCCatalogElement.prototype.SetMainPict = function (intSlider, intPict) {
1616        var index = -1,
1617            indexPict = -1,
1618            i,
1619            j,
1620            value = '',
1621            RowItems = null,
1622            strValue = '';
1623
1624        for (i = 0; i < this.offers.length; i++) {
1625            if (intSlider === this.offers[i].ID) {
1626                index = i;
1627                break;
1628            }
1629        }
1630        if (-1 < index) {
1631            if (0 < this.offers[index].SLIDER_COUNT) {
1632                for (j = 0; j < this.offers[index].SLIDER.length; j++) {
1633                    if (intPict === this.offers[index].SLIDER[j].ID) {
1634                        indexPict = j;
1635                        break;
1636                    }
1637                }
1638                if (-1 < indexPict) {
1639                    if (!!this.offers[index].SLIDER[indexPict]) {
1640                        this.setCurrentImg(this.offers[index].SLIDER[indexPict], true);
1641                    }
1642                    RowItems = BX.findChildren(this.sliders[index].LIST, {tagName: 'li'}, false);
1643                    if (!!RowItems && 0 < RowItems.length) {
1644                        strValue = intSlider + '_' + intPict;
1645                        for (i = 0; i < RowItems.length; i++) {
1646                            value = RowItems[i].getAttribute('data-value');
1647                            if (value === strValue) {
1648                                BX.addClass(RowItems[i], 'bx_active');
1649                            } else {
1650                                BX.removeClass(RowItems[i], 'bx_active');
1651                            }
1652                        }
1653                    }
1654                }
1655            }
1656        }
1657    };
1658
1659    window.JCCatalogElement.prototype.SetMainPictFromItem = function (index) {
1660        if (!!this.obPict) {
1661            var boolSet = false,
1662                obNewPict = {};
1663
1664            if (!!this.offers[index]) {
1665                if (!!this.offers[index].DETAIL_PICTURE) {
1666                    obNewPict = this.offers[index].DETAIL_PICTURE;
1667                    boolSet = true;
1668                } else if (!!this.offers[index].PREVIEW_PICTURE) {
1669                    obNewPict = this.offers[index].PREVIEW_PICTURE;
1670                    boolSet = true;
1671                }
1672            }
1673            if (!boolSet) {
1674                if (!!this.defaultPict.detail) {
1675                    obNewPict = this.defaultPict.detail;
1676                    boolSet = true;
1677                } else if (!!this.defaultPict.preview) {
1678                    obNewPict = this.defaultPict.preview;
1679                    boolSet = true;
1680                }
1681            }
1682            if (boolSet) {
1683                this.setCurrentImg(obNewPict, true);
1684            }
1685        }
1686    };
1687
1688    window.JCCatalogElement.prototype.showMainPictPopup = function (e) {
1689        var pictContent = '';
1690
1691        pictContent = '<div style="text-align: center;"><img src="' +
1692            this.currentImg.src +
1693            '" width="' + this.currentImg.width + '" height="' + this.currentImg.height + '" name=""></div>';
1694        this.obPopupPict.setContent(pictContent);
1695        this.obPopupPict.show();
1696        return BX.PreventDefault(e);
1697    };
1698
1699    window.JCCatalogElement.prototype.QuantityUp = function () {
1700        var curValue = 0,
1701            boolSet = true,
1702            calcPrice;
1703
1704        if (0 === this.errorCode && this.config.showQuantity && this.canBuy) {
1705            curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
1706            if (!isNaN(curValue)) {
1707                curValue += this.stepQuantity;
1708                if (this.checkQuantity) {
1709                    if (curValue > this.maxQuantity) {
1710                        boolSet = false;
1711                    }
1712                }
1713
1714                if (boolSet) {
1715                    if (this.isDblQuantity) {
1716                        curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
1717                    }
1718                    this.obQuantity.value = curValue;
1719                    calcPrice = {
1720                        DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * curValue,
1721                        VALUE: this.currentBasisPrice.VALUE * curValue,
1722                        DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * curValue,
1723                        DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT,
1724                        CURRENCY: this.currentBasisPrice.CURRENCY
1725                    };
1726                    this.setPrice(calcPrice);
1727                }
1728            }
1729        }
1730    };
1731
1732    window.JCCatalogElement.prototype.QuantityDown = function () {
1733        var curValue = 0,
1734            boolSet = true,
1735            calcPrice;
1736
1737        if (0 === this.errorCode && this.config.showQuantity && this.canBuy) {
1738            curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
1739            if (!isNaN(curValue)) {
1740                curValue -= this.stepQuantity;
1741                if (curValue < this.stepQuantity) {
1742                    boolSet = false;
1743                }
1744                if (boolSet) {
1745                    if (this.isDblQuantity) {
1746                        curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
1747                    }
1748                    this.obQuantity.value = curValue;
1749                    calcPrice = {
1750                        DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * curValue,
1751                        VALUE: this.currentBasisPrice.VALUE * curValue,
1752                        DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * curValue,
1753                        DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT,
1754                        CURRENCY: this.currentBasisPrice.CURRENCY
1755                    };
1756                    this.setPrice(calcPrice);
1757                }
1758            }
1759        }
1760    };
1761
1762    window.JCCatalogElement.prototype.QuantityChange = function () {
1763        var curValue = 0,
1764            calcPrice,
1765            intCount,
1766            count;
1767
1768        if (0 === this.errorCode && this.config.showQuantity) {
1769            if (this.canBuy) {
1770                curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
1771                if (!isNaN(curValue)) {
1772                    if (this.checkQuantity) {
1773                        if (curValue > this.maxQuantity) {
1774                            curValue = this.maxQuantity;
1775                        }
1776                    }
1777                    if (curValue < this.stepQuantity) {
1778                        curValue = this.stepQuantity;
1779                    } else {
1780                        count = Math.round((curValue * this.precisionFactor) / this.stepQuantity) / this.precisionFactor;
1781                        intCount = parseInt(count, 10);
1782                        if (isNaN(intCount)) {
1783                            intCount = 1;
1784                            count = 1.1;
1785                        }
1786                        if (count > intCount) {
1787                            curValue = (intCount <= 1 ? this.stepQuantity : intCount * this.stepQuantity);
1788                            curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
1789                        }
1790                    }
1791                    this.obQuantity.value = curValue;
1792                } else {
1793                    this.obQuantity.value = this.stepQuantity;
1794                }
1795            } else {
1796                this.obQuantity.value = this.stepQuantity;
1797            }
1798            calcPrice = {
1799                DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * this.obQuantity.value,
1800                VALUE: this.currentBasisPrice.VALUE * this.obQuantity.value,
1801                DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * this.obQuantity.value,
1802                DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT,
1803                CURRENCY: this.currentBasisPrice.CURRENCY
1804            };
1805            this.setPrice(calcPrice);
1806        }
1807    };
1808
1809    window.JCCatalogElement.prototype.QuantitySet = function (index) {
1810        var basisPrice = '',
1811            strLimit;
1812        if (this.errorCode === 0) {
1813            this.canBuy = this.offers[index].CAN_BUY;
1814            if (this.canBuy) {
1815                if (!!this.obBasketActions) {
1816                    BX.style(this.obBasketActions, 'display', '');
1817                }
1818                if (!!this.obNotAvail) {
1819                    BX.style(this.obNotAvail, 'display', 'none');
1820                }
1821            } else {
1822                if (!!this.obBasketActions) {
1823                    BX.style(this.obBasketActions, 'display', 'none');
1824                }
1825                if (!!this.obNotAvail) {
1826                    BX.style(this.obNotAvail, 'display', '');
1827                }
1828            }
1829            if (this.config.showQuantity) {
1830                this.isDblQuantity = this.offers[index].QUANTITY_FLOAT;
1831                this.checkQuantity = this.offers[index].CHECK_QUANTITY;
1832                if (this.isDblQuantity) {
1833                    this.maxQuantity = parseFloat(this.offers[index].MAX_QUANTITY);
1834                    this.stepQuantity = Math.round(parseFloat(this.offers[index].STEP_QUANTITY) * this.precisionFactor) / this.precisionFactor;
1835                } else {
1836                    this.maxQuantity = parseInt(this.offers[index].MAX_QUANTITY, 10);
1837                    this.stepQuantity = parseInt(this.offers[index].STEP_QUANTITY, 10);
1838                }
1839                this.obQuantity.value = this.stepQuantity;
1840                this.obQuantity.disabled = !this.canBuy;
1841                if (!!this.obMeasure) {
1842                    if (!!this.offers[index].MEASURE) {
1843                        BX.adjust(this.obMeasure, {html: this.offers[index].MEASURE});
1844                    } else {
1845                        BX.adjust(this.obMeasure, {html: ''});
1846                    }
1847                }
1848                if (!!this.obQuantityLimit.all) {
1849                    if (!this.checkQuantity) {
1850                        BX.adjust(this.obQuantityLimit.value, {html: ''});
1851                        BX.adjust(this.obQuantityLimit.all, {style: {display: 'none'}});
1852                    } else {
1853                        strLimit = this.offers[index].MAX_QUANTITY;
1854                        if (!!this.offers[index].MEASURE) {
1855                            strLimit += (' ' + this.offers[index].MEASURE);
1856                        }
1857                        BX.adjust(this.obQuantityLimit.value, {html: strLimit});
1858                        BX.adjust(this.obQuantityLimit.all, {style: {display: ''}});
1859                    }
1860                }
1861                if (!!this.obBasisPrice) {
1862                    if (!!this.offers[index].BASIS_PRICE) {
1863                        basisPrice = BX.message('BASIS_PRICE_MESSAGE');
1864                        basisPrice = basisPrice.replace(
1865                            '#PRICE#',
1866                            BX.Currency.currencyFormat(this.offers[index].BASIS_PRICE.DISCOUNT_VALUE, this.offers[index].BASIS_PRICE.CURRENCY, true)
1867                        );
1868                        basisPrice = basisPrice.replace('#MEASURE#', this.offers[index].MEASURE);
1869                        BX.adjust(this.obBasisPrice, {style: {display: ''}, html: basisPrice});
1870                    } else {
1871                        BX.adjust(this.obBasisPrice, {style: {display: 'none'}, html: ''});
1872                    }
1873                }
1874            }
1875            this.currentBasisPrice = this.offers[index].BASIS_PRICE;
1876        }
1877    };
1878
1879    window.JCCatalogElement.prototype.SelectOfferProp = function () {
1880        //????? ?????????? ???????? ???????????
1881        var i = 0,
1882            strTreeValue = '',
1883            arTreeItem = [],
1884            RowItems = null,
1885            target = BX.proxy_context;
1886
1887        if (!!target && target.hasAttribute('data-treevalue')) {
1888            if (typeof (document.activeElement) === 'object')
1889                document.activeElement.blur();
1890            strTreeValue = target.getAttribute('data-treevalue');
1891            arTreeItem = strTreeValue.split('_');
1892            this.SearchOfferPropIndex(arTreeItem[0], arTreeItem[1]);
1893            RowItems = BX.findChildren(target.parentNode, {tagName: 'li'}, false);
1894            if (!!RowItems && 0 < RowItems.length) {
1895                for (i = 0; i < RowItems.length; i++) {
1896                    BX.removeClass(RowItems[i], 'bx_active');
1897                }
1898            }
1899            BX.addClass(target, 'bx_active');
1900        }
1901
1902        offerID = this.offers[this.offerNum].ID;
1903        newHref = hrefGetDisc + "?PRICE=" + this.currentBasisPrice.DISCOUNT_VALUE + "&PRODUCT_ID=" + offerID;
1904        $(".get-discount").attr("href", newHref);
1905    };
1906
1907    window.JCCatalogElement.prototype.SearchOfferPropIndex = function (strPropID, strPropValue) {
1908        var strName = '',
1909            arShowValues = false,
1910            arCanBuyValues = [],
1911            allValues = [],
1912            index = -1,
1913            i, j,
1914            arFilter = {},
1915            tmpFilter = [];
1916
1917        for (i = 0; i < this.treeProps.length; i++) {
1918            if (this.treeProps[i].ID === strPropID) {
1919                index = i;
1920                break;
1921            }
1922        }
1923
1924        if (-1 < index) {
1925            for (i = 0; i < index; i++) {
1926                strName = 'PROP_' + this.treeProps[i].ID;
1927                arFilter[strName] = this.selectedValues[strName];
1928            }
1929            strName = 'PROP_' + this.treeProps[index].ID;
1930            arFilter[strName] = strPropValue;
1931            for (i = index + 1; i < this.treeProps.length; i++) {
1932                strName = 'PROP_' + this.treeProps[i].ID;
1933                arShowValues = this.GetRowValues(arFilter, strName);
1934                if (!arShowValues) {
1935                    break;
1936                }
1937                allValues = [];
1938                if (this.config.showAbsent) {
1939                    arCanBuyValues = [];
1940                    tmpFilter = [];
1941                    tmpFilter = BX.clone(arFilter, true);
1942                    for (j = 0; j < arShowValues.length; j++) {
1943                        tmpFilter[strName] = arShowValues[j];
1944                        allValues[allValues.length] = arShowValues[j];
1945                        if (this.GetCanBuy(tmpFilter))
1946                            arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
1947                    }
1948                } else {
1949                    arCanBuyValues = arShowValues;
1950                }
1951                if (!!this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arC
1951anBuyValues)) {
1952                    arFilter[strName] = this.selectedValues[strName];
1953                } else {
1954                    if (this.config.showAbsent)
1955                        arFilter[strName] = (arCanBuyValues.length > 0 ? arCanBuyValues[0] : allValues[0]);
1956                    else
1957                        arFilter[strName] = arCanBuyValues[0];
1958                }
1959                this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
1960            }
1961            this.selectedValues = arFilter;
1962            this.ChangeInfo();
1963        }
1964    };
1965
1966    window.JCCatalogElement.prototype.RowLeft = function () {
1967        var strTreeValue = '',
1968            index = -1,
1969            i,
1970            target = BX.proxy_context;
1971        if (!!target && target.hasAttribute('data-treevalue')) {
1972            strTreeValue = target.getAttribute('data-treevalue');
1973            for (i = 0; i < this.treeProps.length; i++) {
1974                if (this.treeProps[i].ID === strTreeValue) {
1975                    index = i;
1976                    break;
1977                }
1978            }
1979            if (-1 < index && this.treeRowShowSize < this.showCount[index]) {
1980                if (0 > this.showStart[index]) {
1981                    this.showStart[index]++;
1982                    BX.adjust(this.obTreeRows[index].LIST, {style: {marginLeft: this.showStart[index] * 20 + '%'}});
1983                    BX.adjust(this.obTreeRows[index].RIGHT, {style: this.treeEnableArrow});
1984                }
1985
1986                if (0 <= this.showStart[index]) {
1987                    BX.adjust(this.obTreeRows[index].LEFT, {style: this.treeDisableArrow});
1988                }
1989            }
1990        }
1991    };
1992
1993    window.JCCatalogElement.prototype.RowRight = function () {
1994        var strTreeValue = '',
1995            index = -1,
1996            i,
1997            target = BX.proxy_context;
1998        if (!!target && target.hasAttribute('data-treevalue')) {
1999            strTreeValue = target.getAttribute('data-treevalue');
2000            for (i = 0; i < this.treeProps.length; i++) {
2001                if (this.treeProps[i].ID === strTreeValue) {
2002                    index = i;
2003                    break;
2004                }
2005            }
2006            if (-1 < index && this.treeRowShowSize < this.showCount[index]) {
2007                if ((this.treeRowShowSize - this.showStart[index]) < this.showCount[index]) {
2008                    this.showStart[index]--;
2009                    BX.adjust(this.obTreeRows[index].LIST, {style: {marginLeft: this.showStart[index] * 20 + '%'}});
2010                    BX.adjust(this.obTreeRows[index].LEFT, {style: this.treeEnableArrow});
2011                }
2012
2013                if ((this.treeRowShowSize - this.showStart[index]) >= this.showCount[index]) {
2014                    BX.adjust(this.obTreeRows[index].RIGHT, {style: this.treeDisableArrow});
2015                }
2016            }
2017        }
2018    };
2019
2020    window.JCCatalogElement.prototype.UpdateRow = function (intNumber, activeID, showID, canBuyID) {
2021        var i = 0,
2022            showI = 0,
2023            value = '',
2024            countShow = 0,
2025            strNewLen = '',
2026            obData = {},
2027            RowItems = null,
2028            pictMode = false,
2029            extShowMode = false,
2030            isCurrent = false,
2031            selectIndex = 0,
2032            obLeft = this.treeEnableArrow,
2033            obRight = this.treeEnableArrow,
2034            currentShowStart = 0,
2035            vis = 0;
2036
2037        if (-1 < intNumber && intNumber < this.obTreeRows.length) {
2038            RowItems = BX.findChildren(this.obTreeRows[intNumber].LIST, {tagName: 'li'}, false);
2039            if (!!RowItems && 0 < RowItems.length) {
2040                pictMode = ('PICT' === this.treeProps[intNumber].SHOW_MODE);
2041                countShow = showID.length;
2042                extShowMode = this.treeRowShowSize < countShow;
2043                /* strNewLen = (this.treeRowShowSize < countShow ? (100/countShow)+'%' : '20%'); */
2044                strNewLen = '40px';
2045                obData = {
2046                    props: {className: ''},
2047                    style: {
2048                        width: strNewLen
2049                    }
2050                };
2051                if (pictMode) {
2052                    obData.style.paddingTop = strNewLen;
2053                }
2054                for (i = 0; i < RowItems.length; i++) {
2055                    value = RowItems[i].getAttribute('data-onevalue');
2056                    isCurrent = (value === activeID);
2057                    if (BX.util.in_array(value, canBuyID)) {
2058                        obData.props.className = (isCurrent ? 'bx_active' : '');
2059                        vis++;
2060                        no_size = false;
2061                        if (RowItems[i].firstElementChild.title == "NO_SIZE") {
2062                            no_size = true;
2063                        }
2064                    } else {
2065                        obData.props.className = (isCurrent ? 'bx_active bx_missing' : 'bx_missing');
2066                    }
2067                    obData.style.display = 'none';
2068                    if (BX.util.in_array(value, showID)) {
2069                        obData.style.display = '';
2070                        if (isCurrent) {
2071                            selectIndex = showI;
2072                        }
2073                        showI++;
2074                    }
2075                    BX.adjust(RowItems[i], obData);
2076                }
2077
2078                obData = {
2079                    style: {
2080                        /* width: (extShowMode ? 20*countShow : 100)+'%', */
2081                        width: '100%',
2082                        marginLeft: '0%'
2083                    }
2084                };
2085
2086                if (pictMode) {
2087                    BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (extShowMode ? 'bx_item_detail_scu full' : 'bx_item_detail_scu')}});
2088                } else {
2089                    BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (extShowMode < countShow ? 'bx_item_detail_size full' : 'bx_item_detail_size')}});
2090                }
2091                if (!extShowMode) {
2092                    if (selectIndex + 1 === countShow) {
2093                        obRight = this.treeDisableArrow;
2094                    }
2095                    if (this.treeRowShowSize <= selectIndex) {
2096                        currentShowStart = this.treeRowShowSize - selectIndex - 1;
2097                        obData.style.marginLeft = currentShowStart * 20 + '%';
2098                    }
2099                    if (0 === currentShowStart) {
2100                        obLeft = this.treeDisableArrow;
2101                    }
2102                    BX.adjust(this.obTreeRows[intNumber].LEFT, {style: obLeft});
2103                    BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: obRight});
2104                } else {
2105                    BX.adjust(this.obTreeRows[intNumber].LEFT, {style: {display: 'none'}});
2106                    BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: {display: 'none'}});
2107                }
2108                BX.adjust(this.obTreeRows[intNumber].LIST, obData);
2109                this.showCount[intNumber] = countShow;
2110                this.showStart[intNumber] = currentShowStart;
2111            }
2112
2113            if (vis <= 0 || (vis == 1 && no_size == true)) {
2114                this.obTree.style.display = "none";
2115            }
2116        }
2117    };
2118
2119    window.JCCatalogElement.prototype.GetRowValues = function (arFilter, index) {
2120        var arValues = [],
2121            i = 0,
2122            j = 0,
2123            boolSearch = false,
2124            boolOneSearch = true;
2125
2126        if (0 === arFilter.length) {
2127            for (i = 0; i < this.offers.length; i++) {
2128                if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) {
2129                    arValues[arValues.length] = this.offers[i].TREE[index];
2130                }
2131            }
2132            boolSearch = true;
2133        } else {
2134            for (i = 0; i < this.offers.length; i++) {
2135                boolOneSearch = true;
2136                for (j in arFilter) {
2137                    if (arFilter[j] !== this.offers[i].TREE[j]) {
2138                        boolOneSearch = false;
2139                        break;
2140                    }
2141                }
2142                if (boolOneSearch) {
2143                    if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) {
2144                        arValues[arValues.length] = this.offers[i].TREE[index];
2145                    }
2146                    boolSearch = true;
2147                }
2148            }
2149        }
2150        return (boolSearch ? arValues : false);
2151    };
2152
2153    window.JCCatalogElement.prototype.GetCanBuy = function (arFilter) {
2154        var i = 0,
2155            j = 0,
2156            boolOneSearch = true,
2157            boolSearch = false;
2158
2159        for (i = 0; i < this.offers.length; i++) {
2160            boolOneSearch = true;
2161            for (j in arFilter) {
2162                if (arFilter[j] !== this.offers[i].TREE[j]) {
2163                    boolOneSearch = false;
2164                    break;
2165                }
2166            }
2167            if (boolOneSearch) {
2168                if (this.offers[i].CAN_BUY) {
2169                    boolSearch = true;
2170                    break;
2171                }
2172            }
2173        }
2174        return boolSearch;
2175    };
2176
2177    window.JCCatalogElement.prototype.SetCurrent = function () {
2178        var i = 0,
2179            j = 0,
2180            strName = '',
2181            arShowValues = false,
2182            arCanBuyValues = [],
2183            arFilter = {},
2184            tmpFilter = [],
2185            current = this.offers[this.offerNum].TREE;
2186
2187        for (i = 0; i < this.treeProps.length; i++) {
2188            strName = 'PROP_' + this.treeProps[i].ID;
2189            arShowValues = this.GetRowValues(arFilter, strName);
2190            if (!arShowValues) {
2191                break;
2192            }
2193            if (BX.util.in_array(current[strName], arShowValues)) {
2194                arFilter[strName] = current[strName];
2195            } else {
2196                arFilter[strName] = arShowValues[0];
2197                this.offerNum = 0;
2198            }
2199            if (this.config.showAbsent) {
2200                arCanBuyValues = [];
2201                tmpFilter = [];
2202                tmpFilter = BX.clone(arFilter, true);
2203                for (j = 0; j < arShowValues.length; j++) {
2204                    tmpFilter[strName] = arShowValues[j];
2205                    if (this.GetCanBuy(tmpFilter)) {
2206                        arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
2207                    }
2208                }
2209            } else {
2210                arCanBuyValues = arShowValues;
2211            }
2212            this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
2213        }
2214        this.selectedValues = arFilter;
2215        this.ChangeInfo();
2216    };
2217
2218    window.JCCatalogElement.prototype.ChangeInfo = function () {
2219        var index = -1,
2220            i = 0,
2221            j = 0,
2222            boolOneSearch = true;
2223
2224        for (i = 0; i < this.offers.length; i++) {
2225            boolOneSearch = true;
2226            for (j in this.selectedValues) {
2227                if (this.selectedValues[j] !== this.offers[i].TREE[j]) {
2228                    boolOneSearch = false;
2229                    break;
2230                }
2231            }
2232            if (boolOneSearch) {
2233                index = i;
2234                break;
2235            }
2236        }
2237        if (-1 < index) {
2238            this.setPrice(this.offers[index].PRICE);
2239            for (i = 0; i < this.offers.length; i++) {
2240                if (this.config.showOfferGroup && this.offers[i].OFFER_GROUP) {
2241                    if (i !== index) {
2242                        BX.adjust(BX(this.visual.OFFER_GROUP + this.offers[i].ID), {style: {display: 'none'}});
2243                    }
2244                }
2245                if (!!this.sliders[i].ID) {
2246                    if (i === index) {
2247                        this.sliders[i].START = 0;
2248                        BX.adjust(this.sliders[i].LIST, {style: {marginLeft: '0%'}});
2249                        BX.adjust(this.sliders[i].CONT, {style: {display: ''}});
2250                        BX.adjust(this.sliders[i].LEFT, {style: this.sliderDisableArrow});
2251                        BX.adjust(this.sliders[i].RIGHT, {style: this.sliderEnableArrow});
2252                    } else {
2253                        BX.adjust(this.sliders[i].CONT, {style: {display: 'none'}});
2254                    }
2255                }
2256            }
2257            if (this.config.showOfferGroup && this.offers[index].OFFER_GROUP) {
2258                BX.adjust(BX(this.visual.OFFER_GROUP + this.offers[index].ID), {style: {display: ''}});
2259            }
2260            if (0 < this.offers[index].SLIDER_COUNT) {
2261                this.SetMainPict(this.offers[index].ID, this.offers[index].SLIDER[0].ID);
2262            } else {
2263                this.SetMainPictFromItem(index);
2264            }
2265
2266            if (this.config.showSkuProps && !!this.obSkuProps) {
2267                if (!this.offers[index].DISPLAY_PROPERTIES || this.offers[index].DISPLAY_PROPERTIES.length === 0) {
2268                    BX.adjust(this.obSkuProps, {style: {display: 'none'}, html: ''});
2269                } else {
2270                    BX.adjust(this.obSkuProps, {style: {display: ''}, html: this.offers[index].DISPLAY_PROPERTIES});
2271                }
2272            }
2273            this.offerNum = index;
2274            this.QuantitySet(this.offerNum);
2275
2276            this.incViewedCounter();
2277            BX.onCustomEvent('onCatalogStoreProductChange', [this.offers[this.offerNum].ID]);
2278        }
2279    };
2280
2281    window.JCCatalogElement.prototype.setPrice = function (price) {
2282        var economyInfo = '';
2283
2284        if (!!this.obPrice.price) {
2285            BX.adjust(this.obPrice.price, {html: BX.Currency.currencyFormat(price.DISCOUNT_VALUE, price.CURRENCY, true)});
2286            if (price.DISCOUNT_VALUE !== price.VALUE) {
2287                if (this.config.showOldPrice) {
2288                    if (!!this.obPrice.full) {
2289                        BX.adjust(this.obPrice.full, {
2290                            style: {display: ''},
2291                            html: BX.Currency.currencyFormat(price.VALUE, price.CURRENCY, true)
2292                        });
2293                    }
2294                    if (!!this.obPrice.discount) {
2295                        economyInfo = BX.message('ECONOMY_INFO_MESSAGE');
2296                        economyInfo = price.DISCOUNT_DIFF_PERCENT + "%";//economyInfo.replace('#ECONOMY#', BX.Currency.currencyFormat(price.DISCOUNT_DIFF, price.CURRENCY, true));
2297                        BX.adjust(this.obPrice.discount, {style: {display: ''}, html: economyInfo});
2298                    }
2299                }
2300                if (this.config.showPercent) {
2301                    if (!!this.obPrice.percent) {
2302                        BX.adjust(this.obPrice.percent, {
2303                            style: {display: ''},
2304                            html: price.DISCOUNT_DIFF_PERCENT + '%'
2305                        });
2306                    }
2307                }
2308            } else {
2309                if (this.config.showOldPrice) {
2310                    if (!!this.obPrice.full) {
2311                        BX.adjust(this.obPrice.full, {style: {display: 'none'}, html: ''});
2312                    }
2313                    if (!!this.obPrice.discount) {
2314                        BX.adjust(this.obPrice.discount, {style: {display: 'none'}, html: ''});
2315                    }
2316                }
2317                if (this.config.showPercent) {
2318                    if (!!this.obPrice.percent) {
2319                        BX.adjust(this.obPrice.percent, {style: {display: 'none'}, html: ''});
2320                    }
2321                }
2322            }
2323        }
2324    };
2325
2326    window.JCCatalogElement.prototype.Compare = function () {
2327        var compareParams, compareLink;
2328        if (!!this.compareData.compareUrl) {
2329            switch (this.productType) {
2330                case 0://no catalog
2331                case 1://product
2332                case 2://set
2333                    compareLink = this.compareData.compareUrl.replace('#ID#', this.product.id.toString());
2334                    break;
2335                case 3://sku
2336                    compareLink = this.compareData.compareUrl.replace('#ID#', this.offers[this.offerNum].ID);
2337                    break;
2338            }
2339            compareParams = {
2340                ajax_action: 'Y'
2341            };
2342            BX.ajax.loadJSON(
2343                compareLink,
2344                compareParams,
2345                BX.proxy(this.CompareResult, this)
2346            );
2347        }
2348    };
2349
2350    window.JCCatalogElement.prototype.CompareResult = function (result) {
2351        var popupContent, popupButtons, popupTitle;
2352        if (!!this.obPopupWin)
2353            this.obPopupWin.close();
2354
2355        if (typeof result !== 'object')
2356            return false;
2357
2358        this.InitPopupWindow();
2359        popupTitle = {
2360            content: BX.create('div', {
2361                style: {marginRight: '30px', whiteSpace: 'nowrap'},
2362                text: BX.message('COMPARE_TITLE')
2363            })
2364        };
2365        if (result.STATUS === 'OK') {
2366            BX.onCustomEvent('OnCompareChange');
2367            popupContent = '<div style="width: 96%; margin: 10px 2%; text-align: center;"><p>' + BX.message('COMPARE_MESSAGE_OK') + '</p></div>';
2368            if (this.config.showClosePopup) {
2369                popupButtons = [
2370                    new BasketButton({
2371                        ownerClass: this.obProduct.className,
2372                        text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'),
2373                        events: {
2374                            click: BX.delegate(this.CompareRedirect, this)
2375                        },
2376                        style: {marginRight: '15px'}
2377                    }),
2378                    new BasketButton({
2379                        ownerClass: this.obProduct.className,
2380                        text: BX.message('BTN_MESSAGE_CLOSE_POPUP'),
2381                        events: {
2382                            click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2383                        }
2384                    })
2385                ];
2386            } else {
2387                popupButtons = [
2388                    new BasketButton({
2389                        ownerClass: this.obProduct.className,
2390                        text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'),
2391                        events: {
2392                            click: BX.delegate(this.CompareRedirect, this)
2393                        }
2394                    })
2395                ];
2396            }
2397        } else {
2398            popupContent = '<div style="max-width:300px; width: 96%; margin: 10px 2%; text-align: center;"><p>' + (!!result.MESSAGE ? result.MESSAGE : BX.message('COMPARE_UNKNOWN_ERROR')) + '</p></div>';
2399            popupButtons = [
2400                new BasketButton({
2401                    ownerClass: this.obProduct.className,
2402                    text: BX.message('BTN_MESSAGE_CLOSE'),
2403                    events: {
2404                        click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2405                    }
2406
2407                })
2408            ];
2409
2410
2411        }
2412        this.obPopupWin.setTitleBar(popupTitle);
2413        this.obPopupWin.setContent(popupContent);
2414        this.obPopupWin.setButtons(popupButtons);
2415        this.obPopupWin.show();
2416        return false;
2417    };
2418
2419    window.JCCatalogElement.prototype.CompareRedirect = function () {
2420        if (!!this.compareData.comparePath)
2421            location.href = this.compareData.comparePath;
2422        else
2423            this.obPopupWin.close();
2424    };
2425
2426    window.JCCatalogElement.prototype.InitBasketUrl = function () {
2427        this.basketUrl = (this.basketMode === 'ADD' ? this.basketData.add_url : this.basketData.buy_url);
2428        switch (this.productType) {
2429            case 1://product
2430            case 2://set
2431                this.basketUrl = this.basketUrl.replace('#ID#', this.product.id.toString());
2432                break;
2433            case 3://sku
2434                this.basketUrl = this.basketUrl.replace('#ID#', this.offers[this.offerNum].ID);
2435                break;
2436        }
2437        if (this.basketParamsInSaloon == true) {
2438            this.basketParams = {
2439                'ajax_basket': 'Y',
2440                'in_saloon': 'Y'
2441            };
2442        } else {
2443            this.basketParams = {
2444                'ajax_basket': 'Y'
2445            };
2446        }
2447
2448        if (this.config.showQuantity) {
2449            this.basketParams[this.basketData.quantity] = this.obQuantity.value;
2450        }
2451        if (!!this.basketData.sku_props) {
2452            this.basketParams[this.basketData.sku_props_var] = this.basketData.sku_props;
2453        }
2454    };
2455
2456    window.JCCatalogElement.prototype.FillBasketProps = function () {
2457        if (!this.visual.BASKET_PROP_DIV)
2458            return;
2459
2460        var
2461            i = 0,
2462            propCollection = null,
2463            foundValues = false,
2464            obBasketProps = null;
2465        if (this.basketData.useProps && !this.basketData.emptyProps) {
2466            if (!!this.obPopupWin && !!this.obPopupWin.contentContainer)
2467                obBasketProps = this.obPopupWin.contentContainer;
2468        } else {
2469            obBasketProps = BX(this.visual.BASKET_PROP_DIV);
2470        }
2471        if (!!obBasketProps) {
2472            propCollection = obBasketProps.getElementsByTagName('select');
2473            if (!!propCollection && !!propCollection.length) {
2474                for (i = 0; i < propCollection.length; i++) {
2475                    if (!propCollection[i].disabled) {
2476                        switch (propCollection[i].type.toLowerCase()) {
2477                            case 'select-one':
2478                                this.basketParams[propCollection[i].name] = propCollection[i].value;
2479                                foundValues = true;
2480                                break;
2481                            default:
2482                                break;
2483                        }
2484                    }
2485                }
2486            }
2487            propCollection = obBasketProps.getElementsByTagName('input');
2488            if (!!propCollection && !!propCollection.length) {
2489                for (i = 0; i < propCollection.length; i++) {
2490                    if (!propCollection[i].disabled) {
2491                        switch (propCollection[i].type.toLowerCase()) {
2492                            case 'hidden':
2493                                this.basketParams[propCollection[i].name] = propCollection[i].value;
2494                                foundValues = true;
2495                                break;
2496                            case 'radio':
2497                                if (propCollection[i].checked) {
2498                                    this.basketParams[propCollection[i].name] = propCollection[i].value;
2499                                    foundValues = true;
2500                                }
2501                                break;
2502                            default:
2503                                break;
2504                        }
2505                    }
2506                }
2507            }
2508        }
2509        if (!foundValues) {
2510            this.basketParams[this.basketData.props] = [];
2511            this.basketParams[this.basketData.props][0] = 0;
2512        }
2513    };
2514
2515    window.JCCatalogElement.prototype.SendToBasket = function () {
2516        if (!this.canBuy)
2517            return;
2518
2519        this.InitBasketUrl();
2520        this.FillBasketProps();
2521        BX.ajax.loadJSON(
2522            this.basketUrl,
2523            this.basketParams,
2524            BX.proxy(this.BasketResult, this)
2525        );
2526    };
2527
2528    window.JCCatalogElement.prototype.Add2Basket = function (event) {
2529        let cartCount = (document.querySelector("#countGoods .count")) ? parseInt(document.querySelector("#countGoods .count").innerText) : 0;
2530
2531        if (cartCount < 5) {
2532            if (event.target.id.includes("_link_in_saloon")) {
2533                this.basketParamsInSaloon = true;
2534            }
2535
2536            this.basketMode = 'ADD';
2537
2538            dataLayer.push({
2539                "ecommerce": {
2540                    "add": {
2541                        "products": [
2542                            {
2543                                "id": this.product.id,
2544                                "name": this.product.name,
2545                                "price": this.currentBasisPrice.VALUE,
2546                                "brand": this.productBrand
2547                            }
2548                        ]
2549                    }
2550                }
2551            });
2552
2553            this.Basket();
2554        } else {
2555            this.InitPopupWindow();
2556            let popupContent = '<div style="max-width:300px; width: 96%; margin: 25px 2%; text-align: center;"><p>Вы не можете заказать более пяти товаров в одном заказе</p></div>';
2557
2558            this.obPopupWin.setContent(popupContent);
2559            this.obPopupWin.show();
2560        }
2561    };
2562
2563    window.JCCatalogElement.prototype.Add2Saloon = function (event) {
2564        let _this = this;
2565        _this.InitPopupWindow();
2566
2567        let obContent = BX.create('div', {
2568            attrs: {'id': "trnSaloonForm"},
2569            children: [
2570                _this.AddRow("NAME", "text"),
2571                _this.AddRow("SECOND_NAME", "text"),
2572                _this.AddRow("PHONE", "tel"),
2573                _this.AddRow("EMAIL", "mail"),
2574                _this.AddSelectSallon(),
2575                BX.create("button", {
2576                    text: "Купить",
2577                    events: {
2578                        click: function () {
2579                            _this.AddSaloonOrder(obContent, this);
2580                        }
2581                    }
2582                })
2583            ]
2584        });
2585
2586        _this.obPopupWin.setContent(obContent);
2587        _this.obPopupWin.show();
2588    };
2589
2590    window.JCCatalogElement.prototype.AddSaloonOrder = function (form, btn) {
2591        let _this = this,
2592            fields = form.querySelectorAll("input, select"), data = {}, error = {};
2593
2594        btn.setAttribute('disabled', true);
2595        btn.classList.add('loader');
2596
2597        fields.forEach(item => {
2598            if (item.value === "") {
2599                error[item.name] = true;
2600                item.classList.add("error");
2601            } else {
2602                switch (item.name) {
2603                    case "NAME" :
2604                    case "SECOND_NAME" :
2605                    case "SALOON":
2606                        BX.cleanNode(error[item.name], true);
2607                        item.classList.remove("error");
2608                        data[item.name] = item.value;
2609                        break;
2610
2611                    case "PHONE":
2612                        if (item.value != "") {
2613                            data[item.name] = item.value;
2614                            item.classList.remove("error");
2615                            BX.cleanNode(error[item.name], true);
2616                        } else {
2617                            error[item.name] = true;
2618                        }
2619                        break;
2620
2621                    case "EMAIL":
2622                        if (item.value != "") {
2623                            data[item.name] = item.value;
2624                            item.classList.remove("error");
2625                            BX.cleanNode(error[item.name], true);
2626                        } else {
2627                            error[item.name] = true;
2628                        }
2629                        break;
2630
2631                }
2632
2633            }
2634        });
2635
2636        if(Object.keys(error).length > 0) {
2637            btn.classList.remove('loader');
2638            btn.removeAttribute('disabled');
2639        }
2640        else {
2641            let curActiveKey, curActiveValue, arOffer;
2642
2643            for (let i in this.selectedValues) {
2644                curActiveKey = i;
2645                curActiveValue = this.selectedValues[i];
2646            }
2647
2648            arOffer = this.offers.filter(item => item.TREE[curActiveKey] == curActiveValue)[0];
2649
2650            data['PRODUCT_ID'] = arOffer['ID'];
2651            data['PRODUCT_NAME'] = this.product.name;
2652            data['PRICE'] = arOffer['PRICE']['DISCOUNT_VALUE'];
2653            data['in_saloon'] = "Y";
2654
2655            BX.ajax({
2656                url: "/local/templates/itaita2020/components/bitrix/catalog.element/universal/ajax.php",
2657                method: "POST",
2658                data: data,
2659                onsuccess: function(msg) {
2660                    var popup = BX.PopupWindowManager.create("popup-message", null, {
2661                        content: BX.message('TRN_SUCCESS_ORDER').replace("#ORDER_ID#", msg),
2662                        darkMode: true,
2663                        autoHide: true
2664                    });
2665
2666                    _this.obPopupWin.close();
2667                    popup.show();
2668                }
2669
2670            })
2671        }
2672    };
2673
2674    window.JCCatalogElement.prototype.AddSelectSallon = function () {
2675        let curActiveKey, curActiveValue, arStores, arObStores = [];
2676
2677        for (let i in this.selectedValues) {
2678            curActiveKey = i;
2679            curActiveValue = this.selectedValues[i];
2680        }
2681
2682        arStores = this.offers.filter(item => item.TREE[curActiveKey] == curActiveValue)[0]['STORE'];
2683
2684        arStores.forEach(item => {
2685            arObStores.push(BX.create("option", {
2686                attrs: {
2687                    "value": item.STORE_ID
2688                },
2689                text: item.STORE_NAME + ": \n" + item.STORE_ADDR
2690            }))
2691        });
2692
2693
2694        return BX.create('label', {
2695            attrs: {"for": name.toUpperCase()},
2696            children: [
2697                BX.create("select", {
2698                    attrs: {
2699                        name: "SALOON"
2700                    },
2701                    children: arObStores
2702                }),
2703                BX.create("span", {
2704                    text: BX.message("TRN_FIELD_SALOON")
2705                })
2706            ]
2707        });
2708    };
2709
2710    window.JCCatalogElement.prototype.AddRow = function (name, type) {
2711        return BX.create('label', {
2712            attrs: {"for": name.toUpperCase()},
2713            children: [
2714                BX.create("input", {
2715                    attrs: {
2716                        name: name.toUpperCase(),
2717                        type: type.toLowerCase()
2718                    }
2719                }),
2720                BX.create("span", {
2721                    text: BX.message("TRN_FIELD_" + name.toUpperCase())
2722                })
2723            ]
2724        });
2725    };
2726
2727    window.JCCatalogElement.prototype.BuyBasket = function () {
2728        this.basketMode = 'BUY';
2729        this.Basket();
2730    };
2731
2732    window.JCCatalogElement.prototype.Basket = function () {
2733        var contentBasketProps = '';
2734        if (!this.canBuy)
2735            return;
2736
2737
2738        switch (this.productType) {
2739            case 1://product
2740            case 2://set
2741                if (this.basketData.useProps && !this.basketData.emptyProps) {
2742                    this.InitPopupWindow();
2743                    this.obPopupWin.setTitleBar({
2744                        content: BX.create('div', {
2745                            style: {marginRight: '30px', whiteSpace: 'nowrap'},
2746                            text: BX.message('TITLE_BASKET_PROPS')
2747                        })
2748                    });
2749                    if (BX(this.visual.BASKET_PROP_DIV)) {
2750                        contentBasketProps = BX(this.visual.BASKET_PROP_DIV).innerHTML;
2751                    }
2752                    this.obPopupWin.setContent(contentBasketProps);
2753                    this.obPopupWin.setButtons([
2754                        new BasketButton({
2755                            ownerClass: this.obProduct.className,
2756                            text: BX.message('BTN_SEND_PROPS'),
2757                            events: {
2758                                click: BX.delegate(this.SendToBasket, this)
2759                            }
2760                        })
2761                    ]);
2762                    this.obPopupWin.show();
2763                } else {
2764                    this.SendToBasket();
2765                }
2766                break;
2767            case 3://sku
2768                this.SendToBasket();
2769                break;
2770        }
2771    };
2772
2773    window.JCCatalogElement.prototype.BasketResult = function (arResult) {
2774        var popupContent, popupButtons, popupTitle, productPict;
2775        if (!!this.obPopupWin)
2776            this.obPopupWin.close();
2777
2778        if (typeof arResult !== 'object')
2779            return false;
2780
2781        if (arResult.STATUS === 'OK' && this.basketMode === 'BUY') {
2782            this.BasketRedirect();
2783        } else {
2784            if (window.location.pathname == "/personal/cart/") {
2785                window.location.reload();
2786            } else {
2787
2788                if (this.basketParamsInSaloon == true) {
2789                    this.obAddToBasketInSaloonBtn.classList.add("loading");
2790                } else {
2791                    this.obAddToBasketBtn.classList.add("loading");
2792                }
2793
2794                this.basketParamsInSaloon = false;
2795
2796                // let wait = BX.showWait(this.obAddToBasketBtn);
2797
2798                this.InitPopupWindow();
2799                popupTitle = {
2800                    content: BX.create('div', {
2801                        style: {marginRight: '30px', whiteSpace: 'nowrap'},
2802                        text: (arResult.STATUS === 'OK' ? BX.message('TITLE_SUCCESSFUL') : BX.message('TITLE_ERROR'))
2803                    })
2804                };
2805                if (arResult.STATUS === 'OK') {
2806
2807
2808                    BX.onCustomEvent('OnBasketChange');
2809                    switch (this.productType) {
2810                        case 1://
2811                        case 2://
2812                            productPict = this.product.pict.SRC;
2813                            break;
2814                        case 3:
2815                            productPict = (!!this.offers[this.offerNum].PREVIEW_PICTURE ?
2816                                    this.offers[this.offerNum].PREVIEW_PICTURE.SRC :
2817                                    this.defaultPict.pict.SRC
2818                            );
2819                            break;
2820                    }
2821
2822
2823                    var alertInfo = "";
2824                    popupContent = '<div class="row" style="max-width:800px; width:100%;">';
2825
2826
2827                    // BX.ajax({
2828                    //     url: "/local/templates/itaita2020/ajax/getrecommend.php?ID=" + this.offers[this.offerNum].ID,
2829                    //     method: "POST",
2830                    //     async: false,
2831                    //     onsuccess: function (data) {
2832                    //         recommendContent = data;
2833                    //     }
2834                    // });
2835
2836                    BX.ajax({
2837                        url: "/local/ajax/check-store-by-product-id.php?elementid=" + this.offers[this.offerNum].ID,
2838                        method: "POST",
2839                        async: false,
2840                        onsuccess: function (data) {
2841                            alertInfo = data;
2842                        }
2843                    });
2844                    /*       popupContent += '<div class="col-xs-12 col-sm-7 col-sm-push-5" id="mobileNonMinHeight">' +
2845                               '<h1>' + BX.message('TITLE_SUCCESSFUL') + '</h1><span>' + alertInfo + '</span><div class="hidden-xs">' +
2846                               recommendContent +
2847                               '</div></div>'; */
2848
2849                    sizeShow = (this.offers[this.offerNum].SIZE != "NO_SIZE" ? '<p>Ваш размер: <span class="big-red">' + this.offers[this.offerNum].SIZE + '</span></p>' : "");
2850
2851                    popupContent += '<div class="col-xs-12 col-sm-5 col-sm-pull-7">' +
2852                        '<img src="' + productPict + '" class="img-responsive img-good">' +
2853                        '<h2>' + this.product.name + '</h2>' +
2854                        '<p>Артикул: ' + this.offers[this.offerNum].ARTICLE + '</p>' +
2855                        sizeShow +
2856                        '<p>Цена: <span class="big-red">' + this.offers[this.offerNum].PRICE.PRINT_DISCOUNT_VALUE + '</span></p>' +
2857                        '</div>';
2858
2859                    popupContent += "</div>";
2860
2861                    if (this.config.showClosePopup) {
2862                        popupButtons = [
2863                            new BasketButton({
2864                                ownerClass: this.obProduct.className,
2865                                text: "Перейти в корзину", //BX.message('BTN_MESSAGE_BASKET_REDIRECT'),
2866                                id: "basketTo",
2867                                events: {
2868                                    click: BX.delegate(this.BasketRedirect, this)
2869                                },
2870                                style: {marginRight: '10px'}
2871                            }),
2872                            new BasketButton({
2873                                ownerClass: this.obProduct.className,
2874                                text: "Продолжить покупки",//BX.message('BTN_MESSAGE_CLOSE_POPUP'),
2875                                id: "basketContinue",
2876                                events: {
2877                                    click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2878                                }
2879                            })
2880                        ];
2881                    } else {
2882                        popupButtons = [
2883                            new BasketButton({
2884                                ownerClass: this.obProduct.className,
2885                                text: BX.message('BTN_MESSAGE_BASKET_REDIRECT'),
2886                                events: {
2887                                    click: BX.delegate(this.BasketRedirect, this)
2888                                }
2889                            })
2890                        ];
2891                    }
2892                } else {
2893                    popupContent = '<div style="max-width:300px; width: 96%; margin: 25px 2%; text-align: center;"><p>' + (!!arResult.MESSAGE ? arResult.MESSAGE : BX.message('BASKET_UNKNOWN_ERROR')) + '</p></div>';
2894                    popupButtons = [
2895                        /*
2896                    new BasketButton({
2897                        ownerClass: this.obProduct.className,
2898                        text: BX.message('BTN_MESSAGE_CLOSE'),
2899                        events: {
2900                            click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2901                        }
2902
2903                    })
2904                    */
2905                    ];
2906                    this.obPopupWin.setButtons(popupButtons);
2907                    this.obPopupWin.setContent(popupContent);
2908                    this.obPopupWin.show();
2909                }
2910
2911
2912                // BX.closeWait(this.obAddToBasketBtn, wait);
2913
2914                //this.obPopupWin.setTitleBar(popupTitle);
2915                // this.obPopupWin.setButtons(popupButtons);
2916                // this.obPopupWin.setContent(popupContent);
2917
2918                // this.obPopupWin.show();
2919
2920                let overlay = $("#mitOverlay"),
2921                    modal = $("#mitModal");
2922                modal.hide(100).css("display", "none");
2923                overlay.hide(100).css("display", "none");
2924
2925                let basketsCounts = document.querySelectorAll(".bx-basket .bx-basket-block .count");
2926                for (let i = 0; i < basketsCounts.length; i++) {
2927                    let basketCount = basketsCounts[i];
2928                    if (basketCount.classList.contains("pulsate-fwd")) {
2929                        basketCount.classList.remove("pulsate-fwd");
2930                    }
2931                    basketCount.classList.add("pulsate-fwd");
2932                }
2933
2934                let loadBtn = this.obAddToBasketBtn,
2935                    loadInSaloonBtn = this.obAddToBasketInSaloonBtn;
2936
2937                function removeLoad() {
2938                    loadBtn.classList.remove("loading");
2939                    loadInSaloonBtn.classList.remove("loading");
2940                }
2941
2942                setTimeout(removeLoad, 1000);
2943
2944            }
2945
2946        }
2947        return false;
2948    };
2949
2950    window.JCCatalogElement.prototype.BasketRedirect = function () {
2951        location.href = (!!this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL'));
2952    };
2953
2954    window.JCCatalogElement.prototype.InitPopupWindow = function () {
2955        if (!!this.obPopupWin)
2956            return;
2957
2958        this.obPopupWin = BX.PopupWindowManager.create('CatalogElementBasket_' + this.visual.ID, null, {
2959            autoHide: false,
2960            offsetLeft: 0,
2961            offsetTop: 0,
2962            overlay: true,
2963            closeByEsc: true,
2964            titleBar: true,
2965            closeIcon: {top: '10px', right: '10px'}
2966        });
2967    };
2968
2969    window.JCCatalogElement.prototype.onPopupWindowShow = function (popup) {
2970        BX.bind(document, 'click', BX.proxy(this.popupWindowClick, this));
2971    };
2972
2973    window.JCCatalogElement.prototype.onPopupWindowClose = function (popup, event) {
2974        BX.unbind(document, 'click', BX.proxy(this.popupWindowClick, this));
2975    };
2976
2977    window.JCCatalogElement.prototype.popupWindowClick = function () {
2978        if (!!this.obPopupPict && typeof (this.obPopupPict) === 'object') {
2979            if (this.obPopupPict.isShown())
2980                this.obPopupPict.close();
2981        }
2982    };
2983
2984    window.JCCatalogElement.prototype.incViewedCounter = function () {
2985        if (this.currentIsSet && !this.updateViewedCount) {
2986            switch (this.productType) {
2987                case 1:
2988                case 2:
2989                    this.viewedCounter.params.PRODUCT_ID = this.product.id;
2990                    this.viewedCounter.params.PARENT_ID = this.product.id;
2991                    break;
2992                case 3:
2993                    this.viewedCounter.params.PARENT_ID = this.product.id;
2994                    this.viewedCounter.params.PRODUCT_ID = this.offers[this.offerNum].ID;
2995                    break;
2996                default:
2997                    return;
2998            }
2999            this.viewedCounter.params.SITE_ID = BX.message('SITE_ID');
3000            this.updateViewedCount = true;
3001            BX.ajax.post(
3002                this.viewedCounter.path,
3003                this.viewedCounter.params,
3004                BX.delegate(function () {
3005                    this.updateViewedCount = false;
3006                }, this)
3007            );
3008        }
3009    };
3010
3011    window.JCCatalogElement.prototype.allowViewedCount = function (update) {
3012        update = !!update;
3013        this.currentIsSet = true;
3014        if (update)
3015            this.incViewedCounter();
3016    };
3017
3018    window.JCCatalogElement.prototype.VkAddToCartEvent = function () {
3019        VK.Retargeting.ProductEvent(3158, 'add_to_cart', this.eventParamsCard);
3020    };
3021})(window);
3022
3023
3024$(document).ready(function () {
3025    let lazyLoadInstance = new LazyLoad({
3026        elements_selector: ".lazy"
3027        // ... more custom settings?
3028    });
3029
3030    // console.dir(lazyLoadInstance);
3031
3032    function fancyShow(e) {
3033
3034        var url = BX.findChild(e, {"tag": "img"}, true, true)[0]['currentSrc'],
3035            windowInnerSize = BX.GetWindowInnerSize();
3036
3037        // console.log(windowInnerSize.innerWidth);
3038        if (windowInnerSize.innerWidth > 760 && windowInnerSize.innerWidth < 990) {
3039            $.fancybox({
3040                content: "<img width='650' height='650' src='" + url + "'/>",
3041                width: 650,
3042                minHeight: 650,
3043                height: 650,
3044                type: 'image',
3045                closeClick: false,
3046                openEffect: 'none',
3047                closeEffect: 'none',
3048                tpl: {
3049                    closeBtn: '<a title="Close" class="mit-close" href="javascript:;"><span class="popup-window-close-icon"></span></a>'
3050                }
3051            });
3052        }
3053    }
3054
3055    $(".various").fancybox({
3056        minWidth: 100,
3057        maxWidth: 9999,
3058        maxHeight: 800,
3059        fitToView: false,
3060        width: '60%',
3061        height: '90%',
3062        autoSize: true,
3063        closeClick: false,
3064        openEffect: 'none',
3065        closeEffect: 'none',
3066        scrolling: 'auto',
3067        tpl: {
3068            closeBtn: '<a title="Close" class="mit-close" href="javascript:;"><span class="popup-window-close-icon"></span></a>'
3069        }
3070    });
3071
3072
3073    // VK.Retargeting.ProductEvent(3158, "view_product", eventParamsCard<?=$arResult['ID']?>);
3074// console.dir(VK.Retargeting);
3075
3076    $.ajax({
3077        url: "/local/templates/itaita2020/ajax/check_logged.php",
3078    }).done(function (msg) {
3079        if (msg == "true") {
3080            // $(".in-basket__like").click(function (e) {
3081            //     e.preventDefault();
3082            //     var elCount = parseInt($('#count_in_fav').text());
3083            //
3084            //     var idid = $('.in-basket__like').data('id');
3085            //     var $this = $(this);
3086            //     $.get("/ajax_favorite.php", {
3087            //         elid: $this.data('id')
3088            //     }, function (data) {
3089            //         switch (data) {
3090            //             case 'done' :
3091            //                 var response = 'Товар успешно добавлен в список "Моих желаний"';
3092            //                 var textlink = 'Удалить из "Моих желаний"';
3093            //                 VK.Retargeting.ProductEvent(3158, "add_to_wishlist", eventParamsCard<?=$arResult['ID']?>);
3094            //                 fbq('track', 'AddToWishlist');
3095            //                 $this.addClass("in-basket__like_active");
3096            //                 if ($('*').is('#count_in_fav')) {
3097            //                     $('#count_in_fav').text(elCount + 1);
3098            //                 } else {
3099            //                     $('.vb-favorites-link a span').html('Мои желания <b id="count_in_fav">1</b>');
3100            //                 }
3101            //                 break;
3102            //
3103            //             case 'deleted' :
3104            //                 var response = 'Товар успешно удален из списка "Моих желаний"';
3105            //                 var textlink = 'Добавить в "Мои желания"';
3106            //                 VK.Retargeting.ProductEvent(3158, "remove_from_wishlist", eventParamsCard<?=$arResult['ID']?>);
3107            //                 $this.removeClass("in-basket__like_active");
3108            //
3109            //                 if (elCount > 1) {
3110            //                     $('#count_in_fav').text(elCount - 1);
3111            //                 } else {
3112            //                     $('#count_in_fav').remove();
3113            //                 }
3114            //                 break;
3115            //
3116            //             case 'fail' :
3117            //                 var response = 'Вы не авторизованы, либо Ваш запрос некорректен';
3118            //                 var textlink = 'Добавить в "Мои желания"';
3119            //                 $this.removeClass("in-basket__like_active");
3120            //                 break;
3121            //         }
3122            //         $("#favorit_label").html(response).fadeIn(1000).delay(5000).fadeOut();
3123            //         $("#textlink").html(textlink).fadeIn(1000);
3124            //     });
3125            // });
3126        } else {
3127            // $(".favorite_auth_need").click(function (e) {
3128            //     alert("Для добавления товара в избранное необходимо авторизоваться")
3129            // });
3130        }
3131    });
3132
3133
3134    let rateElements = document.querySelectorAll("div:not(.bx_catalog_list_home) .bx_item_detail_rating");
3135
3136
3137    rateElements.forEach(function (rateElement, index) {
3138        rateElement.querySelector(".bx_stars_bg").addEventListener("click", function () {
3139            let newIndex;
3140
3141
3142            let getWidth = function () {
3143                let width = rateElement.querySelector(".bx_stars_progress").style.width;
3144                return width;
3145            };
3146            let getVotes = function () {
3147                let votes = rateElement.querySelector(".bx_stars_rating_votes").innerText;
3148                return votes;
3149            };
3150
3151
3152            if (index == 1) {
3153                newIndex = 0;
3154            } else {
3155                newIndex = 1;
3156            }
3157
3158
3159            setTimeout(function () {
3160                rateElements[newIndex].querySelector(".bx_stars_bg").style.pointerEvents = "none";
3161                rateElements[newIndex].querySelector(".bx_stars_progress").style.width = getWidth();
3162                rateElements[newIndex].querySelector(".bx_stars_rating_votes").innerText = getVotes();
3163            }, 500);
3164
3165        })
3166    })
3167
3168});
3169
3170

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.