change "quote selection" to "reply" when we're done

pull/176/head
Aevann 2023-08-03 10:33:57 +03:00
parent 588a8bb7a0
commit 0030858521
3 changed files with 29 additions and 9 deletions

View File

@ -164,14 +164,14 @@ function post_reply(id) {
ta.value = ''
document.getElementById('message-reply-'+id).innerHTML = ''
document.getElementById('reply-message-c_'+id).classList.add('d-none')
document.getElementById('reply-to-c_'+id).classList.add('d-none')
const input = ta.parentElement.querySelector('input[type="file"]')
input.previousElementSibling.innerHTML = '';
input.value = null;
oldfiles[ta.id] = []
remove_dialog();
restore_reply_buttons(`c_${id}`)
} else {
showToast(false, getMessageFromJsonData(false, data));
}
@ -298,7 +298,7 @@ function post_comment(fullname, hide){
const ghost_town_box = document.getElementById('ghost-town-box')
if (ghost_town_box) ghost_town_box.remove()
remove_dialog();
restore_reply_buttons(fullname)
}
else {
showToast(false, getMessageFromJsonData(false, data));
@ -347,3 +347,23 @@ function handle_action(type, cid, thing) {
}
xhr.send(form)
}
function restore_reply_buttons(fullname) {
const reply_buttons = [document.getElementById(`toggle-reply-${fullname}`)]
const mobile_reply_button = document.getElementById(`toggle-reply-${fullname}-mobile`)
if (mobile_reply_button) reply_buttons.push(mobile_reply_button)
for (const t of reply_buttons) {
let newHTML = ''
if (t.innerHTML.includes('<i class="fas fa-'))
newHTML += '<i class="fas fa-reply"></i>'
if (t.innerText)
newHTML += 'Reply'
t.innerHTML = newHTML
}
remove_dialog();
}
function cancel(fullname) {
document.getElementById(`reply-to-${fullname}`).classList.add('d-none')
restore_reply_buttons(fullname)
}

View File

@ -303,7 +303,7 @@
</li>
{% if v and not c.deleted_utc %}
<button type="button" class="list-inline-item mr-3 btn nobackground" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox(this, 'reply-to-{{c.fullname}}')"><i class="fas fa-reply"></i></button>
<button id="toggle-reply-{{c.fullname}}-mobile" type="button" class="list-inline-item mr-3 btn nobackground" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox(this, 'reply-to-{{c.fullname}}')"><i class="fas fa-reply"></i></button>
{% endif %}
<li class="list-inline-item">
@ -394,7 +394,7 @@
{% if v %}
{% if not c.deleted_utc %}
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox(this, 'reply-to-{{c.fullname}}')"><i class="fas fa-reply"></i>Reply</button>
<button id="toggle-reply-{{c.fullname}}" type="button" class="btn caction py-0 nobackground px-1 text-muted" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox(this, 'reply-to-{{c.fullname}}')"><i class="fas fa-reply"></i>Reply</button>
{% endif %}
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-bs-toggle="modal" data-bs-target="#reportCommentModal" data-nonce="{{g.nonce}}" data-onclick="report_commentModal('{{c.id}}','{{c.author_name}}',)"><i class="fas fa-flag fa-fw"></i>Report</button>
@ -541,9 +541,9 @@
<button type="button" class="btn btn-primary mt-2 mr-3 {% if not c.author.is_muted %}d-none{% endif %}" id="unmute-user-{{c.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmute_user/{{c.author.id}}','mute-user-{{c.id}}','unmute-user-{{c.id}}','d-none')">Unmute</button>
{% endif %}
<button type="button" class="btn btn-primary nobackground mt-2" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox(this, 'reply-message-{{c.fullname}}')">Reply</button>
<button id="toggle-reply-{{c.fullname}}" type="button" class="btn btn-primary nobackground mt-2" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox(this, 'reply-to-{{c.fullname}}')">Reply</button>
<div id="reply-message-{{c.fullname}}" class="d-none">
<div id="reply-to-{{c.fullname}}" class="d-none">
<div id="comment-form-space-{{c.id}}" class="comment-write collapsed child">
<div class="input-group">
<input hidden name="formkey" value="{{v|formkey}}">
@ -560,7 +560,7 @@
<span></span>
</span>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="remove_dialog()" class="btn btn-link text-muted ml-auto" data-toggleelement="#reply-message-{{c.fullname}}" data-toggleattr="d-none">Cancel</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="cancel('{{c.fullname}}')" class="btn btn-link text-muted ml-auto">Cancel</button>
<button type="button" id="save-reply-to-{{c.id}}" class="btn btn-primary ml-2" data-nonce="{{g.nonce}}" data-onclick="post_reply('{{c.id}}')">Reply</button>
</div>

View File

@ -134,7 +134,7 @@
<button type="button" id="save-reply-to-{{target_fullname}}" form="reply-to-{{target_fullname}}" class="btn btn-primary text-whitebtn ml-auto fl-r" data-nonce="{{g.nonce}}" data-onclick="post_comment('{{target_fullname}}', '{{hide}}')">Comment</button>
{% if enable_cancel_button %}
<button type="button" data-nonce="{{g.nonce}}" data-onclick="remove_dialog()" data-toggleelement="#reply-to-{{target_fullname}}" data-toggleattr="d-none" class="btn btn-link text-muted ml-auto fl-r mr-3">Cancel</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="cancel('{{target_fullname}}')" class="btn btn-link text-muted ml-auto fl-r mr-3">Cancel</button>
{% endif %}
<span id="upload-prog-{{target_fullname}}" class="d-none mt-1 mr-2 fl-r">