2025-10-16 10:16:08 +00:00
|
|
|
(function ($) {
|
|
|
|
|
$(function () {
|
|
|
|
|
$('#id_categories, #id_wikimedia_projects').each(function () {
|
|
|
|
|
const otherCheckbox = $(this).find('input[value=0]');
|
|
|
|
|
const otherInputSelector = '#'.concat(this.id, '_other');
|
|
|
|
|
const otherInput = $(otherInputSelector);
|
|
|
|
|
const otherLabelSelector = 'label'.concat('[for="', this.id, '_other"]');
|
|
|
|
|
const otherLabel = $(otherLabelSelector);
|
2025-11-10 10:15:42 +00:00
|
|
|
const otherTableRow = otherInput.parents('tr');
|
2025-10-16 10:16:08 +00:00
|
|
|
|
|
|
|
|
const toggle = function () {
|
|
|
|
|
const checked = otherCheckbox.prop('checked');
|
|
|
|
|
|
|
|
|
|
otherInput.prop('disabled', !checked);
|
|
|
|
|
otherInput.prop('required', checked);
|
|
|
|
|
otherLabel.toggleClass('required', checked);
|
2025-11-10 10:15:42 +00:00
|
|
|
otherTableRow.css('visibility', checked ? 'visible' : 'collapse');
|
2025-10-16 10:16:08 +00:00
|
|
|
|
|
|
|
|
if (checked) {
|
|
|
|
|
otherInput.focus();
|
|
|
|
|
} else {
|
|
|
|
|
otherInput.val('');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
toggle();
|
|
|
|
|
|
|
|
|
|
otherCheckbox.on('change', toggle);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
})(django.jQuery);
|