- Author:
- David Nickerson <david.nickerson@gmail.com>
- Date:
- 2021-09-16 00:41:19+12:00
- Desc:
- Updating Noble 1962 model:
* Exposing the membrane potential to the top-level model;
* adding SED-ML for the paced and pacemaker variants of the model.
Using OpenCOR Snapshot release 2021-09-14.
- Permanent Source URI:
- https://models.fieldml.org/workspace/a1/rawfile/f954e59183314cd37f86c8832dc81317d01c8ec5/dojo-presentation/js/dojo/dojo/currency.js
dojo.provide("dojo.currency");
dojo.require("dojo.number");
dojo.require("dojo.i18n");
dojo.requireLocalization("dojo.cldr", "currency");
dojo.require("dojo.cldr.monetary");
/*=====
dojo.currency = {
// summary: localized formatting and parsing routines for currencies
}
=====*/
dojo.currency._mixInDefaults = function(options){
options = options || {};
options.type = "currency";
// Get locale-depenent currency data, like the symbol
var bundle = dojo.i18n.getLocalization("dojo.cldr", "currency", options.locale) || {};
// Mixin locale-independent currency data, like # of places
var iso = options.currency;
var data = dojo.cldr.monetary.getData(iso);
dojo.forEach(["displayName","symbol","group","decimal"], function(prop){
data[prop] = bundle[iso+"_"+prop];
});
data.fractional = [true, false];
// Mixin with provided options
return dojo.mixin(data, options);
}
dojo.currency.format = function(/*Number*/value, /*dojo.number.__FormatOptions?*/options){
// summary:
// Format a Number as a currency, using locale-specific settings
//
// description:
// Create a string from a Number using a known, localized pattern.
// [Formatting patterns](http://www.unicode.org/reports/tr35/#Number_Elements) appropriate to the locale are chosen from the [CLDR](http://unicode.org/cldr)
// as well as the appropriate symbols and delimiters.
//
// value:
// the number to be formatted.
return dojo.number.format(value, dojo.currency._mixInDefaults(options));
}
dojo.currency.regexp = function(/*dojo.number.__RegexpOptions?*/options){
//
// summary:
// Builds the regular needed to parse a currency value
//
// description:
// Returns regular expression with positive and negative match, group and decimal separators
// Note: the options.places default, the number of decimal places to accept, is defined by the currency type.
return dojo.number.regexp(dojo.currency._mixInDefaults(options)); // String
}
/*=====
dojo.declare("dojo.currency.__ParseOptions", [dojo.number.__ParseOptions], {
// type: String?
// currency, set by default.
// symbol: String?
// override currency symbol. Normally, will be looked up in table of supported currencies,
// and ISO currency code will be used if not found. See dojo.i18n.cldr.nls->currency.js
// places: Number?
// number of decimal places to accept. Default is defined by currency.
// fractional: Boolean?|Array?
// where places are implied by pattern or explicit 'places' parameter, whether to include the fractional portion.
// By default for currencies, it the fractional portion is optional.
type: "",
symbol: "",
places: "",
fractional: ""
});
=====*/
dojo.currency.parse = function(/*String*/expression, /*dojo.currency.__ParseOptions?*/options){
//
// summary:
// Convert a properly formatted currency string to a primitive Number,
// using locale-specific settings.
//
// description:
// Create a Number from a string using a known, localized pattern.
// [Formatting patterns](http://www.unicode.org/reports/tr35/#Number_Format_Patterns) are chosen appropriate to the locale.
//
// expression: A string representation of a Number
return dojo.number.parse(expression, dojo.currency._mixInDefaults(options));
}