{"version":3,"sources":["scripts.js","components/clean-background-video.js"],"names":["document","addEventListener","event","window","NodeList","prototype","forEach","isIE11","MSInputMethodContext","documentMode","CleanBackgroundVideo","cleanBackgroundVideo","arguments","length","undefined","options","_classCallCheck","this","cleanBackgroundVideos","_objectSpread","setDimensions","debounce","bind","bindEvents","_this","playPromise","init","setLoaded","video","error","console","log","target","querySelector","clientWidth","height","clientHeight","style","width","concat","tempVideo","classList","timeout","context","args","callNow","clearTimeout","wait","func"],"mappings":"aAAAA,SAASC,iBAAiB,mBAAoB,SAASC,GAErDC,OAAAC,WAAAA,SAAAC,UAAAC,UACAF,SAAWA,UAAPE,QAAoBF,MAASC,UAAUC;2nCCH7C,IAAMC,SAAWJ,OAAOK,wBAA0BR,SAASS,aAKrDC,qB,WACJ,SAAAA,IAAgD,IAApCC,EAAoC,EAAAC,UAAAC,aAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAb,GAAIG,EAAS,EAAAH,UAAAC,OAAAD,UAAA,QAAAE,EAAAE,gBAAAC,KAAAP,GAC9CO,KAAKC,sBAAwBP,EACzBM,KAAKC,sBAAsBL,QAAU,IAIzCI,KAAKF,QAALI,cAAAA,cAAA,GAFuB,IAEgBJ,GACvCE,KAAKG,cAAgBH,KAAKI,SAASJ,KAAKG,cAAcE,KAAKL,MAAO,IAbhEV,KAAAA,e,6CAkBFU,KAAKM,aAbHb,KAAAA,kB,mCAC4C,IAAAc,EAAAP,KAiB9Cd,OAAOF,iBAAiB,SAAU,WAAQuB,EAAKJ,kBAE/CH,KAAKC,sBAAsBZ,QAAS,SAACK,GAlBrC,IAAKO,EAAAA,EAAwBP,cAA7B,SACIc,EAAKP,EAAAA,YAITJ,IAAKC,GACLU,EAAKL,KAAgB,WAChBM,EAALC,UAAA,KAAAC,KADA,MAED,SAAAC,GAkBOC,QAAQC,IAAIF,KAflBtB,QACAiB,EAAKJ,UAAAA,KAALQ,O,gCAIA1B,E,GAAA0B,EAAA,EAAAhB,UAAAC,aAAAC,I,IAAA,MAEKI,OAAAA,EAAsBZ,EAAS0B,OAACrB,GAC/BiB,UAAQjB,IAAAA,2BACZM,KAAAG,kB,sCAIIH,KAAAC,sBAAeZ,QAAf,SAAAK,GACD,IAAAiB,EAFDjB,EAEqBsB,cAAA,SACnBH,EAAAA,EAAAI,YACDC,EAJDxB,EAAAyB,aA6BFR,EAAMS,MAAMC,MAAZ,GAAAC,OAAuBD,EAAvB,MAtBAV,EAAIrB,MAAJ4B,OAAY,OAEXA,EAAAP,EAAAQ,eAdHR,EAAAS,MAAAC,MAAA,OAiBDV,EAAAS,MAAAF,OAAA,GAAAI,OAAAJ,EAAA,W,+BAOCK,EAAUC,EAAAA,GACV,IAAAC,EACD,OAAA,WA0BG,IAAIC,EAAU1B,KAAM2B,EAAOhC,UArB3BiC,EAAYlC,IAAAA,EACZmC,aAAUJ,GAEVd,EAAMS,WAmBM,WACVK,EAAU,KAzBTxB,GAAAA,EAAAA,MAAsBZ,EAASsC,IAKlCG,GACAnB,GAAAoB,EAAYb,MAASQ,EAArBC,U","file":"clean-background-video.min.js","sourcesContent":["document.addEventListener('DOMContentLoaded', function(event) {\r\n\r\n // Polyfills\r\n if (window.NodeList && !NodeList.prototype.forEach) {\r\n NodeList.prototype.forEach = Array.prototype.forEach;\r\n }\r\n \r\n});\r\n","const isIE11 = !!window.MSInputMethodContext && !!document.documentMode;\r\n\r\n/**\r\n * Entry point for the plugin.\r\n */\r\nclass CleanBackgroundVideo {\r\n constructor(cleanBackgroundVideo = [], options) {\r\n this.cleanBackgroundVideos = cleanBackgroundVideo;\r\n if (this.cleanBackgroundVideos.length <= 0) return;\r\n \r\n const defaultOptions = { }\r\n\r\n this.options = { ...defaultOptions, ...options };\r\n this.setDimensions = this.debounce(this.setDimensions.bind(this), 50);\r\n this.init();\r\n }\r\n\r\n init() {\r\n this.bindEvents();\r\n this.setDimensions();\r\n }\r\n\r\n bindEvents() {\r\n window.addEventListener('resize', () => { this.setDimensions() });\r\n\r\n this.cleanBackgroundVideos.forEach( (cleanBackgroundVideo) => {\r\n let video = cleanBackgroundVideo.querySelector('video');\r\n let playPromise = video.play();\r\n\r\n if (playPromise !== undefined) {\r\n playPromise.then( () => {\r\n this.setLoaded(null, video)\r\n }).catch( (error) => {\r\n console.log(error);\r\n })\r\n }\r\n\r\n if (isIE11) {\r\n this.setLoaded(null, video);\r\n }\r\n\r\n })\r\n }\r\n\r\n /**\r\n * Sets the loaded classes on video elements.\r\n */\r\n setLoaded(event, video = null) {\r\n let tempVideo = event !== null ? event.target : video;\r\n tempVideo.classList.add('background-video-loaded');\r\n this.setDimensions();\r\n }\r\n\r\n setDimensions() {\r\n this.cleanBackgroundVideos.forEach( (cleanBackgroundVideo) => {\r\n let video = cleanBackgroundVideo.querySelector('video');\r\n let width = cleanBackgroundVideo.clientWidth;\r\n let height = cleanBackgroundVideo.clientHeight;\r\n\r\n video.style.width = `${width}px`;\r\n video.style.height = 'auto';\r\n\r\n if (height > video.clientHeight) {\r\n video.style.width = 'auto';\r\n video.style.height = `${height}px`;\r\n }\r\n\r\n });\r\n }\r\n\r\n // Returns a function, that, as long as it continues to be invoked, will not\r\n // be triggered. The function will be called after it stops being called for\r\n // N milliseconds. If `immediate` is passed, trigger the function on the\r\n // leading edge, instead of the trailing.\r\n debounce(func, wait, immediate) {\r\n var timeout;\r\n return function() {\r\n var context = this, args = arguments;\r\n var later = function() {\r\n timeout = null;\r\n if (!immediate) func.apply(context, args);\r\n };\r\n var callNow = immediate && !timeout;\r\n clearTimeout(timeout);\r\n timeout = setTimeout(later, wait);\r\n if (callNow) func.apply(context, args);\r\n };\r\n };\r\n}"]}