MediaWiki:Common.js: Difference between revisions

Content deleted Content added
using mw.util
No edit summary
Line 295:
mw.loader.using( ['mediawiki.util'] ).done( function() {
 
// Block typing symbols in input field, otherwise Safari allows them and then chokes
// https://phabricator.wikimedia.org/T118741
document.getElementById('input_amount_other_box').onkeypress = function(e) {
var chr = String.fromCharCode(e.which);
if ("$£€¥".indexOf(chr) !== -1) {
return false;
}
};
 
// Disable submitting form with return key
$( 'form[name="paypalcontribution"]' ).bind( 'keypress', function(e) {
var code = ( e.keyCode ? e.keyCode : e.which );
if ( code == 13 ) return false;
});
 
if ( document.paypalcontribution ) {
document.paypalcontribution.utm_medium.value = mw.util.getParamValue( 'utm_medium' );
document.paypalcontribution.utm_campaign.value = mw.util.getParamValue( 'utm_campaign' );
document.paypalcontribution.utm_key.value = mw.util.getParamValue( 'utm_key' );
 
// Strip protocol to stop firewall throwing fits
document.paypalcontribution.referrer.value = document.referrer.replace(/https?:\/\//i, "");
 
// hide frequency options in India, where we can only handle one-time donations
if (document.paypalcontribution.country.value === 'IN') {
$("#frequency_onetime").prop('checked', true);
$(".frequency-options").hide();
$("#cancel-monthly").hide();
}
}
}
 
// Disable logo link
$("#p-logo a").attr("href", "#");
$("#p-logo a").attr("title", "");
 
// This is 1 by default, make it 0
$(".frequency-options label").click(function() {
$(".frequency-options label"'#searchInput').removeClassattr("checked"'tabindex', 0);
$(this).addClass("checked");
});
 
$(".input_amount_otherfrequency-options label").click(function() {
$("#input_amount_other_box.frequency-options label").focusremoveClass("checked");
$(this).addClass("checked");
});
});
 
$(".frequency-options labelinput_amount_other").click(function() {
$("#input_amount_other_box").focus();
});
 
// Allow preselecting monthly
if( mw.util.getParamValue('monthly') ) {
$('#frequency_monthly').click();
}
 
// Allow preselecting monthly
try {
if( mw.util.getParamValue('monthly') ) {
adjustHPC();
$('#frequency_monthly').click();
preSelect(); // Make sure to do this *after* other fiddling with values
}
finally {
$('.consider-amounts').show();
$('#actual-form').show();
$('#actual-form-loading').hide();
}
 
try {
// Load list of payment outages from meta, and hide any which are current
adjustHPC();
$.getScript('//meta.wikimedia.org/w/index.php?' + $.param( { title:'MediaWiki:FR2013/Resources/PaymentOutages.js', action:'raw', ctype:'text/javascript' } ),
preSelect(); // Make sure to do this *after* other fiddling with values
function() {
}
setTimeout(checkPaymentOutages(), 250); // allow time for script to have _executed_ (not just loaded)
});finally {
$('.consider-amounts').show();
$('#actual-form').show();
$('#actual-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' } ),
function() {
setTimeout(checkPaymentOutages(), 250); // allow time for script to have _executed_ (not just loaded)
});
 
});