MediaWiki:DonationForm T201415.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
only include referrer param if needed |
currency, country, language, pym_variant, pym_appeal |
||
Line 213: | Line 213: | ||
/* Localize the amount errors. Call when initialising form. */ |
/* Localize the amount errors. Call when initialising form. */ |
||
donationForm.localizeErrors = function() { |
donationForm.localizeErrors = function() { |
||
var |
var currency = donationForm.currency; |
||
⚫ | |||
var minAmount = donationForm.minimums[ currency ]; |
var minAmount = donationForm.minimums[ currency ]; |
||
Line 253: | Line 252: | ||
var hpcSet = mw.util.getParamValue('hpcSet'); |
var hpcSet = mw.util.getParamValue('hpcSet'); |
||
var currency = |
var currency = donationForm.currency; |
||
var language = mw.config.get('wgUserLanguage'); |
var language = mw.config.get('wgUserLanguage'); |
||
Line 707: | Line 706: | ||
} |
} |
||
params.payment_method = paymentMethod; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
Line 719: | Line 717: | ||
} else { |
} else { |
||
params.recurring = true; |
params.recurring = true; |
||
⚫ | |||
params.payment_method = paymentMethod; |
|||
⚫ | |||
⚫ | |||
} |
} |
||
Line 732: | Line 725: | ||
} |
} |
||
params.amount = amount; |
params.amount = amount; |
||
⚫ | |||
params.uselang = mw.config.get('wgUserLanguage'); |
|||
params.country = donationForm.country; |
|||
/* Email optin */ |
/* Email optin */ |
||
Line 737: | Line 734: | ||
var opt_inValue = $('input[name="opt_in"]:checked').val(); |
var opt_inValue = $('input[name="opt_in"]:checked').val(); |
||
params.opt_in = opt_inValue; // donationForm.validate() already checked it's 1 or 0 |
params.opt_in = opt_inValue; // donationForm.validate() already checked it's 1 or 0 |
||
⚫ | |||
// Default to variant = panExplain for India |
|||
⚫ | |||
if ( donationForm.country === 'IN' ) { |
|||
⚫ | |||
} |
|||
if ( mw.util.getParamValue( 'pym_variant' ) ) { |
|||
params.variant = mw.util.getParamValue( 'pym_variant' ); |
|||
} |
|||
⚫ | |||
params.appeal = mw.util.getParamValue( 'pym_appeal' ); |
|||
} |
} |
||
Line 907: | Line 917: | ||
donationForm.validateAmount = function() { |
donationForm.validateAmount = function() { |
||
var form = document.forms['donateForm']; |
|||
var amount = donationForm.getAmount(); |
var amount = donationForm.getAmount(); |
||
var minAmount = donationForm.minimums[ donationForm.currency ] || 1; |
|||
var currency = form.currency_code.value; |
|||
⚫ | |||
if ( amount === null || isNaN(amount) || amount <= 0 || amount < minAmount ) { |
if ( amount === null || isNaN(amount) || amount <= 0 || amount < minAmount ) { |
||
Line 983: | Line 991: | ||
var feeMultiplier = 0.04, |
var feeMultiplier = 0.04, |
||
feeMinimum = feeMinimums[ |
feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, |
||
feeAmount = amount * feeMultiplier; |
feeAmount = amount * feeMultiplier; |
||
Line 1,019: | Line 1,027: | ||
var form = document.forms['donateForm']; |
var form = document.forms['donateForm']; |
||
// These get used in quite a few places |
|||
⚫ | |||
donationForm.country = mw.util.getParamValue('country'); |
|||
// Block typing symbols in input field, otherwise Safari allows them and then chokes |
// Block typing symbols in input field, otherwise Safari allows them and then chokes |
||
Line 1,062: | Line 1,074: | ||
// hide frequency options for some countries |
// hide frequency options for some countries |
||
if ( donationForm.noRecurringCountries.indexOf( |
if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { |
||
$('#frequency_onetime').prop('checked', true); |
$('#frequency_onetime').prop('checked', true); |
||
$('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); |
$('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); |
||
} |
} |
||
addCardTypesClass( |
addCardTypesClass( donationForm.country ); |
||
} |
} |
||
Line 1,086: | Line 1,098: | ||
// Allow preselecting monthly |
// Allow preselecting monthly |
||
if( mw.util.getParamValue('monthly') |
if( mw.util.getParamValue('monthly') |
||
&& donationForm.noRecurringCountries.indexOf( |
&& donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 ) { |
||
$('#frequency_monthly').click(); |
$('#frequency_monthly').click(); |
||
} |
} |