Skip to content

Commit

Permalink
WebUI: fix window can not close regression
Browse files Browse the repository at this point in the history
Fix up 1cd3c58.
Fix up e1bd103.

PR #21919.
  • Loading branch information
Chocobo1 authored Nov 29, 2024
1 parent 90aecfe commit e8d8de8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
16 changes: 8 additions & 8 deletions src/webui/www/private/rename_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"use strict";

(() => {
if (window.parent.qBittorrent !== undefined)
window.qBittorrent = window.parent.qBittorrent;
window.qBittorrent = window.parent.qBittorrent;
const {
options: { data },
windowEl
} = window.MUI.Windows.instances["multiRenamePage"];

const data = window.MUI.Windows.instances["multiRenamePage"].options.data;
const bulkRenameFilesContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
targets: "#bulkRenameFilesTableDiv tr",
menu: "multiRenameFilesMenu",
Expand Down Expand Up @@ -65,11 +65,11 @@
defaultEventType: "keydown",
events: {
"Escape": function(event) {
window.parent.qBittorrent.Client.closeFrameWindow(window);
window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeFrameWindow(window);
window.qBittorrent.Client.closeWindow(windowEl);
event.preventDefault();
}
}
Expand Down Expand Up @@ -284,9 +284,9 @@
LocalPreferences.set("multirename_replaceAll", fileRenamer.replaceAll);
$("renameButton").value = replaceOperation;
});
$("closeButton").addEventListener("click", () => {
window.parent.qBittorrent.Client.closeFrameWindow(window);
$("closeButton").addEventListener("click", (event) => {
event.preventDefault();
window.qBittorrent.Client.closeWindow(windowEl);
});
// synchronize header scrolling to table body
$("bulkRenameFilesTableDiv").onscroll = function() {
Expand Down
8 changes: 4 additions & 4 deletions src/webui/www/private/views/confirmAutoTMM.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
const confirmText = document.getElementById("confirmAutoTmmMessage");

const {
options: { data: { hashes, enable }, id },
options: { data: { hashes, enable } },
windowEl
} = 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]";

cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow(id); });
cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow(windowEl); });
confirmButton.addEventListener("click", (e) => {
new Request({
url: "api/v2/torrents/setAutoManagement",
Expand All @@ -35,7 +35,7 @@
},
onSuccess: () => {
updateMainData();
window.qBittorrent.Client.closeWindow(id);
window.qBittorrent.Client.closeWindow(windowEl);
},
onFailure: () => {
alert("QBT_TR(Unable to set Auto Torrent Management for the selected torrents.)QBT_TR[CONTEXT=HttpServer]");
Expand All @@ -52,7 +52,7 @@
confirmButton.click();
break;
case "Escape":
window.qBittorrent.Client.closeWindow(id);
window.qBittorrent.Client.closeWindow(windowEl);
break;
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/views/confirmdeletion.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
});

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) => {
// Some torrents might be removed when waiting for user input, so refetch the torrent list
Expand All @@ -88,7 +88,7 @@
torrentsTable.deselectAll();
updateMainData();
updatePropertiesPanel();
window.qBittorrent.Client.closeWindow("confirmDeletionPage");
window.qBittorrent.Client.closeWindow(document.getElementById("confirmDeletionPage"));
},
onFailure: () => {
alert("QBT_TR(Unable to delete torrents.)QBT_TR[CONTEXT=HttpServer]");
Expand Down
6 changes: 3 additions & 3 deletions src/webui/www/private/views/installsearchplugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div>
<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;">
<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>
</div>
</div>
Expand Down Expand Up @@ -50,7 +50,7 @@
if ((elem.id === "newPluginPath") || (elem.id === "newPluginOk"))
newPluginOk();
else if (elem.id === "newPluginCancel")
window.qBittorrent.SearchPlugins.closeSearchWindow("installSearchPlugin");
window.qBittorrent.Client.closeWindow(document.getElementById("installSearchPlugin"));
}
}
}).activate();
Expand All @@ -68,7 +68,7 @@
sources: path,
},
onRequest: () => {
window.qBittorrent.SearchPlugins.closeSearchWindow("installSearchPlugin");
window.qBittorrent.Client.closeWindow(document.getElementById("installSearchPlugin"));
}
}).send();
}
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/views/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -3043,12 +3043,12 @@
data: settings,
onFailure: () => {
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: () => {
// Close window
window.parent.location.reload();
window.parent.qBittorrent.Client.closeWindow("preferencesPage");
window.parent.qBittorrent.Client.closeWindow(document.getElementById("preferencesPage"));
}
});
};
Expand Down
7 changes: 1 addition & 6 deletions src/webui/www/private/views/searchplugins.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h2>QBT_TR(Installed search plugins:)QBT_TR[CONTEXT=PluginSelectDlg]</h2>
<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.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>

Expand All @@ -79,7 +79,6 @@ <h2>QBT_TR(Installed search plugins:)QBT_TR[CONTEXT=PluginSelectDlg]</h2>
window.qBittorrent.SearchPlugins ??= (() => {
const exports = () => {
return {
closeSearchWindow: closeSearchWindow,
setup: setup,
installPlugin: installPlugin,
checkForUpdates: checkForUpdates,
Expand Down Expand Up @@ -113,10 +112,6 @@ <h2>QBT_TR(Installed search plugins:)QBT_TR[CONTEXT=PluginSelectDlg]</h2>
updateTable();
};

const closeSearchWindow = (id) => {
window.parent.qBittorrent.Client.closeWindow(window.parent.$(id));
};

const installPlugin = (path) => {
new MochaUI.Window({
id: "installSearchPlugin",
Expand Down

0 comments on commit e8d8de8

Please sign in to comment.