popup/tabswiper: extract click handlers

This commit is contained in:
He4eT 2023-08-17 04:09:10 +03:00
commit 3257dc3cab

View file

@ -0,0 +1,16 @@
export const attachClickHandlers = (store) => {
const controls = [
['currentTab', store.actions.goToTab],
['buttonClose', store.actions.closeTab],
['buttonShow', store.actions.goToTab],
['buttonSkip', store.actions.keepTab],
]
controls.forEach(([elementId, handler]) => {
document.getElementById(elementId).addEventListener('click', (e) => {
e.preventDefault()
handler(store.getCurrentState().currentTab)
})
})
}