{"version":3,"sources":["keditor-component-audio.js"],"names":["$","KEditor","keditor","flog","log","components","getContent","component","componentContent","children","audio","find","unwrap","html","settingEnabled","settingTitle","initSettingForm","form","append","showSettingForm","options","fileInput","btnAudioFileInput","off","on","e","preventDefault","trigger","file","this","files","test","type","attr","URL","createObjectURL","load","showSettingPanel","alert","autoplayToggle","checked","removeAttr","showcontrolsToggle","audioWidth","css","value","jQuery"],"mappings":"CAAA,SAAWA,GACP,GAAIC,GAAUD,EAAEE,QACZC,EAAOF,EAAQG,GAEnBH,GAAQI,WAAkB,OACtBC,WAAY,SAAUC,EAAWL,GAC7BC,EAAK,0CAEL,IAAIK,GAAmBD,EAAUE,SAAS,8BACtCC,EAAQF,EAAiBG,KAAK,QAGlC,OAFAD,GAAME,SAECJ,EAAiBK,QAG5BC,gBAAgB,EAEhBC,aAAc,iBAEdC,gBAAiB,SAAUC,EAAMf,GAC7BC,EAAK,wBAAyBc,GAE9BA,EAAKC,OACD,8oCAgCRC,gBAAiB,SAAUF,EAAMV,EAAWL,GACxCC,EAAK,oCAAqCc,EAAMV,EAEhD,IAAIa,GAAUlB,EAAQkB,QAElBV,EAAQH,EAAUI,KAAK,SACvBU,EAAYJ,EAAKN,KAAK,mBACtBW,EAAoBL,EAAKN,KAAK,sBAClCW,GAAkBC,IAAI,SAASC,GAAG,QAAS,SAAUC,GACjDA,EAAEC,iBAEFL,EAAUM,QAAQ,WAEtBN,EAAUE,IAAI,UAAUC,GAAG,SAAU,WACjC,GAAII,GAAOC,KAAKC,MAAM,EAClB,SAAQC,KAAKH,EAAKI,OAGlBtB,EAAMuB,KAAK,MAAOC,IAAIC,gBAAgBP,IAEtClB,EAAM0B,KAAK,WACPlC,EAAQmC,iBAAiB9B,EAAWa,MAGxCkB,MAAM,6CAId,IAAIC,GAAiBtB,EAAKN,KAAK,kBAC/B4B,GAAehB,IAAI,SAASC,GAAG,QAAS,SAAUC,GAC1CI,KAAKW,QACL9B,EAAMuB,KAAK,WAAY,YAEvBvB,EAAM+B,WAAW,aAIzB,IAAIC,GAAqBzB,EAAKN,KAAK,sBACnC+B,GAAmBnB,IAAI,SAASC,GAAG,QAAS,SAAUC,GAC9CI,KAAKW,QACL9B,EAAMuB,KAAK,WAAY,YAEvBvB,EAAM+B,WAAW,aAIzB,IAAIE,GAAa1B,EAAKN,KAAK,eAC3BgC,GAAWpB,IAAI,UAAUC,GAAG,SAAU,WAClCd,EAAMkC,IAAI,QAASf,KAAKgB,MAAQ,UAI7CC","file":"keditor-component-audio.min.js","sourcesContent":["(function ($) {\r\n var KEditor = $.keditor;\r\n var flog = KEditor.log;\r\n \r\n KEditor.components['audio'] = {\r\n getContent: function (component, keditor) {\r\n flog('getContent \"audio\" component, component');\r\n \r\n var componentContent = component.children('.keditor-component-content');\r\n var audio = componentContent.find('audio');\r\n audio.unwrap();\r\n \r\n return componentContent.html();\r\n },\r\n \r\n settingEnabled: true,\r\n \r\n settingTitle: 'Audio Settings',\r\n \r\n initSettingForm: function (form, keditor) {\r\n flog('init \"audio\" 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 \"audio\" component', form, component);\r\n \r\n var options = keditor.options;\r\n \r\n var audio = component.find('audio');\r\n var fileInput = form.find('#audioFileInput');\r\n var btnAudioFileInput = form.find('.btn-audioFileInput');\r\n btnAudioFileInput.off('click').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 (/audio/.test(file.type)) {\r\n // Todo: Upload to your server :)\r\n \r\n audio.attr('src', URL.createObjectURL(file));\r\n \r\n audio.load(function () {\r\n keditor.showSettingPanel(component, options);\r\n });\r\n } else {\r\n alert('Your selected file is not an audio file!');\r\n }\r\n });\r\n \r\n var autoplayToggle = form.find('#audio-autoplay');\r\n autoplayToggle.off('click').on('click', function (e) {\r\n if (this.checked) {\r\n audio.attr('autoplay', 'autoplay');\r\n } else {\r\n audio.removeAttr('autoplay');\r\n }\r\n });\r\n \r\n var showcontrolsToggle = form.find('#audio-showcontrols');\r\n showcontrolsToggle.off('click').on('click', function (e) {\r\n if (this.checked) {\r\n audio.attr('controls', 'controls');\r\n } else {\r\n audio.removeAttr('controls');\r\n }\r\n });\r\n \r\n var audioWidth = form.find('#audio-width');\r\n audioWidth.off('change').on('change', function () {\r\n audio.css('width', this.value + '%');\r\n });\r\n }\r\n };\r\n})(jQuery);\r\n"]}