diff --git a/assets/js/admin/accounting.js b/assets/js/admin/accounting.js index dfa4d0e4acd..a6feca8a44b 100644 --- a/assets/js/admin/accounting.js +++ b/assets/js/admin/accounting.js @@ -1,12 +1,12 @@ /*! - * accounting.js v0.3.2 - * Copyright 2011, Joss Crowcroft + * accounting.js v0.4.2 + * Copyright 2014 Open Exchange Rates * * Freely distributable under the MIT license. * Portions of accounting.js are inspired or borrowed from underscore.js * * Full details and documentation: - * http://josscrowcroft.github.com/accounting.js/ + * http://openexchangerates.github.io/accounting.js/ */ (function(root, undefined) { @@ -17,7 +17,7 @@ var lib = {}; // Current version - lib.version = '0.3.2'; + lib.version = '0.4.1'; /* --- Exposed settings --- */ @@ -166,7 +166,7 @@ /** * Takes a string/array of strings, removes all formatting/cruft and returns the raw float value - * alias: accounting.`parse(string)` + * Alias: `accounting.parse(string)` * * Decimal must be included in the regular expression to match floats (defaults to * accounting.settings.number.decimal), so if the number uses a non-standard decimal @@ -224,11 +224,12 @@ /** * Format a number, with comma-separated thousands and custom precision/decimal places + * Alias: `accounting.format()` * * Localise by overriding the precision and thousand / decimal separators * 2nd parameter `precision` can be an object matching `settings.number` */ - var formatNumber = lib.formatNumber = function(number, precision, thousand, decimal) { + var formatNumber = lib.formatNumber = lib.format = function(number, precision, thousand, decimal) { // Resursively format arrays: if (isArray(number)) { return map(number, function(val) { diff --git a/assets/js/admin/accounting.min.js b/assets/js/admin/accounting.min.js index 29535c31ff6..2051bc2ff1e 100644 --- a/assets/js/admin/accounting.min.js +++ b/assets/js/admin/accounting.min.js @@ -1,11 +1,11 @@ /*! - * accounting.js v0.3.2 - * Copyright 2011, Joss Crowcroft + * accounting.js v0.4.2 + * Copyright 2014 Open Exchange Rates * * Freely distributable under the MIT license. * Portions of accounting.js are inspired or borrowed from underscore.js * * Full details and documentation: - * http://josscrowcroft.github.com/accounting.js/ + * http://openexchangerates.github.io/accounting.js/ */ -!function(a,b){function c(a){return!!(""===a||a&&a.charCodeAt&&a.substr)}function d(a){return l?l(a):"[object Array]"===m.call(a)}function e(a){return a&&"[object Object]"===m.call(a)}function f(a,b){var c;a=a||{},b=b||{};for(c in b)b.hasOwnProperty(c)&&null==a[c]&&(a[c]=b[c]);return a}function g(a,b,c){var d,e,f=[];if(!a)return f;if(k&&a.map===k)return a.map(b,c);for(d=0,e=a.length;e>d;d++)f[d]=b.call(c,a[d],d,a);return f}function h(a,b){return a=Math.round(Math.abs(a)),isNaN(a)?b:a}function i(a){var b=j.settings.currency.format;return"function"==typeof a&&(a=a()),c(a)&&a.match("%v")?{pos:a,neg:a.replace("-","").replace("%v","-%v"),zero:a}:a&&a.pos&&a.pos.match("%v")?a:c(b)?j.settings.currency.format={pos:b,neg:b.replace("%v","-%v"),zero:b}:b}var j={};j.version="0.3.2",j.settings={currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}};var k=Array.prototype.map,l=Array.isArray,m=Object.prototype.toString,n=j.unformat=j.parse=function(a,b){if(d(a))return g(a,function(a){return n(a,b)});if(a=a||0,"number"==typeof a)return a;b=b||j.settings.number.decimal;var c=new RegExp("[^0-9-"+b+"]",["g"]),e=parseFloat((""+a).replace(/\((.*)\)/,"-$1").replace(c,"").replace(b,"."));return isNaN(e)?0:e},o=j.toFixed=function(a,b){b=h(b,j.settings.number.precision);var c=Math.pow(10,b);return(Math.round(j.unformat(a)*c)/c).toFixed(b)},p=j.formatNumber=function(a,b,c,i){if(d(a))return g(a,function(a){return p(a,b,c,i)});a=n(a);var k=f(e(b)?b:{precision:b,thousand:c,decimal:i},j.settings.number),l=h(k.precision),m=0>a?"-":"",q=parseInt(o(Math.abs(a||0),l),10)+"",r=q.length>3?q.length%3:0;return m+(r?q.substr(0,r)+k.thousand:"")+q.substr(r).replace(/(\d{3})(?=\d)/g,"$1"+k.thousand)+(l?k.decimal+o(Math.abs(a),l).split(".")[1]:"")},q=j.formatMoney=function(a,b,c,k,l,m){if(d(a))return g(a,function(a){return q(a,b,c,k,l,m)});a=n(a);var o=f(e(b)?b:{symbol:b,precision:c,thousand:k,decimal:l,format:m},j.settings.currency),r=i(o.format),s=a>0?r.pos:0>a?r.neg:r.zero;return s.replace("%s",o.symbol).replace("%v",p(Math.abs(a),h(o.precision),o.thousand,o.decimal))};j.formatColumn=function(a,b,k,l,m,o){if(!a)return[];var q=f(e(b)?b:{symbol:b,precision:k,thousand:l,decimal:m,format:o},j.settings.currency),r=i(q.format),s=r.pos.indexOf("%s")0?r.pos:0>a?r.neg:r.zero,c=b.replace("%s",q.symbol).replace("%v",p(Math.abs(a),h(q.precision),q.thousand,q.decimal));return c.length>t&&(t=c.length),c});return g(u,function(a){return c(a)&&a.lengthd;d++)f[d]=b.call(c,a[d],d,a);return f}function h(a,b){return a=Math.round(Math.abs(a)),isNaN(a)?b:a}function i(a){var b=j.settings.currency.format;return"function"==typeof a&&(a=a()),c(a)&&a.match("%v")?{pos:a,neg:a.replace("-","").replace("%v","-%v"),zero:a}:a&&a.pos&&a.pos.match("%v")?a:c(b)?j.settings.currency.format={pos:b,neg:b.replace("%v","-%v"),zero:b}:b}var j={};j.version="0.4.1",j.settings={currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}};var k=Array.prototype.map,l=Array.isArray,m=Object.prototype.toString,n=j.unformat=j.parse=function(a,b){if(d(a))return g(a,function(a){return n(a,b)});if(a=a||0,"number"==typeof a)return a;b=b||j.settings.number.decimal;var c=new RegExp("[^0-9-"+b+"]",["g"]),e=parseFloat((""+a).replace(/\((.*)\)/,"-$1").replace(c,"").replace(b,"."));return isNaN(e)?0:e},o=j.toFixed=function(a,b){b=h(b,j.settings.number.precision);var c=Math.pow(10,b);return(Math.round(j.unformat(a)*c)/c).toFixed(b)},p=j.formatNumber=j.format=function(a,b,c,i){if(d(a))return g(a,function(a){return p(a,b,c,i)});a=n(a);var k=f(e(b)?b:{precision:b,thousand:c,decimal:i},j.settings.number),l=h(k.precision),m=0>a?"-":"",q=parseInt(o(Math.abs(a||0),l),10)+"",r=q.length>3?q.length%3:0;return m+(r?q.substr(0,r)+k.thousand:"")+q.substr(r).replace(/(\d{3})(?=\d)/g,"$1"+k.thousand)+(l?k.decimal+o(Math.abs(a),l).split(".")[1]:"")},q=j.formatMoney=function(a,b,c,k,l,m){if(d(a))return g(a,function(a){return q(a,b,c,k,l,m)});a=n(a);var o=f(e(b)?b:{symbol:b,precision:c,thousand:k,decimal:l,format:m},j.settings.currency),r=i(o.format),s=a>0?r.pos:0>a?r.neg:r.zero;return s.replace("%s",o.symbol).replace("%v",p(Math.abs(a),h(o.precision),o.thousand,o.decimal))};j.formatColumn=function(a,b,k,l,m,o){if(!a)return[];var q=f(e(b)?b:{symbol:b,precision:k,thousand:l,decimal:m,format:o},j.settings.currency),r=i(q.format),s=r.pos.indexOf("%s")0?r.pos:0>a?r.neg:r.zero,c=b.replace("%s",q.symbol).replace("%v",p(Math.abs(a),h(q.precision),q.thousand,q.decimal));return c.length>t&&(t=c.length),c});return g(u,function(a){return c(a)&&a.length