{"version":3,"sources":["keditor-component-video.js"],"names":["$","KEditor","keditor","flog","log","components","init","contentArea","container","component","componentContent","children","video","find","parent","is","wrap","getContent","unwrap","html","settingEnabled","settingTitle","initSettingForm","form","append","showSettingForm","options","fileInput","btnVideoFileInput","on","e","preventDefault","trigger","off","file","this","files","test","type","attr","URL","createObjectURL","load","showSettingPanel","alert","autoplayToggle","checked","prop","removeProp","loopToggle","ratio","currentWidth","css","replace","currentRatio","value","height","showcontrolsToggle","removeAttr","videoWidth","val","jQuery"],"mappings":"CAAA,SAAWA,GACP,GAAIC,GAAUD,EAAEE,QACZC,EAAOF,EAAQG,GAEnBH,GAAQI,WAAkB,OACtBC,KAAM,SAAUC,EAAaC,EAAWC,EAAWP,GAC/CC,EAAK,yBAA0BM,EAE/B,IAAIC,GAAmBD,EAAUE,SAAS,8BACtCC,EAAQF,EAAiBG,KAAK,QAE7BD,GAAME,SAASC,GAAG,mBACnBH,EAAMI,KAAK,sCAInBC,WAAY,SAAUR,EAAWP,GAC7BC,EAAK,+BAAgCM,EAErC,IAAIC,GAAmBD,EAAUE,SAAS,8BACtCC,EAAQF,EAAiBG,KAAK,QAGlC,OAFAD,GAAMM,SAECR,EAAiBS,QAG5BC,gBAAgB,EAEhBC,aAAc,iBAEdC,gBAAiB,SAAUC,EAAMrB,GAC7BC,EAAK,wBAAyBoB,GAE9BA,EAAKC,OACD,2qDA+CRC,gBAAiB,SAAUF,EAAMd,EAAWP,GACxCC,EAAK,mCAAoCoB,EAAMd,EAE/C,IAAIiB,GAAUxB,EAAQwB,QAClBd,EAAQH,EAAUI,KAAK,SACvBc,EAAYJ,EAAKV,KAAK,mBACtBe,EAAoBL,EAAKV,KAAK,sBAClCe,GAAkBC,GAAG,QAAS,SAAUC,GACpCA,EAAEC,iBAEFJ,EAAUK,QAAQ,WAEtBL,EAAUM,IAAI,UAAUJ,GAAG,SAAU,WACjC,GAAIK,GAAOC,KAAKC,MAAM,EAClB,SAAQC,KAAKH,EAAKI,OAGlB1B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GAAMwC,IAAI,SAAUI,EAAS,MAC7B5C,EAAMoC,WAAW,SACjBpC,EAAMoC,WAAW,eAI9Ba","file":"keditor-component-video.min.js","sourcesContent":["(function ($) {\r\n var KEditor = $.keditor;\r\n var flog = KEditor.log;\r\n\r\n KEditor.components['video'] = {\r\n init: function (contentArea, container, component, keditor) {\r\n flog('init \"video\" component', component);\r\n\r\n var componentContent = component.children('.keditor-component-content');\r\n var video = componentContent.find('video');\r\n\r\n if (!video.parent().is('.video-wrapper')) {\r\n video.wrap('
');\r\n }\r\n },\r\n\r\n getContent: function (component, keditor) {\r\n flog('getContent \"video\" component', component);\r\n\r\n var componentContent = component.children('.keditor-component-content');\r\n var video = componentContent.find('video');\r\n video.unwrap();\r\n\r\n return componentContent.html();\r\n },\r\n\r\n settingEnabled: true,\r\n\r\n settingTitle: 'Video Settings',\r\n\r\n initSettingForm: function (form, keditor) {\r\n flog('init \"video\" settings', form);\r\n\r\n form.append(\r\n ''\r\n );\r\n },\r\n\r\n showSettingForm: function (form, component, keditor) {\r\n flog('showSettingForm \"video\" settings', form, component);\r\n\r\n var options = keditor.options;\r\n var video = component.find('video');\r\n var fileInput = form.find('#videoFileInput');\r\n var btnVideoFileInput = form.find('.btn-videoFileInput');\r\n btnVideoFileInput.on('click', function (e) {\r\n e.preventDefault();\r\n\r\n fileInput.trigger('click');\r\n });\r\n fileInput.off('change').on('change', function () {\r\n var file = this.files[0];\r\n if (/video/.test(file.type)) {\r\n // Todo: Upload to your server :)\r\n\r\n video.attr('src', URL.createObjectURL(file));\r\n\r\n video.load(function () {\r\n keditor.showSettingPanel(component, options);\r\n });\r\n } else {\r\n alert('Your selected file is not an video file!');\r\n }\r\n });\r\n\r\n var autoplayToggle = form.find('#video-autoplay');\r\n autoplayToggle.off('click').on('click', function (e) {\r\n if (this.checked) {\r\n video.prop('autoplay', true);\r\n } else {\r\n video.removeProp('autoplay');\r\n }\r\n });\r\n\r\n var loopToggle = form.find('#video-loop');\r\n loopToggle.off('click').on('click', function (e) {\r\n if (this.checked) {\r\n video.prop('loop', true);\r\n } else {\r\n video.removeProp('loop');\r\n }\r\n });\r\n\r\n var ratio = form.find('.video-ratio');\r\n ratio.off('click').on('click', function (e) {\r\n if (this.checked) {\r\n var currentWidth = video.css('width') || video.prop('width');\r\n currentWidth = currentWidth.replace('px', '');\r\n\r\n var currentRatio = this.value === '16/9' ? 16 / 9 : 4 / 3;\r\n var height = currentWidth / currentRatio;\r\n video.css('width', currentWidth + 'px');\r\n video.css('height', height + 'px');\r\n video.removeProp('width');\r\n video.removeProp('height');\r\n }\r\n });\r\n\r\n var showcontrolsToggle = form.find('#video-showcontrols');\r\n showcontrolsToggle.off('click').on('click', function (e) {\r\n if (this.checked) {\r\n video.attr('controls', 'controls');\r\n } else {\r\n video.removeAttr('controls');\r\n }\r\n });\r\n\r\n var videoWidth = form.find('#video-width');\r\n videoWidth.off('change').on('change', function () {\r\n video.css('width', this.value + 'px');\r\n var currentRatio = form.find('.video-ratio:checked').val() === '16/9' ? 16 / 9 : 4 / 3;\r\n var height = this.value / currentRatio;\r\n video.css('height', height + 'px');\r\n video.removeProp('width');\r\n video.removeProp('height');\r\n });\r\n }\r\n };\r\n})(jQuery);\r\n"]}