Setup TypeScript answerbox feature

This commit is contained in:
Andreas Nedbal 2022-01-09 00:54:11 +01:00 committed by Andreas Nedbal
parent 08682308b1
commit 1d21fb650b
2 changed files with 34 additions and 3 deletions

View File

@ -0,0 +1,18 @@
import registerEvents from "retrospring/utilities/registerEvents"
import { commentCharacterCountHandler } from "./count";
import { commentDestroyHandler } from "./destroy";
import { commentCreateHandler } from "./new";
import { commentReportHandler } from "./report";
import { commentSmileHandler } from "./smile";
import { commentToggleHandler } from "./toggle";
export default (): void => {
registerEvents([
{ type: 'click', target: '[name=ab-comments]', handler: commentToggleHandler, global: true },
{ type: 'click', target: '[name=ab-smile-comment]', handler: commentSmileHandler, global: true },
{ type: 'click', target: '[data-action=ab-comment-report]', handler: commentReportHandler, global: true },
{ type: 'click', target: '[data-action=ab-comment-destroy]', handler: commentDestroyHandler, global: true },
{ type: 'keyup', target: '[name=ab-comment-new]', handler: commentCreateHandler, global: true },
{ type: 'input', target: '[name=ab-comment-new]', handler: commentCharacterCountHandler, global: true }
]);
}

View File

@ -1,10 +1,23 @@
import { on } from 'retrospring/utilities/on';
import registerEvents from 'utilities/registerEvents';
import registerAnswerboxCommentEvents from './comment';
import { answerboxDestroyHandler } from './destroy';
import { answerboxReportHandler } from './report';
import { shareEventHandler } from './share';
import { answerboxSmileHandler } from './smile';
import { answerboxSubscribeHandler } from './subscribe';
export default (): void => {
if ('share' in navigator) {
document.body.classList.add('cap-web-share');
}
on('click', '[name=ab-share]', shareEventHandler);
}
registerEvents([
{ type: 'click', target: '[name=ab-share]', handler: shareEventHandler, global: true },
{ type: 'click', target: '[data-action=ab-submarine]', handler: answerboxSubscribeHandler, global: true },
{ type: 'click', target: '[data-action=ab-report]', handler: answerboxReportHandler, global: true },
{ type: 'click', target: '[data-action=ab-destroy]', handler: answerboxDestroyHandler, global: true },
{ type: 'click', target: '[name=ab-smile]', handler: answerboxSmileHandler, global: true }
]);
registerAnswerboxCommentEvents();
}