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AAC;IACvB;EACJ,CAAC,CAAC;AAEN","sources":["webpack://WebpackConfig.Web/./app/src/js/smart-bootstrap-tabs.js"],"sourcesContent":["import { Tab as bootstrapTab } from 'bootstrap';\r\n\r\nconst url = location.href.replace(/\\/$/, \"\");\r\nconst pageUrl = url.split(\"#\")[0];\r\nconst pageTitle = document.title;\r\nlet hashFound = null;\r\nif(location.hash) {\r\n let h = url.split(\"#\")[1];\r\n if(h.length > 0) hashFound = h;\r\n}\r\n\r\nclass SmartTabs {\r\n\r\n constructor(el) {\r\n this.el = el;\r\n this.tabs = el.querySelectorAll('.nav-link');\r\n this.prevPageURL = pageUrl;\r\n this.updaterTimeout = null;\r\n let _this = this;\r\n if(this.tabs != null) {\r\n this.tabs.forEach(t => {\r\n let tabTitle = t.innerText,\r\n tabPageTitle = `${pageTitle} - ${tabTitle}`,\r\n tabTargetId = t.hasAttribute('href') ? t.getAttribute('href') : t.dataset.bsTarget;\r\n // update page url anchor when tabs changed\r\n t.addEventListener('shown.bs.tab', event => {\r\n let url = null;\r\n if(event.target.getAttribute('href')) {\r\n url = pageUrl + event.target.getAttribute('href');\r\n } else if(event.target.dataset.bsTarget) {\r\n url = pageUrl + event.target.dataset.bsTarget;\r\n }\r\n if(url) _this.updatePageURL(url, tabPageTitle);\r\n })\r\n // activate tab if external link to it, or a contained element, is clicked\r\n document.querySelectorAll(`a:not(.nav-link)[href$=\"${tabTargetId}\"]`).forEach(a => {\r\n a.addEventListener('click', () => {\r\n this.showTab(t);\r\n setTimeout(() => {t.focus()}, 100);\r\n });\r\n });\r\n document.querySelector(tabTargetId).querySelectorAll(`[id]`).forEach(a => {\r\n document.querySelectorAll(`a[href$=\"#${a.id}\"]`).forEach(b => {\r\n b.addEventListener('click', () => {\r\n this.showTab(t);\r\n let url = `${pageUrl}#${a.id}`; \r\n this.updatePageURL(url, tabPageTitle);\r\n });\r\n });\r\n });\r\n // set active tab on page load?\r\n if(hashFound) this.findHashInTabs(hashFound);\r\n });\r\n }\r\n // listen for popstate\r\n window.addEventListener('popstate', event => {\r\n if(event.state != null) {\r\n if(event.state.url != null) {\r\n _this.findHashInTabs(event.state.url.split('#')[1]);\r\n }\r\n }\r\n });\r\n }\r\n\r\n findHashInTabs(getHash) {\r\n this.tabs.forEach(t => {\r\n let tabTitle = t.innerText,\r\n tabPageTitle = `${pageTitle} - ${tabTitle}`,\r\n tabTargetId = t.hasAttribute('href') ? t.getAttribute('href') : t.dataset.bsTarget;\r\n // is it this tab?\r\n let found = tabTargetId == `#${getHash}`;\r\n // is it in this tab content\r\n if(!found) found = document.querySelector(`${tabTargetId} #${getHash}`);\r\n // if found, turn on this tab\r\n if(found) {\r\n this.showTab(t);\r\n let url = `${pageUrl}#${getHash}`; \r\n this.updatePageURL(url, tabPageTitle);\r\n }\r\n });\r\n }\r\n\r\n showTab(tab) {\r\n if(!tab.classList.contains('active')) {\r\n let tabToShow = bootstrapTab.getOrCreateInstance(tab);\r\n tabToShow.show();\r\n }\r\n }\r\n\r\n updatePageURL(newURL, newTitle) {\r\n clearTimeout(this.updaterTimeout);\r\n this.updaterTimeout = setTimeout(() => {\r\n if(this.prevPageURL != newURL) {\r\n this.prevPageURL = newURL;\r\n history.pushState({title: newTitle, url: newURL}, newTitle, newURL);\r\n document.title = newTitle;\r\n }\r\n }, 300);\r\n }\r\n\r\n}\r\n\r\n// export the default function to create\r\nexport function createFrom(wrappers) {\r\n\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new SmartTabs(node);\r\n }\r\n });\r\n\r\n}"],"names":["Tab","bootstrapTab","url","location","href","replace","pageUrl","split","pageTitle","document","title","hashFound","hash","h","length","SmartTabs","el","_this2","_classCallCheck","tabs","querySelectorAll","prevPageURL","updaterTimeout","_this","forEach","t","tabTitle","innerText","tabPageTitle","concat","tabTargetId","hasAttribute","getAttribute","dataset","bsTarget","addEventListener","event","target","updatePageURL","a","showTab","setTimeout","focus","querySelector","id","b","findHashInTabs","window","state","_createClass","key","value","getHash","_this3","found","tab","classList","contains","tabToShow","getOrCreateInstance","show","newURL","newTitle","_this4","clearTimeout","history","pushState","createFrom","wrappers","node","nodeType"],"sourceRoot":""}