From 32f29e72c6d9de55948b4d6db04442e24ca035bc Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Fri, 9 Jul 2021 22:38:56 -0700 Subject: [PATCH] Support expanding/collapsing Web UI folders with arrow keys --- src/webui/www/private/scripts/dynamicTable.js | 13 +++++++++++++ src/webui/www/private/scripts/prop-files.js | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 46d8a7b1f..742bdaa1e 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -2066,6 +2066,19 @@ window.qBittorrent.DynamicTable = (function() { row.full_data.remaining = 0; else row.full_data.remaining = (row.full_data.size * (1.0 - (row.full_data.progress / 100))); + }, + + setupTr: function(tr) { + tr.addEvent('keydown', function(event) { + switch (event.key) { + case "left": + qBittorrent.PropFiles.collapseFolder(this._this.getSelectedRowId()); + return false; + case "right": + qBittorrent.PropFiles.expandFolder(this._this.getSelectedRowId()); + return false; + } + }); } }); diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js index 9b8d67ec9..d66092ad2 100644 --- a/src/webui/www/private/scripts/prop-files.js +++ b/src/webui/www/private/scripts/prop-files.js @@ -43,7 +43,9 @@ window.qBittorrent.PropFiles = (function() { createPriorityCombo: createPriorityCombo, updatePriorityCombo: updatePriorityCombo, updateData: updateData, - collapseIconClicked: collapseIconClicked + collapseIconClicked: collapseIconClicked, + expandFolder: expandFolder, + collapseFolder: collapseFolder }; }; @@ -495,6 +497,20 @@ window.qBittorrent.PropFiles = (function() { collapseNode(node); }; + const expandFolder = function(id) { + const node = torrentFilesTable.getNode(id); + if (node.isFolder) { + expandNode(node); + } + }; + + const collapseFolder = function(id) { + const node = torrentFilesTable.getNode(id); + if (node.isFolder) { + collapseNode(node); + } + }; + const filesPriorityMenuClicked = function(priority) { const selectedRows = torrentFilesTable.selectedRowsIds(); if (selectedRows.length === 0) return;