{"version":3,"sources":["videoBackground.es6"],"names":["factory","define","amd","exports","module","require","jQuery","$","fn","videoBackground","options","resize","$this_e","$this_v","ratio_x","ratio_y","width","outerWidth","height","outerHeight","css","settings","extend","this","each","$this","video","find","dataOptions","data","undefined","hasOwnProperty","overflow","position","left","top","transform","window","on"],"mappings":"cASC,SAAWA,GAGc,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,UAAWD,GACO,mBAAZG,SACdC,OAAOD,QAAUH,EAAQK,QAAQ,WAEjCL,EAAQM,SAIf,SAAUC,GAEPA,EAAEC,GAAGC,gBAAkB,SAAUC,GAiD7B,QAASC,GAAOC,EAASC,EAASC,EAASC,GAEvC,GAAIC,GAAQJ,EAAQK,aAChBC,EAASN,EAAQO,aAEjBH,GAAQE,EAASJ,EAAUC,EAC3BF,EAAQO,KACJJ,MAASA,EACTE,OAAUF,EAAQF,EAAUC,IAGhCF,EAAQO,KACJJ,MAASE,EAASH,EAAUD,EAC5BI,OAAUA,IA5DtB,GAAIG,GAAWd,EAAEe,QACbR,QAAS,GACTC,QAAS,GACVL,EAGHH,GAAEgB,MAAMC,KAAK,WAET,GAAIC,GAAQlB,EAAEgB,MAEVT,EAAUO,EAASP,QACnBC,EAAUM,EAASN,QACnBW,EAAQD,EAAME,KAAK,iBAGnBC,EAAcH,EAAMI,KAAK,wBAEVC,IAAfF,IACIA,EAAYG,eAAe,aAC3BjB,EAAUc,EAAYd,SAGtBc,EAAYG,eAAe,aAC3BhB,EAAUa,EAAYb,UAI9BR,EAAEgB,MAAMH,KACJY,SAAU,WAGdN,EAAMN,KACFa,SAAU,WACVC,KAAM,MACNC,IAAK,MACLC,UAAW,0BAGfzB,EAAOc,EAAOC,EAAOZ,EAASC,GAE9BR,EAAE8B,QAAQC,GAAG,cAAe,WACxB3B,EAAOc,EAAOC,EAAOZ,EAASC","file":"videoBackground.min.js","sourcesContent":["/*\n\n Video background\n\n Author: lemehovskiy\n Website: https://github.com/lemehovskiy\n\n */\n\n;(function (factory) {\n 'use strict';\n\n if (typeof define === 'function' && define.amd) {\n define(['jquery'], factory);\n } else if (typeof exports !== 'undefined') {\n module.exports = factory(require('jquery'));\n } else {\n factory(jQuery);\n }\n})\n\n(function ($) {\n\n $.fn.videoBackground = function (options) {\n\n let settings = $.extend({\n ratio_x: 16,\n ratio_y: 9\n }, options);\n\n\n $(this).each(function(){\n\n let $this = $(this);\n\n let ratio_x = settings.ratio_x,\n ratio_y = settings.ratio_y,\n video = $this.find('video, iframe');\n\n\n let dataOptions = $this.data('video-background');\n\n if (dataOptions != undefined) {\n if (dataOptions.hasOwnProperty('ratio-x')) {\n ratio_x = dataOptions.ratio_x;\n }\n\n if (dataOptions.hasOwnProperty('ratio-y')) {\n ratio_y = dataOptions.ratio_y;\n }\n }\n\n $(this).css({\n overflow: 'hidden',\n });\n\n video.css({\n position: 'absolute',\n left: '50%',\n top: '50%',\n transform: 'translate(-50%, -50%)'\n });\n\n resize($this, video, ratio_x, ratio_y);\n\n $(window).on('resize load', function () {\n resize($this, video, ratio_x, ratio_y);\n });\n\n });\n\n\n function resize($this_e, $this_v, ratio_x, ratio_y) {\n\n let width = $this_e.outerWidth();\n let height = $this_e.outerHeight();\n\n if (width / height > ratio_x / ratio_y) {\n $this_v.css({\n \"width\": width,\n \"height\": width / ratio_x * ratio_y\n });\n } else {\n $this_v.css({\n \"width\": height / ratio_y * ratio_x,\n \"height\": height\n });\n }\n }\n\n };\n\n});"]}