{"version":3,"sources":["webpack:///./src/js/modules/rif.js"],"names":["Object","entries","obj","ownProps","keys","i","length","resArray","Array","Rif","this","dom","$head","$","$sectionHeading","el","querySelector","$slider","$form","$submitButton","$formLoader","$location","$coutryOfCitizenship","$studentVisa","$studentVisaRadios","querySelectorAll","$address","$zipcode","$phone","$state","$back","$error","$ohNoInput","title","description","us","isUsCitizen","selectText","innerHTML","setupMasks","styleSelect","getData","window","addEventListener","fillFromPartial","onStep1Submit","updatePrograms","updateVisaFieldDisplay","IMask","mask","detail","location","program","rifTop","offsetTop","setLocationAndProgram","data","locations","document","documentElement","style","scrollTo","top","left","behavior","from","filter","input","value","dataLayer","dataset","dataLayerEvent","script","createElement","text","prepend","e","preventDefault","getFormObject","target","errors","createStep1ValidationSchema","validate","updateFormState","showLoader","post","serverErrors","global","handleServerErrors","hideLoader","remove","resetFormStatus","classList","add","setDataLayer","attr","hidden","hide","show","defaultOptions","itemSelectText","searchEnabled","shouldSort","locationChoices","Choices","containerOuter","element","setAttribute","programChoices","howDidYouHearChoices","hearAboutUs","stateChoices","state","provinceChoices","highSchoolGradYear","gradYear","countryOfCitizenshipChoices","countryCitizenship","checkString","val","Boolean","trim","Schema","type","String","required","min","use","message","getErrorMessage","match","isPlaceholder","phone","address","city","zipcode","studentVisa","field","fieldClass","getAttribute","form","forEach","checked","radio","count","err","path","error","newLocation","newProgram","setLocationChoices","sortChoicesGroups","group","sort","a","b","labelA","label","toUpperCase","labelB","filterorder","parsePrograms","programs","parsedPrograms","programGroupIndex","findIndex","push","id","choices","parsedLocations","locationGroupIndex","customProperties","setChoices","enable","_location","find","toLowerCase","setChoiceByValue","setValue","_program","currentLocation","currentProgram","sessionStorage","setItem","getItem","url","rifEndpoint","queryString","Url","query","getRifSessionInfo","storeLocationAndProgramSessionInfo","axios","get","countries","code","states","map","action","params","serialize","hash","choice","Component"],"mappings":"41FAUKA,OAAOC,UACVD,OAAOC,QAAU,SAAAC,GAKf,IAJA,IAAMC,EAAWH,OAAOI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,GAAK,MAAK,CAAEA,QAAOyF,MAAOzF,MAC1C,QACA,SACA,GAEDyG,SA9BP,iD,6FAkCA,8GACQY,EAAM/K,KAAKC,IAAIO,MAAMoL,OAD7B,SAEyBN,IAAMC,IAAIR,EAAK,CACpCc,OAAQC,IAAU9L,KAAKC,IAAIO,MAAO,CAAEuL,MAAM,MAH9C,uBAEUjJ,EAFV,EAEUA,KAFV,kBAMSA,EAAKwB,QANd,gD,yEASA,SAAeJ,GACblE,KAAKkG,eACFsE,SAAS,CAAErB,MAAOnJ,KAAK2B,WAAY+B,MAAO,WAC1CwG,WAAWhG,EAAE1B,OAAOwJ,OAAO/B,iBAAkB,QAAS,SAAS,GAC/DE,W,oCAGL,SAAuBjG,GACHA,EAAE1B,OAAOwJ,OAAnBtI,QAEM1D,KAAKyB,IACjBzB,KAAKC,IAAIY,aAAaqE,UAAUC,IAAI,aACpCnF,KAAK0B,aAAc,IAEnB1B,KAAKC,IAAIY,aAAaqE,UAAUF,OAAO,aACvChF,KAAK0B,aAAc,K,gCAIvB,SAAmBkD,GACbA,EAAaC,SACf7E,KAAKC,IAAIoB,OAAOO,UAAhB,qDAA0EgD,EAAaC,OAAvF,e,8BApkBYoH,aAykBHlM,a","file":"36.02d4ac44cd64965e3be9.js","sourcesContent":["import { Component } from '@verndale/core';\nimport axios from 'axios';\nimport IMask from 'imask';\nimport serialize from 'form-serialize';\nimport Choices from 'choices.js';\nimport Schema from 'validate';\nimport Url from 'domurl';\n\n// Object.entries entries polyfill\n\nif (!Object.entries) {\n Object.entries = obj => {\n const ownProps = Object.keys(obj);\n let i = ownProps.length;\n const resArray = new Array(i);\n\n while(i--) resArray[i] = [ownProps[i], obj[ownProps[i]]];\n return resArray;\n };\n}\n\nconst rifLocationKey = 'RIF-LOCATION-KEY';\nconst rifProgramKey = 'RIF-PROGRAM-KEY';\n\nclass Rif extends Component {\n setupDefaults() {\n this.dom = {\n $head: $('head'),\n $sectionHeading: this.el.querySelector('.section-heading__tag'),\n $slider: this.el.querySelector('.rif__steps'),\n $form: this.el.querySelector('.rif__step--one .rif__form'),\n $submitButton: this.el.querySelector('.rif__form .rif__submit'),\n $formLoader: this.el.querySelector('.rif__form .rif__loader'),\n $location: this.el.querySelector('[data-field=\"location\"]'),\n $coutryOfCitizenship: this.el.querySelector(\n '[data-field=\"country-of-citizenship\"]'\n ),\n $studentVisa: this.el.querySelector('[data-field=\"student-visa\"]'),\n $studentVisaRadios: this.el.querySelectorAll(\n '[data-field=\"student-visa\"] [type=\"radio\"]'\n ),\n $address: this.el.querySelector('[data-field=\"address\"] [type=\"text\"]'),\n $zipcode: this.el.querySelector(\n '[data-field=\"zipcode\"] input:not(.oh-no-input)'\n ),\n $phone: this.el.querySelector(\n '[data-field=\"phone\"] input:not(.oh-no-input)'\n ),\n $state: this.el.querySelector('[data-field=\"state\"]'),\n $back: this.el.querySelector('.rif__back'),\n $error: this.el.querySelector('.rif__global-error-wrapper'),\n $ohNoInput: this.el.querySelectorAll('.oh-no-input'),\n title: this.el.querySelector('.section-heading__title'),\n description: this.el.querySelector('.section-heading__description')\n };\n\n this.us = '';\n this.isUsCitizen = true;\n this.selectText = this.dom.$location.querySelector('option').innerHTML;\n this.setupMasks();\n this.styleSelect();\n this.getData();\n }\n\n addListeners() {\n window.addEventListener('fill-rif-from-partial', ::this.fillFromPartial);\n this.dom.$form.addEventListener('submit', ::this.onStep1Submit);\n this.dom.$location.addEventListener('choice', ::this.updatePrograms);\n this.dom.$coutryOfCitizenship.addEventListener(\n 'choice',\n ::this.updateVisaFieldDisplay\n );\n }\n\n setupMasks() {\n IMask(this.dom.$phone, { mask: '000-000-0000' });\n IMask(this.dom.$zipcode, { mask: '00000' });\n }\n\n fillFromPartial({ detail: { location, program } }) {\n const rifTop = this.el.offsetTop - 100;\n this.setLocationAndProgram(this.data.locations, location, program, false);\n const supportsNativeSmoothScroll =\n 'scrollBehavior' in document.documentElement.style;\n if (!supportsNativeSmoothScroll) {\n return window.scrollTo(0, rifTop);\n }\n window.scrollTo({\n top: rifTop,\n left: 0,\n behavior: 'smooth'\n });\n }\n\n isHoneypotClean() {\n return !Array.from(this.dom.$ohNoInput).filter(input => input.value)\n .length;\n }\n\n setDataLayer() {\n const { $sectionHeading, $head } = this.dom;\n\n const dataLayer = `\n window.dataLayer = window.dataLayer || [];\n window.dataLayer.push({\n 'event': '${this.el.dataset.dataLayerEvent}',\n 'visitorType':'${$sectionHeading.innerHTML}'\n });`;\n\n const script = document.createElement('script');\n script.text = dataLayer;\n\n $head.prepend(script);\n }\n\n async onStep1Submit(e) {\n e.preventDefault();\n //if (!this.isHoneypotClean()) return;\n const data = this.getFormObject(e.target);\n const errors = this.createStep1ValidationSchema().validate(data);\n if (errors.length) {\n this.updateFormState(errors, this.dom.$form);\n return;\n }\n this.showLoader();\n\n try {\n const serverErrors = await this.post();\n if (serverErrors && serverErrors.global) {\n this.handleServerErrors(serverErrors);\n this.hideLoader();\n return;\n }\n this.dom.title.remove();\n this.dom.description.remove();\n this.resetFormStatus(e.target);\n this.el.classList.add('success');\n window.scrollTo({\n top: this.el.offsetTop - 100,\n left: 0,\n behavior: 'smooth'\n });\n if (this.el.dataset.dataLayerEvent) {\n this.setDataLayer();\n }\n } catch (error) {\n this.hideLoader();\n }\n }\n\n showLoader() {\n $(this.dom.$formLoader).attr({\n 'aria-hidden': false,\n hidden: false\n });\n $(this.dom.$submitButton).hide();\n }\n\n hideLoader() {\n $(this.dom.$formLoader).attr({\n 'aria-hidden': true,\n hidden: true\n });\n $(this.dom.$submitButton).show();\n }\n\n styleSelect() {\n const defaultOptions = {\n itemSelectText: '',\n searchEnabled: false,\n shouldSort: false\n };\n\n this.locationChoices = new Choices(\n '.rif [data-field=\"location\"] .rif__field--select',\n defaultOptions\n );\n this.locationChoices.containerOuter.element.setAttribute('aria-label', this.el.dataset.location);\n\n this.programChoices = new Choices(\n '.rif [data-field=\"program\"] .rif__field--select',\n defaultOptions\n );\n this.programChoices.containerOuter.element.setAttribute('aria-label', this.el.dataset.program);\n\n this.howDidYouHearChoices = new Choices(\n '.rif [data-field=\"how-did-you-hear-about-us\"] .rif__field--select',\n defaultOptions\n );\n this.howDidYouHearChoices.containerOuter.element.setAttribute('aria-label', this.el.dataset.hearAboutUs);\n\n this.stateChoices = new Choices(\n '.rif [data-field=\"state\"] .rif__field--select',\n defaultOptions\n );\n this.stateChoices.containerOuter.element.setAttribute('aria-label', this.el.dataset.state);\n\n this.provinceChoices = new Choices(\n '.rif [data-field=\"province\"] .rif__field--select',\n defaultOptions\n );\n\n this.highSchoolGradYear = new Choices(\n '.rif [data-field=\"high-school-grad-year\"] .rif__field--select',\n defaultOptions\n );\n this.highSchoolGradYear.containerOuter.element.setAttribute('aria-label', this.el.dataset.gradYear);\n\n this.countryOfCitizenshipChoices = new Choices(\n '.rif [data-field=\"country-of-citizenship\"] .rif__field--select',\n defaultOptions\n );\n this.countryOfCitizenshipChoices.containerOuter.element.setAttribute('aria-label', this.el.dataset.countryCitizenship);\n\n }\n\n createStep1ValidationSchema() {\n const isPlaceholder = val => val !== 'select';\n\n const zipcode = val => {\n const length = val.length;\n return length === 5 && val.match(/[0-9]/);\n };\n\n const checkString = val => Boolean(val.trim().length >= 2);\n\n const state = val => {\n if (val.length) return true;\n return false;\n };\n\n const studentVisa = val =>\n this.isUsCitizen || (!this.isUsCitizen && !!val);\n\n return new Schema({\n 'first-name': {\n type: String,\n required: true,\n length: { min: 2 },\n use: { checkString },\n message: {\n required: this.getErrorMessage('first-name', 'required'),\n length: this.getErrorMessage('first-name', 'invalid'),\n checkString: this.getErrorMessage('first-name', 'required')\n }\n },\n 'last-name': {\n type: String,\n required: true,\n length: { min: 2 },\n use: { checkString },\n message: {\n required: this.getErrorMessage('last-name', 'required'),\n length: this.getErrorMessage('last-name', 'invalid'),\n checkString: this.getErrorMessage('last-name', 'required')\n }\n },\n 'email-address': {\n type: String,\n required: true,\n match: /^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$/,\n message: {\n required: this.getErrorMessage('email-address', 'required'),\n match: this.getErrorMessage('email-address', 'valid')\n }\n },\n location: {\n type: String,\n required: true,\n message: {\n required: this.getErrorMessage('location', 'required')\n }\n },\n program: {\n type: String,\n required: true,\n use: { isPlaceholder },\n message: {\n required: this.getErrorMessage('program', 'required'),\n isPlaceholder: this.getErrorMessage('program', 'required')\n }\n },\n phone: {\n type: String,\n required: true,\n match: /[2-9][0-9]{2}-[0-9]{3}-[0-9]{4}/,\n message: {\n required: this.getErrorMessage('phone', 'required'),\n match: this.getErrorMessage('phone', 'valid')\n }\n },\n 'how-did-you-hear-about-us': {\n type: String,\n required: true,\n message: {\n required: this.getErrorMessage(\n 'how-did-you-hear-about-us',\n 'required'\n )\n }\n },\n address: {\n type: String,\n required: true,\n message: {\n required: this.getErrorMessage('address', 'required')\n }\n },\n city: {\n type: String,\n required: true,\n message: {\n required: this.getErrorMessage('city', 'required')\n }\n },\n zipcode: {\n required: true,\n use: { zipcode },\n message: this.getErrorMessage('zipcode', 'required')\n },\n state: {\n use: { state },\n message: this.getErrorMessage('state', 'required')\n },\n 'student-visa': {\n use: { studentVisa },\n message: this.getErrorMessage('student-visa', 'required')\n },\n 'high-school-grad-year': {\n type: String,\n required: true,\n message: {\n required: this.getErrorMessage('high-school-grad-year', 'required')\n }\n }\n });\n }\n\n getErrorMessage(field, type) {\n const fieldClass = field === 'student-visa' ? 'rif__radios' : 'rif__field';\n return this.el\n .querySelector(`[data-field=${field}]`)\n .querySelector(`.${fieldClass}`)\n .getAttribute(`data-msg-${type}`);\n }\n\n getFormObject(form) {\n const obj = {};\n form.querySelectorAll('.rif__field-wrapper').forEach(el => {\n const { field } = el.dataset;\n if (field === 'student-visa') {\n const checked = [...el.querySelectorAll('[type=\"radio\"]')].filter(\n radio => radio.checked\n ).length;\n obj[field] = checked ? 'yes' : '';\n } else {\n obj[field] = el.querySelector('.rif__field').value;\n }\n });\n\n return obj;\n }\n\n updateFormState(errors, form) {\n let count = 0;\n\n this.resetFormStatus(form);\n\n errors.forEach(err => {\n const field = form.querySelector(`[data-field=${err.path}]`);\n if (field) {\n const error = field.querySelector('.rif__error-wrapper');\n field.classList.add('error');\n if (err.path === 'phone') {\n error.innerHTML = `\n \n \n Please enter a valid Phone Number\n \n `;\n } else {\n error.innerHTML = `\n \n \n ${err.message}\n \n `;\n }\n count = count + 1;\n }\n });\n\n return count;\n }\n\n resetFormStatus(form) {\n this.dom.$error.innerHTML = '';\n\n form.querySelectorAll('.rif__field-wrapper').forEach(el => {\n const error = el.querySelector('.rif__error-wrapper');\n el.classList.remove('error');\n error.innerHTML = '';\n });\n }\n\n setLocationAndProgram(\n locations,\n newLocation,\n newProgram,\n setLocationChoices = true\n ) {\n const sortChoicesGroups = group =>\n group\n .sort((a, b) => {\n const labelA = a.label.toUpperCase();\n const labelB = b.label.toUpperCase();\n if (labelA < labelB) return -1;\n if (labelA > labelB) return 1;\n return 0;\n })\n .sort((a, b) => a.filterorder - b.filterorder);\n\n const parsePrograms = (programs = []) => {\n const parsedPrograms = [];\n programs.forEach(program => {\n const programGroupIndex = parsedPrograms.findIndex(\n ({ label }) => label === program.group\n );\n if (programGroupIndex < 0) {\n parsedPrograms.push({\n label: program.group,\n id: program.value,\n filterorder: program.filterorder,\n choices: [\n {\n filterorder: program.filterorder,\n value: program.value,\n label: program.label\n }\n ]\n });\n } else {\n parsedPrograms[programGroupIndex].choices.push({\n value: program.value,\n label: program.label,\n filterorder: program.filterorder\n });\n }\n });\n parsedPrograms.forEach(({ choices }) => sortChoicesGroups(choices));\n sortChoicesGroups(parsedPrograms);\n return parsedPrograms;\n };\n\n if (locations && locations.length) {\n // Parsed locations\n const parsedLocations = [];\n locations.forEach(location => {\n const locationGroupIndex = parsedLocations.findIndex(\n ({ label }) => label === location.group\n );\n if (locationGroupIndex < 0) {\n parsedLocations.push({\n label: location.group,\n filterorder: location.filterorder,\n id: location.group,\n choices: [\n {\n value: location.value,\n label: location.label,\n customProperties: parsePrograms(location.programs)\n }\n ]\n });\n } else {\n parsedLocations[locationGroupIndex].choices.push({\n value: location.value,\n label: location.label,\n customProperties: parsePrograms(location.programs)\n });\n }\n });\n parsedLocations.forEach(({ choices }) => sortChoicesGroups(choices));\n sortChoicesGroups(parsedLocations);\n // Set locations\n if (setLocationChoices) {\n this.locationChoices\n .setChoices(parsedLocations, 'value', 'label', false)\n .enable();\n }\n\n // Set default values if newLocation exists\n if (newLocation) {\n let location, program;\n parsedLocations.forEach(({ choices }) => {\n const _location = choices.find(\n ({ value }) => value.toLowerCase() === newLocation.toLowerCase()\n );\n if (_location) location = _location;\n });\n // Set default default location if exists\n if (!location) return;\n this.locationChoices.setChoiceByValue(newLocation);\n // Set location programs\n const programs = location.customProperties;\n this.programChoices\n .setValue({ label: this.selectText, value: 'select' })\n .setChoices(programs, 'value', 'label', true)\n .enable();\n // Set default program if exists\n programs.forEach(({ choices }) => {\n const _program = choices.find(\n ({ value }) => String(value) === String(newProgram)\n );\n if (_program) program = _program;\n });\n if (program) {\n this.programChoices.setChoiceByValue(newProgram);\n }\n }\n }\n }\n\n storeLocationAndProgramSessionInfo() {\n // Get info from element dataset\n const { currentLocation, currentProgram } = this.el.dataset;\n // Update info only if location exists\n if (currentLocation) {\n window.sessionStorage.setItem(rifLocationKey, currentLocation);\n window.sessionStorage.setItem(rifProgramKey, currentProgram);\n }\n }\n\n getRifSessionInfo() {\n return {\n location: window.sessionStorage.getItem(rifLocationKey),\n program: window.sessionStorage.getItem(rifProgramKey)\n };\n }\n\n async getData() {\n const url = this.el.dataset.rifEndpoint;\n const queryString = new Url().query;\n const { location, program } = this.getRifSessionInfo();\n const currentLocation =\n queryString.location || this.el.dataset.currentLocation || location;\n const currentProgram =\n queryString.program || this.el.dataset.currentProgram || program;\n this.storeLocationAndProgramSessionInfo();\n const { data } = await axios.get(url);\n this.data = data;\n\n this.setLocationAndProgram(data.locations, currentLocation, currentProgram);\n\n if (data.countries && data.countries.length) {\n this.us = data.countries[0].code;\n this.countryOfCitizenshipChoices\n .setChoices(data.countries, 'code', 'name', false)\n .enable()\n .setChoiceByValue(this.us);\n }\n\n if (data.states && data.states.length) {\n this.stateChoices\n .setChoices(\n data.states.map(value => ({ value, label: value })),\n 'value',\n 'label',\n false\n )\n .enable();\n }\n }\n\n async post() {\n const url = this.dom.$form.action;\n const { data } = await axios.get(url, {\n params: serialize(this.dom.$form, { hash: true })\n });\n\n return data.errors;\n }\n\n updatePrograms(e) {\n this.programChoices\n .setValue({ label: this.selectText, value: 'select' })\n .setChoices(e.detail.choice.customProperties, 'value', 'label', true)\n .enable();\n }\n\n updateVisaFieldDisplay(e) {\n const { value } = e.detail.choice;\n\n if (value === this.us) {\n this.dom.$studentVisa.classList.add('is-hidden');\n this.isUsCitizen = true;\n } else {\n this.dom.$studentVisa.classList.remove('is-hidden');\n this.isUsCitizen = false;\n }\n }\n\n handleServerErrors(serverErrors) {\n if (serverErrors.global) {\n this.dom.$error.innerHTML = `${serverErrors.global}`;\n }\n }\n}\n\nexport default Rif;\n"],"sourceRoot":""}