{"version":3,"sources":["videoLightbox.js"],"names":["VideoLightbox","targets","Error","let","elements","closeLightboxes","lightboxes","document","querySelectorAll","forEach","lightbox","patternVimeo","test","html","querySelector","classList","remove","Array","prototype","slice","call","element","addEventListener","e","videoUrl","getCookie","closeButton","createElement","add","innerHTML","lightboxCookie","preventDefault","dataset","closeLabel","href","lightboxInner","lightboxVideo","setAttribute","url","patternYouTube","module","window","replace","appendChild","cookieConsent","body","getVideoEmbedHtmlFromUrl","focus","exports"],"mappings":"AAAA,CAAA,WACE,aAEA,SAASA,EAAcC,GACrB,GAAI,CAACA,EAAS,MAAM,IAAIC,MAAM,qBAAqB,EAInDC,IAAIC,EA2EJ,SAqBQC,IAIN,IAAAC,EAAAC,SAAAC,iBAAA,gBAAA,EAvBIF,GAyBJA,EAAAG,QAAA,SAAAC,GACIC,EAAAA,OAAaC,CACfC,CAAAA,EAOJN,SAAAO,cAAA,MAAA,EAEOC,UAAAC,OAAA,qBAAA,CA5BP,CA4BA,MA/GkBf,UAAjB,OAAUA,EACTG,EAAWa,MAAMC,UAAUC,MAAMC,KAAKnB,SAAQO,iBAAAP,CAAA,CAAA,EAChD,UAAA,OAAAA,IAEAG,EAASK,MAAQS,UAACG,MAAOD,KAAKnB,CAAA,GAA9BG,EAASK,QAAQ,SAACY,GAChBA,EAGEC,iBAAA,QAAA,SAAAC,GACAlB,EAAAA,eAAe,EAAfA,EAAe,EAMfF,IAAAqB,EAAcH,EAAGd,KACjBG,EAASK,KAASU,UAAK,qBAAgB,EAGjCC,EAAWnB,SAAGA,cAASoB,KAAc,EAO3CD,GANAA,EAAAA,UAAYX,IAAUa,eAAI,EAMdC,SACVF,cAAA,GAAA,GAuBAG,GAlBFJ,EAAYJ,UAAAA,IAAAA,sBAA2BC,EAXvCG,EAYIK,aACF1B,aACAgB,EAAAW,QAAAC,YAAA,gBAAA,EAEFP,EAAAQ,KAAA,IACAR,EAAMS,UACNA,6jBAPAT,EAYEU,iBAA2B,QAAQ,SAAAb,GACnCa,EAAAA,eAAcrB,EACdqB,EAAcP,CAXhB,CAAC,EAegBQ,SAAaV,cAAQ,KAAS,GA0B/CrB,GArCA6B,EAYEL,UAAef,IAAUa,sBAAI,EAKhB,aAAbO,IACFC,EAAA7B,SAAAoB,cAAA,KAAA,GAEapB,aAASO,OAAc,QAAO,EAdzCsB,EAAcrB,UAAUa,IAAI,sBAAsB,EAgBpDQ,EAAAP,UAqDN,SAAAS,GAEI,IAAAC,EACFC,mIACK7B,EACL8B,iHACF5B,EAAA,IA3BQ0B,EAAe3B,KAAK0B,CAAG,IACzBzB,EAAOyB,EAAII,QACTH,EACA,4LAA4L,GAK5L5B,EAAaC,KAAK0B,CAAG,IACvBzB,EAAOyB,EAAII,QACT/B,EACA,yKAAyK,GAI7K,OAAOE,CACT,EAhDIW,CAAA,EACAd,EAASiC,YAAYjB,CAAY,KAG5BX,EAAcR,SAAAoB,cAAsB,KAAA,GACxBjB,aAAS,OAAA,QAAA,EAfxBoB,EAAef,UAAUa,IAAI,uBAAuB,EAiBtDE,EAAAf,UAAAa,IAAA,YAAA,EACAF,EAAiBG,UACjBR,EAAAW,QAAAY,eACF,+PAEFT,EAAS9B,YAAkByB,CAAA,GAGZrB,SAAQK,cAACJ,MAAa,GAGnCA,EAAAiC,YAAAjB,CAAA,EAEAhB,EAAUiC,YAAY7B,CAAc,EAEtC+B,EAAA9B,UAAAa,IAAA,qBAAA,EAEAiB,EAASC,YAAAA,CAAAA,EAKPpB,EAAcqB,MAAA,CApBd,CAAC,CACH,CAAC,EAwCM,CACL1C,gBAAiBA,CACnB,CACF,CAEsB,aAAlB,OAAOmC,QAAoD,KAAA,IAAnBA,OAAOQ,QACjDR,OAAOQ,QAAUhD,EAEjByC,OAAOzC,cAAgBA,CAE1B,EAAA","file":"../videoLightbox.min.js","sourcesContent":["(function () {\n 'use strict';\n\n function VideoLightbox(targets) {\n if (!targets) throw new Error('Missing selector 😢');\n\n let elements;\n\n if (typeof targets === 'string') {\n elements = Array.prototype.slice.call(document.querySelectorAll(targets));\n } else if (typeof targets === 'object') {\n elements = Array.prototype.slice.call(targets);\n }\n\n elements.forEach((element) => {\n element.addEventListener('click', (e) => {\n e.preventDefault();\n\n // close any open lightboxes\n closeLightboxes();\n\n let videoUrl = element.href;\n let cookie = util.getCookie('cookieconsent_other');\n\n // create lightbox\n const lightbox = document.createElement('div');\n lightbox.classList.add('videoLightbox');\n\n // create close button\n const closeButton = document.createElement('a');\n closeButton.classList.add('videoLightbox__close');\n closeButton.setAttribute(\n 'aria-label',\n element.dataset.closeLabel ?? 'Close lightbox'\n );\n closeButton.href = '#';\n closeButton.innerHTML =\n '' +\n '' +\n '' +\n '';\n\n closeButton.addEventListener('click', (e) => {\n e.preventDefault();\n closeLightboxes();\n });\n\n // create lightbox inner\n const lightboxInner = document.createElement('div');\n lightboxInner.classList.add('videoLightbox__inner');\n\n // show message when cookie consent has not been given\n if (cookie === 'accepted') {\n const lightboxVideo = document.createElement('div');\n lightboxVideo.setAttribute('role', 'dialog');\n lightboxVideo.classList.add('videoLightbox__video');\n lightboxVideo.innerHTML = getVideoEmbedHtmlFromUrl(videoUrl);\n lightboxInner.appendChild(lightboxVideo);\n } else {\n const lightboxCookie = document.createElement('div');\n lightboxCookie.setAttribute('role', 'dialog');\n lightboxCookie.classList.add('videoLightbox__cookie');\n lightboxCookie.classList.add('is-content');\n lightboxCookie.innerHTML =\n element.dataset.cookieConsent ??\n 'Hier wordt een video ingeladen. We mogen deze video echter alleen tonen als u toestemming geeft voor het plaatsen van social media cookies. Pas uw instellingen aan en open de video opnieuw.';\n lightboxInner.appendChild(lightboxCookie);\n }\n\n const body = document.querySelector('body');\n\n // add lightbox to DOM\n lightbox.appendChild(closeButton);\n lightbox.appendChild(lightboxInner);\n\n body.classList.add('videoLightbox--open');\n body.appendChild(lightbox);\n\n // focus on close button\n closeButton.focus();\n });\n });\n\n function closeLightboxes() {\n const lightboxes = document.querySelectorAll('.videoLightbox');\n if (lightboxes) {\n lightboxes.forEach((lightbox) => {\n lightbox.remove();\n });\n }\n\n const body = document.querySelector('body');\n body.classList.remove('videoLightbox--open');\n }\n\n function getVideoEmbedHtmlFromUrl(url) {\n var patternYouTube =\n /(?:http|https)?:\\/\\/(?:www\\.)?(?:youtube\\.com\\/\\S*(?:(?:\\/e(?:mbed))?\\/|watch\\?(?:\\S*?&?v\\=))|youtu\\.be\\/)([a-zA-Z0-9_-]{6,11})/g;\n var patternVimeo =\n /(?:http|https)?:\\/\\/(?:www\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)?|groups\\/(?:[^\\/]*)\\/videos\\/|)(\\d+)(?:|\\/\\?)/g;\n var html = '#';\n\n // YouTube\n if (patternYouTube.test(url)) {\n html = url.replace(\n patternYouTube,\n \"\"\n );\n }\n\n // Vimeo\n if (patternVimeo.test(url)) {\n html = url.replace(\n patternVimeo,\n \"\"\n );\n }\n\n return html;\n }\n\n return {\n closeLightboxes: closeLightboxes,\n };\n }\n\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\n module.exports = VideoLightbox;\n } else {\n window.VideoLightbox = VideoLightbox;\n }\n})();\n"]}