Fix to close modal & reply input

This commit is contained in:
Thomas Mathews 2023-01-09 11:53:30 -08:00
parent c536582889
commit fa36bb72aa
3 changed files with 14 additions and 13 deletions

View file

@ -257,18 +257,16 @@
<div id="reply-modal-content" class="modal-content"> <div id="reply-modal-content" class="modal-content">
<header> <header>
<label>Reply To</label> <label>Reply To</label>
<button class="icon" onclick="close_reply()"> <button class="icon" onclick="close_modal(this)">
<img class="icon svg" src="icon/close-modal.svg"/> <img class="icon svg" src="icon/close-modal.svg"/>
</button> </button>
</header> </header>
<div id="replying-to"></div> <div id="replying-to"></div>
<div id="replybox"> <div id="replybox">
<textarea id="reply-content" class="post-input" oninput="post_input_changed(this)" <textarea id="reply-content" class="post-input"
placeholder="Write your reply here..."></textarea> placeholder="Reply..."></textarea>
<div class="post-tools"> <div class="post-tools">
<button id="reply-button" class="action" onclick="do_send_reply()"> <button id="reply-button" class="action">Reply</button>
Reply
</button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -488,6 +488,14 @@ function init_postbox(model) {
find_node("button[role='send']").addEventListener("click", onclick_send); find_node("button[role='send']").addEventListener("click", onclick_send);
find_node("button[role='toggle-cw']") find_node("button[role='toggle-cw']")
.addEventListener("click", onclick_toggle_cw); .addEventListener("click", onclick_toggle_cw);
// Do reply box
// TODO refactor & cleanup reply modal init
find_node("#reply-content").addEventListener("input", oninput_post);
find_node("#reply-button").addEventListener("click", onclick_reply);
}
async function onclick_reply(ev) {
// Temp method
do_send_reply();
} }
async function onclick_send(ev) { async function onclick_send(ev) {
const el = view_get_timeline_el(); const el = view_get_timeline_el();

View file

@ -77,11 +77,6 @@ function close_media_preview() {
find_node("#media-preview").classList.add("closed"); find_node("#media-preview").classList.add("closed");
} }
function close_reply() {
const modal = document.querySelector("#reply-modal")
modal.classList.add("closed");
}
function delete_post_confirm(evid) { function delete_post_confirm(evid) {
if (!confirm("Are you sure you want to delete this post?")) if (!confirm("Are you sure you want to delete this post?"))
return; return;
@ -100,7 +95,7 @@ async function do_send_reply() {
const content = reply_content_el.value; const content = reply_content_el.value;
await send_reply(content, evid, all); await send_reply(content, evid, all);
reply_content_el.value = ""; reply_content_el.value = "";
close_reply(); close_modal(modal);
} }
function reply(evid, all=false) { function reply(evid, all=false) {
@ -204,7 +199,7 @@ function open_faqs() {
} }
function close_modal(el) { function close_modal(el) {
while (el.parentElement) { while (el) {
if (el.classList.contains("modal")) { if (el.classList.contains("modal")) {
el.classList.add("closed"); el.classList.add("closed");
break; break;