{"version":3,"sources":["webpack:///./src/js/modules/content-row.js"],"names":["ContentRow","Component","setupDefaults","this","dom","copy","el","querySelector","link","videoPlaceholder","expandableCopy","dataset","setupVideoObserver","addEventListener","moduleId","id","replace","loadVideo","focusableElements","querySelectorAll","isExpanded","makeCopyExpandable","console","warn","IntersectionObserver","entries","observer","forEach","entry","isIntersecting","target","error","unobserve","root","rootMargin","threshold","observe","placeholder","document","getElementById","videoId","getAttribute","videoSource","iframe","createElement","src","setAttribute","style","height","width","innerHTML","appendChild","parentDiv","parentElement","readMoreButton","classList","add","innerText","readMoreLabel","previousElementSibling","contains","insertBefore","append","calculateTabIndex","handleReadMore","bind","textContent","remove","readLessLabel","element","tabIndex","containerTop","getBoundingClientRect","top","elementTop","maxHeight"],"mappings":"2FAAA,yBAMA,MAAMA,UAAmBC,YACvBC,gBACEC,KAAKC,IAAM,CACTC,KAAMF,KAAKG,GAAGC,cAAc,qBAC5BC,KAAML,KAAKG,GAAGC,cAAc,oBAC5BE,iBAAkBN,KAAKG,GAAGC,cAAc,6BACxCG,eAAgBP,KAAKG,GAAGK,QAAQD,gBAE9BP,KAAKC,IAAIK,mBACXN,KAAKS,qBACLT,KAAKC,IAAIK,iBAAiBI,iBAAiB,QAAS,KAClD,MAAMC,EAAWX,KAAKC,IAAIK,iBAAiBM,GAAGC,QAAQ,qBAAsB,IAC5Eb,KAAKc,UAAUH,MAGnBX,KAAKe,kBAAoBf,KAAKC,IAAIC,KAAKc,iBAAiBD,KACxDf,KAAKiB,YAAa,EAClBjB,KAAKkB,qBAEPT,qBACE,IAAKT,KAAKC,IAAIK,iBAEZ,YADAa,QAAQC,KAAK,+BAGE,IAAIC,qBAAqB,CAACC,EAASC,KAClDD,EAAQE,QAASC,IACf,GAAIA,EAAMC,eAAgB,CACxB,MAAMf,EAAWc,EAAME,OAAOf,GAAGC,QAAQ,qBAAsB,IAC3DF,EACFX,KAAKc,UAAUH,GAEfQ,QAAQS,MAAM,yCAA0CH,EAAME,QAEhEJ,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AI,gCAIhCQ,iBACO7D,KAAKiB,YAMRjB,KAAKiB,YAAa,EAClBjB,KAAKC,IAAIC,KAAKkD,UAAUC,IAAI,+BAC5BrD,KAAKmD,eAAeY,YAAc/D,KAAKG,GAAGK,QAAQ+C,cAClDvD,KAAK4D,sBARL5D,KAAKiB,YAAa,EAClBjB,KAAKC,IAAIC,KAAKkD,UAAUY,OAAO,+BAC/BhE,KAAKmD,eAAeY,YAAc/D,KAAKG,GAAGK,QAAQyD,cAClDjE,KAAKe,kBAAkBS,QAAS0C,GAAaA,EAAQC,SAAW,IASpEP,oBACE5D,KAAKe,kBAAkBS,QAAS0C,IAC9B,MAAME,EAAepE,KAAKC,IAAIC,KAAKmE,wBAAwBC,IACrDC,EAAaL,EAAQG,wBAAwBC,IAEnDJ,EAAQC,SAAWI,EAAaH,EAAeI,KAA0B,EAAI,KAKpE3E","file":"90.bundle.js","sourcesContent":["import { Component } from '@verndale/core'\nimport { focusableElements } from '../utils'\n\nconst maxHeight = 250\nconst fadeHeight = 120\n\nclass ContentRow extends Component {\n setupDefaults() {\n this.dom = {\n copy: this.el.querySelector('.content-row-copy'),\n link: this.el.querySelector('.content-row-cta'),\n videoPlaceholder: this.el.querySelector('.content-row-image--video'),\n expandableCopy: this.el.dataset.expandableCopy\n }\n if (this.dom.videoPlaceholder) {\n this.setupVideoObserver();\n this.dom.videoPlaceholder.addEventListener('click', () => {\n const moduleId = this.dom.videoPlaceholder.id.replace('video-placeholder-', '');\n this.loadVideo(moduleId);\n });\n }\n this.focusableElements = this.dom.copy.querySelectorAll(focusableElements)\n this.isExpanded = false\n this.makeCopyExpandable()\n }\n setupVideoObserver() {\n if (!this.dom.videoPlaceholder) {\n console.warn('No video placeholder found.');\n return;\n }\n const observer = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n const moduleId = entry.target.id.replace('video-placeholder-', '');\n if (moduleId) {\n this.loadVideo(moduleId);\n } else {\n console.error('Module ID not found for video element:', entry.target);\n }\n observer.unobserve(entry.target);\n }\n });\n }, { root: null, rootMargin: '0px', threshold: 0.1 });\n\n observer.observe(this.dom.videoPlaceholder);\n }\n\n loadVideo(moduleId){\n const placeholder = document.getElementById(`video-placeholder-${ moduleId}`);\n if (!placeholder) {\n console.error('Placeholder not found for moduleId:', moduleId);\n return;\n }\n const videoId = placeholder.getAttribute('data-video-id');\n const videoSource = placeholder.getAttribute('data-video-source');\n // adding a condition to check the videoId and videoSource\n if (!videoId || !videoSource) {\n console.error('Missing videoId or videoSource for moduleId:', moduleId);\n return;\n }\n const iframe = document.createElement('iframe');\n let src = '';\n // Set the iframe source based on the video source\n if (videoSource === 'youtube') {\n src = `//www.youtube.com/embed/${ videoId }?rel=0`;\n } else {\n src = `//players.brightcove.net/1547387903001/zf9qLy17UG_default/index.html?videoId=${ videoId}`;\n }\n // Set iframe attributes\n iframe.setAttribute('src', src);\n iframe.setAttribute('allowfullscreen', '');\n iframe.setAttribute('webkitallowfullscreen', 'true');\n iframe.setAttribute('mozallowfullscreen', 'true');\n iframe.setAttribute('title', 'video');\n iframe.setAttribute('loading', 'lazy');\n iframe.style.height = '100%';\n iframe.style.width = '100%';\n // Clear the placeholder content and append the iframe\n placeholder.innerHTML = '';\n placeholder.appendChild(iframe);\n }\n makeCopyExpandable() {\n if (this.dom.expandableCopy === 'true') {\n const parentDiv = this.dom.copy.parentElement\n this.readMoreButton = document.createElement('button')\n this.readMoreButton.classList.add('content-row-expandable-button')\n this.readMoreButton.innerText = this.el.dataset.readMoreLabel\n if (\n this.dom.link &&\n !this.dom.link.previousElementSibling.classList.contains('content-row-info__inner')\n ) {\n parentDiv.insertBefore(this.readMoreButton, this.dom.link)\n } else {\n parentDiv.append(this.readMoreButton)\n }\n this.calculateTabIndex()\n this.readMoreButton.addEventListener('click', this.handleReadMore.bind(this))\n this.dom.copy.classList.add('content-row-expandable-copy')\n }\n }\n\n handleReadMore() {\n if (!this.isExpanded) {\n this.isExpanded = true\n this.dom.copy.classList.remove('content-row-expandable-copy')\n this.readMoreButton.textContent = this.el.dataset.readLessLabel\n this.focusableElements.forEach((element) => (element.tabIndex = 0))\n } else {\n this.isExpanded = false\n this.dom.copy.classList.add('content-row-expandable-copy')\n this.readMoreButton.textContent = this.el.dataset.readMoreLabel\n this.calculateTabIndex()\n }\n }\n\n calculateTabIndex() {\n this.focusableElements.forEach((element) => {\n const containerTop = this.dom.copy.getBoundingClientRect().top\n const elementTop = element.getBoundingClientRect().top\n\n element.tabIndex = elementTop - containerTop > maxHeight - fadeHeight ? -1 : 0\n })\n }\n}\n\nexport default ContentRow\n"],"sourceRoot":""}