BX.Currency.Core
ES6 extension for handling currencies and their formats.
BX.Currency.Core
Methods
Method | Description | Available from version |
---|---|---|
BX.Currency.Core.getCurrencyList(): CurrencyItem[] |
Static method. Returns internal list of currencies. | |
BX.Currency.Core.setCurrencyFormat(currency: string, format, replace: boolean): void |
Static method. Defines format for specific currency. Parameters:
|
|
BX.Currency.Core.setCurrencies(currencies: [], replace: boolean) |
Static method. Defines formats for several currencies simultaneously. Parameters:
|
|
BX.Currency.Core.getCurrencyFormat(currency: string) |
Static method. Returns currency format. Parameters:
|
|
BX.Currency.Core.getCurrencyIndex(currency: string): number |
Static method. Returns currency position in an internal currency list. Parameters:
|
|
BX.Currency.Core.getPriceControl(control: Element, currency: string) |
Static method. Allows formatting currency, by taking HTML-element as numerical value. Parameters:
Example: the page has an element <h1 id="currency">3000</h1> :
const el = document.getElementById('currency'); CurrencyCore.getPriceControl(el, 'USD'); // returns string "<h1 id="currency">3000</h1> ₽" |
22.500.0 |
BX.Currency.Core.clearCurrency(currency: string): number |
Static method. Deletes currency format by code from internal list (if available). Parameters:
|
|
BX.Currency.Core.clean() |
Static method. Clears internal list. | |
BX.Currency.Core.currencyFormat(price: number, currency: string, useTemplate: boolean) |
Static method. Formats the price. Parameters:
|
|
BX.Currency.Core.loadCurrencyFormat(currency) |
Static method. Asynchronous format upload. Parameters:
|
Example
example.js import {CurrencyCore} from 'currency.currency-core'; export class Example { constructor(currencyId: string) { this.currencyFormat = CurrencyCore.loadCurrencyFormat(currencyId); } }
© «Bitrix24», 2001-2024