summaryrefslogtreecommitdiff
path: root/assets/js/src/board.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/src/board.js')
-rw-r--r--assets/js/src/board.js113
1 files changed, 89 insertions, 24 deletions
diff --git a/assets/js/src/board.js b/assets/js/src/board.js
index e4ba4ed5..8e086c93 100644
--- a/assets/js/src/board.js
+++ b/assets/js/src/board.js
@@ -4,6 +4,9 @@ Kanboard.Board = (function() {
function on_popover(e)
{
+ e.preventDefault();
+ e.stopPropagation();
+
Kanboard.Popover(e, Kanboard.InitAfterAjax);
}
@@ -12,10 +15,82 @@ Kanboard.Board = (function() {
Mousetrap.bind("n", function() {
Kanboard.OpenPopover(
- $(".task-creation-popover").attr('href'),
+ $("#board").data("task-creation-url"),
Kanboard.InitAfterAjax
);
});
+
+ Mousetrap.bind("s", function() {
+ stack_toggle();
+ });
+ }
+
+ // Collapse/Expand tasks
+ function stack_load_events()
+ {
+ $(".filter-expand-link").click(function(e) {
+ e.preventDefault();
+ stack_expand();
+ Kanboard.SetStorageItem(stack_key(), "expanded");
+ });
+
+ $(".filter-collapse-link").click(function(e) {
+ e.preventDefault();
+ stack_collapse();
+ Kanboard.SetStorageItem(stack_key(), "collapsed");
+ });
+
+ stack_show();
+ }
+
+ function stack_key()
+ {
+ var projectId = $('#board').data('project-id');
+ return "board_stacking_" + projectId;
+ }
+
+ function stack_collapse()
+ {
+ $(".filter-collapse").hide();
+ $(".task-board-collapsed").show();
+
+ $(".filter-expand").show();
+ $(".task-board-expanded").hide();
+ }
+
+ function stack_expand()
+ {
+ $(".filter-collapse").show();
+ $(".task-board-collapsed").hide();
+
+ $(".filter-expand").hide();
+ $(".task-board-expanded").show();
+ }
+
+ function stack_toggle()
+ {
+ var state = Kanboard.GetStorageItem(stack_key()) || "expanded";
+
+ if (state === "expanded") {
+ stack_collapse();
+ Kanboard.SetStorageItem(stack_key(), "collapsed");
+ }
+ else {
+ stack_expand();
+ Kanboard.SetStorageItem(stack_key(), "expanded");
+ }
+ }
+
+ function stack_show()
+ {
+ var state = Kanboard.GetStorageItem(stack_key()) || "expanded";
+
+ if (state === "expanded") {
+ stack_expand();
+ }
+ else {
+ stack_collapse();
+ }
}
// Setup the board
@@ -37,18 +112,13 @@ Kanboard.Board = (function() {
}
});
- // Assignee change
- $(".assignee-popover").click(on_popover);
-
- // Category change
- $(".category-popover").click(on_popover);
+ // Task popover
+ $("#board").on("click", ".task-board-popover", on_popover);
- // Task edit popover
- $(".task-edit-popover").click(on_popover);
- $(".task-creation-popover").click(on_popover);
-
- // Description popover
- $(".task-description-popover").click(on_popover);
+ // Redirect to the task details page
+ $("#board").on("click", ".task-board", function() {
+ window.location = $(this).data("task-url");
+ });
// Tooltips for tasks
$(".task-board-tooltip").tooltip({
@@ -133,13 +203,6 @@ Kanboard.Board = (function() {
}, 100);
});
- // Redirect to the task details page
- $("[data-task-url]").each(function() {
- $(this).click(function() {
- window.location = $(this).attr("data-task-url");
- });
- });
-
// Automatic refresh
var interval = parseInt($("#board").attr("data-check-interval"));
@@ -151,7 +214,6 @@ Kanboard.Board = (function() {
// Stop events
function board_unload_events()
{
- $("[data-task-url]").off();
clearInterval(checkInterval);
}
@@ -178,6 +240,7 @@ Kanboard.Board = (function() {
Kanboard.InitAfterAjax();
board_load_events();
filter_apply();
+ stack_show();
}
});
}
@@ -197,6 +260,7 @@ Kanboard.Board = (function() {
board_unload_events();
board_load_events();
filter_apply();
+ stack_show();
}
}
});
@@ -232,7 +296,7 @@ Kanboard.Board = (function() {
item.style.opacity = "0.2";
}
});
-
+
// Save filter settings
Kanboard.SetStorageItem("board_filter_" + projectId + "_form-user_id", selectedUserId);
Kanboard.SetStorageItem("board_filter_" + projectId + "_form-category_id", selectedCategoryId);
@@ -251,17 +315,17 @@ Kanboard.Board = (function() {
filter_apply();
e.preventDefault();
});
-
+
// Get and set filters from localStorage
$("#form-user_id").val(Kanboard.GetStorageItem("board_filter_" + projectId + "_form-user_id") || -1);
$("#form-category_id").val(Kanboard.GetStorageItem("board_filter_" + projectId + "_form-category_id") || -1);
-
+
if (+Kanboard.GetStorageItem("board_filter_" + projectId + "_filter-due-date")) {
$("#filter-due-date").addClass("filter-on");
} else {
$("#filter-due-date").removeClass("filter-on");
}
-
+
filter_apply();
}
@@ -270,6 +334,7 @@ Kanboard.Board = (function() {
if (Kanboard.Exists("board")) {
board_load_events();
filter_load_events();
+ stack_load_events();
keyboard_shortcuts();
}
});