Move openBanWindow to its own separate file

It is now shared between the admin view and the inline view.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-23 22:58:31 -07:00
parent 4c5d8cee2a
commit 024f0c1290
5 changed files with 26 additions and 21 deletions

View File

@@ -1,25 +1,8 @@
function openBanWindow(e, postElement) {
e.preventDefault();
let banUrl = $(postElement).attr("data-ban-url");
if (window.top.banWindow) {
window.top.banWindow.close();
}
window.top.banWindow = new WinBox("New ban", {
url: banUrl,
x: "center",
y: "center",
root: document.body,
onclose: function (force) {
window.top.banWindow = null;
}
});
}
if (typeof window.menuItemFactories !== "undefined") {
window.menuItemFactories.push(
(postElement) => $("<a>")
.text("Ban")
.attr("href", "#")
.on("click", (e) => { return openBanWindow(e, postElement); })
.on("click", (e) => { openBanWindow(e, $(postElement).attr("data-ban-url")); })
)
}

View File

@@ -0,0 +1,18 @@
function openBanWindow(e, banUrl) {
e.preventDefault();
if (window.top.banWindow) {
window.top.banWindow.close();
}
window.top.banWindow = new WinBox("New ban", {
class: ["nobuttons"],
url: banUrl,
x: "center",
y: "center",
width: 475,
height: 475,
root: document.body,
onclose: function (force) {
window.top.banWindow = null;
}
});
}

View File

@@ -87,5 +87,5 @@ window.menuItemFactories.push(
$("<a>")
.text("Report")
.attr("href", "#")
.on("click", (e) => { return openReportWindow(e, postElement); })
.on("click", (e) => { openReportWindow(e, postElement); })
);