MediaWiki:DonationFormSandbox.js: Difference between revisions

Content deleted Content added
m Reverted edits by PPenloglou-WMF (talk) to last revision by Pcoombe
Tag: Rollback
m Bringing this up to date with DonationForm.js
Line 795:
}
 
varlet frequency = $('input[name="frequency"]:checked')donationForm.valgetFrequency();
if ( frequency !=== 'monthly' ) {
params.recurring = false'1';
} else { params.frequency_unit = 'month';
} else if ( params.recurringfrequency === 'annual' ) true;{
params.recurring = '1';
params.frequency_unit = 'year';
}
 
Line 1,027 ⟶ 1,029:
if ( form.opt_in ) {
if ( $('input[name="opt_in"]:checked').val() === undefined ) {
$('#error-optin').show().focus();
error = true;
} else {
Line 1,048 ⟶ 1,050:
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').hide();
$('.lp-error-smallamount').show().focus();
return false;
} else if ( amount > donationForm.maxLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').show().focus();
return false;
} else {
Line 1,062 ⟶ 1,064:
};
 
donationForm.toggleMonthlygetFrequency = function(monthly) {
return document.forms.donateForm.dataset.frequency || 'onetime';
if (monthly) {
};
$('#form-wrapper').addClass('form-monthly');
 
donationForm.setFrequency = function( frequency ) {
// TODO: add some validation to reject invalid frequency values
let form = document.forms.donateForm;
 
form.frequency.value = frequency; // change input
form.dataset.frequency = frequency;
};
 
/* Wrapper for compatibility with old forms */
donationForm.toggleMonthly = function( monthly ) {
if ( monthly ) {
donationForm.validateAmountsetFrequency( 'monthly' );
} else {
$('#form-wrapper')donationForm.removeClasssetFrequency( 'form-monthlyonetime' );
}
};
Line 1,390 ⟶ 1,405:
donationForm.otherInputControl( document.getElementById('input_amount_other_box') );
 
// ValidateClear amounterrors and update fee when selected/entered
$('.amount-options').on( 'input change', function() {
// Ideally we would validate the amount, but this causes issues with focus
donationForm.validateAmount();
$('.amount-options .lp-error').hide();
donationForm.updateFeeDisplay();
});
Line 1,469 ⟶ 1,485:
});
 
// Allow preselecting monthlyfrequency if possible
if (
donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1
mw.util.getParamValue('monthly')
&& mw.util.getParamValue( 'monthlyutm_medium' ) !== '0endowment'
&& donationFormmw.noRecurringCountriesutil.indexOfgetParamValue( donationForm.country'wmf_medium' ) =!== -1'endowment'
&& mw.util.getParamValue('utm_medium') !== 'endowment'
&& mw.util.getParamValue('wmf_medium') !== 'endowment'
) {
$if ( mw.util.getParamValue( '#frequency_monthlyfrequency' ).click( ); {
donationForm.setFrequency( mw.util.getParamValue( 'monthlyfrequency' ) );
} else if ( mw.util.getParamValue('monthly') && mw.util.getParamValue('utm_mediummonthly') !== 'endowment0' ) {
// old method with "monthly=" parameter
donationForm.setFrequency( 'monthly' );
} else {
donationForm.setFrequency( 'onetime' );
}
}