PageSourceSearch

https://poly-max.com/local/templates/polymax_copy/components/bitri…/script.js?17845401175698

js poly-max.com collected 2026-09-29 15:52:51 UTC 5,698 bytes, 174 lines download raw bytes

1'use strict';
2
3function BitrixSmallCart() {}
4
5BitrixSmallCart.prototype = {
6  activate: function () {
7    this.cartElement = BX(this.cartId);
8    this.fixedPosition = this.arParams.POSITION_FIXED == 'Y';
9    if (this.fixedPosition) {
10      this.cartClosed = true;
11      this.maxHeight = false;
12      this.itemRemoved = false;
13      this.verticalPosition = this.arParams.POSITION_VERTICAL;
14      this.horizontalPosition = this.arParams.POSITION_HORIZONTAL;
15      this.topPanelElement = BX('bx-panel');
16
17      this.fixAfterRender(); // TODO onready
18      this.fixAfterRenderClosure = this.closure('fixAfterRender');
19
20      var fixCartClosure = this.closure('fixCart');
21      this.fixCartClosure = fixCartClosure;
22
23      if (this.topPanelElement && this.verticalPosition == 'top')
24        BX.addCustomEvent(window, 'onTopPanelCollapse', fixCartClosure);
25
26      var resizeTimer = null;
27      BX.bind(window, 'resize', function () {
28        clearTimeout(resizeTimer);
29        resizeTimer = setTimeout(fixCartClosure, 200);
30      });
31    }
32    this.setCartBodyClosure = this.closure('setCartBody');
33    BX.addCustomEvent(window, 'OnBasketChange', this.closure('refreshCart', {}));
34  },
35
36  fixAfterRender: function () {
37    this.statusElement = BX(this.cartId + 'status');
38    if (this.statusElement) {
39      if (this.cartClosed) this.statusElement.innerHTML = this.openMessage;
40      else this.statusElement.innerHTML = this.closeMessage;
41    }
42    this.productsElement = BX(this.cartId + 'products');
43    //		this.fixCart();
44  },
45
46  closure: function (fname, data) {
47    var obj = this;
48    return data
49      ? function () {
50          obj[fname](data);
51        }
52      : function (arg1) {
53          obj[fname](arg1);
54        };
55  },
56
57  toggleOpenCloseCart: function () {
58    if (this.cartClosed) {
59      BX.removeClass(this.cartElement, 'bx-closed');
60      BX.addClass(this.cartElement, 'bx-opener');
61      this.statusElement.innerHTML = this.closeMessage;
62      this.cartClosed = false;
63      this.fixCart();
64    } // Opened
65    else {
66      BX.addClass(this.cartElement, 'bx-closed');
67      BX.removeClass(this.cartElement, 'bx-opener');
68      BX.removeClass(this.cartElement, 'bx-max-height');
69      this.statusElement.innerHTML = this.openMessage;
70      this.cartClosed = true;
71      var itemList = this.cartElement.querySelector("[data-role='basket-item-list']");
72      if (itemList) itemList.style.top = 'auto';
73    }
74    setTimeout(this.fixCartClosure, 100);
75  },
76
77  setVerticalCenter: function (windowHeight) {
78    var top = windowHeight / 2 - this.cartElement.offsetHeight / 2;
79    if (top < 5) top = 5;
80    this.cartElement.style.top = top + 'px';
81  },
82
83  fixCart: function () {
84    // set horizontal center
85    if (this.horizontalPosition == 'hcenter') {
86      var windowWidth =
87        'innerWidth' in window ? window.innerWidth : document.documentElement.offsetWidth;
88      var left = windowWidth / 2 - this.cartElement.offsetWidth / 2;
89      if (left < 5) left = 5;
90      this.cartElement.style.left = left + 'px';
91    }
92
93    var windowHeight =
94      'innerHeight' in window ? window.innerHeight : document.documentElement.offsetHeight;
95
96    // set vertical position
97    switch (this.verticalPosition) {
98      case 'top':
99        if (this.topPanelElement)
100          this.cartElement.style.top = this.topPanelElement.offsetHeight + 5 + 'px';
101        break;
102      case 'vcenter':
103        this.setVerticalCenter(windowHeight);
104        break;
105    }
106
107    // toggle max height
108    if (this.productsElement) {
109      var itemList = this.cartElement.querySelector("[data-role='basket-item-list']");
110      if (this.cartClosed) {
111        if (this.maxHeight) {
112          BX.removeClass(this.cartElement, 'bx-max-height');
113          if (itemList) itemList.style.top = 'auto';
114          this.maxHeight = false;
115        }
116      } // Opened
117      else {
118        if (this.maxHeight) {
119          if (this.productsElement.scrollHeight == this.productsElement.clientHeight) {
120            BX.removeClass(this.cartElement, 'bx-max-height');
121            if (itemList) itemList.style.top = 'auto';
122            this.maxHeight = false;
123          }
124        } else {
125          if (this.verticalPosition == 'top' || this.verticalPosition == 'vcenter') {
126            if (this.cartElement.offsetTop + this.cartElement.offsetHeight >= windowHeight) {
127              BX.addClass(this.cartElement, 'bx-max-height');
128              if (itemList) itemList.style.top = 82 + 'px';
129              this.maxHeight = true;
130            }
131          } else {
132            if (this.cartElement.offsetHeight >= windowHeight) {
133              BX.addClass(this.cartElement, 'bx-max-height');
134              if (itemList) itemList.style.top = 82 + 'px';
135              this.maxHeight = true;
136            }
137          }
138        }
139      }
140
141      if (this.verticalPosition == 'vcenter') this.setVerticalCenter(windowHeight);
142    }
143  },
144
145  refreshCart: function (data) {
146    if (this.itemRemoved) {
147      this.itemRemoved = false;
148      return;
149    }
150    data.sessid = BX.bitrix_sessid();
151    data.siteId = this.siteId;
152    data.templateName = this.templateName;
153    data.arParams = this.arParams;
154    BX.ajax({
155      url: this.ajaxPath,
156      method: 'POST',
157      dataType: 'html',
158      data: data,
159      onsuccess: this.setCartBodyClosure,
160    });
161  },
162
163  setCartBody: function (result) {
164    if (this.cartElement)
165      this.cartElement.innerHTML = result.replace(/#CURRENT_URL#/g, this.currentUrl);
166    if (this.fixedPosition) setTimeout(this.fixAfterRenderClosure, 100);
167  },
168
169  removeItemFromCart: function (id) {
170    this.refreshCart({sbblRemoveItemFromCart: id});
171    this.itemRemoved = true;
172    BX.onCustomEvent('OnBasketChange');
173  },
174};

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.