summaryrefslogtreecommitdiff
path: root/assets/js/src/BoardHorizontalScrolling.js
blob: d4c3aaf36c398a7bcff7f5a0e8e2d45899b4a613 (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
53
54
55
Kanboard.BoardHorizontalScrolling = function(app) {
    this.app = app;
};

Kanboard.BoardHorizontalScrolling.prototype.execute = function() {
    if (this.app.hasId("board")) {
        this.render();
    }
};

Kanboard.BoardHorizontalScrolling.prototype.listen = function() {
    var self = this;

    $(document).on('click', ".filter-toggle-scrolling", function(e) {
        e.preventDefault();
        self.toggle();
    });
};

Kanboard.BoardHorizontalScrolling.prototype.keyboardShortcuts = function() {
    var self = this;

    if (self.app.hasId("board")) {
        Mousetrap.bind("c", function () {
            self.toggle();
        });
    }
};

Kanboard.BoardHorizontalScrolling.prototype.onBoardRendered = function() {
    this.render();
};

Kanboard.BoardHorizontalScrolling.prototype.toggle = function() {
    var scrolling = localStorage.getItem("horizontal_scroll") || 1;
    localStorage.setItem("horizontal_scroll", scrolling == 0 ? 1 : 0);
    this.render();
};

Kanboard.BoardHorizontalScrolling.prototype.render = function() {
    if (localStorage.getItem("horizontal_scroll") == 0) {
        $(".filter-wide").show();
        $(".filter-compact").hide();

        $("#board-container").addClass("board-container-compact");
        $("#board th:not(.board-column-header-collapsed)").addClass("board-column-compact");
    }
    else {
        $(".filter-wide").hide();
        $(".filter-compact").show();

        $("#board-container").removeClass("board-container-compact");
        $("#board th").removeClass("board-column-compact");
    }
};