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AAC,CAAC,C","sources":["webpack://kallax-gut-blocks/./src/tabs/front.js"],"sourcesContent":["'use strict';\r\n\r\nclass KallaxTabs {\r\n constructor(groupNode) {\r\n this.tablistNode = groupNode;\r\n\r\n this.tabs = [];\r\n\r\n this.firstTab = null;\r\n this.lastTab = null;\r\n\r\n this.tabs = Array.from(this.tablistNode.querySelectorAll('[role=tab]'));\r\n this.tabpanels = [];\r\n\r\n for (var i = 0; i < this.tabs.length; i += 1) {\r\n var tab = this.tabs[i];\r\n var tabpanel = document.getElementById(tab.getAttribute('aria-controls'));\r\n\r\n tab.tabIndex = -1;\r\n // tab.setAttribute('aria-selected', 'false');\r\n this.tabpanels.push(tabpanel);\r\n\r\n tab.addEventListener('keydown', this.onKeydown.bind(this));\r\n tab.addEventListener('click', this.onClick.bind(this));\r\n\r\n if (!this.firstTab) {\r\n this.firstTab = tab;\r\n }\r\n this.lastTab = tab;\r\n }\r\n\r\n // Uncomment if default is fist tab\r\n // this.setSelectedTab(this.firstTab, false);\r\n }\r\n\r\n setSelectedTab(currentTab, setFocus) {\r\n if (typeof setFocus !== 'boolean') {\r\n setFocus = true;\r\n }\r\n for (var i = 0; i < this.tabs.length; i += 1) {\r\n var tab = this.tabs[i];\r\n if (currentTab === tab) {\r\n tab.setAttribute('aria-selected', 'true');\r\n tab.removeAttribute('tabindex');\r\n this.tabpanels[i].removeAttribute('hidden');\r\n if (setFocus) {\r\n tab.focus();\r\n }\r\n } else {\r\n tab.setAttribute('aria-selected', 'false');\r\n tab.tabIndex = -1;\r\n this.tabpanels[i].setAttribute('hidden', '');\r\n }\r\n }\r\n }\r\n\r\n setSelectedToPreviousTab(currentTab) {\r\n var index;\r\n\r\n if (currentTab === this.firstTab) {\r\n this.setSelectedTab(this.lastTab);\r\n } else {\r\n index = this.tabs.indexOf(currentTab);\r\n this.setSelectedTab(this.tabs[index - 1]);\r\n }\r\n }\r\n\r\n setSelectedToNextTab(currentTab) {\r\n var index;\r\n\r\n if (currentTab === this.lastTab) {\r\n this.setSelectedTab(this.firstTab);\r\n } else {\r\n index = this.tabs.indexOf(currentTab);\r\n this.setSelectedTab(this.tabs[index + 1]);\r\n }\r\n }\r\n\r\n /* EVENT HANDLERS */\r\n\r\n onKeydown(event) {\r\n var tgt = event.currentTarget,\r\n flag = false;\r\n\r\n switch (event.key) {\r\n case 'ArrowLeft':\r\n this.setSelectedToPreviousTab(tgt);\r\n flag = true;\r\n break;\r\n\r\n case 'ArrowRight':\r\n this.setSelectedToNextTab(tgt);\r\n flag = true;\r\n break;\r\n\r\n case 'Home':\r\n this.setSelectedTab(this.firstTab);\r\n flag = true;\r\n break;\r\n\r\n case 'End':\r\n this.setSelectedTab(this.lastTab);\r\n flag = true;\r\n break;\r\n\r\n default:\r\n break;\r\n }\r\n\r\n if (flag) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n }\r\n\r\n onClick(event) {\r\n this.setSelectedTab(event.currentTarget);\r\n }\r\n}\r\n\r\n// Initialize tablist\r\n\r\nwindow.addEventListener('load', function () {\r\n var tablists = document.querySelectorAll('.c-tablist[role=tablist]');\r\n for (var i = 0; i < tablists.length; i++) {\r\n new KallaxTabs(tablists[i]);\r\n }\r\n});\r\n"],"names":["KallaxTabs","constructor","groupNode","tablistNode","tabs","firstTab","lastTab","Array","from","querySelectorAll","tabpanels","i","length","tab","tabpanel","document","getElementById","getAttribute","tabIndex","push","addEventListener","onKeydown","bind","onClick","setSelectedTab","currentTab","setFocus","setAttribute","removeAttribute","focus","setSelectedToPreviousTab","index","indexOf","setSelectedToNextTab","event","tgt","currentTarget","flag","key","stopPropagation","preventDefault","window","tablists"],"sourceRoot":""}