Add post and image deletion
This one was kind of a doozy. This also adds a custom 403 error page and fixes some permission denied behavior that I was having issues with for a while. This is also set up in a way that hopefully will allow me to easily implement user post deletion. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -3,7 +3,8 @@ const OPEN = "open";
|
||||
const CLOSED = "closed";
|
||||
const replyWindowName = "reply-window";
|
||||
const postWindowName = "post-window";
|
||||
const reportWindowName = "report-window"
|
||||
const reportWindowName = "report-window";
|
||||
const deleteWindowName = "delete-window";
|
||||
const WINDOW_INNER_PADDING = 25;
|
||||
|
||||
|
||||
@@ -204,6 +205,31 @@ function openReportWindow(reportUrl) {
|
||||
reportWindow.show();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Post delete window
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
function getDeleteWindow() {
|
||||
return window.top.jsFrame.getWindowByName(deleteWindowName);
|
||||
}
|
||||
|
||||
function openDeleteWindow(deleteUrl) {
|
||||
if (window.top.jsFrame.containsWindowName(deleteWindowName)) {
|
||||
getDeleteWindow().closeFrame();
|
||||
}
|
||||
|
||||
let deleteWindow = window.top.jsFrame.create({
|
||||
title: "Deleting post",
|
||||
name: deleteWindowName,
|
||||
width: 475,
|
||||
url: deleteUrl,
|
||||
});
|
||||
$(deleteWindow.iframe, "iframe").on("load", () => {
|
||||
fitWindowToContent(deleteWindow);
|
||||
deleteWindow.setResizable(false);
|
||||
});
|
||||
deleteWindow.show();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Post hiding
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -365,4 +391,13 @@ window.menuItemFactories.push(
|
||||
addHiddenPost(id);
|
||||
}
|
||||
})
|
||||
);
|
||||
window.menuItemFactories.push(
|
||||
(postElement) => $("<a>")
|
||||
.text("Delete post")
|
||||
.attr("href", "#")
|
||||
.on("click", (e) => {
|
||||
e.preventDefault();
|
||||
openDeleteWindow($(postElement).attr("data-delete-url"));
|
||||
})
|
||||
);
|
||||
Reference in New Issue
Block a user