Port inbox entry option functionality to TypeScript

This commit is contained in:
Andreas Nedbal 2022-01-03 03:27:14 +01:00 committed by Andreas Nedbal
parent 2fe4438068
commit 2b06d6a6cc
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,15 @@
import registerEvents from 'utilities/registerEvents';
import { answerEntryHandler, answerEntryInputHandler } from './answer';
import { deleteEntryHandler } from './delete';
import optionsEntryHandler from './options';
import { reportEventHandler } from './report';
export default (): void => {
registerEvents([
{ type: 'click', target: 'button[name="ib-answer"]', handler: answerEntryHandler, global: true },
{ type: 'click', target: '[name="ib-destroy"]', handler: deleteEntryHandler, global: true },
{ type: 'click', target: '[name=ib-report]', handler: reportEventHandler, global: true },
{ type: 'click', target: 'button[name=ib-options]', handler: optionsEntryHandler, global: true },
{ type: 'keydown', target: 'textarea[name=ib-answer]', handler: answerEntryInputHandler, global: true }
]);
}

View File

@ -0,0 +1,7 @@
export default function optionsEntryHandler(event: Event): void {
const button = event.target as HTMLElement;
const inboxId = button.dataset.ibId;
const options = document.querySelector(`#ib-options-${inboxId}`);
options.classList.toggle('d-none');
}