diff --git a/src/webui/www/private/css/dynamicTable.css b/src/webui/www/private/css/dynamicTable.css index bf79be70a..1eb7888b7 100644 --- a/src/webui/www/private/css/dynamicTable.css +++ b/src/webui/www/private/css/dynamicTable.css @@ -6,9 +6,7 @@ v 0.4 **************************************************************/ - -.dynamicTable tbody tr:nth-child(even), -.dynamicTable tbody tr.alt { +.altRowColors tbody tr:nth-child(odd of :not(.invisible)) { background-color: var(--color-background-default); } @@ -16,12 +14,12 @@ padding: 4px 2px; } -.dynamicTable tbody tr.selected { +.dynamicTableDiv table.dynamicTable tbody tr.selected { background-color: var(--color-background-blue); color: var(--color-text-white); } -.dynamicTable tbody tr:hover { +.dynamicTableDiv table.dynamicTable tbody tr:hover { background-color: var(--color-background-hover); color: var(--color-text-white); } diff --git a/src/webui/www/private/rename_files.html b/src/webui/www/private/rename_files.html index 1e23675ec..8b03d5c16 100644 --- a/src/webui/www/private/rename_files.html +++ b/src/webui/www/private/rename_files.html @@ -380,7 +380,6 @@ bulkRenameFilesTable.populateTable(rootNode); bulkRenameFilesTable.updateTable(false); - bulkRenameFilesTable.altRow(); if (selectedRows !== undefined) bulkRenameFilesTable.reselectRows(selectedRows); diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 548550819..87bebda72 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -845,7 +845,6 @@ window.addEventListener("DOMContentLoaded", () => { }); } torrentsTable.updateTable(full_update); - torrentsTable.altRow(); if (response["server_state"]) { const tmp = response["server_state"]; for (const k in tmp) { diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 532efbf09..e3bab83f1 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -88,6 +88,7 @@ window.qBittorrent.DynamicTable ??= (() => { this.setupHeaderEvents(); this.setupHeaderMenu(); this.setSortedColumnIcon(this.sortedColumn, null, (this.reverseSort === "1")); + this.setupAltRow(); }, setupCommonEvents: function() { @@ -555,17 +556,10 @@ window.qBittorrent.DynamicTable ??= (() => { return this.selectedRows.contains(rowId); }, - altRow: function() { - if (!MUI.ieLegacySupport) - return; - - const trs = this.tableBody.getElements("tr"); - trs.each((el, i) => { - if (i % 2) - el.addClass("alt"); - else - el.removeClass("alt"); - }); + setupAltRow: function() { + const useAltRowColors = (LocalPreferences.get("use_alt_row_colors", "true") === "true"); + if (useAltRowColors) + document.getElementById(this.dynamicTableDivId).classList.add("altRowColors"); }, selectAll: function() { @@ -2134,25 +2128,6 @@ window.qBittorrent.DynamicTable ??= (() => { this.updateGlobalCheckbox(); }, - altRow: function() { - let addClass = false; - const trs = this.tableBody.getElements("tr"); - trs.each((tr) => { - if (tr.hasClass("invisible")) - return; - - if (addClass) { - tr.addClass("alt"); - tr.removeClass("nonAlt"); - } - else { - tr.removeClass("alt"); - tr.addClass("nonAlt"); - } - addClass = !addClass; - }); - }, - _sortNodesByColumn: function(nodes, column) { nodes.sort((row1, row2) => { // list folders before files when sorting by name @@ -2483,25 +2458,6 @@ window.qBittorrent.DynamicTable ??= (() => { this.columns["availability"].updateTd = displayPercentage; }, - altRow: function() { - let addClass = false; - const trs = this.tableBody.getElements("tr"); - trs.each((tr) => { - if (tr.hasClass("invisible")) - return; - - if (addClass) { - tr.addClass("alt"); - tr.removeClass("nonAlt"); - } - else { - tr.removeClass("alt"); - tr.addClass("nonAlt"); - } - addClass = !addClass; - }); - }, - _sortNodesByColumn: function(nodes, column) { nodes.sort((row1, row2) => { // list folders before files when sorting by name diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js index f396f0545..b2da0bec7 100644 --- a/src/webui/www/private/scripts/prop-files.js +++ b/src/webui/www/private/scripts/prop-files.js @@ -477,7 +477,6 @@ window.qBittorrent.PropFiles ??= (() => { torrentFilesTable.populateTable(rootNode); torrentFilesTable.updateTable(false); - torrentFilesTable.altRow(); if (selectedFiles.length > 0) torrentFilesTable.reselectRows(selectedFiles); @@ -706,12 +705,10 @@ window.qBittorrent.PropFiles ??= (() => { const expandNode = function(node) { _collapseNode(node, false, false, false); - torrentFilesTable.altRow(); }; const collapseNode = function(node) { _collapseNode(node, true, false, false); - torrentFilesTable.altRow(); }; const expandAllNodes = function() { @@ -721,7 +718,6 @@ window.qBittorrent.PropFiles ??= (() => { _collapseNode(child, false, true, false); }); }); - torrentFilesTable.altRow(); }; const collapseAllNodes = function() { @@ -731,7 +727,6 @@ window.qBittorrent.PropFiles ??= (() => { _collapseNode(child, true, true, false); }); }); - torrentFilesTable.altRow(); }; /** diff --git a/src/webui/www/private/scripts/prop-peers.js b/src/webui/www/private/scripts/prop-peers.js index aed2ea9a8..2a6b2f057 100644 --- a/src/webui/www/private/scripts/prop-peers.js +++ b/src/webui/www/private/scripts/prop-peers.js @@ -90,7 +90,6 @@ window.qBittorrent.PropPeers ??= (() => { }); } torrentPeersTable.updateTable(full_update); - torrentPeersTable.altRow(); if (response["show_flags"]) { if (show_flags !== response["show_flags"]) { diff --git a/src/webui/www/private/scripts/prop-trackers.js b/src/webui/www/private/scripts/prop-trackers.js index c88cae879..bf7c903ed 100644 --- a/src/webui/www/private/scripts/prop-trackers.js +++ b/src/webui/www/private/scripts/prop-trackers.js @@ -108,7 +108,6 @@ window.qBittorrent.PropTrackers ??= (() => { }); torrentTrackersTable.updateTable(false); - torrentTrackersTable.altRow(); if (selectedTrackers.length > 0) torrentTrackersTable.reselectRows(selectedTrackers); diff --git a/src/webui/www/private/scripts/search.js b/src/webui/www/private/scripts/search.js index 72b447b49..222481526 100644 --- a/src/webui/www/private/scripts/search.js +++ b/src/webui/www/private/scripts/search.js @@ -343,7 +343,6 @@ window.qBittorrent.Search ??= (() => { // must restore all filters before calling updateTable searchResultsTable.updateTable(); - searchResultsTable.altRow(); // must reselect rows after calling updateTable if (rowsToSelect.length > 0) @@ -825,7 +824,6 @@ window.qBittorrent.Search ??= (() => { $("numSearchResultsTotal").textContent = searchResultsTable.getRowIds().length; searchResultsTable.updateTable(); - searchResultsTable.altRow(); } setupSearchTableEvents(true); diff --git a/src/webui/www/private/views/log.html b/src/webui/www/private/views/log.html index f77d7b751..d5ced4281 100644 --- a/src/webui/www/private/views/log.html +++ b/src/webui/www/private/views/log.html @@ -405,7 +405,6 @@ } tableInfo[curTab].instance.updateTable(); - tableInfo[curTab].instance.altRow(); updateLabelCount(curTab); } diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index f795ee8f1..30bb87c2b 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -8,29 +8,36 @@