Port comment toggle functionality to TypeScript

This commit is contained in:
Andreas Nedbal 2022-01-09 00:56:01 +01:00 committed by Andreas Nedbal
parent 0feb05828a
commit da26bbc6c0
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,6 @@
export function commentToggleHandler(event: Event): void {
const button = event.target as HTMLButtonElement;
const id = button.dataset.aId;
document.querySelector(`#ab-comments-section-${id}`).classList.toggle('d-none');
}

View File

@ -35,6 +35,6 @@
= link_to(raw(t('views.answerbox.time', time: time_tooltip(a))), show_user_answer_path(a.user.screen_name, a.id), class: 'answerbox__permalink')
.col-md-6.d-md-flex.answerbox__actions
= render 'answerbox/actions', a: a, display_all: display_all
.card-footer{ id: "ab-comments-section-#{a.id}", style: display_all.nil? ? 'display: none' : nil }
.card-footer{ id: "ab-comments-section-#{a.id}", class: display_all.nil? ? 'd-none' : nil }
%div{ id: "ab-smiles-#{a.id}" }= render 'answerbox/smiles', a: a
%div{ id: "ab-comments-#{a.id}" }= render 'answerbox/comments', a: a