PageSourceSearch

https://www.allfordj.ru/bitrix/js/currency/currency-core/dist/currency-core.bundle.js?17205873018800

js allfordj.ru collected 2026-09-26 02:34:57 UTC 8,800 bytes, 231 lines download raw bytes

1/* eslint-disable */
2this.BX = this.BX || {};
3(function (exports,main_core) {
4	'use strict';
5
6	function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7	function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
8	var _currency = /*#__PURE__*/new WeakMap();
9	var _format = /*#__PURE__*/new WeakMap();
10	var CurrencyItem = /*#__PURE__*/function () {
11	  function CurrencyItem(currency, format) {
12	    babelHelpers.classCallCheck(this, CurrencyItem);
13	    _classPrivateFieldInitSpec(this, _currency, {
14	      writable: true,
15	      value: ''
16	    });
17	    _classPrivateFieldInitSpec(this, _format, {
18	      writable: true,
19	      value: {}
20	    });
21	    babelHelpers.classPrivateFieldSet(this, _currency, currency);
22	    babelHelpers.classPrivateFieldSet(this, _format, format);
23	  }
24	  babelHelpers.createClass(CurrencyItem, [{
25	    key: "getCurrency",
26	    value: function getCurrency() {
27	      return babelHelpers.classPrivateFieldGet(this, _currency);
28	    }
29	  }, {
30	    key: "getFormat",
31	    value: function getFormat() {
32	      return babelHelpers.classPrivateFieldGet(this, _format);
33	    }
34	  }, {
35	    key: "setFormat",
36	    value: function setFormat(format) {
37	      babelHelpers.classPrivateFieldSet(this, _format, format);
38	    }
39	  }]);
40	  return CurrencyItem;
41	}();
42
43	function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
44	function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { babelHelpers.defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
45	var CurrencyCore = /*#__PURE__*/function () {
46	  function CurrencyCore() {
47	    babelHelpers.classCallCheck(this, CurrencyCore);
48	  }
49	  babelHelpers.createClass(CurrencyCore, null, [{
50	    key: "getCurrencyList",
51	    value: function getCurrencyList() {
52	      return this.currencies;
53	    }
54	  }, {
55	    key: "setCurrencyFormat",
56	    value: function setCurrencyFormat(currency, format, replace) {
57	      if (!main_core.Type.isStringFilled(currency) || !main_core.Type.isPlainObject(format)) {
58	        return;
59	      }
60	      var index = this.getCurrencyIndex(currency);
61	      if (index > -1 && !replace) {
62	        return;
63	      }
64	      var innerFormat = _objectSpread(_objectSpread({}, this.defaultFormat), format);
65	      if (index === -1) {
66	        this.currencies.push(new CurrencyItem(currency, innerFormat));
67	      } else {
68	        this.currencies[index].setFormat(innerFormat);
69	      }
70	    }
71	  }, {
72	    key: "setCurrencies",
73	    value: function setCurrencies(currencies, replace) {
74	      if (main_core.Type.isArray(currencies)) {
75	        for (var i = 0; i < currencies.length; i++) {
76	          if (!main_core.Type.isPlainObject(currencies[i]) || !main_core.Type.isStringFilled(currencies[i].CURRENCY) || !main_core.Type.isPlainObject(currencies[i].FORMAT)) {
77	            continue;
78	          }
79	          this.setCurrencyFormat(currencies[i].CURRENCY, currencies[i].FORMAT, replace);
80	        }
81	      }
82	    }
83	  }, {
84	    key: "getCurrencyFormat",
85	    value: function getCurrencyFormat(currency) {
86	      var index = this.getCurrencyIndex(currency);
87	      return index > -1 ? this.getCurrencyList()[index].getFormat() : false;
88	    }
89	  }, {
90	    key: "getCurrencyIndex",
91	    value: function getCurrencyIndex(currency) {
92	      var currencyList = this.getCurrencyList();
93	      for (var i = 0; i < currencyList.length; i++) {
94	        if (currencyList[i].getCurrency() === currency) {
95	          return i;
96	        }
97	      }
98	      return -1;
99	    }
100	  }, {
101	    key: "clearCurrency",
102	    value: function clearCurrency(currency) {
103	      var index = this.getCurrencyIndex(currency);
104	      if (index > -1) {
105	        this.currencies = BX.util.deleteFromArray(this.currencies, index);
106	      }
107	    }
108	  }, {
109	    key: "clean",
110	    value: function clean() {
111	      this.currencies = [];
112	    }
113	  }, {
114	    key: "initRegion",
115	    value: function initRegion() {
116	      if (this.region === '') {
117	        var settings = main_core.Extension.getSettings('currency.currency-core');
118	        this.region = settings.get('region') || '-';
119	      }
120	    }
121	  }, {
122	    key: "checkInrFormat",
123	    value: function checkInrFormat(currency) {
124	      this.initRegion();
125	      return currency === 'INR' && (this.region === 'hi' || this.region === '
125in');
126	    }
127	  }, {
128	    key: "currencyFormat",
129	    value: function currencyFormat(price, currency, useTemplate) {
130	      var result = '';
131	      var format = this.getCurrencyFormat(currency);
132	      if (main_core.Type.isObject(format)) {
133	        price = Number(price);
134	        var currentDecimals = format.DECIMALS;
135	        var separator = format.SEPARATOR || format.THOUSANDS_SEP;
136	        if (format.HIDE_ZERO === 'Y' && main_core.Type.isInteger(price)) {
137	          currentDecimals = 0;
138	        }
139	        if (this.checkInrFormat(currency)) {
140	          result = this.numberFormatInr(price, currentDecimals, format.DEC_POINT, separator);
141	        } else {
142	          result = BX.util.number_format(price, currentDecimals, format.DEC_POINT, separator);
143	        }
144	        if (useTemplate) {
145	          result = format.FORMAT_STRING.replace(/(^|[^&])#/, '$1' + result);
146	        }
147	      }
148	      return result;
149	    }
150	  }, {
151	    key: "getPriceControl",
152	    value: function getPriceControl(control, currency) {
153	      var result = '';
154	      var format = this.getCurrencyFormat(currency);
155	      if (main_core.Type.isObject(format)) {
156	        result = format.FORMAT_STRING.replace(/(^|[^&])#/, '$1' + control.outerHTML);
157	      }
158	      return result;
159	    }
160	  }, {
161	    key: "loadCurrencyFormat",
162	    value: function loadCurrencyFormat(currency) {
163	      var _this = this;
164	      return new Promise(function (resolve, reject) {
165	        var index = _this.getCurrencyIndex(currency);
166	        if (index > -1) {
167	          resolve(_this.getCurrencyList()[index].getFormat());
168	        } else {
169	          BX.ajax.runAction('currency.format.get', {
170	            data: {
171	              currencyId: currency
172	            }
173	          }).then(function (response) {
174	            var format = response.data;
175	            _this.setCurrencyFormat(currency, format);
176	            resolve(format);
177	          })["catch"](function (response) {
178	            reject(response.errors);
179	          });
180	        }
181	      });
182	    }
183	  }, {
184	    key: "numberFormatInr",
185	    value: function numberFormatInr(value, decimals, decPoint, thousandsSep) {
186	      if (Number.isNaN(decimals) || decimals < 0) {
187	        decimals = 2;
188	      }
189	      decPoint = decPoint || ',';
190	      thousandsSep = thousandsSep || '.';
191	      var sign = '';
192	      value = (+value || 0).toFixed(decimals);
193	      if (value < 0) {
194	        sign = '-';
195	        value = -value;
196	      }
197	      var i = parseInt(value, 10).toString();
198	      var km = '';
199	      var kw;
200	      if (i.length <= 3) {
201	        kw = i;
202	      } else {
203	        var rightTriad = thousandsSep + i.slice(-3);
204	        var leftBlock = i.slice(0, -3);
205	        var j = leftBlock.length > 2 ? leftBlock.length % 2 : 0;
206	        km = j ? leftBlock.slice(0, j) + thousandsSep : '';
207	        kw = leftBlock.slice(j).replace(/(\d{2})(?=\d)/g, "$1" + thousandsSep) + rightTriad;
208	      }
209	      var kd = decimals ? decPoint + Math.abs(value - i).toFixed(decimals).replace(/-/, '0').slice(2) : '';
210	      return sign + km + kw + kd;
211	    }
212	  }]);
213	  return CurrencyCore;
214	}();
215
216	/** @deprecated use import { CurrencyCore } from 'currency.core' */
217	babelHelpers.defineProperty(CurrencyCore, "currencies", []);
218	babelHelpers.defineProperty(CurrencyCore, "defaultFormat", {
219	  FORMAT_STRING: '#',
220	  DEC_POINT: '.',
221	  THOUSANDS_SEP: ' ',
222	  DECIMALS: 2,
223	  HIDE_ZERO: 'N'
224	});
225	babelHelpers.defineProperty(CurrencyCore, "region", '');
226	main_core.Reflection.namespace('BX.Currency').Core = CurrencyCore;
227
228	exports.CurrencyCore = CurrencyCore;
229
230}((this.BX.Currency = this.BX.Currency || {}),BX));
231//# sourceMappingURL=currency-core.bundle.js.map

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.