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AKa,QAAU4C,CAC3C,CACJ,EAIG,SAASE,EAAWC,GACvBA,EAASC,SAASC,IAEQ,IAAlBA,EAAKC,UACL,IAAIlE,EAAOiE,EACf,GAER,C","sources":["webpack://UKCISA/./wwwroot/app/src/modules/responsive-nav-bar/responsive-nav-bar.js"],"sourcesContent":["import { ResizeObserver as Polyfill } from '@juggle/resize-observer';\r\nconst ResizeObserver = window.ResizeObserver || Polyfill;\r\n\r\nimport './responsive-nav-bar.scss';\r\n\r\nclass NavBar {\r\n constructor(el) {\r\n\r\n // store for later\r\n this.el = el;\r\n this.mask = el.querySelector('.responsive-nav-bar--ul-mask');\r\n this.content = el.querySelector('ul');\r\n this.prevBtn = el.querySelector('.responsive-nav-bar--button.previous');\r\n this.nextBtn = el.querySelector('.responsive-nav-bar--button.next');\r\n this.tabbedContent = el.classList.contains('responsive-nav-bar--tabbed-content');\r\n this.scrollMode = false;\r\n this.offsetIndex = 0;\r\n this.focusIndex = 0;\r\n this.activeIndex = 0;\r\n this.offset = 0;\r\n this.resizeRequested = false;\r\n this.resizeTimeout = null;\r\n this.touchStartX = null;\r\n this.swipeThreshold = 60;\r\n\r\n // get links in nav bar\r\n this.items = [...el.querySelectorAll('.nav-item a')];\r\n this.itemsCount = this.items.length;\r\n\r\n // loop through links / get active index\r\n for(let x= 0; x < this.itemsCount; x++) {\r\n if(this.items[x].classList.contains('active')) {\r\n this.offsetIndex = x;\r\n this.focusIndex = x;\r\n this.activeIndex = x;\r\n }\r\n this.items[x].addEventListener('click', () => {\r\n this.setActive(x);\r\n });\r\n }\r\n\r\n // buttons\r\n this.prevBtn.addEventListener('click', () => {\r\n this.offsetMove(false);\r\n });\r\n this.nextBtn.addEventListener('click', () => {\r\n this.offsetMove(true);\r\n });\r\n\r\n // keyboard nav\r\n this.el.addEventListener('keydown', (e) => {\r\n switch (e.key) {\r\n // next item (no looping)\r\n case 'Right':\r\n case 'ArrowRight':\r\n e.preventDefault();\r\n this.focusMove(true);\r\n break;\r\n // previous item (no looping)\r\n case 'Left':\r\n case 'ArrowLeft':\r\n e.preventDefault();\r\n this.focusMove(false);\r\n break;\r\n // SPACE/ENTER/RETURN to click a item\r\n case 'Spacebar':\r\n case ' ':\r\n case 'Enter':\r\n case 'Return':\r\n e.preventDefault();\r\n this.items[this.focusIndex].click();\r\n break;\r\n }\r\n });\r\n\r\n // swiping\r\n this.mask.ontouchstart = (e) => {\r\n if (e.touches.length == 1) {\r\n let touch = e.touches[0];\r\n this.touchStartX = touch.pageX;\r\n }\r\n };\r\n this.el.ontouchmove = (e) => {\r\n if (this.touchStartX != null) {\r\n e.preventDefault();\r\n let touchCurrentX = e.changedTouches[0].pageX;\r\n if ((touchCurrentX - this.touchStartX) > this.swipeThreshold) {\r\n this.touchStartX = null;\r\n this.offsetMove(false);\r\n } else if ((this.touchStartX - touchCurrentX) > this.swipeThreshold) {\r\n this.touchStartX = null;\r\n this.offsetMove(true);\r\n }\r\n }\r\n };\r\n this.el.ontouchend = () => {\r\n this.touchStartX = null;\r\n };\r\n\r\n // add resize observer\r\n this.ro = new ResizeObserver(() => {\r\n if(!this.resizeRequested) {\r\n this.resizeRequested = true;\r\n this.resizeTimeout = setTimeout(() => {\r\n this.resize();\r\n this.resizeRequested = false;\r\n this.resizeTimeout = null;\r\n }, 200);\r\n }\r\n });\r\n this.ro.observe(this.el); // Watch dimension changes wrapping element\r\n\r\n }\r\n\r\n offsetMove(mode) {\r\n let prevIndex = this.offsetIndex;\r\n if(mode && this.offsetIndex < (this.itemsCount-1)) {\r\n this.offsetIndex = this.offsetIndex + 1;\r\n } else if(!mode && this.offsetIndex > 0) {\r\n this.offsetIndex = this.offsetIndex - 1;\r\n }\r\n if(prevIndex !== this.offsetIndex) {\r\n this.updateOffset();\r\n }\r\n }\r\n\r\n focusMove(mode) {\r\n let prevIndex = this.focusIndex;\r\n if(mode && this.focusIndex < (this.itemsCount-1)) {\r\n this.focusIndex = this.focusIndex + 1;\r\n } else if(!mode && this.focusIndex > 0) {\r\n this.focusIndex = this.focusIndex - 1;\r\n }\r\n if(prevIndex !== this.focusIndex) {\r\n this.items[this.focusIndex].setAttribute('tabIndex','0');\r\n this.items[this.focusIndex].focus();\r\n this.items[prevIndex].setAttribute('tabIndex','-1');\r\n this.offsetIndex = this.focusIndex;\r\n this.updateOffset();\r\n }\r\n }\r\n\r\n setActive(newIndex) {\r\n if(newIndex != this.activeIndex) {\r\n if(!this.tabbedContent) this.items[this.activeIndex].classList.remove('active');\r\n this.items[this.activeIndex].setAttribute('tabIndex','-1');\r\n this.activeIndex = newIndex;\r\n this.focusIndex = newIndex;\r\n if(!this.tabbedContent) this.items[this.activeIndex].classList.add('active');\r\n this.items[this.activeIndex].setAttribute('tabIndex','0');\r\n }\r\n }\r\n\r\n resize() {\r\n if(this.content.offsetWidth > this.mask.offsetWidth) {\r\n if(!this.scrollMode) {\r\n this.scrollMode = true;\r\n this.el.classList.add('scroll');\r\n }\r\n this.updateOffset();\r\n } else {\r\n if(this.scrollMode) {\r\n this.scrollMode = false;\r\n this.el.classList.remove('scroll');\r\n this.offset = 0;\r\n this.content.style.transform = 'translateX(0)';\r\n }\r\n }\r\n }\r\n\r\n updateOffset() {\r\n if(this.scrollMode) {\r\n let itemLeft = this.items[this.offsetIndex].offsetLeft,\r\n maskWidth = this.mask.offsetWidth,\r\n contentWidth = this.content.offsetWidth,\r\n offsetMax = contentWidth - maskWidth;\r\n this.offset = itemLeft > offsetMax ? offsetMax : itemLeft;\r\n this.content.style.transform = 'translateX(-' + this.offset + 'px)';\r\n // update buttons status\r\n this.prevBtn.disabled = this.offsetIndex == 0;\r\n this.nextBtn.disabled = this.offset >= offsetMax;\r\n }\r\n }\r\n}\r\n\r\n// export the default function to create\r\nexport function createFrom(wrappers) {\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new NavBar(node);\r\n }\r\n });\r\n}"],"names":["ResizeObserver","window","Polyfill","NavBar","constructor","el","this","mask","querySelector","content","prevBtn","nextBtn","tabbedContent","classList","contains","scrollMode","offsetIndex","focusIndex","activeIndex","offset","resizeRequested","resizeTimeout","touchStartX","swipeThreshold","items","querySelectorAll","itemsCount","length","x","addEventListener","setActive","offsetMove","e","key","preventDefault","focusMove","click","ontouchstart","touches","touch","pageX","ontouchmove","touchCurrentX","changedTouches","ontouchend","ro","setTimeout","resize","observe","mode","prevIndex","updateOffset","setAttribute","focus","newIndex","remove","add","offsetWidth","style","transform","itemLeft","offsetLeft","maskWidth","offsetMax","disabled","createFrom","wrappers","forEach","node","nodeType"],"sourceRoot":""}