MediaWiki:Common.js: Difference between revisions

Content deleted Content added
add basic preSelect() option
improved preSelect(), allows filling out 'Other' box
Line 317:
 
function preSelect() {
/* Check for a 'preSelect' url parameter, and select that option */.
If there isn't an option, add it to the "Other" box and select that */
if ( mw.util.getParamValue('preSelect') ) {
var $preSelectOptionpreSelectAmount = $('input[name="amount"][value="' + mw.util.getParamValue('preSelect') + '"]');
if ( preSelectAmount.length ) {
if ($preSelectOption) {
$preSelectOption = $('input[name="amount"][value="' + preSelectAmount + '"]');
if ( $preSelectOption.length ) {
// Select existing input, and add class to label for IE
$preSelectOption.prop('checked', true);
$preSelectOption.siblings('label').addClass('checked');
} else {
$('#input_amount_other_box').val( preSelectAmount );
$('#input_amount_other').prop('checked', true);
$('label[for="input_amount_other"]').addClass('checked');
}
}
}