mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
parent
d73201c098
commit
87644441ad
2 changed files with 30 additions and 5 deletions
|
@ -86,6 +86,25 @@ window.qBittorrent.Search ??= (() => {
|
||||||
maxUnit: 3
|
maxUnit: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const searchResultsTabsContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
|
||||||
|
targets: ".searchTab",
|
||||||
|
menu: "searchResultsTabsMenu",
|
||||||
|
actions: {
|
||||||
|
closeTab: (tab) => { closeSearchTab(tab); },
|
||||||
|
closeAllTabs: () => {
|
||||||
|
for (const tab of document.querySelectorAll("#searchTabs .searchTab"))
|
||||||
|
closeSearchTab(tab);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
offsets: {
|
||||||
|
x: -15,
|
||||||
|
y: -53
|
||||||
|
},
|
||||||
|
onShow: function() {
|
||||||
|
setActiveTab(this.options.element);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const init = function() {
|
const init = function() {
|
||||||
// load "Search in" preference from local storage
|
// load "Search in" preference from local storage
|
||||||
$("searchInTorrentName").value = (LocalPreferences.get("search_in_filter") === "names") ? "names" : "everywhere";
|
$("searchInTorrentName").value = (LocalPreferences.get("search_in_filter") === "names") ? "names" : "everywhere";
|
||||||
|
@ -168,7 +187,7 @@ window.qBittorrent.Search ??= (() => {
|
||||||
width: "8",
|
width: "8",
|
||||||
height: "8",
|
height: "8",
|
||||||
style: "padding-right: 7px; margin-bottom: -1px; margin-left: -5px",
|
style: "padding-right: 7px; margin-bottom: -1px; margin-left: -5px",
|
||||||
onclick: "qBittorrent.Search.closeSearchTab(event, this);",
|
onclick: "qBittorrent.Search.closeSearchTab(this);",
|
||||||
});
|
});
|
||||||
closeTabElem.inject(tabElem, "top");
|
closeTabElem.inject(tabElem, "top");
|
||||||
|
|
||||||
|
@ -176,13 +195,14 @@ window.qBittorrent.Search ??= (() => {
|
||||||
|
|
||||||
const listItem = document.createElement("li");
|
const listItem = document.createElement("li");
|
||||||
listItem.id = newTabId;
|
listItem.id = newTabId;
|
||||||
listItem.classList.add("selected");
|
listItem.classList.add("selected", "searchTab");
|
||||||
listItem.addEventListener("click", (e) => {
|
listItem.addEventListener("click", (e) => {
|
||||||
setActiveTab(listItem);
|
setActiveTab(listItem);
|
||||||
document.getElementById("startSearchButton").lastChild.textContent = "QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]";
|
document.getElementById("startSearchButton").lastChild.textContent = "QBT_TR(Search)QBT_TR[CONTEXT=SearchEngineWidget]";
|
||||||
});
|
});
|
||||||
listItem.appendChild(tabElem);
|
listItem.appendChild(tabElem);
|
||||||
$("searchTabs").appendChild(listItem);
|
$("searchTabs").appendChild(listItem);
|
||||||
|
searchResultsTabsContextMenu.addTarget(listItem);
|
||||||
|
|
||||||
// unhide the results elements
|
// unhide the results elements
|
||||||
if (numSearchTabs() >= 1) {
|
if (numSearchTabs() >= 1) {
|
||||||
|
@ -214,10 +234,11 @@ window.qBittorrent.Search ??= (() => {
|
||||||
updateSearchResultsData(searchId);
|
updateSearchResultsData(searchId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeSearchTab = function(e, el) {
|
const closeSearchTab = function(el) {
|
||||||
e.stopPropagation();
|
const tab = el.closest("li.searchTab");
|
||||||
|
if (!tab)
|
||||||
|
return;
|
||||||
|
|
||||||
const tab = el.parentElement.parentElement;
|
|
||||||
const searchId = getSearchIdFromTab(tab);
|
const searchId = getSearchIdFromTab(tab);
|
||||||
const isTabSelected = tab.hasClass("selected");
|
const isTabSelected = tab.hasClass("selected");
|
||||||
const newTabToSelect = isTabSelected ? (tab.nextSibling || tab.previousSibling) : null;
|
const newTabToSelect = isTabSelected ? (tab.nextSibling || tab.previousSibling) : null;
|
||||||
|
|
|
@ -213,3 +213,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul id="searchResultsTabsMenu" class="contextMenu">
|
||||||
|
<li><a href="#closeTab">QBT_TR(Close tab)QBT_TR[CONTEXT=SearchJobWidget]</a></li>
|
||||||
|
<li><a href="#closeAllTabs">QBT_TR(Close all tabs)QBT_TR[CONTEXT=SearchJobWidget]</a></li>
|
||||||
|
</ul>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue