WebUI: Always close one window

Closing all windows is overly broad and never the intention.

PR #21804.
This commit is contained in:
Thomas Piccirello 2024-11-16 04:12:35 -03:00 committed by GitHub
parent 0f12d077c8
commit 1cd3c586c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 70 additions and 70 deletions

View file

@ -16,11 +16,11 @@
defaultEventType: "keydown",
events: {
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -52,7 +52,7 @@
alert("QBT_TR(Unable to add peers. Please ensure you are adhering to the IP:port format.)QBT_TR[CONTEXT=HttpServer]");
},
onSuccess: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
});
@ -65,7 +65,7 @@
<label for="peers">QBT_TR(List of peers to add (one IP per line):)QBT_TR[CONTEXT=PeersAdditionDialog]</label>
<textarea id="peers" rows="10" style="width: 100%;" placeholder="QBT_TR(Format: IPv4:port / [IPv6]:port)QBT_TR[CONTEXT=PeersAdditionDialog]"></textarea>
<div style="margin-top: 10px; text-align: center;">
<button type="button" onclick="parent.qBittorrent.Client.closeWindows();">QBT_TR(Cancel)QBT_TR[CONTEXT=PeersAdditionDialog]</button>
<button type="button" onclick="parent.qBittorrent.Client.closeFrameWindow(window);">QBT_TR(Cancel)QBT_TR[CONTEXT=PeersAdditionDialog]</button>
<button type="button" id="addPeersOk">QBT_TR(Ok)QBT_TR[CONTEXT=PeersAdditionDialog]</button>
</div>
</div>

View file

@ -17,11 +17,11 @@
defaultEventType: "keydown",
events: {
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -41,7 +41,7 @@
urls: $("trackersUrls").value
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
});

View file

@ -17,11 +17,11 @@
defaultEventType: "keydown",
events: {
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -39,7 +39,7 @@
urls: $("urls").value.split("\n").map(w => encodeURIComponent(w.trim())).filter(w => (w.length > 0)).join("|")
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
});

View file

@ -18,7 +18,7 @@
$("cancelBtn").addEventListener("click", (e) => {
e.preventDefault();
e.stopPropagation();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
$("confirmBtn").addEventListener("click", (e) => {
e.preventDefault();
@ -36,7 +36,7 @@
++completionCount;
if (completionCount === paths.length) {
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}
}).send();

View file

@ -20,7 +20,7 @@
$("cancelBtn").focus();
$("cancelBtn").addEvent("click", (e) => {
e.stopPropagation();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
$("confirmBtn").addEvent("click", (e) => {
e.stopPropagation();
@ -33,7 +33,7 @@
urls: urls,
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
});

View file

@ -187,7 +187,7 @@
$("download_frame").addEventListener("load", () => {
if (submitted)
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
window.qBittorrent.pathAutofill.attachPathAutofill();

View file

@ -45,7 +45,7 @@
},
onComplete: () => {
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
}
@ -58,7 +58,7 @@
"limit": limit
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
}
@ -72,11 +72,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}

View file

@ -21,11 +21,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -52,7 +52,7 @@
newUrl: $("trackerUrl").value
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
});

View file

@ -21,11 +21,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -47,7 +47,7 @@
newUrl: encodeURIComponent($("url").value.trim()),
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
});

View file

@ -22,11 +22,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -94,7 +94,7 @@
},
onSuccess: () => {
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
},
onFailure: () => {
alert("QBT_TR(Unable to set category)QBT_TR[CONTEXT=Category]");
@ -120,7 +120,7 @@
},
onSuccess: () => {
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
},
onFailure: () => {
alert("QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category]");
@ -137,7 +137,7 @@
},
onSuccess: () => {
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
},
onFailure: () => {
alert("QBT_TR(Unable to edit category)QBT_TR[CONTEXT=Category]");

View file

@ -21,11 +21,11 @@
event.preventDefault();
},
"Escape": (event) => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": (event) => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -55,7 +55,7 @@
},
onSuccess: (response) => {
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
},
onFailure: (response) => {
if (response.status === 409)

View file

@ -22,11 +22,11 @@
event.preventDefault();
},
"Escape": (event) => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": (event) => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -55,7 +55,7 @@
},
onSuccess: (response) => {
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
},
onFailure: (response) => {
if (response.status === 409)

View file

@ -21,11 +21,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -69,7 +69,7 @@
tags: tagName,
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
break;
@ -85,7 +85,7 @@
tags: tagName,
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
break;

View file

@ -21,11 +21,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -57,7 +57,7 @@
name: name
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
}

View file

@ -21,11 +21,11 @@
event.preventDefault();
},
"Escape": (event) => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": (event) => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -64,7 +64,7 @@
},
onSuccess: (response) => {
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
},
onFailure: (response) => {
if (response.status === 409)

View file

@ -22,11 +22,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -74,7 +74,7 @@
newPath: newPath
},
onSuccess: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
},
onFailure: () => {
alert("QBT_TR(Failed to update name)QBT_TR[CONTEXT=HttpServer]");

View file

@ -65,11 +65,11 @@
defaultEventType: "keydown",
events: {
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -285,7 +285,7 @@
$("renameButton").value = replaceOperation;
});
$("closeButton").addEventListener("click", () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
});
// synchronize header scrolling to table body

View file

@ -30,7 +30,7 @@ window.qBittorrent.Client ??= (() => {
const exports = () => {
return {
closeWindow: closeWindow,
closeWindows: closeWindows,
closeFrameWindow: closeFrameWindow,
getSyncMainDataInterval: getSyncMainDataInterval,
isStopped: isStopped,
stop: stop,
@ -51,8 +51,8 @@ window.qBittorrent.Client ??= (() => {
MochaUI.closeWindow(window);
};
const closeWindows = () => {
MochaUI.closeAll();
const closeFrameWindow = (window) => {
closeWindow(window.frameElement.closest("div.mocha").id);
};
const getSyncMainDataInterval = () => {

View file

@ -21,11 +21,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -59,7 +59,7 @@
location: location
},
onSuccess: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
},
onFailure: (xhr) => {
$("error_div").textContent = xhr.response;

View file

@ -24,11 +24,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}
@ -115,7 +115,7 @@
inactiveSeedingTimeLimit: inactiveSeedingTimeLimitValue
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
});

View file

@ -172,7 +172,7 @@
$("upload_frame").addEventListener("load", () => {
if (submitted)
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
if ((Browser.platform === "ios") || ((Browser.platform === "mac") && (navigator.maxTouchPoints > 1)))

View file

@ -45,7 +45,7 @@
},
onComplete: () => {
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
}
@ -58,7 +58,7 @@
"limit": limit
},
onComplete: () => {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
}).send();
}
@ -72,11 +72,11 @@
event.preventDefault();
},
"Escape": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
},
"Esc": function(event) {
window.parent.qBittorrent.Client.closeWindows();
window.parent.qBittorrent.Client.closeFrameWindow(window);
event.preventDefault();
}
}

View file

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

View file

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