MediaWiki:DonationFormSandbox.js: Difference between revisions

Content deleted Content added
factor out donationForm.formatAmount method
use new method when localizing errors
Line 225:
/* Localize the amount errors. Call when initialising form. */
donationForm.localizeErrors = function() {
var currency = donationForm.currency;,
var minAmount = donationForm.minimums[ currency ];,
locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
/* T287706 - round to 2 decimal places (rounding up) */
var numFormat = function( amount ) {
return Math.ceil( amount * 100 ) / 100;
};
 
$('.lp-error-smallamount').text( function( index, oldText ) {
return oldText.replace( '$1', numFormatdonationForm.formatAmount( minAmount, locale ) + ' ' + currency );
});
 
Line 245 ⟶ 242:
 
$('.lp-error-bigamount').text( function( index, oldText ) {
return oldText.replace( '$1', numFormatdonationForm.formatAmount( donationForm.maxUSD * minAmount, locale ) )
.replace( '$2', currency )
.replace( '$3', 'benefactors@wikimedia.org' )
.replace( '$4', donationForm.formatAmount( donationForm.maxUSD, locale ) );
});
};