MediaWiki:Common.js: Difference between revisions

Content deleted Content added
Undo revision 27996 by Pcoombe (talk)
move initialisation to function, only run on actual landing pages
Line 290:
/* End form functions */
 
function donationPageInit() {
 
$ if ( document).ready(function(paypalcontribution ) {
document.paypalcontribution.utm_keyutm_medium.value = mw.util.getParamValue( 'utm_keyutm_medium' );
document.paypalcontribution.utm_campaign.value = mw.util.getParamValue( 'utm_campaign' );
if (document.paypalcontribution.countryutm_key.value === mw.util.getParamValue( 'INutm_key') {);
 
// Strip protocol to stop firewall throwing fits
mw.loader.using( ['mediawiki.util'] ).done( function() {
document.paypalcontribution.referrer.value = document.referrer.replace(/https?:\/\//i, "");
 
// Blockhide typingfrequency symbolsoptions in input fieldIndia, otherwisewhere Safariwe allowscan themonly andhandle thenone-time chokesdonations
if ( document.paypalcontribution.country.value === 'IN') {
// https://phabricator.wikimedia.org/T118741
$("#frequency_onetime").prop('checked', true);
document.getElementById('input_amount_other_box').onkeypress = function(e) {
var chr = String.fromCharCode$(e".whichfrequency-options").hide();
if $("$£€¥#cancel-monthly").indexOfhide(chr) !== -1) {;
return false;}
}
};
 
// Block typing symbols in input field, otherwise Safari allows them and then chokes
// Disable submitting form with return key
// https://phabricator.wikimedia.org/T118741
$( 'form[name="paypalcontribution"]' ).bind( 'keypress', function(e) {
document.getElementById('input_amount_other_box').onkeypress = function(e) {
var code = ( e.keyCode ? e.keyCode : e.which );
var chr = if String.fromCharCode( code == 13 e.which) return false;
if ("$£€¥".indexOf(chr) !== -1) {
});
adjustHPC()return false;
};
};
 
// Disable submitting form with return key
if ( document.paypalcontribution ) {
$( document.'form[name="paypalcontribution.utm_medium.value"]' = mw).util.getParamValuebind( 'utm_mediumkeypress', function(e); {
var code = ( e.keyCode ? e.keyCode : e.which );
document.paypalcontribution.utm_campaign.value = mw.util.getParamValue( 'utm_campaign' );
if ( code == 13 ) return false;
document.paypalcontribution.utm_key.value = mw.util.getParamValue( 'utm_key' );
});
 
// Disable logo link
// Strip protocol to stop firewall throwing fits
$("#p-logo a").attr("titlehref", "#");
document.paypalcontribution.referrer.value = document.referrer.replace(/https?:\/\//i, "");
$("#p-logo a").attr("title", "");
 
// This is 1 by default, make it 0
// hide frequency options in India, where we can only handle one-time donations
$('#searchInput').attr('tabindex', 0);
if (document.paypalcontribution.country.value === 'IN') {
$("#frequency_onetime").prop('checked', true);
$(".frequency-options").hide();
$("#cancel-monthly").hide();
}
}
 
$(".input_amount_other").click(function() {
// Disable logo link
$("#p-logo ainput_amount_other_box").attrfocus("href", "#");
});
$("#p-logo a").attr("title", "");
 
// Allow preselecting monthly
// This is 1 by default, make it 0
if( mw.util.getParamValue('monthly') ) {
$('#searchInput').attr('tabindex', 0);
$('#frequency_monthly').click();
}
 
try {
$(".input_amount_other").click(function() {
$("#input_amount_other_box").focusadjustHPC();
preSelect(); // Make sure to do this *after* other fiddling with values
});
}
finally {
$('.consider-amounts').show();
$('#actual-form').show();
$("'#cancelactual-monthly"form-loading').hide();
}
 
// Load list of payment outages from meta, and hide any which are current
 
$.getScript('//meta.wikimedia.org/w/index.php?' + $.param( { title:'MediaWiki:FR2013/Resources/PaymentOutages.js', action:'raw', ctype:'text/javascript' } ),
// Allow preselecting monthly
iffunction( mw.util.getParamValue('monthly') ) {
setTimeout(checkPaymentOutages(), 250); // allow time for script to have _executed_ (not just loaded)
$('#frequency_monthly').click();
}
);
}
 
try {
adjustHPC();
preSelect(); // Make sure to do this *after* other fiddling with values
}
finally {
$('.consider-amounts').show();
$('#actual-form').show();
$('#actual-form-loading').hide();
}
 
$(document).ready(function() {
// Load list of payment outages from meta, and hide any which are current
$.getScript('//meta.wikimedia.org/w/index.php?' + $.param( { title:'MediaWiki:FR2013/Resources/PaymentOutages.js', action:'raw', ctype:'text/javascript' } ),
function() {
setTimeout(checkPaymentOutages(), 250); // allow time for script to have _executed_ (not just loaded)
});
 
mw.loader.using( ['mediawiki.util','mediawiki.config'] ).done( function() {
if ( mw.config.get('wgPageName') === 'Special:LandingPage' ) {
functiondonationPageInit() {;
});
});