Retrospring/app/javascript/retrospring/features/answerbox/index.ts

18 lines
567 B
TypeScript
Raw Normal View History

2021-08-10 04:16:40 -07:00
import registerEvents from "retrospring/utilities/registerEvents";
import {createShareEvent} from "./share";
export default (): void => {
2021-08-10 06:50:17 -07:00
if ('share' in navigator) {
document.body.classList.add('cap-web-share');
const entries: NodeList = document.querySelectorAll('.answerbox:not(.js-initialized)');
2021-08-10 04:16:40 -07:00
2021-08-10 06:50:17 -07:00
entries.forEach((element: HTMLElement) => {
registerEvents([
{ type: 'click', target: element.querySelector('[name=ab-share]'), handler: createShareEvent(element) }
2021-08-10 06:50:17 -07:00
]);
2021-08-10 04:16:40 -07:00
2021-08-10 06:50:17 -07:00
element.classList.add('js-initialized');
});
}
}