MediaWiki:DonationForm mctest.js: Difference between revisions
Content deleted Content added
hook in monthly convert |
add utility function donationForm.getLocale |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1,048:
});
};
/**
* Block typing letters and symbols in given input. Used for Other amount inputs
*
* If we don't do this, Safari allows typing them and then chokes on submit
*
* @param {Element} inputElement The element to block typing on
*/
donationForm.otherInputControl = function( inputElement ) {
if ( inputElement ) {
};▼
};
/**
* Make language and country into a standard javascript Intl locale identifier
*
* Currently only used in monthlyconvert, but this could be useful
*
* @param {string} language
* @param {string} country
* @return {string} locale identifier
*/
donationForm.getLocale = function( language, country ) {
if ( language === 'en-gb' ) {
language = 'en';
}
if ( language === 'es-419' ) {
language = 'es';
}
if ( language === 'pt-br' ) {
language = 'pt';
}
return language + '-' + country;
};
/* End form functions */
Line 1,056 ⟶ 1,104:
var form = document.forms['donateForm'];
▲ }
// These get used in quite a few places
Line 1,067 ⟶ 1,109:
donationForm.country = mw.util.getParamValue('country');
// Block typing symbols in
▲ // https://phabricator.wikimedia.org/T118741, https://phabricator.wikimedia.org/T173431
▲ var amountOtherInput = document.getElementById('input_amount_other_box');
▲ amountOtherInput.onkeypress = function(e) {
▲ // Allow special keys in Firefox
▲ if ((e.code == 'ArrowLeft') || (e.code == 'ArrowRight') ||
▲ (e.code == 'ArrowUp') || (e.code == 'ArrowDown') ||
▲ (e.code == 'Delete') || (e.code == 'Backspace')) {
▲ return;
▲ }
▲ var chr = String.fromCharCode(e.which);
▲ if ('0123456789., '.indexOf(chr) === -1) {
▲ return false;
▲ };
▲ }
// Validate amount and update fee when selected/entered
|