aboutsummaryrefslogtreecommitdiff
path: root/uploader/static/js/datatables.js
blob: 76b1877fa2234b6e91573b044355e4c634d2b6dd (about) (plain)
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
/** Handlers for events in datatables **/

var dtAddRowSelectionHandler = (tableId) => {
    $(tableId).on("draw.dt", (event) => {
        $(".chk-row-select").on("change", (event) => {
            var checkboxOrRadio = event.target;
            var tablerow = checkboxOrRadio.parentElement.parentElement;
            var tableclass = tablerow.getAttribute("class");
            if(checkboxOrRadio.checked) {
                if (checkboxOrRadio.type == "radio") {
                    $(tableId + " tr").each((index, row) => {
                        var rowKlass = $(row).attr("class") || "";
                        row.setAttribute(
                            "class", rowKlass.replaceAll("selected", "").trim());
                    });
                }
                tablerow.setAttribute("class", `${tableclass} selected`);
            }
            else {
                tablerow.setAttribute(
                    "class", tableclass.replaceAll("selected", "").trim());
            }
        });
    });
};