3.3.1 Javascript Variables
SmartWebs frontend exposes a number of Javascript variables that the system uses in the Javascript code.
These variables can be used by developers, to develop their own Javascript components. The variables are stored in a window element and are explained below.
The following variables can be found with the DOM inspector.
Platform Variables
- currency - Stores the currency data as Symbol, Decimal etc.
- general - Stores general data as Domain, Site/Language id etc.
- language - Stores the language data as ISO language code.
- page - Stores page data as Page type, id etc.
- settings - Stores settings saved in the Control Panel.
- template - Stores template data as name, domain and settings.
- user - Stores user data, if logged in.
Platform Functions
- subscribe - This function listens for events e.g. On item card (Variant selection).
- unsubscribe - This function removes a subscription to events.
- publish - This function sends events e.g. On item card.
- currency_format - This function formats the currency value.
- number_format - Javascript implementation of PHPs number_format for formatting numbers.
For products that are exposed
- product - Stores product data as title, price, link etc.
Text Variable
- Stores all text translations for the chosen languages.
Template Variables
- Stores break-points for templates.
Template Functions
- bp.current - Function that states which TorqueUI breakpoint you are on/using.