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,EACmB,SAAfE,GACIC,IACAA,EAAYwB,eAAe,GAC3BxB,EAAY+B,QAID,WAAfhC,EACAgB,EAAgBQ,UAAYP,GAIxBG,EAAQL,EAAMhB,cAAc,UAC1BiC,OAItB,EAGId,EAAsB,SAASe,GAK/B,OAHAA,EAAgBA,EAAcJ,QAAQ,KAAM,KAAKA,QAAQ,KAAM,KAE3CK,KAAKD,EAE7B,CACJ,E","sources":["webpack://frontendplaceholder/./Src/Scripts/components/modal.js"],"sourcesContent":["//Should be changed to be conditionally imported\nimport VimeoPlayer from '@vimeo/player';\n\nexport default class Modal {\n constructor(elm) {\n if (!elm.dataset.modalId)\n return;\n\n var opener = document.querySelectorAll('[data-modal-opens=' + elm.dataset.modalId + ']');\n\n if (!opener)\n return;\n\n let iframe = elm.querySelector('iframe');\n let videoPlayer = elm.dataset.videoPlayer;\n let vimeoPlayer = null;\n\n if (elm.dataset.videoPlayer === 'vimeo') {\n if (iframe) {\n vimeoPlayer = new VimeoPlayer(iframe);\n }\n }\n\n opener.forEach(x => x.addEventListener('click', function () { toggleModal(elm); }));\n elm.addEventListener('click', function (e) {\n if (!e.target.closest(\"video, iframe\")) { \n toggleModal(elm);\n }\n\n });\n\n document.onkeydown = function (evt) {\n evt = evt || window.event;\n if (evt.keyCode == 27) {\n toggleModal(elm);\n }\n };\n\n var toggleModal = function (modal) {\n const iframeContainer = modal.querySelector('.responsive-container');\n const videoEmbedMarkup = urlSafeBase64Decode(modal.dataset.encodedEmbed);\n\n if (modal.classList.contains('modal--active')) {\n //Closing\n modal.classList.remove('modal--active');\n if (videoPlayer == \"youtube\") {\n iframeContainer.innerHTML = \"\";\n } else {\n //Stopping & resetting video if any\n if (iframe) {\n if (videoPlayer == \"vimeo\") {\n if (vimeoPlayer) {\n vimeoPlayer.setCurrentTime(0);\n vimeoPlayer.pause();\n }\n } else if (videoPlayer == \"youtube\") {\n if (iframe.src.indexOf('?autoplay=1') > -1) {\n iframe.src = iframe.src.replace('?autoplay=1', '');\n } else {\n iframe.src = iframe.src.replace('&autoplay=1', '');\n }\n }\n } else {\n //For potential mp4 player\n var video = modal.querySelector('video');\n video.pause();\n video.currentTime = 0;\n }\n } \n } else {\n //Opening\n modal.classList.add('modal--active');\n //Playing video if any \n if (iframe) {\n if (videoPlayer == \"vimeo\") {\n if (vimeoPlayer) {\n vimeoPlayer.setCurrentTime(0);\n vimeoPlayer.play();\n }\n }\n } else {\n if (videoPlayer == \"youtube\") {\n iframeContainer.innerHTML = videoEmbedMarkup;\n }\n else {\n //For potential mp4 player\n var video = modal.querySelector('video');\n video.play();\n } \n }\n }\n }\n\n // should be moved out to its own utility component\n var urlSafeBase64Decode = function(encodedString) {\n // Replace any characters that are URL-safe encoded back to their original form\n encodedString = encodedString.replace(/-/g, '+').replace(/_/g, '/');\n // Use atob() to decode the base64 string\n let decodedString = atob(encodedString);\n return decodedString;\n }\n }\n}\n"],"names":["obj","_player","require","__esModule","default","exports","constructor","elm","dataset","modalId","opener","document","querySelectorAll","iframe","querySelector","videoPlayer","vimeoPlayer","VimeoPlayer","forEach","x","addEventListener","toggleModal","e","target","closest","onkeydown","evt","window","event","keyCode","modal","iframeContainer","videoEmbedMarkup","urlSafeBase64Decode","encodedEmbed","video","classList","contains","remove","innerHTML","setCurrentTime","pause","src","indexOf","replace","currentTime","add","play","encodedString","atob"],"sourceRoot":""}