Refactor table row selection logic and remove associated CSS styles for improved clarity and maintainability

This commit is contained in:
Ross
2025-11-01 21:04:01 +00:00
parent cbf4c3497d
commit 62c26d199e
3 changed files with 3 additions and 47 deletions
-31
View File
@@ -176,37 +176,6 @@ $(document).ready(function () {
});
// Table row selection
// Delegate click event to all table rows
document.querySelectorAll('.row-selector tbody tr').forEach(function(row) {
row.addEventListener('click', function(e) {
// Ignore clicks on links or checkboxes
if (e.target.tagName === 'A' || e.target.tagName === 'INPUT') return;
// Find the checkbox in this row
const checkbox = row.querySelector('input[name="selection"]');
if (checkbox) {
checkbox.checked = !checkbox.checked;
row.classList.toggle('selected', checkbox.checked);
}
});
// Keep row visually in sync with checkbox state (e.g. after page reload)
const checkbox = row.querySelector('input[name="selection"]');
if (checkbox && checkbox.checked) {
row.classList.add('selected');
}
// Also toggle row selection when checkbox is clicked directly
if (checkbox) {
checkbox.addEventListener('click', function(e) {
row.classList.toggle('selected', checkbox.checked);
// Prevent row click event from firing
e.stopPropagation();
});
}
});
});
window.loadDicomViewerEvent = new Event('loadDicomViewer');