Localize formatting to 1 decimal [PREMIUM-1]
This commit is contained in:
@ -164,9 +164,9 @@ const _StatisticsMixin = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// format to 1 decimal place
|
// format to 1 decimal place
|
||||||
percentage_clicked = percentage_clicked.toFixed(1);
|
percentage_clicked = MailPoet.Num.toLocaleFixed(percentage_clicked, 1);
|
||||||
percentage_opened = percentage_opened.toFixed(1);
|
percentage_opened = MailPoet.Num.toLocaleFixed(percentage_opened, 1);
|
||||||
percentage_unsubscribed = percentage_unsubscribed.toFixed(1);
|
percentage_unsubscribed = MailPoet.Num.toLocaleFixed(percentage_unsubscribed, 1);
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<span>
|
<span>
|
||||||
|
@ -293,9 +293,9 @@ const NewsletterListWelcome = React.createClass({
|
|||||||
let percentage_unsubscribed = (newsletter.statistics.unsubscribed * 100) / total_sent;
|
let percentage_unsubscribed = (newsletter.statistics.unsubscribed * 100) / total_sent;
|
||||||
|
|
||||||
// format to 1 decimal place
|
// format to 1 decimal place
|
||||||
percentage_clicked = percentage_clicked.toFixed(1);
|
percentage_clicked = MailPoet.Num.toLocaleFixed(percentage_clicked, 1);
|
||||||
percentage_opened = percentage_opened.toFixed(1);
|
percentage_opened = MailPoet.Num.toLocaleFixed(percentage_opened, 1);
|
||||||
percentage_unsubscribed = percentage_unsubscribed.toFixed(1);
|
percentage_unsubscribed = MailPoet.Num.toLocaleFixed(percentage_unsubscribed, 1);
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<span>
|
<span>
|
||||||
|
21
assets/js/src/num.js
Normal file
21
assets/js/src/num.js
Normal 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}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
@ -125,6 +125,7 @@ config.push(_.extend({}, baseConfig, {
|
|||||||
'i18n',
|
'i18n',
|
||||||
'modal',
|
'modal',
|
||||||
'notice',
|
'notice',
|
||||||
|
'num',
|
||||||
'jquery.serialize_object',
|
'jquery.serialize_object',
|
||||||
'parsleyjs'
|
'parsleyjs'
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user