Localize formatting to 1 decimal [PREMIUM-1]

This commit is contained in:
Alexey Stoletniy
2017-04-06 18:44:14 +03:00
parent fbc0a3ad8d
commit 72aa087411
4 changed files with 28 additions and 6 deletions

21
assets/js/src/num.js Normal file
View File

@ -0,0 +1,21 @@
define('num',
[
'mailpoet'
], function(
MailPoet
) {
'use strict';
MailPoet.Num = {
toLocaleFixed: function (num, precision) {
precision = precision || 0;
var factor = Math.pow(10, precision);
return (Math.round(num * factor) / factor)
.toLocaleString(
undefined,
{minimumFractionDigits: precision, maximumFractionDigits: precision}
);
}
};
});