{"version":3,"sources":["webpack:///./src/feature/question-view/question-view.js"],"names":["classes","section","sectionActive","sectionClosed","step","stepClosed","QuestionView","element","el","initDomCache","sectionId","getAttribute","steps","querySelectorAll","nextStep","prevStep","openOnRender","animationDuration","closeTimeout","addEventListeners","addSubscriptions","dom","toggle","addEventListener","classList","contains","openSection","closeSection","forEach","button","handleNextStep","publish","handlePrevStep","subscribe","newHeight","content","firstChild","nextSibling","offsetHeight","add","remove","expansionBlockActive","setAttribute","style","maxHeight","setTimeout","closest","nextElementSibling","closeStep","openStep","previousElementSibling","attr","BaseFeature"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;;;;;;;;;AAEA,IAAMA,UAAU;AACfC,UAAS,0BADM;AAEfC,gBAAe,yBAFA;AAGfC,gBAAe,yBAHA;AAIfC,OAAM,4BAJS;AAKfC,aAAY;AALG,CAAhB;;IAQqBC,Y;;;AACpB,uBAAYC,OAAZ,EAAqB;AAAA;;AAAA,0HACdA,OADc;;AAEpB,QAAKC,EAAL,GAAUD,OAAV;AACA,QAAKE,YAAL;;AAEA,QAAKC,SAAL,GAAiB,MAAKF,EAAL,CAAQG,YAAR,CAAqB,gBAArB,CAAjB;AACA,QAAKC,KAAL,GAAa,MAAKJ,EAAL,CAAQK,gBAAR,CAAyB,aAAzB,CAAb;AACA,QAAKC,QAAL,GAAgB,MAAKN,EAAL,CAAQK,gBAAR,CAAyB,uBAAzB,CAAhB;AACA,QAAKE,QAAL,GAAgB,MAAKP,EAAL,CAAQK,gBAAR,CAAyB,uBAAzB,CAAhB;AACA,QAAKG,YAAL,GAAoB,MAAKR,EAAL,CAAQG,YAAR,CAAqB,qBAArB,CAApB;AACA;AACA;AACA,QAAKM,iBAAL,GAAyB,GAAzB;AACA,QAAKC,YAAL,GAAoB,IAApB;AACA,QAAKC,iBAAL;AACA,QAAKC,gBAAL;AAfoB;AAgBpB;;;;sCAEmB;AAAA;;AACnB,OAAI,KAAKC,GAAL,CAASC,MAAb,EAAqB;A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AI,IAAvC;AACA;;;iCAEqBf,M,EAAQ;AAC7B,OAAMd,WAAWc,OAAOiB,OAAP,OAAmB9C,QAAQI,IAA3B,CAAjB;AACA,OAAMU,WAAWC,SAASgC,kBAA1B;AACAzC,gBAAa0C,SAAb,CAAuBjC,QAAvB;AACAT,gBAAa2C,QAAb,CAAsBnC,QAAtB;AACA;;;iCACqBe,M,EAAQ;AAC7B,OAAMd,WAAWc,OAAOiB,OAAP,OAAmB9C,QAAQI,IAA3B,CAAjB;AACA,OAAMU,WAAWC,SAASmC,sBAA1B;AACA5C,gBAAa0C,SAAb,CAAuBjC,QAAvB;AACAT,gBAAa2C,QAAb,CAAsBnC,QAAtB;AACA;;;4BAEgBC,Q,EAAU;AAC1B;AACA,yBAAEA,QAAF,EAAYoC,IAAZ,CAAiB,UAAjB,EAA6B,IAA7B;AACApC,YAASS,SAAT,CAAmBe,GAAnB,CAAuBvC,QAAQK,UAA/B;AACA;;;2BACeU,Q,EAAU;AACzB;AACA,yBAAEA,QAAF,EAAYoC,IAAZ,CAAiB,UAAjB,EAA6B,KAA7B;AACApC,YAASS,SAAT,CAAmBgB,MAAnB,CAA0BxC,QAAQK,UAAlC;AACA;;;;EA7GwC+C,c;;kBAArB9C,Y","file":"35-5fd35321.pkg.js","sourcesContent":["import $ from 'jquery';\r\nimport BaseFeature from '../../foundation/base/base';\r\n\r\nconst classes = {\r\n\tsection: 'o-question-view__section',\r\n\tsectionActive: 'o-question-view--active',\r\n\tsectionClosed: 'o-question-view--closed',\r\n\tstep: 'o-question-view__form-step',\r\n\tstepClosed: 'o-question-view__form-step--hidden'\r\n};\r\n\r\nexport default class QuestionView extends BaseFeature {\r\n\tconstructor(element) {\r\n\t\tsuper(element);\r\n\t\tthis.el = element;\r\n\t\tthis.initDomCache();\r\n\r\n\t\tthis.sectionId = this.el.getAttribute('[data-section]');\r\n\t\tthis.steps = this.el.querySelectorAll('[data-step]');\r\n\t\tthis.nextStep = this.el.querySelectorAll('[data-js=\"next-step\"]');\r\n\t\tthis.prevStep = this.el.querySelectorAll('[data-js=\"prev-step\"]');\r\n\t\tthis.openOnRender = this.el.getAttribute('data-open-on-render');\r\n\t\t// Timeout corresponds to animation duration in scss.\r\n\t\t// If changed,this must be changed in styling for checkout sections as well.\r\n\t\tthis.animationDuration = 400;\r\n\t\tthis.closeTimeout = null;\r\n\t\tthis.addEventListeners();\r\n\t\tthis.addSubscriptions();\r\n\t}\r\n\r\n\taddEventListeners() {\r\n\t\tif (this.dom.toggle) {\r\n\t\t\tthis.addEventListener(this.dom.toggle, 'click', () => {\r\n\t\t\t\tif (this.el.classList.contains(classes.sectionClosed)) {\r\n\t\t\t\t\tthis.openSection();\r\n\t\t\t\t} else if (this.el.classList.contains(classes.sectionActive)) {\r\n\t\t\t\t\tthis.closeSection();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.nextStep) {\r\n\t\t\tthis.nextStep.forEach((button) => {\r\n\t\t\t\tthis.addEventListener(button, 'click', () => {\r\n\t\t\t\t\tQuestionView.handleNextStep(button);\r\n\t\t\t\t\tthis.publish('/sofo/trackSection');\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.prevStep) {\r\n\t\t\tthis.prevStep.forEach((button) => {\r\n\t\t\t\tthis.addEventListener(button, 'click', () => {\r\n\t\t\t\t\tQuestionView.handlePrevStep(button);\r\n\t\t\t\t\tthis.publish('/sofo/trackSection');\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\taddSubscriptions() {\r\n\t\tthis.subscribe('/form/question/close', ({ section }) => {\r\n\t\t\tif (section === this.el) {\r\n\t\t\t\tthis.closeSection();\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis.subscribe('/form/question/open', ({ section }) => {\r\n\t\t\tif (section === this.el) {\r\n\t\t\t\tthis.openSection();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\topenSection() {\r\n\t\tconst newHeight = this.dom.content.firstChild.nextSibling.offsetHeight;\r\n\t\tthis.el.classList.add(classes.sectionActive);\r\n\t\tthis.el.classList.remove(classes.sectionClosed);\r\n\r\n\t\tthis.el.classList.add(classes.expansionBlockActive);\r\n\t\tthis.el.setAttribute('aria-expanded', 'true');\r\n\t\tthis.dom.content.setAttribute('aria-hidden', 'false');\r\n\t\tthis.dom.content.style.maxHeight = newHeight + 'px';\r\n\r\n\t\tthis.closeTimeout = setTimeout(() => {\r\n\t\t\tthis.dom.content.style.maxHeight = 'none';\r\n\t\t}, this.animationDuration);\r\n\t}\r\n\r\n\tcloseSection() {\r\n\t\tconst newHeight = this.dom.content.firstChild.nextSibling.offsetHeight;\r\n\t\tthis.el.setAttribute('aria-expanded', 'false');\r\n\t\tthis.dom.content.setAttribute('aria-hidden', 'true');\r\n\t\tthis.dom.content.style.maxHeight = newHeight + 'px';\r\n\t\tthis.el.classList.remove(classes.sectionActive);\r\n\t\tthis.el.classList.add(classes.sectionClosed);\r\n\t\tthis.dom.content.style.maxHeight = 0 + 'px';\r\n\t}\r\n\r\n\tstatic handleNextStep(button) {\r\n\t\tconst prevStep = button.closest(`.${classes.step}`);\r\n\t\tconst nextStep = prevStep.nextElementSibling;\r\n\t\tQuestionView.closeStep(prevStep);\r\n\t\tQuestionView.openStep(nextStep);\r\n\t}\r\n\tstatic handlePrevStep(button) {\r\n\t\tconst prevStep = button.closest(`.${classes.step}`);\r\n\t\tconst nextStep = prevStep.previousElementSibling;\r\n\t\tQuestionView.closeStep(prevStep);\r\n\t\tQuestionView.openStep(nextStep);\r\n\t}\r\n\r\n\tstatic closeStep(prevStep) {\r\n\t\t// disable all inputs in skipped step\r\n\t\t$(prevStep).attr('disabled', true);\r\n\t\tprevStep.classList.add(classes.stepClosed);\r\n\t}\r\n\tstatic openStep(prevStep) {\r\n\t\t// enable all inputs in current step\r\n\t\t$(prevStep).attr('disabled', false);\r\n\t\tprevStep.classList.remove(classes.stepClosed);\r\n\t}\r\n}\r\n"],"sourceRoot":""}