@eastsideco/escshopify
Version:
WIP JS library for Shopify, containing a variety of useful functionality.
164 lines (134 loc) • 8.29 kB
HTML
<html>
<head>
<meta charset="utf-8">
<base data-ice="baseUrl" href="../../../">
<title data-ice="title">src/easycurrency/main.js | @eastsideco/escshopify</title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
<script src="script/prettify/prettify.js"></script>
<script src="script/manual.js"></script>
<meta name="description" content="Produce universal library with webpack and es6"><meta property="twitter:card" content="summary"><meta property="twitter:title" content="@eastsideco/escshopify"><meta property="twitter:description" content="Produce universal library with webpack and es6"></head>
<body class="layout-container" data-ice="rootContainer">
<header>
<a href="./">Home</a>
<a href="./manual/index.html" data-ice="manualHeaderLink">Manual</a>
<a href="identifiers.html">Reference</a>
<a href="source.html">Source</a>
<div class="search-box">
<span>
<img src="./image/search.png">
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
</span>
<ul class="search-result"></ul>
</div>
<a style="position:relative; top:3px;" href="https://github.com/krasimir/webpack-library-starter.git"><img width="20px" src="./image/github.png"></a></header>
<nav class="navigation" data-ice="nav"><div>
<ul>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-easyCurrency">easyCurrency</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-geoService">geoService</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-utils">utils</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-external">E</span><span data-ice="name"><span><a href="https://www.npmjs.com/package/js-money">js-money</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#easycurrency">easycurrency</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/easycurrency/MoneySpan.js~MoneySpan.html">MoneySpan</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/easycurrency/config.js~Config.html">Config</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/easycurrency/main.js~EasyCurrency.html">EasyCurrency</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/easycurrency/state.js~State.html">State</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#easycurrency-resolvers">easycurrency/resolvers</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/easycurrency/resolvers/CurrencyResolver.js~CurrencyResolver.html">CurrencyResolver</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/easycurrency/resolvers/GeoserviceResolver.js~GeoserviceResolver.html">GeoserviceResolver</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#geoservice">geoservice</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/geoservice/API.js~API.html">API</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/geoservice/main.js~GeoService.html">GeoService</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/utils/Log.js~Log.html">Log</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/utils/general.js~GeneralUtils.html">GeneralUtils</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils-loggers">utils/loggers</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/utils/loggers/ConsoleLogger.js~ConsoleLogger.html">ConsoleLogger</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/utils/loggers/Logger.js~Logger.html">Logger</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/utils/loggers/logLevel.js~LogLevel.html">LogLevel</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-logLevel">logLevel</a></span></span></li>
</ul>
</div>
</nav>
<div class="content" data-ice="content"><h1 data-ice="title">src/easycurrency/main.js</h1>
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import Evee from 'evee';
import config from './config';
import state from './state';
import log from 'log';
const TAG = 'EasyCurrency';
/**
* Plugin for automatic currency conversion, tax handling, etc.
* @private
*/
export default class EasyCurrency extends Evee {
/** This is a singleton class - do not create instances directly. */
constructor() {
super();
/** @type {src/easycurrency/config.js~Config} */
this._config = config;
/** @type {src/easycurrency/resolver.js~CurrencyResolver} */
this._resolver = null;
/** @type {src/easycurrency/state.js~State} */
this._state = state;
}
/**
* Start running EasyCurrency on the current page.
*/
initialize(config) {
log.debug(TAG, 'Initialized with config', config);
if (config) {
this._config = Object.assign({}, this._config, config);
}
this.setActiveCurrency(this._config.defaultCurrency);
}
/**
* Sets the active currency, and refreshs any money spans.
* @param {String} currency Currency code
*/
setActiveCurrency(currency) {
log.debug(TAG, 'Set active currency', currency);
this._state.currency = currency;
}
getState() {
return this._state;
}
/**
* Format a value as a currency
* @param {js-money|Number} amount
* @param {String|null} currency If null, uses current currency.
*/
format(amount, currency) {
}
/**
* Convert an amount to another currency.
* @param {js-money|Number} amount
* @param {String} to
* @param {null|String} from Ignored if amount is a Money object.
*/
convert(amount, to, from) {
}
/**
* Adds the current tax rate to the given amount
* @param {js-money|Number} amount
*/
addTax(amount) {
}
/**
* Overrides the default currency resolver, which provides information
* about the available currencies.
* @param {src/easycurrency/resolver.js~CurrencyResolver} resolver
*/
setCurrencyResolver(resolver) {
this._resolver = resolver;
}
}
</code></pre>
</div>
<footer class="footer">
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.0.4)</span><img src="./image/esdoc-logo-mini-black.png"></a>
</footer>
<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>