MediaWiki:DonationForm.js: Difference between revisions
Content deleted Content added
hide card text when showing logos |
new donationForm.formatAmount method, and use it for both fee and error amounts |
||
Line 225:
/* Localize the amount errors. Call when initialising form. */
donationForm.localizeErrors = function() {
var currency = donationForm.currency
locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
var numFormat = function( amount ) {▼
};▼
$('.lp-error-smallamount').text( function( index, oldText ) {
return oldText.replace( '$1',
});
Line 245 ⟶ 242:
$('.lp-error-bigamount').text( function( index, oldText ) {
return oldText.replace( '$1',
.replace( '$2', currency )
.replace( '$3', 'benefactors@wikimedia.org' )
.replace( '$4', donationForm.formatAmount( donationForm.maxUSD, locale ) );
});
};
Line 754 ⟶ 751:
}
if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) {
}
Line 991 ⟶ 988:
minAmount = donationForm.minimums[ donationForm.currency ] || 1,
maxAmount = donationForm.maxUSD * minAmount,
feeText, locale
locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
feeText = donationForm.formatAmount( feeAmount, locale );
if ( feeAmount % 1 !== 0 ) { // Not a whole number▼
formatterOptions = { minimumFractionDigits: 2 };▼
} else {▼
formatterOptions = {};▼
}▼
try {▼
feeText = feeAmount.toLocaleString( locale, formatterOptions );▼
} catch(e) {▼
feeText = feeAmount.toFixed(2);▼
$('.ptf label span').text( feeText );
Line 1,106 ⟶ 1,092:
* @param {string} language
* @param {string} country
* @return {string} locale identifier e.g.
*/
donationForm.getLocale = function( language, country ) {
Line 1,140 ⟶ 1,126:
return false;
};
/**
* Format an amount for a given locale
*
* 2 decimal places if it has a fractional part, 0 if not
* Note this doesn't include any currency symbol
*
* @param {number} amount
* @param {string} locale To determine correct separators
* @return {string}
*/
var formatterOptions, output;
▲ formatterOptions = { minimumFractionDigits: 2, maximumFractionDigits: 2 };
▲ } else {
▲ formatterOptions = {};
▲ try {
▲ } catch(e) {
▲ }
return output;
}
|