blob: 77f459072663a067b4e78e6cefb4f9c6fd3ee1ed (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
Kanboard.Swimlane = (function() {
// Expand a Swimlane via display attributes
function expand(swimlaneId)
{
$('.swimlane-row-' + swimlaneId).css('display', 'table-row');
$('.show-icon-swimlane-' + swimlaneId).css('display', 'none');
$('.hide-icon-swimlane-' + swimlaneId).css('display', 'inline');
}
// Collapse a Swimlane via display attributes
function collapse(swimlaneId)
{
$('.swimlane-row-' + swimlaneId).css('display', 'none');
$('.show-icon-swimlane-' + swimlaneId).css('display', 'inline');
$('.hide-icon-swimlane-' + swimlaneId).css('display', 'none');
}
// Add swimlane Id to the hidden list and stores the list to localStorage
function hide(id)
{
var storageKey = "hidden_swimlanes_" + $("#board").data("project-id");
var hiddenSwimlaneIds = JSON.parse(Kanboard.GetStorageItem(storageKey)) || [];
hiddenSwimlaneIds.push(id);
Kanboard.SetStorageItem(storageKey, JSON.stringify(hiddenSwimlaneIds));
}
// Remove swimlane Id from the hidden list and stores the list to
// localStorage
function unhide(id)
{
var storageKey = "hidden_swimlanes_" + $("#board").data("project-id");
var hiddenSwimlaneIds = JSON.parse(Kanboard.GetStorageItem(storageKey)) || [];
var index = hiddenSwimlaneIds.indexOf(id);
if (index > -1) {
hiddenSwimlaneIds.splice(index, 1);
}
Kanboard.SetStorageItem(storageKey, JSON.stringify(hiddenSwimlaneIds));
}
// Check if swimlane Id is hidden. Anything > -1 means hidden.
function isHidden(id)
{
return getAllHidden().indexOf(id) > -1;
}
// Gets all swimlane Ids that are hidden
function getAllHidden()
{
var storageKey = "hidden_swimlanes_" + $("#board").data("project-id");
return JSON.parse(Kanboard.GetStorageItem(storageKey)) || [];
}
// Reload the swimlane states (shown/hidden) after an ajax call
jQuery(document).ajaxComplete(function() {
getAllHidden().map(function(swimlaneId) {
collapse(swimlaneId);
});
});
// Reload the swimlane states (shown/hidden) after page refresh
jQuery(document).ready(function() {
getAllHidden().map(function(swimlaneId) {
collapse(swimlaneId);
});
});
// Clicking on Show/Hide icon fires this.
jQuery(document).on('click', ".board-swimlane-toggle", function(e) {
e.preventDefault();
var swimlaneId = $(this).data('swimlane-id');
if (isHidden(swimlaneId)) {
unhide(swimlaneId);
expand(swimlaneId);
}
else {
hide(swimlaneId);
collapse(swimlaneId);
}
});
})();
|