diff --git a/board/static/board/ban.js b/board/static/board/ban.js deleted file mode 100644 index 8cd516e..0000000 --- a/board/static/board/ban.js +++ /dev/null @@ -1,46 +0,0 @@ -// 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.setPosition( - window.innerWidth, - window.innerHeight / 2, - "RIGHT_CENTER" - ); - $(banWindow.iframe, "iframe").on("load", () => { - banWindow.iframe.contentWindow.thisWindow = banWindow; - }); - banWindow.show(); -} diff --git a/board/static/board/modify.js b/board/static/board/modify.js deleted file mode 100644 index 8d3246c..0000000 --- a/board/static/board/modify.js +++ /dev/null @@ -1,40 +0,0 @@ -if (typeof window.menuItemFactories !== "undefined") { - window.menuItemFactories.push( - (postElement) => $("") - .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.iframe.contentWindow.thisWindow = modifyWindow; - }); - modifyWindow.show(); -} \ No newline at end of file diff --git a/board/static/board/restricted.js b/board/static/board/restricted.js new file mode 100644 index 0000000..7322713 --- /dev/null +++ b/board/static/board/restricted.js @@ -0,0 +1,91 @@ +//////////////////////////////////////////////////////////////////////////////// +// Constants +//////////////////////////////////////////////////////////////////////////////// + +// 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"; + window.modifyWindowName = "modify-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")); + }) + ); + window.menuItemFactories.push( + (postElement) => $("") + .text("Modify post") + .attr("href", "#") + .on("click", (e) => { + e.preventDefault(); + openModifyWindow($(postElement).attr("data-modify-url")); + }) + ); +} + +//////////////////////////////////////////////////////////////////////////////// +// Ban window +//////////////////////////////////////////////////////////////////////////////// + +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.setPosition( + window.innerWidth, + window.innerHeight / 2, + "RIGHT_CENTER" + ); + $(banWindow.iframe, "iframe").on("load", () => { + banWindow.iframe.contentWindow.thisWindow = banWindow; + }); + banWindow.show(); +} + +//////////////////////////////////////////////////////////////////////////////// +// 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.iframe.contentWindow.thisWindow = modifyWindow; + }); + modifyWindow.show(); +} \ No newline at end of file diff --git a/board/templates/admin/board/reportrecord/change_list.html b/board/templates/admin/board/reportrecord/change_list.html index 7dac6a8..fd30830 100644 --- a/board/templates/admin/board/reportrecord/change_list.html +++ b/board/templates/admin/board/reportrecord/change_list.html @@ -17,7 +17,7 @@ - + {% endblock extrahead %} {% block footer %} diff --git a/board/templates/board/base.html b/board/templates/board/base.html index 6df7da1..5e50f0f 100644 --- a/board/templates/board/base.html +++ b/board/templates/board/base.html @@ -13,8 +13,7 @@ {% if user.is_staff %} - - + {% endif %} {% block extrajs %}{% endblock %}