Add post modify view

This allows moderators to modify posts (add sticky, etc).

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-30 16:21:36 -07:00
parent 2947ab6cf2
commit 6f99472f16
13 changed files with 124 additions and 22 deletions

View File

@@ -4,6 +4,18 @@ 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);
}
@@ -20,4 +32,4 @@ function openBanWindow(banUrl) {
url: banUrl,
});
banWindow.show();
}
}

View File

@@ -1,11 +0,0 @@
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"));
})
)
}

View File

@@ -0,0 +1,36 @@
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,
height: 475,
url: modifyUrl,
});
modifyWindow.show();
}

View File

@@ -85,6 +85,10 @@ th {
clear: both;
}
.post_sticky {
font-weight: bold;
}
.post_id {
cursor: pointer;
}