diff --git a/board/static/board/ban.js b/board/static/board/ban.js index bce0260..7100d67 100644 --- a/board/static/board/ban.js +++ b/board/static/board/ban.js @@ -28,8 +28,11 @@ function openBanWindow(banUrl) { title: "New Ban", name: banWindowName, width: 475, - height: 475, url: banUrl, }); + $(banWindow.iframe, "iframe").on("load", () => { + fitWindowToContent(banWindow); + banWindow.setResizable(false); + }); banWindow.show(); } diff --git a/board/static/board/modify.js b/board/static/board/modify.js index 99991c2..9947a3b 100644 --- a/board/static/board/modify.js +++ b/board/static/board/modify.js @@ -29,8 +29,11 @@ function openModifyWindow(modifyUrl) { title: "Modifying post", name: modifyWindowName, width: 475, - height: 475, url: modifyUrl, }); + $(modifyWindow.iframe, "iframe").on("load", () => { + fitWindowToContent(modifyWindow); + modifyWindow.setResizable(false); + }); modifyWindow.show(); } \ No newline at end of file diff --git a/board/static/board/post.js b/board/static/board/post.js index 5749d2f..a19bd3e 100644 --- a/board/static/board/post.js +++ b/board/static/board/post.js @@ -3,6 +3,7 @@ const CLOSED = "closed"; const replyWindowName = "reply-window"; const postWindowName = "post-window"; const reportWindowName = "report-window" +const WINDOW_INNER_PADDING = 25; function documentClick(e) { let sender = e.target; @@ -53,6 +54,14 @@ function openMenu(e) { $(document).on("click", closeMenu); } +//////////////////////////////////////////////////////////////////////////////// +// Generic window functions +//////////////////////////////////////////////////////////////////////////////// +function fitWindowToContent(frame) { + let rect = frame.$("html").getBoundingClientRect(); + frame.setSize(rect.width, rect.bottom + WINDOW_INNER_PADDING) +} + //////////////////////////////////////////////////////////////////////////////// // Reply window //////////////////////////////////////////////////////////////////////////////// @@ -67,10 +76,13 @@ function openReplyWindow(replyUrl) { let replyWindow = window.top.jsFrame.create({ title: "New Reply", name: replyWindowName, - width: 385, - height: 350, + width: 500, url: replyUrl }); + $(replyWindow.iframe, "iframe").on("load", () => { + fitWindowToContent(replyWindow); + replyWindow.$("#id_text").focus(); + }); replyWindow.show(); return replyWindow; } @@ -114,10 +126,13 @@ function openPostWindow(postUrl) { let postWindow = window.top.jsFrame.create({ title: "New Thread", name: postWindowName, - width: 385, - height: 350, + width: 500, url: postUrl, }); + $(postWindow.iframe, "iframe").on("load", () => { + fitWindowToContent(postWindow); + postWindow.$("#id_text").focus(); + }); postWindow.show(); } @@ -141,9 +156,11 @@ function openReportWindow(reportUrl) { let reportWindow = window.top.jsFrame.create({ url: reportUrl, name: reportWindowName, - modal: true, width: 360, - height: 95, + }); + $(reportWindow.iframe, "iframe").on("load", () => { + fitWindowToContent(reportWindow); + reportWindow.setResizable(false); }); reportWindow.show(); } diff --git a/board/templates/board/post_create_view.html b/board/templates/board/post_create_view.html index a85e2aa..953722b 100644 --- a/board/templates/board/post_create_view.html +++ b/board/templates/board/post_create_view.html @@ -1,6 +1,30 @@ {% extends "board/base.html" %} {% load i18n post_body %} +{% block extrastyle %} + +{% endblock %} + {% block content %}