From 29a2bc01237bd9d0ec3f9a8bba1caf12ff2afb2e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 23 Jul 2022 10:53:43 +0200 Subject: [PATCH] allow ppl to click on the reply icon again to hide the reply box --- files/assets/js/comments_v.js | 20 ++++++++++++-------- files/templates/comments.html | 8 ++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 5f5ba4074..086c49645 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -62,18 +62,22 @@ function getSelectionTextHtml() { return html; } -function openReplyBox(id) { +function ToggleReplyBox(id) { const element = document.getElementById(id); const textarea = element.getElementsByTagName('textarea')[0] - let text = getSelection().toString().trim() - if (text) + element.classList.toggle('d-none') + + if (!element.classList.contains('d-none')) { - textarea.value = '> ' + text - textarea.value = textarea.value.replace(/\n/g,"\n> ").replace(/\*/g,"\\*") - if (!textarea.value.endsWith('\n')) textarea.value += '\n' + let text = getSelection().toString().trim() + if (text) + { + textarea.value = '> ' + text + textarea.value = textarea.value.replace(/\n/g,"\n> ").replace(/\*/g,"\\*") + if (!textarea.value.endsWith('\n')) textarea.value += '\n' + } + textarea.focus() } - element.classList.remove('d-none') - textarea.focus() } function toggleEdit(id){ diff --git a/files/templates/comments.html b/files/templates/comments.html index 3dd4b1861..13166cabe 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -352,7 +352,7 @@ {% if v %} - + {% endif %}
  • @@ -449,7 +449,7 @@ {% if v %} - + @@ -611,7 +611,7 @@ {% endif %} {% if request.path.startswith('/notifications') and c.level == 1 and c.sentto and not c.parent_submission and c.author_id != AUTOJANNY_ID %} - Reply + Reply