{"version":3,"file":"uppsala.tabpanel.min.js","names":["define","showTabPanel","el","tabPanelToOpen","target","getAttribute","tabPanels","document","querySelectorAll","g","length","classList","add","getElementById","remove","querySelector","addEventListener","e","firstTab","firstElementChild","lastTab","lastElementChild","key","activeElement","click","focus","newSelectedTab","previousElementSibling","preventDefault","nextElementSibling","init","this","SetupTabPanel","refreshTabs","activeTabId","tabs","i"],"sources":["components/uppsala.tabpanel.js"],"mappings":"AAAAA,QAAO,WAGH,SAASC,EAAaC,GAClB,IAAIC,EAAiBD,EAAGE,OAAOC,aAAa,iBACxCC,EAAYC,SAASC,iBAAiB,mBAE1C,IAAKC,EAAI,EAAGA,EAAIH,EAAUI,OAAQD,IAC9BH,EAAUG,GAAGE,UAAUC,IAAI,eAG/BL,SAASM,eAAeV,GAAgBQ,UAAUG,OAAO,eAGzDP,SAASQ,cAAc,kBAAkBC,iBAAiB,WAAW,SAAUC,GAC3E,IAAIC,EAAWX,SAASQ,cAAc,kBAAkBI,kBACpDC,EAAUb,SAASQ,cAAc,kBAAkBM,iBACvD,GAAc,cAAVJ,EAAEK,IAAqB,CACvB,GAAIf,SAASgB,eAAiBL,EAC1BE,EAAQI,QACRJ,EAAQK,aAEJC,EAAiBnB,SAASQ,cAAc,uBAAuBY,wBACpDH,QACfE,EAAeD,QAEnBR,EAAEW,gBACN,CACA,GAAc,eAAVX,EAAEK,IAAsB,CAKpB,IAAII,EAJR,GAAInB,SAASgB,eAAiBH,EAC1BF,EAASM,QACTN,EAASO,aAELC,EAAiBnB,SAASQ,cAAc,uBAAuBc,oBACpDL,QACfE,EAAeD,QAEnBR,EAAEW,gBACN,CACJ,GACJ,CA6BA,MA3Be,CAEXE,KAAM,WACFC,KAAKC,eACT,EACAC,YAAa,SAAUC,GACnB,IACI/B,EADkBI,SAASM,eAAeqB,GACT7B,aAAa,iBAC9CC,EAAYC,SAASC,iBAAiB,mBAE1C,IAAKC,EAAI,EAAGA,EAAIH,EAAUI,OAAQD,IAC9BH,EAAUG,GAAGE,UAAUC,IAAI,eAG/BL,SAASM,eAAeV,GAAgBQ,UAAUG,OAAO,cAC7D,EACAkB,cAAe,WACX,IAAIG,EAAO5B,SAASC,iBAAiB,cAGrC,IAAK4B,EAAI,EAAGA,EAAID,EAAKzB,OAAQ0B,IACzBD,EAAKC,GAAGpB,iBAAiB,QAASf,EAE1C,EAKR","ignoreList":[],"sourcesContent":["define(function () {\n\n //runs when tab is clicked\n function showTabPanel(el) {\n var tabPanelToOpen = el.target.getAttribute('aria-controls'); //get the aria-controls value of the tab that was clicked\n var tabPanels = document.querySelectorAll('[role=tabpanel]'); //get all tabpanels as a variable\n\n for (g = 0; g < tabPanels.length; g++) {\n tabPanels[g].classList.add(\"panelhidden\"); //hide all tabpanels\n }\n\n document.getElementById(tabPanelToOpen).classList.remove(\"panelhidden\"); //show tabpanel who's tab was clicked\n\n //left and right arrow key navigation\n document.querySelector('[role=tablist]').addEventListener('keydown', function (e) {\n var firstTab = document.querySelector('[role=tablist]').firstElementChild,\n lastTab = document.querySelector('[role=tablist]').lastElementChild\n if (e.key === \"ArrowLeft\") {\n if (document.activeElement == firstTab) {\n lastTab.click()\n lastTab.focus()\n } else {\n var newSelectedTab = document.querySelector('[aria-selected=true').previousElementSibling\n newSelectedTab.click()\n newSelectedTab.focus()\n }\n e.preventDefault()\n }\n if (e.key === \"ArrowRight\") {\n if (document.activeElement == lastTab) {\n firstTab.click()\n firstTab.focus()\n } else {\n var newSelectedTab = document.querySelector('[aria-selected=true').nextElementSibling\n newSelectedTab.click()\n newSelectedTab.focus()\n }\n e.preventDefault()\n }\n });\n }\n\n var tabPanel = {\n\n init: function () {\n this.SetupTabPanel();\n },\n refreshTabs: function (activeTabId) {\n var activeTabButton = document.getElementById(activeTabId);\n var tabPanelToOpen = activeTabButton.getAttribute('aria-controls'); //get the aria-controls value of the tab that was clicked\n var tabPanels = document.querySelectorAll('[role=tabpanel]'); //get all tabpanels as a variable\n\n for (g = 0; g < tabPanels.length; g++) {\n tabPanels[g].classList.add(\"panelhidden\"); //hide all tabpanels\n }\n\n document.getElementById(tabPanelToOpen).classList.remove(\"panelhidden\"); //show tabpanel who's tab was clicked\n },\n SetupTabPanel: function () {\n var tabs = document.querySelectorAll('[role=tab]'); //get all role=tab elements as a variable\n\n //add click event to each tab to run the showTabPanel function\n for (i = 0; i < tabs.length; i++) {\n tabs[i].addEventListener(\"click\", showTabPanel);\n }\n },\n }\n\n\n return tabPanel;\n});"]}