WebUI: fix window can not close regression

Fix up 1cd3c586c1.
Fix up e1bd1038c0.

PR #21919.
This commit is contained in:
Chocobo1 2024-11-29 23:59:58 +08:00 committed by GitHub
parent 90aecfea02
commit e8d8de8f19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 25 deletions

View file

@ -15,11 +15,11 @@
"use strict"; "use strict";
(() => { (() => {
if (window.parent.qBittorrent !== undefined) const {
window.qBittorrent = window.parent.qBittorrent; options: { data },
window.qBittorrent = window.parent.qBittorrent; windowEl
} = window.MUI.Windows.instances["multiRenamePage"];
const data = window.MUI.Windows.instances["multiRenamePage"].options.data;
const bulkRenameFilesContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({ const bulkRenameFilesContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
targets: "#bulkRenameFilesTableDiv tr", targets: "#bulkRenameFilesTableDiv tr",
menu: "multiRenameFilesMenu", menu: "multiRenameFilesMenu",
@ -65,11 +65,11 @@
defaultEventType: "keydown", defaultEventType: "keydown",
events: { events: {
"Escape": function(event) { "Escape": function(event) {
window.parent.qBittorrent.Client.closeFrameWindow(window); window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault(); event.preventDefault();
}, },
"Esc": function(event) { "Esc": function(event) {
window.parent.qBittorrent.Client.closeFrameWindow(window); window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault(); event.preventDefault();
} }
} }
@ -284,9 +284,9 @@
LocalPreferences.set("multirename_replaceAll", fileRenamer.replaceAll); LocalPreferences.set("multirename_replaceAll", fileRenamer.replaceAll);
$("renameButton").value = replaceOperation; $("renameButton").value = replaceOperation;
}); });
$("closeButton").addEventListener("click", () => { $("closeButton").addEventListener("click", (event) => {
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault(); event.preventDefault();
window.qBittorrent.Client.closeWindow(windowEl);
}); });
// synchronize header scrolling to table body // synchronize header scrolling to table body
$("bulkRenameFilesTableDiv").onscroll = function() { $("bulkRenameFilesTableDiv").onscroll = function() {

View file

@ -18,13 +18,13 @@
const confirmText = document.getElementById("confirmAutoTmmMessage"); const confirmText = document.getElementById("confirmAutoTmmMessage");
const { const {
options: { data: { hashes, enable }, id }, options: { data: { hashes, enable } },
windowEl windowEl
} = window.MUI.Windows.instances["confirmAutoTMMDialog"]; } = window.MUI.Windows.instances["confirmAutoTMMDialog"];
confirmText.textContent = "QBT_TR(Are you sure you want to enable Automatic Torrent Management for the selected torrent(s)? They may be relocated.)QBT_TR[CONTEXT=confirmAutoTMMDialog]"; confirmText.textContent = "QBT_TR(Are you sure you want to enable Automatic Torrent Management for the selected torrent(s)? They may be relocated.)QBT_TR[CONTEXT=confirmAutoTMMDialog]";
cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow(id); }); cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow(windowEl); });
confirmButton.addEventListener("click", (e) => { confirmButton.addEventListener("click", (e) => {
new Request({ new Request({
url: "api/v2/torrents/setAutoManagement", url: "api/v2/torrents/setAutoManagement",
@ -35,7 +35,7 @@
}, },
onSuccess: () => { onSuccess: () => {
updateMainData(); updateMainData();
window.qBittorrent.Client.closeWindow(id); window.qBittorrent.Client.closeWindow(windowEl);
}, },
onFailure: () => { onFailure: () => {
alert("QBT_TR(Unable to set Auto Torrent Management for the selected torrents.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Unable to set Auto Torrent Management for the selected torrents.)QBT_TR[CONTEXT=HttpServer]");
@ -52,7 +52,7 @@
confirmButton.click(); confirmButton.click();
break; break;
case "Escape": case "Escape":
window.qBittorrent.Client.closeWindow(id); window.qBittorrent.Client.closeWindow(windowEl);
break; break;
} }
}); });

View file

@ -69,7 +69,7 @@
}); });
cancelButton.focus(); cancelButton.focus();
cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow("confirmDeletionPage"); }); cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow(document.getElementById("confirmDeletionPage")); });
confirmButton.addEventListener("click", (e) => { confirmButton.addEventListener("click", (e) => {
// Some torrents might be removed when waiting for user input, so refetch the torrent list // Some torrents might be removed when waiting for user input, so refetch the torrent list
@ -88,7 +88,7 @@
torrentsTable.deselectAll(); torrentsTable.deselectAll();
updateMainData(); updateMainData();
updatePropertiesPanel(); updatePropertiesPanel();
window.qBittorrent.Client.closeWindow("confirmDeletionPage"); window.qBittorrent.Client.closeWindow(document.getElementById("confirmDeletionPage"));
}, },
onFailure: () => { onFailure: () => {
alert("QBT_TR(Unable to delete torrents.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Unable to delete torrents.)QBT_TR[CONTEXT=HttpServer]");

View file

@ -19,7 +19,7 @@
<div> <div>
<input type="text" id="newPluginPath" placeholder="QBT_TR(URL or local directory)QBT_TR[CONTEXT=PluginSourceDlg]" autocorrect="off" autocapitalize="none"> <input type="text" id="newPluginPath" placeholder="QBT_TR(URL or local directory)QBT_TR[CONTEXT=PluginSourceDlg]" autocorrect="off" autocapitalize="none">
<div style="margin-top: 10px; text-align: center;"> <div style="margin-top: 10px; text-align: center;">
<button type="button" id="newPluginCancel" onclick="qBittorrent.SearchPlugins.closeSearchWindow('installSearchPlugin');">QBT_TR(Cancel)QBT_TR[CONTEXT=PluginSourceDlg]</button> <button type="button" id="newPluginCancel" onclick="window.qBittorrent.Client.closeWindow(document.getElementById('installSearchPlugin'));">QBT_TR(Cancel)QBT_TR[CONTEXT=PluginSourceDlg]</button>
<button type="button" id="newPluginOk" onclick="qBittorrent.InstallSearchPlugin.newPluginOk();">QBT_TR(Ok)QBT_TR[CONTEXT=PluginSourceDlg]</button> <button type="button" id="newPluginOk" onclick="qBittorrent.InstallSearchPlugin.newPluginOk();">QBT_TR(Ok)QBT_TR[CONTEXT=PluginSourceDlg]</button>
</div> </div>
</div> </div>
@ -50,7 +50,7 @@
if ((elem.id === "newPluginPath") || (elem.id === "newPluginOk")) if ((elem.id === "newPluginPath") || (elem.id === "newPluginOk"))
newPluginOk(); newPluginOk();
else if (elem.id === "newPluginCancel") else if (elem.id === "newPluginCancel")
window.qBittorrent.SearchPlugins.closeSearchWindow("installSearchPlugin"); window.qBittorrent.Client.closeWindow(document.getElementById("installSearchPlugin"));
} }
} }
}).activate(); }).activate();
@ -68,7 +68,7 @@
sources: path, sources: path,
}, },
onRequest: () => { onRequest: () => {
window.qBittorrent.SearchPlugins.closeSearchWindow("installSearchPlugin"); window.qBittorrent.Client.closeWindow(document.getElementById("installSearchPlugin"));
} }
}).send(); }).send();
} }

