Add floating window for new threads

New threads get a floating window just like new replies have. This only
pops up on the board detail view.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-28 23:55:44 -07:00
parent 6ad2a72b86
commit 6c11d210e8
8 changed files with 151 additions and 58 deletions

View File

@@ -23,23 +23,9 @@
<div class="column">&nbsp;</div>
<div class="column">
<div class="row">
<h2>{% translate "Create a new thread" %}</h2>
</div>
<div class="row">
<form method="post" action="{% url 'board:board_detail' url=board.url %}" enctype="multipart/form-data">
{% csrf_token %}
<table>
{{ form.as_table }}
<tr>
<th>&nbsp;</th>
<td>
{% translate "Max image size" %}:
{{ max_upload_size|measure_bytes }}
</td>
</tr>
<tr><th>&nbsp;</th><td><input type="submit" value="Submit" /></td></tr>
</table>
</form>
<h2>
<a id="create_post" href="{% url 'board:post_create' url=board.url %}">{% translate "Create a new thread" %}</a>
</h2>
</div>
</div>
<div class="column">&nbsp;</div>
@@ -85,4 +71,12 @@
{% endwith %}
{% endif %}
</div>
<script>
const POST_URL = "{% url 'board:post_create' url=board.url %}";
$("#create_post").on("click", (e) => {
e.preventDefault();
openPostWindow(POST_URL);
});
</script>
{% endblock content %}

View File

@@ -0,0 +1,34 @@
{% extends "board/base.html" %}
{% load i18n post_body %}
{% block content %}
<form method="post" action="{% url 'board:post_create' url=board.url %}" enctype="multipart/form-data">
{% csrf_token %}
<table>
{% for field in form %}
{% if field.name != "capcode" %}
<tr>
<th>{{field.label_tag}}</th>
<td>{{field}}</td>
</tr>
{% endif %}
{% endfor %}
{% if capcodes %}
<tr>
<th>{{form.capcode.label_tag}}</th>
<td>
{{form.capcode}}
</td>
</tr>
{% endif %}
<tr>
<th>&nbsp;</th>
<td>
{% translate "Max image size" %}:
{{ max_upload_size|measure_bytes }}
</td>
</tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Submit" /></td></tr>
</table>
</form>
{% endblock content %}

View File

@@ -54,14 +54,7 @@ $("#create_reply").on("click", (e) => {
$(window).on("quote", (e, postId) => {
openReplyWindow(REPLY_URL);
let toAdd = ">>" + postId + "\n";
let textbox = replyTextbox();
if (typeof textbox === "undefined" || textbox.length === 0) {
$("iframe").on("load", () => {
replyAppend(toAdd);
});
} else {
replyAppend(toAdd);
}
replyAppend(toAdd);
});
</script>
{% endblock content %}

View File

@@ -15,16 +15,22 @@ function isIframe() {
}
}
setTimeout(function() {
if(isIframe()) {
// check for possible windows
let replyWindow = getReplyWindow();
if(replyWindow) {
replyWindow.closeFrame();
$(window).on("load", () => {
setTimeout(function() {
let params = new URLSearchParams(window.location.search);
let next = params.get("next");
let target = isIframe()
? window.top
: window;
if(next) {
target.location = next;
if(next.includes("#")) {
target.location.reload();
}
} else {
target.close();
}
} else {
window.close();
}
}, 1000 * {{window_timeout}});
}, 1000 * {{window_timeout}});
});
</script>
{% endblock content %}