{"version":3,"sources":["webpack:///./src/js/components/dropdown.js","webpack:///./src/js/modules/online-learning-card.js"],"names":["Dropdown","this","choices","Choices","el","itemSelectText","searchEnabled","shouldSort","value","setChoiceByValue","Component","OnlineLearningCard","dom","campusDropdown","querySelector","cta","locations","dataset","JSON","parse","length","fillLocations","addEventListener","e","handleCampusChange","forEach","location","option","document","createElement","textContent","label","appendChild","initDropdown","setAttribute","ariaLabel","href","classList","remove","tabIndex","add","target","selectedLocation","find","enableCta","url","disableCta"],"mappings":"ykDAGMA,E,sWACJ,WACEC,KAAKC,QAAU,IAAIC,IAAQF,KAAKG,GAAI,CAClCC,eAAgB,GAChBC,eAAe,EACfC,YAAY,M,8BAIhB,SAAiBC,GACfP,KAAKC,QAAQO,iBAAiBD,Q,8BAVXE,aAcRV,O,yhDCdTW,E,sWACJ,WACEV,KAAKW,IAAM,CACTC,eAAgBZ,KAAKG,GAAGU,cAAc,mCACtCC,IAAKd,KAAKG,GAAGU,cAAc,+BAG7Bb,KAAKe,UAAYf,KAAKG,GAAGa,QAAQD,UAAYE,KAAKC,MAAMlB,KAAKG,GAAGa,QAAQD,WAAa,KAEjFf,KAAKe,WAAaf,KAAKW,IAAIC,eAAeO,QAC5CnB,KAAKoB,kB,0BAIT,WAAe,WACTpB,KAAKe,WAAaf,KAAKW,IAAIC,eAAeO,QAC5CnB,KAAKW,IAAIC,eAAeS,iBAAiB,UAAU,SAAAC,GAAC,OAAI,EAAKC,mBAAmBD,Q,2BAIpF,WAAgB,WACdtB,KAAKe,UAAUS,SAAQ,SAAAC,GACrB,IAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOnB,MAAQkB,EAASlB,MACxBmB,EAAOG,YAAcJ,EAASK,MAC9B,EAAKnB,IAAIC,eAAemB,YAAYL,MAGtC1B,KAAKgC,iB,0BAGP,WACE,IAAIjC,IAASC,KAAKW,IAAIC,gBACNZ,KAAKG,GAAGU,cAAc,YAC9BoB,aAAa,aAAcjC,KAAKW,IAAIC,eAAesB,a,uBAG7D,SAAUC,GACRnC,KAAKW,IAAIG,IAAIsB,UAAUC,OAAO,uCAC9BrC,KAAKW,IAAIG,IAAIwB,SAAW,EACxBtC,KAAKW,IAAIG,IAAIqB,KAAOA,I,wBAGtB,WACEnC,KAAKW,IAAIG,IAAIsB,UAAUG,IAAI,uCAC3BvC,KAAKW,IAAIG,IAAIwB,UAAY,I,gCAG3B,SAAmBhB,GACjB,IAAMf,EAAQe,EAAEkB,OAAOjC,MAEvB,GAAKA,EAAL,CAKA,IAAMkC,EAAmBzC,KAAKe,UAAU2B,MAAK,SAAAjB,GAAQ,OAAIA,EAASlB,QAAUA,KAC5EP,KAAK2C,UAAUF,EAAiBG,UAL9B5C,KAAK6C,kB,8BApDsBpC,aA6DlBC","file":"30.918ffc89cf50c9186c67.js","sourcesContent":["import { Component } from '@verndale/core';\nimport Choices from 'choices.js';\n\nclass Dropdown extends Component {\n setupDefaults() {\n this.choices = new Choices(this.el, {\n itemSelectText: '',\n searchEnabled: false,\n shouldSort: false\n });\n }\n\n setChoiceByValue(value) {\n this.choices.setChoiceByValue(value);\n }\n}\n\nexport default Dropdown;\n","import { Component } from '@verndale/core';\nimport Dropdown from '../components/dropdown';\n\nclass OnlineLearningCard extends Component {\n setupDefaults() {\n this.dom = {\n campusDropdown: this.el.querySelector('.online-learning-card__dropdown'),\n cta: this.el.querySelector('.online-learning-card__cta')\n };\n\n this.locations = this.el.dataset.locations ? JSON.parse(this.el.dataset.locations) : null;\n\n if (this.locations && this.dom.campusDropdown.length) {\n this.fillLocations();\n }\n }\n\n addListeners() {\n if (this.locations && this.dom.campusDropdown.length) {\n this.dom.campusDropdown.addEventListener('change', e => this.handleCampusChange(e));\n }\n }\n\n fillLocations() {\n this.locations.forEach(location => {\n const option = document.createElement('option');\n option.value = location.value;\n option.textContent = location.label;\n this.dom.campusDropdown.appendChild(option);\n });\n\n this.initDropdown();\n }\n\n initDropdown() {\n new Dropdown(this.dom.campusDropdown);\n const choices = this.el.querySelector('.choices');\n choices.setAttribute('aria-label', this.dom.campusDropdown.ariaLabel);\n }\n\n enableCta(href) {\n this.dom.cta.classList.remove('online-learning-card__cta--disabled');\n this.dom.cta.tabIndex = 0;\n this.dom.cta.href = href;\n }\n\n disableCta() {\n this.dom.cta.classList.add('online-learning-card__cta--disabled');\n this.dom.cta.tabIndex = -1;\n }\n\n handleCampusChange(e) {\n const value = e.target.value;\n\n if (!value) {\n this.disableCta();\n return;\n }\n\n const selectedLocation = this.locations.find(location => location.value === value);\n this.enableCta(selectedLocation.url);\n }\n}\n\nexport default OnlineLearningCard;\n"],"sourceRoot":""}