{"version":3,"sources":["webpack://fair-labour/./assets/components/video/js/youtube-handler.js","webpack://fair-labour/./assets/components/video/index.js","webpack://fair-labour/./assets/config.js"],"names":["youtubeHandler","_DcBaseComponent","_inherits","_super","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_assertThisInitialized","call","apply","concat","deviceObserver","player","playVideo","initYT","stopVideo","autoplay","refs","contentVideo","getAttribute","_unsubscrbeChange","bind","onPlayerReady","hideCoverAndBtn","key","value","this","element","classList","contains","_checking","_this2","youtubeLoader","ScriptLoader","window","YT","load","uniqId","querySelector","params","height","width","videoId","events","onReady","playerVars","controls","loop","playlist","onYouTubeIframeAPIReady","Player","_this3","playBtn","videoCover","addListener","navigator","userAgent","toLowerCase","indexOf","mute","setLoop","add","DcBaseComponent","dcFactory","YoutubeHandler","module","exports","viewports","mobile","tablet","desktop","containerMaxWidth"],"mappings":"2zCAEwE,IAEnDA,EAAc,SAAAC,I,qRAAAC,CAAAF,EAAAC,GAAA,I,UAAAE,G,EAAAH,E,6jBAC/B,SAAAA,IAAqB,IAAAI,E,mGAAAC,CAAA,KAAAL,GAAA,QAAAM,EAAAC,UAAAC,OAANC,EAAI,IAAAC,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAJF,EAAIE,GAAAJ,UAAAI,GAOwC,O,EANxCC,EAAfR,EAAAD,EAAAU,KAAAC,MAAAX,EAAA,OAAAY,OAASN,K,EA0BD,WACJO,OAAkB,KAAM,WACpBZ,EAAKa,OACLb,EAAKa,OAAOC,YAEZd,EAAKe,SAGLf,EAAKa,QACLb,EAAKa,OAAOG,WAGxB,G,MAtCmB,gB,wFACfhB,EAAKa,OAAS,KACdb,EAAKiB,SAAWjB,EAAKkB,KAAKC,aAAaC,aAAa,iBACpDpB,EAAKqB,kBAAoB,KACzBrB,EAAKe,OAASf,EAAKe,OAAOO,KAAId,EAAAR,IAC9BA,EAAKuB,cAAgBvB,EAAKuB,cAAcD,KAAId,EAAAR,IAC5CA,EAAKwB,gBA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AOmC,KAAO,EACnBrB,KAAKd,OAAO+C,OACZjC,KAAKd,OAAOC,YAEpB,GAAC,CAAAW,IAAA,kBAAAC,MAED,WACIC,KAAKT,KAAKoC,WAAWzB,UAAUiC,IAAI,aACnCnC,KAAKT,KAAKmC,QAAQxB,UAAUiC,IAAI,YACpC,GAAC,CAAArC,IAAA,YAAAC,MAED,WACIC,KAAKN,mBACT,M,8EAnFCzB,CAAA,CAjB8B,CAASmE,MCC5CC,cAAmBC,E,oBCLnBC,EAAOC,QAAU,CACbC,UAAW,CACPC,OAAQ,IACR,cAAe,IACfC,OAAQ,IACRC,QAAS,KACT,eAAgB,KAChB,gBAAiB,MAErBC,kBAAmB,K","file":"video.9b1a3054eff9b3367df5.js","sourcesContent":["import { DcBaseComponent } from '@deleteagency/dc';\nimport { deviceObserver } from 'project/general/js/device';\nimport ScriptLoader from '../../../project/script-loader/script-loader';\n\nexport default class youtubeHandler extends DcBaseComponent {\n constructor(...args) {\n super(...args);\n this.player = null;\n this.autoplay = this.refs.contentVideo.getAttribute('data-autoplay');\n this._unsubscrbeChange = null;\n this.initYT = this.initYT.bind(this);\n this.onPlayerReady = this.onPlayerReady.bind(this);\n this.hideCoverAndBtn = this.hideCoverAndBtn.bind(this);\n }\n\n static getNamespace() {\n return 'video';\n }\n\n static getRequiredRefs() {\n return ['contentVideo'];\n }\n\n onInit() {\n if (this.element.classList.contains('no-mobile')) {\n this._checking();\n this._unsubscrbeChange = deviceObserver.subscribeOnChange(this._checking);\n } else {\n this.initYT();\n }\n }\n\n _checking = () => {\n if (deviceObserver.is('>=', 'desktop')) {\n if (this.player) {\n this.player.playVideo();\n } else {\n this.initYT();\n }\n } else {\n if (this.player) {\n this.player.stopVideo();\n }\n }\n }\n\n initYT() {\n this.youtubeLoader = new ScriptLoader('https://www.youtube.com/iframe_api', window.YT);\n this.youtubeLoader.load();\n this.uniqId = this.refs.contentVideo.getAttribute('data-ytvideoid');\n\n if (this.uniqId === null) {\n this.uniqId = this.refs.contentVideo.querySelector('iframe').getAttribute('data-ytvideoid');\n }\n\n const params = {\n height: '100%',\n width: '100%',\n videoId: this.uniqId,\n events: {\n onReady: this.onPlayerReady,\n }\n };\n\n if (this.autoplay) {\n params.playerVars = {\n autoplay: 1,\n controls: 0,\n loop: 1,\n playlist: this.uniqId,\n };\n }\n\n window.onYouTubeIframeAPIReady = () => {\n this.player = new YT.Player(this.refs.contentVideo, params);\n };\n }\n\n onPlayerReady() {\n if (this.refs.playBtn && this.refs.videoCover) {\n this.addListener(this.refs.playBtn, 'click', () => {\n this.hideCoverAndBtn();\n if (window.navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {\n this.player.mute();\n }\n this.player.playVideo();\n });\n }\n\n if (this.autoplay) {\n this.player.setLoop(true);\n this.player.loop = 1;\n this.player.mute();\n this.player.playVideo();\n }\n }\n\n hideCoverAndBtn() {\n this.refs.videoCover.classList.add('is-hidden');\n this.refs.playBtn.classList.add('is-hidden');\n }\n\n onDestroy() {\n this._unsubscrbeChange();\n }\n}\n","import './scss/index.scss';\n\nimport { dcFactory } from '@deleteagency/dc';\nimport YoutubeHandler from './js/youtube-handler';\n\ndcFactory.register(YoutubeHandler);\n","module.exports = {\n viewports: {\n mobile: 375,\n 'mobile-wide': 580,\n tablet: 768,\n desktop: 1024,\n 'desktop-wide': 1280,\n 'desktop-ultra': 1440,\n },\n containerMaxWidth: 1160,\n};\n"],"sourceRoot":""}