From 0c580c3174a7468fb9c92676a28d4f33cdb044f5 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 9 Aug 2024 17:21:01 +0800 Subject: [PATCH] WebUI: remove redundant events The base class already handle them. Also optimize the base implementation a bit. --- src/webui/www/private/scripts/dynamicTable.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index b8af2dacb..5c177bb1c 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -95,8 +95,9 @@ window.qBittorrent.DynamicTable ??= (() => { const tableDiv = $(this.dynamicTableDivId); const tableFixedHeaderDiv = $(this.dynamicTableFixedHeaderDivId); + const tableElement = tableFixedHeaderDiv.querySelector("table"); tableDiv.addEventListener("scroll", () => { - tableFixedHeaderDiv.getElements("table")[0].style.left = `${-tableDiv.scrollLeft}px`; + tableElement.style.left = `${-tableDiv.scrollLeft}px`; }); // if the table exists within a panel @@ -2764,13 +2765,6 @@ window.qBittorrent.DynamicTable ??= (() => { this.hiddenTableHeader.appendChild(new Element("th")); this.fixedTableHeader.appendChild(new Element("th")); - }, - setupCommonEvents: function() { - const scrollFn = function() { - $(this.dynamicTableFixedHeaderDivId).getElements("table")[0].style.left = -$(this.dynamicTableDivId).scrollLeft + "px"; - }.bind(this); - - $(this.dynamicTableDivId).addEventListener("scroll", scrollFn); } }); @@ -2859,13 +2853,6 @@ window.qBittorrent.DynamicTable ??= (() => { this.hiddenTableHeader.appendChild(new Element("th")); this.fixedTableHeader.appendChild(new Element("th")); - }, - setupCommonEvents: function() { - const scrollFn = function() { - $(this.dynamicTableFixedHeaderDivId).getElements("table")[0].style.left = -$(this.dynamicTableDivId).scrollLeft + "px"; - }.bind(this); - - $(this.dynamicTableDivId).addEventListener("scroll", scrollFn); } }); -- 2.11.4.GIT