summaryrefslogtreecommitdiff
path: root/assets/js/src/dashboard.js
blob: d0867e54bc7202abbd4f0324b7eeb0c1f540e994 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Kanboard.Dashboard = (function() {

    jQuery(document).ready(function() {

        var state = Kanboard.GetStorageItem("dashboard_view");

        if (state) {

            var sections = JSON.parse(state);

            for (var section in sections) {
                $("#dashboard-" + section).toggle(sections[section]);
            }

            hideColumns();
        }
    });

    jQuery(document).on('click', ".dashboard-toggle", function(e) {
        e.preventDefault();

        $("#dashboard-" + $(this).data("toggle")).toggle();
        hideColumns();

        var sections = ["projects", "tasks", "subtasks", "activities", "calendar"];
        var state = {};

        for (var i = 0; i < sections.length; i++) {
            state[sections[i]] = $("#dashboard-" + sections[i]).is(":visible");
        }

        Kanboard.SetStorageItem("dashboard_view", JSON.stringify(state));
    });

    function hideColumns()
    {
        if ($(".dashboard-right-column > div:visible").size() > 0) {
            $(".dashboard-left-column").removeClass("dashboard-single-column");
        }
        else {
            $(".dashboard-left-column").addClass("dashboard-single-column");
        }

        if ($(".dashboard-left-column > div:visible").size() > 0) {
            $(".dashboard-right-column").removeClass("dashboard-single-column");
        }
        else {
            $(".dashboard-right-column").addClass("dashboard-single-column");
        }
    }

})();