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,SAAR,CAAkBa,MAAlB,CAAyB,OAAzB;AACH,OAJD;AAKH;AAED;AACJ;AACA;AACA;;;;WACI,sBAAatB,MAAb,EAAqB;AAAA;;AACjB,UAAME,IAAI,GAAG,KAAKC,iBAAL,CAAuBH,MAAvB,CAAb,CADiB,CAEjB;;AACA,UAAIuB,UAAU,GAAG,KAAjB;AACA,WAAKjC,QAAL,CAAcL,OAAd,CAAsB,UAAAoC,OAAO,EAAI;AAC7B,YAAIA,OAAO,CAACG,EAAR,KAAetB,IAAI,CAACK,YAAL,CAAkB,eAAlB,CAAnB,EAAuD;AACnDgB,UAAAA,UAAU,GAAG,IAAb;AACArB,UAAAA,IAAI,CAACkB,YAAL,CAAkB,eAAlB,EAAmC,MAAnC;AACAC,UAAAA,OAAO,CAACZ,SAAR,CAAkBC,GAAlB,CAAsB,QAAtB;;AAEA,gBAAI,CAACtB,SAAL,CAAeqC,aAAf,CAA6B,IAAIC,WAAJ,CAAgB,QAAhB,CAA7B;AACH;AACJ,OARD;;AAUA,UAAI,CAACH,UAAL,EAAiB;AACbzB,QAAAA,OAAO,CAACC,KAAR,mDAAyDG,IAAI,CAACK,YAAL,CAAkB,eAAlB,CAAzD;AACH;AACJ;AAED;AACJ;AACA;AACA;AACA;;;;WACI,2BAAkBP,MAAlB,EAA0B;AACtB,aAAOA,MAAM,CAAC2B,aAAP,CAAqB,WAArB,CAAP;AACH","sources":["webpack://amaris_2021/./corporate/scripts/controllers/tabs/controller.js","webpack://amaris_2021/./corporate/scripts/controllers/tabs/tabs.js"],"sourcesContent":["import Tabs from './tabs.js';\r\n\r\nexport default class TabsController {\r\n constructor() {\r\n this.selector = '.tabs';\r\n this.tabs = [];\r\n\r\n this.init();\r\n }\r\n\r\n init() {\r\n if (document.querySelectorAll(this.selector).length) {\r\n document.querySelectorAll(this.selector).forEach(tabsElement => {\r\n let tabs = new Tabs(tabsElement);\r\n this.tabs.push(tabs);\r\n\r\n tabs.init();\r\n });\r\n }\r\n }\r\n}","export default class Tabs {\r\n /**\r\n * @param {Element} container Container that includes both the tab headers and tab contents\r\n */\r\n constructor(container) {\r\n this.container = container;\r\n this.headers = null;\r\n this.contents = null;\r\n this.updateHash = false;\r\n this.watchHashUpdates = false;\r\n this.selectedIndex = 0;\r\n }\r\n\r\n /**\r\n * Initialize tab functionality\r\n */\r\n init() {\r\n if (this.container.querySelectorAll('.tabHeaders .tabHeader').length && this.container.querySelectorAll('.tabContents .tabContent').length) {\r\n this.headers = this.container.querySelectorAll('.tabHeaders .tabHeader');\r\n this.contents = this.container.querySelectorAll('.tabContents .tabContent');\r\n\r\n if (this.container.dataset.updateHash !== undefined && this.container.dataset.updateHash == 'true') {\r\n this.updateHash = true;\r\n this.watchHashUpdates = true;\r\n }\r\n\r\n this.setEventListeners();\r\n this.checkHash();\r\n } else {\r\n console.error(`Headers or contents are missing for tabs:`);\r\n console.error(this.container);\r\n }\r\n }\r\n\r\n /**\r\n * Listens for clicks/keyboard presses on the tab headers\r\n */\r\n setEventListeners() {\r\n this.headers.forEach((header, index) => {\r\n const link = this.getLinkFromHeader(header);\r\n\r\n // Mouse/Touch\r\n link.addEventListener('click', e => {\r\n e.preventDefault();\r\n \r\n if (!!link.getAttribute('aria-selected')) {\r\n this.setAllTabsInactive();\r\n\r\n // Decide if a class needs to be added to indicate if a user goes 'left or right' in the tab list\r\n if (index > this.selectedIndex) {\r\n this.contents[index].classList.add('right');\r\n } else if (index < this.selectedIndex) {\r\n this.contents[index].classList.add('left');\r\n }\r\n\r\n this.setTabActive(header);\r\n\r\n this.selectedIndex = index;\r\n\r\n if (this.updateHash) {\r\n location.hash = link.getAttribute('aria-controls');\r\n }\r\n }\r\n });\r\n\r\n // Keyboard\r\n link.addEventListener('keyup', e => {\r\n e.preventDefault();\r\n if (e.key.toLowerCase() == 'enter') {\r\n // Emulate click\r\n link.click();\r\n }\r\n })\r\n });\r\n\r\n if (this.watchHashUpdates) {\r\n window.addEventListener('hashchange', this.checkHash.bind(this));\r\n }\r\n }\r\n\r\n /**\r\n * Checks location.hash and updates if it matches a tab content ID\r\n */\r\n checkHash() {\r\n const hash = location.hash.replace('#', '');\r\n this.headers.forEach(header => {\r\n const link = this.getLinkFromHeader(header);\r\n if (link.getAttribute('aria-controls') == hash) {\r\n link.click();\r\n }\r\n })\r\n }\r\n\r\n /**\r\n * Removes active status from all tab headers and tab contents\r\n */\r\n setAllTabsInactive() {\r\n this.headers.forEach(header => {\r\n const link = this.getLinkFromHeader(header);\r\n link.setAttribute('aria-selected', 'false');\r\n });\r\n\r\n this.contents.forEach(content => {\r\n content.classList.remove('active');\r\n content.classList.remove('left');\r\n content.classList.remove('right');\r\n });\r\n }\r\n\r\n /**\r\n * Sets tab header and tab content to active based on the header's `aria-controls` attribute\r\n * @param {Element} header \r\n */\r\n setTabActive(header) {\r\n const link = this.getLinkFromHeader(header);\r\n // Find matching tabContent\r\n let matchFound = false;\r\n this.contents.forEach(content => {\r\n if (content.id === link.getAttribute('aria-controls')) {\r\n matchFound = true;\r\n link.setAttribute('aria-selected', 'true');\r\n content.classList.add('active');\r\n\r\n this.container.dispatchEvent(new CustomEvent('select'));\r\n }\r\n });\r\n\r\n if (!matchFound) {\r\n console.error(`No matching tabContent found for tab ID ${link.getAttribute('aria-controls')}`);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the a tag or button tag from a header\r\n * @param {Element} header\r\n * @returns {Element}\r\n */\r\n getLinkFromHeader(header) {\r\n return header.querySelector('a, button');\r\n }\r\n}"],"names":["Tabs","TabsController","selector","tabs","init","document","querySelectorAll","length","forEach","tabsElement","push","container","headers","contents","updateHash","watchHashUpdates","selectedIndex","dataset","undefined","setEventListeners","checkHash","console","error","header","index","link","getLinkFromHeader","addEventListener","e","preventDefault","getAttribute","setAllTabsInactive","classList","add","setTabActive","location","hash","key","toLowerCase","click","window","bind","replace","setAttribute","content","remove","matchFound","id","dispatchEvent","CustomEvent","querySelector"],"sourceRoot":""}