Files
interchan/board/static/board/ban.js
Alek Ratzloff b791cf6a6b Update various windows that open to have their height automatically set
Some windows have a variable height based on the user's permissions
(e.g. having a capcode option). This sets the window height to the
minimum requiremed height based on the document loaded in.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 20:37:19 -07:00

39 lines
1.1 KiB
JavaScript

// HACK: this should be a const, but it will cause an error if included twice in
// the same page (like an iframe).
if (typeof window.banWindowName === "undefined") {
window.banWindowName = "ban-window";
}
if (typeof window.menuItemFactories !== "undefined") {
window.menuItemFactories.push(
(postElement) => $("<a>")
.text("Ban")
.attr("href", "#")
.on("click", (e) => {
e.preventDefault();
openBanWindow($(postElement).attr("data-ban-url"));
})
);
}
function getBanWindow() {
return window.top.jsFrame.getWindowByName(banWindowName);
}
function openBanWindow(banUrl) {
if (window.top.jsFrame.containsWindowName(banWindowName)) {
getBanWindow().closeFrame();
}
let banWindow = window.top.jsFrame.create({
title: "New Ban",
name: banWindowName,
width: 475,
url: banUrl,
});
$(banWindow.iframe, "iframe").on("load", () => {
fitWindowToContent(banWindow);
banWindow.setResizable(false);
});
banWindow.show();
}