{"version":3,"sources":["webpack://@verndale/toolkit/./src/js/modules/full-width-video.js","webpack://@verndale/toolkit/./src/js/modules/video.js"],"names":["_interopRequireDefault","obj","_video","Module","Component","$overlay","$video","overlayElement","e","$image","autoplay","controls","iframe","video","source","script","videoType"],"mappings":"oJAEA,SAASA,EAAuBC,EAAK,CAAE,OAAOA,GAAOA,EAAI,WAAaA,EAAM,CAAE,QAASA,CAAI,CAAG,CAE9F,MAAMC,EAASF,EAAuB,EAAQ,KAAS,CAAC,EAExD,MAAMG,UAAeC,WAAU,CAC3B,eAAgB,CACd,KAAK,IAAM,CACT,SAAU,KAAK,GAAG,iBAAiB,4BAA4B,EAC/D,OAAQ,KAAK,GAAG,cAAc,QAAQ,CACxC,CACF,CAEA,cAAe,CACb,KAAM,CACJ,SAAAC,EACA,OAAAC,CACF,EAAI,KAAK,IAETD,EAAS,QAAQE,GAAkB,CACjCA,EAAe,iBAAiB,QAAS,KAAK,YAAY,KAAK,IAAI,CAAC,CACtE,CAAC,EAEDD,EAAO,iBAAiB,QAAS,KAAK,iBAAiB,KAAK,IAAI,CAAC,CAEnE,CAEA,YAAYE,EAAG,CACGA,EAAE,OAAO,QAAQ,gCAAgC,IAG/D,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,GAAG,QAAQ,aAAe,OAE/B,IAAIN,EAAO,QAAQ,KAAK,GAAG,cAAc,0BAA0B,CAAC,EAAE,YAAY,EAAI,EAE1F,CAEA,iBAAiBM,EAAG,EACfA,EAAE,OAAO,UAAU,SAAS,eAAe,GAAKA,EAAE,OAAO,QAAQ,gBAAgB,KAClF,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,GAAG,QAAQ,aAAe,OAE/B,IAAIN,EAAO,QAAQ,KAAK,GAAG,cAAc,0BAA0B,CAAC,EAAE,YAAY,EAAI,EAE1F,CAEA,eAAgB,CACd,KAAM,CACJ,SAAAG,CACF,EAAI,KAAK,IAGTA,EAAS,QAAQE,GAAkB,CACjCA,GAAg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kB,CAChB,KAAK,MAAM,UAAU,IAAI,gBAAgB,EACzC,KAAK,MAAM,aAAa,WAAY,UAAU,CAChD,CAEA,kBAAmB,CACjB,KAAK,MAAM,UAAU,OAAO,gBAAgB,EAC5C,KAAK,MAAM,gBAAgB,UAAU,CACvC,CAEA,gBAAiB,CACf,KAAK,MAAM,UAAU,OAAO,gBAAgB,EAC5C,KAAK,MAAM,gBAAgB,UAAU,EACrC,KAAK,MAAM,YAAc,EACzB,KAAK,MAAM,KAAK,CAClB,CAEF,CAEA,UAAeT,C","file":"scripts/64.4c45ac7f.js","sourcesContent":["import { Component } from '@verndale/core';\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nconst _video = _interopRequireDefault(require(\"./video\"));\n\nclass Module extends Component {\n setupDefaults() {\n this.dom = {\n $overlay: this.el.querySelectorAll('.full-width-video__overlay'),\n $video: this.el.querySelector('.video'),\n };\n }\n\n addListeners() {\n const {\n $overlay,\n $video\n } = this.dom;\n\n $overlay.forEach(overlayElement => {\n overlayElement.addEventListener('click', this.handleClick.bind(this));\n });\n\n $video.addEventListener('click', this.handleVideoClick.bind(this));\n\n }\n\n handleClick(e) {\n const $button = e.target.closest('.full-width-video__play-button');\n\n if ($button) {\n this.removeOverlay();\n this.removeImage();\n this.el.dataset.hideGradient = 'true';\n // eslint-disable-next-line new-cap\n new _video.default(this.el.querySelector('.full-width-video .video')).removeCover(true);\n }\n }\n\n handleVideoClick(e) {\n if(e.target.classList.contains('video__poster') || e.target.closest('.video__poster')) {\n this.removeOverlay();\n this.removeImage();\n this.el.dataset.hideGradient = 'true';\n // eslint-disable-next-line new-cap\n new _video.default(this.el.querySelector('.full-width-video .video')).removeCover(true);\n }\n }\n\n removeOverlay() {\n const {\n $overlay\n } = this.dom;\n\n\n $overlay.forEach(overlayElement => {\n overlayElement?.parentNode?.removeChild(overlayElement);\n });\n }\n\n removeImage() {\n const {\n $image\n } = this.dom;\n\n if ($image) {\n this.dom.$image.remove();\n }\n }\n\n }\n\nexport default Module;\n","import { Component } from '@verndale/core';\n\nclass Module extends Component {\n setupDefaults() {\n this.dom = {\n poster: this.el.querySelector('.video__poster'),\n backgroundVideo: this.el.querySelector('.video__background'),\n icon: this.el.querySelector('svg'),\n videoPoster: this.el.parentNode.querySelector('picture:not(.video__poster)'),\n video: this.el.querySelector('video')\n };\n this.initialized = false;\n this.videoId = this.el.dataset.videoId;\n this.videoPlayer = this.el.dataset.videoPlayer;\n this.videoBackgroundImage = this.el.dataset.videoBackgroundImage;\n this.autoplay = this.el.dataset.videoAutoPlay;\n this.vimeoPlayer = 'vimeo';\n this.youtubePlayer = 'youtube';\n this.localVideo = 'video';\n this.vimeoScript = 'https://player.vimeo.com/api/player.js';\n }\n\n addListeners() {\n if(this.dom.poster) {\n this.dom.poster.addEventListener('click', this.removeCover.bind(this));\n }\n if(this.dom.icon) {\n this.dom.icon.addEventListener('click', this.removeCover.bind(this));\n }\n }\n\n getCurrentPlayer() {\n // eslint-disable-next-line prefer-rest-params\n const autoplay = this.autoplay === 'true' ? 1 : 0;\n\n if (this.initialized) return;\n\n if (this.vimeoPlayer === this.el.dataset.videoPlayer) {\n return this.handleInitVideos(this.el.dataset.videoPlayer, this.getVimeoIframe(autoplay));\n }\n\n if (this.youtubePlayer === this.el.dataset.videoPlayer) {\n return this.handleInitVideos(this.el.dataset.videoPlayer, this.getYoutubeIframe(false, autoplay));\n }\n\n if (this.localVideo === this.el.dataset.videoPlayer) {\n this.handleInitVideos(this.el.dataset.videoPlayer, this.getLocalVideo(autoplay));\n this.addVideoListeners();\n }\n\n return null;\n }\n\n addVideoListeners() {\n this.video = this.el.querySelector('video');\n\n if (!this.initialized) {\n this.definePlayingObject();\n return;\n }\n\n this.video.addEventListener('click', this.handleVideoClick.bind(this));\n this.video.addEventListener('play', this.handleVideoPlay.bind(this));\n this.video.addEventListener('pause', this.handleVideoPause.bind(this));\n this.video.addEventListener('ended', this.handleVideoEnd.bind(this));\n }\n\n definePlayingObject() {\n Object.defineProperty(this.video, 'playing', {\n // eslint-disable-next-line object-shorthand, func-names\n get: function () {\n return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2);\n }\n });\n }\n\n getYoutubeIframe() {\n // eslint-disable-next-line prefer-rest-params\n const controls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n // eslint-disable-next-line prefer-rest-params\n const autoplay = this.autoplay === 'true' ? 1 : 0;\n const iframe = document.createElement('iframe');\n iframe.setAttribute('width', 640);\n iframe.setAttribute('height', 360);\n iframe.setAttribute('frameborder', 0);\n iframe.setAttribute('webkitallowfullscreen', 'webkitallowfullscreen');\n iframe.setAttribute('mozallowfullscreen', 'mozallowfullscreen');\n iframe.setAttribute('allowfullscreen', 'allowfullscreen');\n iframe.setAttribute('src', `https://www.youtube.com/embed/${this.videoId}?modestbranding=1&rel=0&showinfo=0&autohide=1&autoplay=${autoplay}&mute=0${controls ? '&controls=0' : ''}`);\n iframe.setAttribute('id', 'ytplayer');\n iframe.setAttribute('data-youtube-id', this.videoId);\n iframe.setAttribute('allow', 'autoplay');\n return iframe;\n }\n\n getVimeoIframe() {\n // eslint-disable-next-line prefer-rest-params\n const autoplay = this.autoplay === 'true' ? 1 : 0;\n const iframe = document.createElement('iframe');\n iframe.setAttribute('width', 640);\n iframe.setAttribute('height', 360);\n iframe.setAttribute('frameborder', 0);\n iframe.setAttribute('webkitallowfullscreen', 'webkitallowfullscreen');\n iframe.setAttribute('mozallowfullscreen', 'mozallowfullscreen');\n iframe.setAttribute('allowfullscreen', 'allowfullscreen');\n iframe.setAttribute('allow', 'autoplay');\n iframe.setAttribute('src', `https://player.vimeo.com/video/${this.videoId}?title=false&autoplay=${autoplay}&muted=0`);\n iframe.setAttribute('data-vimeo-id', this.videoId);\n iframe.setAttribute('id', 'vimeoplayer');\n return iframe;\n }\n\n getLocalVideo() {\n const video = document.createElement('video');\n const source = document.createElement('source');\n source.src = this.el.dataset.videoId;\n video.autoplay = this.autoplay;\n video.poster = this.el.dataset.videoPoster;\n video.appendChild(source);\n return video;\n }\n\n removeCover() {\n if (this.dom.poster) this.dom.poster.remove();\n if (this.dom.icon) this.dom.icon.remove();\n }\n\n addVimeoScript() {\n const script = document.createElement('script');\n script.setAttribute('src', this.vimeoScript);\n document.body.prepend(script);\n }\n\n handleInitVideos(videoType, iframe) {\n if (videoType === this.vimeoPlayer) {\n this.addVimeoScript();\n }\n\n if (videoType === this.localVideo) {\n this.removeCover();\n }\n\n if (!this.initialized) {\n iframe.onload = () => {\n this.removeCover();\n };\n\n this.dom.backgroundVideo.appendChild(iframe);\n this.initialized = true;\n }\n }\n\n handleVideoClick() {\n if (!this.video.playing) {\n this.video.play();\n }\n }\n\n handleVideoPlay() {\n this.video.classList.add('video--playing');\n this.video.setAttribute('controls', 'controls');\n }\n\n handleVideoPause() {\n this.video.classList.remove('video--playing');\n this.video.removeAttribute('controls');\n }\n\n handleVideoEnd() {\n this.video.classList.remove('video--playing');\n this.video.removeAttribute('controls');\n this.video.currentTime = 0;\n this.video.load();\n }\n\n}\n\nexport default Module;\n"],"sourceRoot":""}