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A,MAA3B;AAAmC4B,MAAAA,IAAnC;AAAyCjC,MAAAA;AAAzC,KAAX;AACH;;AAED,OAAK0C,WAAL,CAAiBoC,gBAAjB,CAAkC,OAAlC,EAA4Ca,CAAD,IAAO;AAAE,SAAKX,UAAL;AAAoB,GAAxE;AAEAtB,EAAAA,MAAM,CAACoB,gBAAP,CAAwB,QAAxB,EAAmCzC,KAAD,IAAW;AACzC4B,IAAAA,aAAa,GAAG,IAAID,IAAJ,EAAhB;;AACA,QAAI,CAACqB,aAAL,EAAoB;AAChBA,MAAAA,aAAa,GAAG,IAAhB;AACAlB,MAAAA,UAAU,CAAC,KAAKP,QAAN,EAAgBM,WAAhB,CAAV;AACH;AACJ,GAND;AAOH;;AAED,+DAAe,MAAMlE,OAAN,IAAiB;AAAE;AAE9B,QAAM4F,OAAO,GAAG,IAAI9G,IAAJ,CAASkB,OAAT,CAAhB;AAEA,QAAM6F,SAAS,GAAGD,OAAO,CAAC3C,OAAR,CAAgB,CAAhB,CAAlB;AAEA,MAAI4C,SAAS,KAAK1C,SAAd,IAA2B,CAAC0C,SAAS,CAACnB,UAAtC,IAAoDkB,OAAO,CAACrC,MAAR,EAAxD,EACIqC,OAAO,CAACrB,GAAR,CAAY,CAAZ;AAEJqB,EAAAA,OAAO,CAACjB,iBAAR;AACH,CAVD","sources":["webpack://selectrucks/./scripts/feature/ddlNav.js"],"sourcesContent":["\nfunction menu(parent) {\n \n const DATASET_FOCUS = 'focusindex';\n const STATE_CLOSED = 'tw-arrow-down';\n const STATE_OPEN = 'tw-arrow-up';\n const STATE_FOCUS = 'tw-ddlNav-focus';\n const items = []; \n const mainSection = document.querySelector('body > main');\n\n const getParentHeight = () => {\n return parent.parentElement.getBoundingClientRect().height;\n };\n\n if (!mainSection) {\n console.warn('ddlNav.js -> Main section cannot be found.');\n return;\n }\n \n const anchorTo = (item) => {\n \n const element = positions.find(x => { return x.id === item.anchor });\n \n if (element) {\n\n let position = 0;\n\n if (element.id === items[0].anchor) {\n position = 0;\n } else {\n\n const mainNavHeight = mainSection.offsetTop;\n let offset = parentHeight + mainNavHeight;\n if (parentHeight > mainNavHeight) {\n offset += parentHeight - mainNavHeight;\n }\n\n position = element.top - offset;\n }\n \n mainSection.scrollTo(0, position);\n }\n }\n\n const clamp = (value) => Math.max(0, value);\n\n const isBetween = (value, floor, ceil) => value >= floor && value <= ceil;\n\n const getPosition = (anchor) => {\n \n const element = document.getElementById(anchor);\n\n if (!element)\n return { id: anchor, top: -1, bottom: -1 };\n\n const rect = element.getBoundingClientRect();\n const top = clamp(rect.top);\n const bottom = clamp(rect.bottom);\n\n return { id: anchor, top, bottom }; \n };\n\n const listener = (positions, scroll) => {\n\n if (!isScrolling) {\n\n const mainNavHeight = mainSection.offsetTop;\n let offset = parentHeight + mainNavHeight;\n if (parentHeight > mainNavHeight) {\n offset += parentHeight - mainNavHeight;\n }\n\n const position = scroll + offset;\n\n const anchorInRange = positions.find(({ top, bottom }) => isBetween(position, top, bottom));\n\n if (anchorInRange) {\n\n const anchorItems = this.GetItemsByAnchor(anchorInRange.id);\n\n for (let i = 0, l = anchorItems.length; i < l; i++) {\n\n if (anchorItems[i].type === 'mobile')\n this.SetFocus(anchorItems[i]);\n\n this.SetFocusOnItem(anchorItems[i]);\n }\n\n }\n }\n };\n\n const setListener = (event) => {\n\n listener(positions, event.srcElement.scrollTop);\n };\n\n const setPositions = () => {\n\n positions = [];\n\n for (let i = 0, l = items.length; i < l; i++) {\n\n if (items[i].anchor !== '') {\n const anchor = items[i].anchor;\n const position = getPosition(anchor);\n positions.push(position);\n }\n }\n };\n\n this.FocusedItem = parent.querySelector(`[data-${DATASET_FOCUS}]`);\n\n if (!this.FocusedItem) {\n console.warn\n (`The ddlNav feature is missing an element to apply focus. Attribute should be data-${DATASET_FOCUS}`);\n return;\n }\n \n this.CloseMenu = () => {\n\n this.FocusedItem.classList.remove(STATE_OPEN);\n this.FocusedItem.classList.add(STATE_CLOSED);\n\n for (let i = 0, l = items.length; i < l; i++) {\n if (items[i].type === 'mobile')\n items[i].element.style.display = 'none'; \n }\n };\n\n this.GetItem = (index) => {\n\n for (let i = 0, l = items.length; i < l; i++) {\n if (items[i].index === index)\n return items[i];\n }\n\n return undefined;\n };\n\n this.GetItemsByAnchor = (anchor) => {\n\n const anchorItems = [];\n\n for (let i = 0, l = items.length; i < l; i++) {\n if (items[i].anchor === anchor)\n anchorItems.push(items[i]);\n }\n\n return anchorItems;\n }\n\n this.GoTo = (item) => {\n\n if (item.anchor !== '') {\n anchorTo(item);\n } else {\n location.href = item.href;\n }\n };\n\n this.IsOpen = () => {\n return this.FocusedItem.classList.contains('tw-arrow-up');\n };\n\n\n let initialWidth = window.innerWidth;\n\n this.OnResize = () => {\n let currentWidth = window.innerWidth;\n let widthDifference = Math.abs(currentWidth - initialWidth);\n\n if (new Date() - resizeRunTime < resizeDelta) {\n setTimeout(this.OnResize, resizeDelta);\n } else {\n if (widthDifference > 500) {\n location.reload();\n console.log(\"ACTIVE!\");\n }\n // Update initial width and resizeRunTime\n initialWidth = currentWidth;\n resizeRunTime = new Date();\n }\n };\n\n this.OpenMenu = () => {\n\n this.FocusedItem.classList.remove(STATE_CLOSED);\n this.FocusedItem.classList.add(STATE_OPEN);\n\n for (let i = 0, l = items.length; i < l; i++) { \n if(items[i].type === 'mobile')\n items[i].element.style.display = 'block';\n }\n };\n \n this.Set = (index) => {\n\n if (isScrolling) {\n setTimeout(() => { this.Set(index); }, 100);\n return;\n }\n\n const item = this.GetItem(index);\n\n if (item === undefined)\n return;\n\n this.SetFocus(item)\n\n this.SetFocusOnItem(item);\n\n isScrolling = true;\n\n this.GoTo(item);\n\n setTimeout(() => { isScrolling = false; }, 800);\n\n this.CloseMenu();\n };\n\n this.SetFocus = (item) => {\n\n this.FocusedItem.innerHTML = item.element.innerHTML;\n this.FocusedItem.dataset[DATASET_FOCUS] = item.index;\n };\n\n this.SetFocusOnItem = (item) => {\n\n item.isSelected = true;\n\n for (let i = 0, l = items.length; i < l; i++) {\n\n if (items[i].anchor !== '' && items[i].anchor === item.anchor) { \n items[i].element.classList.add(STATE_FOCUS); \n } else {\n items[i].element.classList.remove(STATE_FOCUS);\n items[i].isSelected = false;\n }\n }\n };\n\n this.SetScrollListener = () => {\n\n if (isListenerSet)\n mainSection.removeEventListener('scroll', setListener);\n\n setPositions();\n\n mainSection.addEventListener('scroll', setListener);\n\n resizeScrolling = true;\n isListenerSet = true;\n };\n\n this.ToggleMenu = () => {\n\n const isOpen = this.IsOpen();\n\n if (isOpen)\n this.CloseMenu();\n else\n this.OpenMenu();\n };\n\n const indexItems = parent.querySelectorAll('[data-index]');\n\n let isSelected = undefined;\n let parentHeight = getParentHeight();\n let isScrolling = false;\n let isListenerSet = false;\n let isResizing = false;\n let positions = [];\n let resizeDelta = 500;\n let resizeRunTime;\n let resizeScrolling = false;\n let resizeTimeOut = false;\n \n for (let i = 0, l = indexItems.length; i < l; i++) {\n\n const index = parseInt(indexItems[i].dataset['index']);\n if (isNaN(index))\n continue;\n\n const href = indexItems[i].dataset['href'];\n if (!href)\n continue;\n\n const element = indexItems[i];\n const self = this;\n const anchor = href.indexOf('#') === 0 ? href.substr(1, href.length) : '';\n const type = indexItems[i].dataset['type'] === 'desktop' ? 'desktop' : 'mobile';\n \n element.addEventListener('click', (e) => { self.Set(index); });\n\n isSelected = isSelected === undefined && element.dataset['selected'] === 'true';\n\n items.push({ index, href, isSelected, anchor, type, element });\n } \n\n this.FocusedItem.addEventListener('click', (e) => { this.ToggleMenu(); });\n\n window.addEventListener('resize', (event) => {\n resizeRunTime = new Date();\n if (!resizeTimeOut) {\n resizeTimeOut = true;\n setTimeout(this.OnResize, resizeDelta);\n }\n });\n}\n\nexport default async element => { // feature=\"ddlNav\"\n\n const ddlMenu = new menu(element);\n\n const firstItem = ddlMenu.GetItem(0);\n\n if (firstItem !== undefined && !firstItem.isSelected && ddlMenu.IsOpen())\n ddlMenu.Set(0);\n\n ddlMenu.SetScrollListener();\n};"],"names":["menu","parent","DATASET_FOCUS","STATE_CLOSED","STATE_OPEN","STATE_FOCUS","items","mainSection","document","querySelector","getParentHeight","parentElement","getBoundingClientRect","height","console","warn","anchorTo","item","element","positions","find","x","id","anchor","position","mainNavHeight","offsetTop","offset","parentHeight","top","scrollTo","clamp","value","Math","max","isBetween","floor","ceil","getPosition","getElementById","bottom","rect","listener","scroll","isScrolling","anchorInRange","anchorItems","GetItemsByAnchor","i","l","length","type","SetFocus","SetFocusOnItem","setListener","event","srcElement","scrollTop","setPositions","push","FocusedItem","CloseMenu","classList","remove","add","style","display","GetItem","index","undefined","GoTo","location","href","IsOpen","contains","initialWidth","window","innerWidth","OnResize","currentWidth","widthDifference","abs","Date","resizeRunTime","resizeDelta","setTimeout","reload","log","OpenMenu","Set","innerHTML","dataset","isSelected","SetScrollListener","isListenerSet","removeEventListener","addEventListener","resizeScrolling","ToggleMenu","isOpen","indexItems","querySelectorAll","isResizing","resizeTimeOut","parseInt","isNaN","self","indexOf","substr","e","ddlMenu","firstItem"],"sourceRoot":""}