Files
Bubberstation/html/admin/banpanel.js
Beatrice 4e491c902d Admins Can Once Again Click Ban Panel Categories to Toggle Their Checkboxes (#60904)
* Re-Adds Header Checkboxes

- Ban Panel categories can now be clicked to click all the checkboxes in their category
- Adds a new js method called header_click_all_checkboxes whichs clicks all the checkboxes whose class is the hidden checkbox's name

Re-introduces a function that was lost with #60578 (6c4134d1ea) , closes #60903 (Admins being unable to click on the ban category and check all subcheckboxes). The method was largely copied, but was changed to comply with the toggle_other_checkboxes() method introduced with the aforementioned PR by replacing a .checked assignment with a .click() call to ensure that duplicate entries are properly marked

Admins can now click categories to more easily ban people from all entries in that category. Demonstrated below to show that checkboxes are being toggled correctly in all relevant categories

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
2021-08-31 16:31:59 -07:00

20 lines
637 B
JavaScript

function toggle_other_checkboxes(source, copycats_str, our_index_str) {
const copycats = parseInt(copycats_str);
const our_index = parseInt(our_index_str);
for (var i = 1; i <= copycats; i++) {
if(i === our_index) {
continue;
}
document.getElementById(source.id.slice(0, -1) + i).checked = source.checked;
}
}
function header_click_all_checkboxes(source) {
var checkboxes = document.getElementsByClassName(source.name);
for(var i = 0, n = checkboxes.length; i < n; i++) {
if(checkboxes[i].checked != source.checked && checkboxes[i] != source) {
checkboxes[i].click();
}
}
}