1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-27 02:43:01 +00:00

Use JQuery addClass and removeClass

This commit is contained in:
Alexandre Iooss 2020-04-10 20:12:14 +02:00
parent cf67e17e85
commit 18c95f2063
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02

View File

@ -24,9 +24,8 @@ $(document).ready(function() {
}); });
// Switching in double consumptions mode should update the layout // Switching in double consumptions mode should update the layout
let double_conso_obj = $("#double_conso"); $("#double_conso").click(function() {
double_conso_obj.click(function() { $("#consos_list_div").removeClass('d-none');
$("#consos_list_div").attr('class', 'col-xl-5');
$("#infos_div").attr('class', 'col-sm-5 col-xl-6'); $("#infos_div").attr('class', 'col-sm-5 col-xl-6');
$("#note_infos_div").attr('class', 'col-xl-3'); $("#note_infos_div").attr('class', 'col-xl-3');
$("#user_select_div").attr('class', 'col-xl-4'); $("#user_select_div").attr('class', 'col-xl-4');
@ -44,9 +43,8 @@ $(document).ready(function() {
} }
}); });
let single_conso_obj = $("#single_conso"); $("#single_conso").click(function() {
single_conso_obj.click(function() { $("#consos_list_div").addClass('d-none');
$("#consos_list_div").attr('class', 'col-xl-5 d-none');
$("#infos_div").attr('class', 'col-sm-5 col-md-4'); $("#infos_div").attr('class', 'col-sm-5 col-md-4');
$("#note_infos_div").attr('class', 'col-xl-5'); $("#note_infos_div").attr('class', 'col-xl-5');
$("#user_select_div").attr('class', 'col-xl-7'); $("#user_select_div").attr('class', 'col-xl-7');
@ -69,10 +67,8 @@ $(document).ready(function() {
} }
}); });
// Ensure we begin in single consumption. Removing these lines may cause problems when reloading. // Ensure we begin in single consumption. Fix issue with TurboLinks and BootstrapJS
single_conso_obj.prop('checked', 'true'); $("label[for='double_conso']").removeClass('active');
double_conso_obj.removeAttr('checked');
$("label[for='double_conso']").attr('class', 'btn btn-sm btn-outline-primary');
$("#consume_all").click(consumeAll); $("#consume_all").click(consumeAll);
}); });