// 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) => $("") .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(); }