View file

@ -3043,12 +3043,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
data: settings, data: settings,
onFailure: () => { onFailure: () => {
alert("QBT_TR(Unable to save program preferences, qBittorrent is probably unreachable.)QBT_TR[CONTEXT=HttpServer]"); alert("QBT_TR(Unable to save program preferences, qBittorrent is probably unreachable.)QBT_TR[CONTEXT=HttpServer]");
window.parent.qBittorrent.Client.closeWindow("preferencesPage"); window.parent.qBittorrent.Client.closeWindow(document.getElementById("preferencesPage"));
}, },
onSuccess: () => { onSuccess: () => {
// Close window // Close window
window.parent.location.reload(); window.parent.location.reload();
window.parent.qBittorrent.Client.closeWindow("preferencesPage"); window.parent.qBittorrent.Client.closeWindow(document.getElementById("preferencesPage"));
} }
}); });
}; };

View file

@ -63,7 +63,7 @@
<div style="width: 100%; margin-top: 10px;"> <div style="width: 100%; margin-top: 10px;">
<button type="button" style="width: 33%; line-height: 1.4em;" onclick="qBittorrent.SearchPlugins.installPlugin();">QBT_TR(Install new plugin)QBT_TR[CONTEXT=PluginSelectDlg]</button> <button type="button" style="width: 33%; line-height: 1.4em;" onclick="qBittorrent.SearchPlugins.installPlugin();">QBT_TR(Install new plugin)QBT_TR[CONTEXT=PluginSelectDlg]</button>
<button type="button" style="width: 33%; line-height: 1.4em;" onclick="qBittorrent.SearchPlugins.checkForUpdates();">QBT_TR(Check for updates)QBT_TR[CONTEXT=PluginSelectDlg]</button> <button type="button" style="width: 33%; line-height: 1.4em;" onclick="qBittorrent.SearchPlugins.checkForUpdates();">QBT_TR(Check for updates)QBT_TR[CONTEXT=PluginSelectDlg]</button>
<button type="button" style="width: 32%; line-height: 1.4em;" onclick="qBittorrent.SearchPlugins.closeSearchWindow('searchPlugins');">QBT_TR(Close)QBT_TR[CONTEXT=PluginSelectDlg]</button> <button type="button" style="width: 32%; line-height: 1.4em;" onclick="window.qBittorrent.Client.closeWindow(document.getElementById('searchPlugins'));">QBT_TR(Close)QBT_TR[CONTEXT=PluginSelectDlg]</button>
</div> </div>
</div> </div>
@ -79,7 +79,6 @@
window.qBittorrent.SearchPlugins ??= (() => { window.qBittorrent.SearchPlugins ??= (() => {
const exports = () => { const exports = () => {
return { return {
closeSearchWindow: closeSearchWindow,
setup: setup, setup: setup,
installPlugin: installPlugin, installPlugin: installPlugin,
checkForUpdates: checkForUpdates, checkForUpdates: checkForUpdates,
@ -113,10 +112,6 @@
updateTable(); updateTable();
}; };
const closeSearchWindow = (id) => {
window.parent.qBittorrent.Client.closeWindow(window.parent.$(id));
};
const installPlugin = (path) => { const installPlugin = (path) => {
new MochaUI.Window({ new MochaUI.Window({
id: "installSearchPlugin", id: "installSearchPlugin",