MediaWiki:DonationFormSandbox.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 13:
 
donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ];
 
donationForm.maxUSD = 25000;
 
donationForm.currencyRates = {
Line 217 ⟶ 215:
'ZWD' : 373
};
 
// Usually minimums are about 1 USD, but there can be exceptions
donationForm.minimums = donationForm.currencyRates;
donationForm.minimums.INR = 10;
 
/* Localize the amount errors. Call when initialising form. */
donationForm.localizeErrors = function() {
var currency = donationForm.currency,
currencyRate = donationForm.currencyRates[ currency ] || 1,
minAmount = donationForm.minimums[ currency ],
locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
 
// Round up
minAmount = Math.ceil( minAmount * 100 ) / 100;
 
$('.lp-error-smallamount').text( function( index, oldText ) {
return oldText.replace( '$1', donationForm.formatAmount( minAmountdonationForm.minLocal, locale ) + '\xa0' + currency );
});
 
Line 245 ⟶ 234:
 
$('.lp-error-bigamount').text( function( index, oldText ) {
return oldText.replace( '$1', donationForm.formatAmount( donationForm.maxUSD * currencyRatemaxLocal, locale ) )
.replace( '$2', currency )
.replace( '$3', 'benefactors@wikimedia.org' )
Line 933 ⟶ 922:
donationForm.validateAmount = function() {
 
var amount = donationForm.getAmount(),;
currencyRate = donationForm.currencyRates[ donationForm.currency ] || 1,
minAmount = donationForm.minimums[ donationForm.currency ] || 1;
 
if ( amount === null || isNaN(amount) || amount <= 0 || amount < minAmountdonationForm.minLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').hide();
$('.lp-error-smallamount').show();
return false;
} else if ( amount > donationForm.maxUSD * currencyRatemaxLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').show();
Line 965 ⟶ 952:
var selectedAmount = donationForm.getAmount(),
feeAmount = donationForm.calculateFee( selectedAmount ),
currencyRate = donationForm.currencyRates[ donationForm.currency ] || 1,
maxAmount = donationForm.maxUSD * currencyRate,
feeText, locale;
 
Line 973 ⟶ 958:
 
$('.ptf label span').text( feeText );
if ( selectedAmount + feeAmount <= maxAmountdonationForm.maxLocal ) {
$('.ptf').slideDown();
}
Line 1,320 ⟶ 1,305:
}
donationForm.country = mw.util.getParamValue('country').toUpperCase();
 
// Minimum amount is usually about 1 USD
donationForm.minimumsminLocal = donationForm.currencyRates[ donationForm.currency ];
donationForm.minLocal = Math.ceil( donationForm.minLocal * 100 ) / 100; // Round it up
donationForm.maxUSD = 25000;
currencyRatedonationForm.maxLocal = donationForm.currencyRates[ donationForm.currency ] ||* 1,donationForm.maxUSD;
 
// Overrides for India
minAmountif =( donationForm.minimums[ currency ],=== 'INR' ) {
donationForm.minimums.INRminLocal = 10;
// Until https://phabricator.wikimedia.org/T370583 fixed?
maxAmount = donationForm.maxUSD * currencyRate, = 3000;
donationForm.maxLocal = 250000;
}
 
// Block typing symbols in Other field