MediaWiki:DonationForm.js: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
using slightly better syntax for accessing form
renaming form from paypalcontribution to donateForm
Line 210: Line 210:
/* Localize the amount errors. Call when initialising form. */
/* Localize the amount errors. Call when initialising form. */
donationForm.localizeErrors = function() {
donationForm.localizeErrors = function() {
var form = document.forms['paypalcontribution'];
var form = document.forms['donateForm'];
var currency = form.currency_code.value;
var currency = form.currency_code.value;
var minAmount = donationForm.minimums[ currency ];
var minAmount = donationForm.minimums[ currency ];
Line 678: Line 678:
donationForm.redirectPayment = function( paymentMethod, paymentSubMethod, skipAmountValidation ) {
donationForm.redirectPayment = function( paymentMethod, paymentSubMethod, skipAmountValidation ) {


var form = document.forms['paypalcontribution']; // we should really change this some day
var form = document.forms['donateForm']; // we should really change this some day


if ( donationForm.validate( skipAmountValidation ) ) {
if ( donationForm.validate( skipAmountValidation ) ) {
Line 806: Line 806:
/* Return amount selected or input */
/* Return amount selected or input */
donationForm.getAmount = function() {
donationForm.getAmount = function() {
var form = document.forms['paypalcontribution'];
var form = document.forms['donateForm'];
var amount = null;
var amount = null;
donationForm.extraData.otherAmt = 0;
donationForm.extraData.otherAmt = 0;
Line 848: Line 848:


var error = false;
var error = false;
var form = document.forms['paypalcontribution'];
var form = document.forms['donateForm'];


// Reset all errors
// Reset all errors
Line 876: Line 876:
donationForm.validateAmount = function() {
donationForm.validateAmount = function() {


var form = document.forms['paypalcontribution'];
var form = document.forms['donateForm'];
var amount = donationForm.getAmount();
var amount = donationForm.getAmount();
var currency = form.currency_code.value;
var currency = form.currency_code.value;
Line 924: Line 924:
donationForm.calculateFee = function( amount ) {
donationForm.calculateFee = function( amount ) {


var form = document.forms['paypalcontribution'];
var form = document.forms['donateForm'];


// Minimum fee/PTF amounts. Default is 0.35.
// Minimum fee/PTF amounts. Default is 0.35.
Line 987: Line 987:
mw.loader.using( ['mediawiki.util'] ).done( function() {
mw.loader.using( ['mediawiki.util'] ).done( function() {


var form = document.forms['paypalcontribution'];
var form = document.forms['donateForm'];


// 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,014: Line 1,014:


// Disable submitting form with Enter key
// Disable submitting form with Enter key
$('form[name="paypalcontribution"]').on('keypress', function(e) {
$('form[name="donateForm"]').on('keypress', function(e) {
var code = ( e.keyCode ? e.keyCode : e.which );
var code = ( e.keyCode ? e.keyCode : e.which );
if ( code == 13 ) {
if ( code == 13 ) {