forked from ponlawat-w/moodle-block_hubcourseranking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_form.js
28 lines (23 loc) · 764 Bytes
/
edit_form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require(['jquery'], $ => {
$(document).ready(() => {
const inputs = [
{name: 'config_by', manual: false},
{name: 'config_duration', manual: false},
{name: 'config_manual', manual: true}
];
const setInput = (input, display) => {
const $formgroup = $(`[name=${input.name}]`).closest('.form-group');
if (display) {
$formgroup.show();
} else {
$formgroup.hide();
}
};
const updateRankingType = () => {
const manual = parseInt($('[name=config_ismanual]:checked').val()) ? true : false;
$.each(inputs, (_, input) => setInput(input, manual === input.manual));
};
$('[name=config_ismanual]').change(() => { updateRankingType(); });
updateRankingType();
});
});