MediaWiki:DonationFormSandbox.js: Difference between revisions

Content deleted Content added
use donationForm.formatCurrency for pay the fee
try and use currencyDisplay: 'narrowSymbol' if browser supports it
Line 246:
};
 
/* Amount and currency formatting */
let formatters = {
// WithAmounts without currency symbol
currencyFractionamountFraction: new Intl.NumberFormat( donationForm.locale,
donationForm.locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }
donationForm.locale, { style: 'currency', currency: donationForm.currency }
),
currencyWholeamountWhole: new Intl.NumberFormat( donationForm.locale,
{}
donationForm.locale, { style: 'currency', currency: donationForm.currency, minimumFractionDigits: 0 }
),
// Without currency symbol
amountFraction: new Intl.NumberFormat(
donationForm.locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }
),
amountWhole: new Intl.NumberFormat(
donationForm.locale, {}
)
};
 
// currencyDisplay: 'narrowSymbol' fixes some issues like en-CO showing the ISO code
// but browser support is lacking, so wrap in a try/catch
try {
formatters.currencyFraction = new Intl.NumberFormat( donationForm.locale,
{ style: 'currency', currency: donationForm.currency, currencyDisplay: 'narrowSymbol' }
),;
formatters.currencyWhole = new Intl.NumberFormat( donationForm.locale,
{ style: 'currency', currency: donationForm.currency, currencyDisplay: 'narrowSymbol', minimumFractionDigits: 0 }
),;
} catch(e) {
formatters.currencyFraction = new Intl.NumberFormat( donationForm.locale,
donationForm.locale, { style: 'currency', currency: donationForm.currency }
);
formatters.currencyWhole = new Intl.NumberFormat( donationForm.locale,
donationForm.locale, { style: 'currency', currency: donationForm.currency, minimumFractionDigits: 0 }
);
}
 
donationForm.formatCurrency = function( amount ) {