{"version":3,"sources":["webpack:///./Scripts/youtube.js"],"names":["__webpack_require__","r","__webpack_exports__","element","window","onYouTubeIframeAPIReady","videos","updateSize","video","parentRect","parentElement","getBoundingClientRect","style","width","right","left","height","parseInt","addVideo","id","url","getAttribute","videoId","player","index","indexOf","substring","pauseFlag","videoTitle","YT","Player","playerVars","controls","fs","modestbranding","origin","document","location","href","rel","showinfo","color","events","onReady","event","getElementById","getVideoData","title","onStateChange","ga","create","action","label","data","PlayerState","PLAYING","PAUSED","ENDED","push","elements","querySelectorAll","i","length","addEventListener","tag","createElement","src","firstScriptTag","getElementsByTagName","parentNode","insertBefore"],"mappings":"2FAAAA,EAAAC,EAAAC,GAAeA,EAAA,iBAAAC,GACXC,OAAOC,wBAA0B,WAmF7B,IAlFA,IAAIC,KAEAC,EAAa,SAAUC,GACvB,IAAIC,EAAaD,EAAML,QAAQO,cAAcC,wBAClCH,EAAML,QAAQQ,wBAEzBH,EAAML,QAAQS,MAAMC,MAASJ,EAAWK,MAAQL,EAAWM,KAAQ,KACnEP,EAAML,QAAQS,MAAMI,OAAWC,SAAST,EAAML,QAAQa,QAAUC,SAAST,EAAML,QAAQU,QAAWJ,EAAWK,MAAQL,EAAWM,MAAS,MAGzIG,EAAW,SAAUf,GACrB,IAAIK,GACAL,QAAS,KACTgB,GAAIhB,EAAQgB,GACZC,IAAKjB,EAAQkB,aAAa,gBAC1BC,QAAS,GACTC,OAAQ,MAGRC,EAAQhB,EAAMY,IAAIK,QAAQ,OAC1BD,GAAS,IACThB,EAAMc,QAAUd,EAAMY,IAAIM,UAAUF,EAAQ,IAC5CA,EAAQhB,EAAMc,QAAQG,QAAQ,MAClB,IACRjB,EAAMc,QAAUd,EAAMc,QAAQI,UAAU,EAAGF,KAGnD,IAAIG,GAAY,EACZC,EAAa,GAEjBpB,EAAMe,OAAS,IAAIM,GAAGC,OAAOtB,EAAMW,IAC/BG,QAASd,EAAMc,QACfS,YACIC,SAAU,EACVC,GAAI,EACJC,eAAgB,EAChBC,OAAQC,SAASC,SAASC,KAC1BC,IAAK,EACLC,SAAU,EACVC,MAAO,SAEXC,QACEC,QAAW,SAAUC,GACnBpC,EAAML,QAAUiC,SAASS,eAAerC,EAAMW,IAC9CZ,EAAWC,GAEXoB,EAAapB,EAAMe,OAAOuB,eAAeC,OAE3CC,cAAiB,SAAUJ,GACvB,GAAIxC,OAAO6C,IAAMA,GAAGC,OAAQ,CACxB,IACIC,EAAS,GACTC,EAAQxB,EAGRgB,EAAMS,MAAQxB,GAAGyB,YAAYC,UAC7BJ,EAAS,OACTxB,GAAY,GAIZiB,EAAMS,MAAQxB,GAAGyB,YAAYE,QAAU7B,IACvCwB,EAAS,QACTxB,GAAY,GAIZiB,EAAMS,MAAQxB,GAAGyB,YAAYG,QAC7BN,EAAS,YAGbF,GAAG,OAAQ,QArBI,SAqBeE,EAAQC,QAMpD9C,EAAOoD,KAAKlD,IAIZmD,EAAWxD,EAAQyD,iBAAiB,kBAC/BC,EAAI,EAAGA,EAAIF,EAASG,OAAQD,IACjC3C,EAASyC,EAASE,IAEtBzD,OAAO2D,iBAAiB,SAAU,WAC9B,IAAK,IAAIF,EAAI,EAAGA,EAAIvD,EAAOwD,OAAQD,IAC/BtD,EAAWD,EAAOuD,OAI9B,IAAIG,EAAM5B,SAAS6B,cAAc,UACjCD,EAAIE,IAAM,+BAEV,IAAIC,EAAiB/B,SAASgC,qBAAqB,UAAU,GAC7DD,EAAeE,WAAWC,aAAaN,EAAKG","file":"13.js","sourcesContent":["export default element => {\n window.onYouTubeIframeAPIReady = function () {\n let videos = [];\n \n let updateSize = function (video) {\n var parentRect = video.element.parentElement.getBoundingClientRect();\n var rect = video.element.getBoundingClientRect();\n\n video.element.style.width = (parentRect.right - parentRect.left) + \"px\";\n video.element.style.height = ((parseInt(video.element.height) / parseInt(video.element.width)) * (parentRect.right - parentRect.left)) + \"px\";\n };\n\n let addVideo = function (element) {\n var video = {\n element: null,\n id: element.id,\n url: element.getAttribute('data-youtube'),\n videoId: \"\",\n player: null,\n };\n\n var index = video.url.indexOf(\"?v=\");\n if (index >= 0) {\n video.videoId = video.url.substring(index + 3);\n index = video.videoId.indexOf(\"&\");\n if (index > 0)\n video.videoId = video.videoId.substring(0, index);\n }\n\n let pauseFlag = false;\n let videoTitle = '';\n\n video.player = new YT.Player(video.id, {\n videoId: video.videoId,\n playerVars: {\n controls: 1,\n fs: 0,\n modestbranding: 1,\n origin: document.location.href,\n rel: 0,\n showinfo: 0,\n color: \"white\",\n },\n events: {\n 'onReady': function (event) {\n video.element = document.getElementById(video.id);\n updateSize(video);\n\n videoTitle = video.player.getVideoData().title\n },\n 'onStateChange': function (event) {\n if (window.ga && ga.create) {\n var category = 'Videos';\n var action = '';\n var label = videoTitle;\n\n // track when user clicks to Play\n if (event.data == YT.PlayerState.PLAYING) {\n action = 'Play';\n pauseFlag = true;\n }\n\n // track when user clicks to Pause\n if (event.data == YT.PlayerState.PAUSED && pauseFlag) {\n action = 'Pause';\n pauseFlag = false;\n }\n\n // track when video ends\n if (event.data == YT.PlayerState.ENDED) {\n action = 'Finished';\n }\n\n ga('send', 'event', category, action, label);\n }\n }\n }\n });\n\n videos.push(video);\n };\n\n\n var elements = element.querySelectorAll(\"[data-youtube]\");\n for (var i = 0; i < elements.length; i++)\n addVideo(elements[i]);\n\n window.addEventListener(\"resize\", function () {\n for (var i = 0; i < videos.length; i++)\n updateSize(videos[i]);\n });\n };\n\n var tag = document.createElement('script');\n tag.src = \"//www.youtube.com/iframe_api\";\n\n var firstScriptTag = document.getElementsByTagName('script')[0];\n firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\n};"],"sourceRoot":""}