From 627d8aaa8c7669fe2c486049d3c1fba4a7f31e74 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 14 Feb 2015 22:53:12 -0500 Subject: Add keyboard shortcut to expand/collapse board tasks --- assets/js/src/board.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'assets/js/src') diff --git a/assets/js/src/board.js b/assets/js/src/board.js index 45b43794..ecf94b9c 100644 --- a/assets/js/src/board.js +++ b/assets/js/src/board.js @@ -16,6 +16,10 @@ Kanboard.Board = (function() { Kanboard.InitAfterAjax ); }); + + Mousetrap.bind("s", function() { + stack_toggle(); + }); } // Collapse/Expand tasks @@ -24,13 +28,13 @@ Kanboard.Board = (function() { $(".filter-expand-link").click(function(e) { e.preventDefault(); stack_expand(); - Kanboard.SetStorageItem(stack_key(), "expanded") + Kanboard.SetStorageItem(stack_key(), "expanded"); }); $(".filter-collapse-link").click(function(e) { e.preventDefault(); stack_collapse(); - Kanboard.SetStorageItem(stack_key(), "collapsed") + Kanboard.SetStorageItem(stack_key(), "collapsed"); }); stack_show(); @@ -60,6 +64,20 @@ Kanboard.Board = (function() { $(".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"; -- cgit v1.2.3