{"version":3,"file":"page-intro.js","names":[],"sources":["../resources/modern-javascript/page-intro.js"],"sourcesContent":["import { delegate, Viewport } from '@d3r/js-tools';\n\nconst getIntro = (el) => {\n    return el.querySelector('.page-intro__intro');\n}\n\nconst getText = (el) => {\n    return el.querySelector('.page-intro__text');\n}\n\nconst getReadMore = (el) => {\n    return el.querySelector('.page-intro__read-more');\n}\n\nconst updateVisibility = (el) => {\n    const intro = getIntro(el);\n    const text = getText(el);\n    const readMore = getReadMore(el);\n\n    if (intro && text && readMore) {\n        if (text.offsetHeight > intro.offsetHeight) {\n            readMore.classList.add('page-intro__read-more--show');\n        } else {\n            readMore.classList.remove('page-intro__read-more--show');\n        }\n    }\n}\n\nconst checkInstances = () => {\n    document.querySelectorAll('.page-intro').forEach(el => {\n        updateVisibility(el)\n    });\n}\n\nconst observe = () => {\n    const viewport = new Viewport(Soho.breakpoints);\n\n    checkInstances();\n\n    viewport.resize(() => {\n        checkInstances();\n    });\n\n    delegate(document, 'click', '.page-intro__read-more', (e) => {\n        const pageIntro = e.target.closest('.page-intro');\n        const intro = getIntro(pageIntro);\n        const readMore = getReadMore(pageIntro);\n\n        if (intro && readMore) {\n            intro.classList.remove('page-intro__intro--compact');\n            readMore.remove();\n        }\n    });\n}\n\nif (document.readyState === 'loading') {\n    document.addEventListener('DOMContentLoaded', () => {\n        observe();\n    });\n} else {\n    observe();\n}\n"],"mappings":"6FAEA,IAAM,EAAA,SAAY,EAAO,CACrB,OAAO,EAAG,cAAc,oBAAoB,CAChD,EAEM,EAAA,SAAW,EAAO,CACpB,OAAO,EAAG,cAAc,mBAAmB,CAC/C,EAEM,EAAA,SAAe,EAAO,CACxB,OAAO,EAAG,cAAc,wBAAwB,CACpD,EAEM,EAAA,SAAoB,EAAO,CAC7B,IAAM,EAAQ,EAAS,CAAE,EACnB,EAAO,EAAQ,CAAE,EACjB,EAAW,EAAY,CAAE,EAE3B,GAAS,GAAQ,IACb,EAAK,aAAe,EAAM,aAC1B,EAAS,UAAU,IAAI,6BAA6B,EAEpD,EAAS,UAAU,OAAO,6BAA6B,EAGnE,EAEM,EAAA,UAAuB,CACzB,SAAS,iBAAiB,aAAa,CAAC,CAAC,QAAA,SAAQ,EAAM,CACnD,EAAiB,CAAE,CACvB,CAAC,CACL,EAEM,EAAA,UAAgB,CAClB,IAAM,EAAW,IAAI,EAAS,KAAK,WAAW,EAE9C,EAAe,EAEf,EAAS,OAAA,UAAa,CAClB,EAAe,CACnB,CAAC,EAED,EAAS,SAAU,QAAS,yBAAA,SAA2B,EAAM,CACzD,IAAM,EAAY,EAAE,OAAO,QAAQ,aAAa,EAC1C,EAAQ,EAAS,CAAS,EAC1B,EAAW,EAAY,CAAS,EAElC,GAAS,IACT,EAAM,UAAU,OAAO,4BAA4B,EACnD,EAAS,OAAO,EAExB,CAAC,CACL,EAEI,SAAS,aAAe,UACxB,SAAS,iBAAiB,mBAAA,UAA0B,CAChD,EAAQ,CACZ,CAAC,EAED,EAAQ"}