{"version":3,"sources":["webpack:///./src/js/modules/short-form.js"],"names":["shortForm","Component","setupDefaults","this","dom","$footnotesBtnShowMore","el","querySelectorAll","$footnotesBtnShowLess","$footnotesContentHiddenWrapper","showMoreInitState","addListeners","forEach","btn","addEventListener","handleFootnotesButtonClick","bind","wrapper","Array","from","children","reduce","acc","child","offsetHeight","nextElementSibling","style","display","e","target","parentElement","previousElementSibling","classList","toggle"],"mappings":"0FAAA,uBAGA,MAAMA,UAAkBC,YACtBC,gBACEC,KAAKC,IAAM,CACTC,sBAAuBF,KAAKG,GAAGC,iBAAiB,yCAChDC,sBAAuBL,KAAKG,GAAGC,iBAAiB,yCAChDE,+BAAgCN,KAAKG,GAAGC,iBAAiB,2CAG3DJ,KAAKO,oBAGPC,eACER,KAAKC,IAAIC,sBAAsBO,QAASC,IACtCA,EAAIC,iBAAiB,QAASX,KAAKY,2BAA2BC,KAAKb,SAErEA,KAAKC,IAAII,sBAAsBI,QAASC,IACtCA,EAAIC,iBAAiB,QAASX,KAAKY,2BAA2BC,KAAKb,SAIvEO,oBAEEP,KAAKC,IAAIK,+BAA+BG,QAASK,IAE/C,GADeC,MAAMC,KAAKF,EAAQG,UAAUC,OAAO,CAACC,EAAKC,IAAUD,EAAMC,EAAMC,aAAc,IAC/E,GAAI,CACcP,EAAQQ,mBAChBC,MAAMC,QAAU,UAK5CZ,2BAA2Ba,GAEIA,EAAEC,OAAOC,cAAcC,uBAC/BC,UAAUC,OAAO,yCAEvBL,EAAEC,OAAOC,cACjBE,UAAUC,OAAO,WAKbjC","file":"31.66c571714c26fcee97eb.js","sourcesContent":["import { Component } from '@verndale/core';\nimport { setParentBlockSize } from '../utils/dom';\n\nclass shortForm extends Component {\n setupDefaults() {\n this.dom = {\n $footnotesBtnShowMore: this.el.querySelectorAll('.short-form__footnotes-cta--show-more'),\n $footnotesBtnShowLess: this.el.querySelectorAll('.short-form__footnotes-cta--show-less'),\n $footnotesContentHiddenWrapper: this.el.querySelectorAll('.short-form__footnotes-content--hidden')\n };\n\n this.showMoreInitState();\n }\n\n addListeners() {\n this.dom.$footnotesBtnShowMore.forEach((btn) => {\n btn.addEventListener('click', this.handleFootnotesButtonClick.bind(this));\n });\n this.dom.$footnotesBtnShowLess.forEach((btn) => {\n btn.addEventListener('click', this.handleFootnotesButtonClick.bind(this));\n });\n }\n\n showMoreInitState() {\n const hiddenWrapper = '80px';\n this.dom.$footnotesContentHiddenWrapper.forEach((wrapper) => {\n const height = Array.from(wrapper.children).reduce((acc, child) => acc + child.offsetHeight, 0);\n if (height <= 80) {\n const footnotesBtnContainer = wrapper.nextElementSibling;\n footnotesBtnContainer.style.display = 'none';\n }\n });\n }\n\n handleFootnotesButtonClick(e) {\n // find the previous element siblign of its parent\n const hiddenContentWrapper = e.target.parentElement.previousElementSibling;\n hiddenContentWrapper.classList.toggle('short-form__footnotes-content--hidden');\n // find the parent\n const parent = e.target.parentElement;\n parent.classList.toggle('hidden');\n }\n\n}\n\nexport default shortForm;\n"],"sourceRoot":""}