Move openBanWindow to its own separate file
It is now shared between the admin view and the inline view. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,25 +1,8 @@
|
||||
function openBanWindow(e, postElement) {
|
||||
e.preventDefault();
|
||||
let banUrl = $(postElement).attr("data-ban-url");
|
||||
if (window.top.banWindow) {
|
||||
window.top.banWindow.close();
|
||||
}
|
||||
window.top.banWindow = new WinBox("New ban", {
|
||||
url: banUrl,
|
||||
x: "center",
|
||||
y: "center",
|
||||
root: document.body,
|
||||
onclose: function (force) {
|
||||
window.top.banWindow = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof window.menuItemFactories !== "undefined") {
|
||||
window.menuItemFactories.push(
|
||||
(postElement) => $("<a>")
|
||||
.text("Ban")
|
||||
.attr("href", "#")
|
||||
.on("click", (e) => { return openBanWindow(e, postElement); })
|
||||
.on("click", (e) => { openBanWindow(e, $(postElement).attr("data-ban-url")); })
|
||||
)
|
||||
}
|
||||
18
board/static/board/ban_window.js
Normal file
18
board/static/board/ban_window.js
Normal file
@@ -0,0 +1,18 @@
|
||||
function openBanWindow(e, banUrl) {
|
||||
e.preventDefault();
|
||||
if (window.top.banWindow) {
|
||||
window.top.banWindow.close();
|
||||
}
|
||||
window.top.banWindow = new WinBox("New ban", {
|
||||
class: ["nobuttons"],
|
||||
url: banUrl,
|
||||
x: "center",
|
||||
y: "center",
|
||||
width: 475,
|
||||
height: 475,
|
||||
root: document.body,
|
||||
onclose: function (force) {
|
||||
window.top.banWindow = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -87,5 +87,5 @@ window.menuItemFactories.push(
|
||||
$("<a>")
|
||||
.text("Report")
|
||||
.attr("href", "#")
|
||||
.on("click", (e) => { return openReportWindow(e, postElement); })
|
||||
.on("click", (e) => { openReportWindow(e, postElement); })
|
||||
);
|
||||
@@ -32,13 +32,15 @@
|
||||
{{block.super}}
|
||||
<script src="{% static 'board/jquery.js' %}"></script>
|
||||
<script src="{% static 'board/winbox.bundle.js' %}"></script>
|
||||
<script src="{% static 'board/ban_window.js' %}"></script>
|
||||
{% endblock extrahead %}
|
||||
|
||||
{% block footer %}
|
||||
{{block.super}}
|
||||
<script>
|
||||
|
||||
function openBanWindow(e) {
|
||||
/*
|
||||
function openBanWindow(e, banUrl) {
|
||||
e.preventDefault();
|
||||
let banUrl = e.target.getAttribute("data-ban-url");
|
||||
if (window.banWindow) {
|
||||
@@ -55,12 +57,13 @@ function openBanWindow(e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
function onLoad(e) {
|
||||
window.banWindow = null;
|
||||
}
|
||||
|
||||
$(".ban_link").on("click", openBanWindow);
|
||||
$(".ban_link").on("click", (e) => { openBanWindow(e, $(e.target).attr("data-ban-url")); });
|
||||
$(window).on("load", onLoad);
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -12,6 +12,7 @@
|
||||
<script src="{% static 'board/winbox.bundle.js' %}"></script>
|
||||
<script src="{% static 'board/post.js' %}"></script>
|
||||
{% if perms.board.create_ban %}
|
||||
<script src="{% static 'board/ban_window.js' %}"></script>
|
||||
<script src="{% static 'board/ban_menu.js' %}"></script>
|
||||
{% endif %}
|
||||
{% block extrajs %}{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user