Files
interchan/board/static/board/modify.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

if (typeof window.menuItemFactories !== "undefined") {
window.menuItemFactories.push(
(postElement) => $("<a>")
.text("Modify post")
.attr("href", "#")
.on("click", (e) => {
e.preventDefault();
openModifyWindow($(postElement).attr("data-modify-url"));
})
);
}
// 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.modifyWindowName === "undefined") {
window.modifyWindowName = "modify-window";
}
function getModifyWindow() {
return window.top.jsFrame.getWindowByName(modifyWindowName);
}
function openModifyWindow(modifyUrl) {
if (window.top.jsFrame.containsWindowName(modifyWindowName)) {
getModifyWindow().closeFrame();
}
let modifyWindow = window.top.jsFrame.create({
title: "Modifying post",
name: modifyWindowName,
width: 475,
url: modifyUrl,
});
$(modifyWindow.iframe, "iframe").on("load", () => {
fitWindowToContent(modifyWindow);
modifyWindow.setResizable(false);
});
modifyWindow.show();
}