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>
39 lines
1.1 KiB
JavaScript
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();
|
|
}
|