MediaWiki:DonationForm.js: Difference between revisions

Content deleted Content added
moving inline javascript from Template:Optin/Default
using slightly better syntax for accessing form
Line 210:
/* Localize the amount errors. Call when initialising form. */
donationForm.localizeErrors = function() {
var currency form = document.forms['paypalcontribution.currency_code.value'];
var currency = form.currency_code.value;
var minAmount = donationForm.minimums[ currency ];
 
Line 677 ⟶ 678:
donationForm.redirectPayment = function( paymentMethod, paymentSubMethod, skipAmountValidation ) {
 
var form = document.forms['paypalcontribution']; // we should really change this some day
 
if ( donationForm.validate( skipAmountValidation ) ) {
Line 805 ⟶ 806:
/* Return amount selected or input */
donationForm.getAmount = function() {
var form = document.forms['paypalcontribution'];
var amount = null;
donationForm.extraData.otherAmt = 0;
Line 847 ⟶ 848:
 
var error = false;
var form = document.forms['paypalcontribution'];
 
// Reset all errors
Line 875 ⟶ 876:
donationForm.validateAmount = function() {
 
var form = document.forms['paypalcontribution'];
var amount = donationForm.getAmount();
var currency = document.paypalcontributionform.currency_code.value;
var minAmount = donationForm.minimums[ currency ] || 1;
 
Line 921 ⟶ 923:
*/
donationForm.calculateFee = function( amount ) {
 
var form = document.forms['paypalcontribution'];
 
// Minimum fee/PTF amounts. Default is 0.35.
Line 948 ⟶ 952:
 
var feeMultiplier = 0.04,
feeMinimum = feeMinimums[document.paypalcontribution form.currency_code.value ] || 0.35,
feeAmount = amount * feeMultiplier;
 
Line 982 ⟶ 986:
 
mw.loader.using( ['mediawiki.util'] ).done( function() {
 
var form = document.forms['paypalcontribution'];
 
// Block typing symbols in input field, otherwise Safari allows them and then chokes
// https://phabricator.wikimedia.org/T118741, https://phabricator.wikimedia.org/T173431
 
var amountOtherInput = document.getElementById('input_amount_other_box');
if ( amountOtherInput ) {
Line 1,023 ⟶ 1,028:
});
 
if ( document.paypalcontributionform ) {
document.paypalcontributionform.utm_medium.value = mw.util.getParamValue( 'utm_medium' );
document.paypalcontributionform.utm_campaign.value = mw.util.getParamValue( 'utm_campaign' );
document.paypalcontributionform.utm_key.value = mw.util.getParamValue( 'utm_key' );
 
// Strip protocol to stop firewall throwing fits
document.paypalcontributionform.referrer.value = document.referrer.replace(/https?:\/\//i, "");
 
// hide frequency options in India, where we can only handle one-time donations
if (document.paypalcontribution form.country.value === 'IN' ) {
$("#frequency_onetime").prop('checked', true);
$(".frequency-options").hide();
Line 1,038 ⟶ 1,043:
}
 
addCardTypesClass(document.paypalcontribution form.country.value );
}