diff --git a/popup/tabswiper/modules/clickHandlers.js b/popup/tabswiper/modules/clickHandlers.js new file mode 100644 index 0000000..ad652cf --- /dev/null +++ b/popup/tabswiper/modules/clickHandlers.js @@ -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) + }) + }) +} +