mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 22:33:34 -07:00
WebUI: Use classlist.toggle() whenever possible
This commit is contained in:
parent
8a494fbf95
commit
00d0725ce1
3 changed files with 9 additions and 33 deletions
|
@ -415,10 +415,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
|||
const show_seq_dl = (all_are_seq_dl || !there_are_seq_dl);
|
||||
const show_f_l_piece_prio = (all_are_f_l_piece_prio || !there_are_f_l_piece_prio);
|
||||
|
||||
if (!show_seq_dl && show_f_l_piece_prio)
|
||||
this.menu.getElement("a[href$=firstLastPiecePrio]").parentNode.classList.add("separator");
|
||||
else
|
||||
this.menu.getElement("a[href$=firstLastPiecePrio]").parentNode.classList.remove("separator");
|
||||
this.menu.getElement("a[href$=firstLastPiecePrio]").parentNode.classList.toggle("separator", !show_seq_dl && show_f_l_piece_prio);
|
||||
|
||||
if (show_seq_dl)
|
||||
this.showItem("sequentialDownload");
|
||||
|
|
|
@ -598,10 +598,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||
th.setAttribute("style", "width: " + this.columns[i].width + "px;" + this.columns[i].style);
|
||||
th.columnName = this.columns[i].name;
|
||||
th.classList.add("column_" + th.columnName);
|
||||
if ((this.columns[i].visible === "0") || this.columns[i].force_hide)
|
||||
th.classList.add("invisible");
|
||||
else
|
||||
th.classList.remove("invisible");
|
||||
th.classList.toggle("invisible", (this.columns[i].visible === "0") || this.columns[i].force_hide);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -676,10 +673,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||
const colElem = getCol(this.dynamicTableFixedHeaderDivId, newColumn);
|
||||
if (colElem !== null) {
|
||||
colElem.classList.add("sorted");
|
||||
if (isReverse)
|
||||
colElem.classList.add("reverse");
|
||||
else
|
||||
colElem.classList.remove("reverse");
|
||||
colElem.classList.toggle("reverse", isReverse);
|
||||
}
|
||||
const oldColElem = getCol(this.dynamicTableFixedHeaderDivId, oldColumn);
|
||||
if (oldColElem !== null) {
|
||||
|
@ -711,7 +705,6 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||
for (let i = 0; i < trs.length; ++i) {
|
||||
const tr = trs[i];
|
||||
this.selectedRows.push(tr.rowId);
|
||||
if (!tr.classList.contains("selected"))
|
||||
tr.classList.add("selected");
|
||||
}
|
||||
},
|
||||
|
@ -764,13 +757,8 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||
},
|
||||
|
||||
setRowClass: function() {
|
||||
const that = this;
|
||||
this.tableBody.getElements("tr").each((tr) => {
|
||||
if (that.isRowSelected(tr.rowId))
|
||||
tr.classList.add("selected");
|
||||
else
|
||||
tr.classList.remove("selected");
|
||||
});
|
||||
for (const tr of this.tableBody.querySelectorAll("tr"))
|
||||
tr.classList.toggle("selected", this.isRowSelected(tr.rowId));
|
||||
},
|
||||
|
||||
onSelectedRowChanged: () => {},
|
||||
|
@ -2987,10 +2975,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||
updateRow: function(tr, fullUpdate) {
|
||||
const row = this.rows.get(tr.rowId);
|
||||
const data = row[fullUpdate ? "full_data" : "data"];
|
||||
if (!row.full_data.isRead)
|
||||
tr.classList.add("unreadArticle");
|
||||
else
|
||||
tr.classList.remove("unreadArticle");
|
||||
tr.classList.toggle("unreadArticle", !row.full_data.isRead);
|
||||
|
||||
const tds = tr.getElements("td");
|
||||
for (let i = 0; i < this.columns.length; ++i) {
|
||||
|
|
|
@ -668,10 +668,7 @@ window.qBittorrent.PropFiles ??= (() => {
|
|||
if (span === null)
|
||||
return;
|
||||
const rowElem = span.parentElement.parentElement;
|
||||
if (shouldHide)
|
||||
rowElem.classList.add("invisible");
|
||||
else
|
||||
rowElem.classList.remove("invisible");
|
||||
rowElem.classList.toggle("invisible", shouldHide);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -689,10 +686,7 @@ window.qBittorrent.PropFiles ??= (() => {
|
|||
|
||||
// rotate the collapse icon
|
||||
const collapseIcon = td.getElementsByClassName("filesTableCollapseIcon")[0];
|
||||
if (isCollapsed)
|
||||
collapseIcon.classList.add("rotate");
|
||||
else
|
||||
collapseIcon.classList.remove("rotate");
|
||||
collapseIcon.classList.toggle("rotate", isCollapsed);
|
||||
};
|
||||
|
||||
const _isCollapsed = (node) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue