{"version":3,"sources":["keditor-component-youtube.js"],"names":["$","KEditor","keditor","flog","log","components","init","contentArea","container","component","iframe","find","wrapper","parent","initIframeCover","settingEnabled","settingTitle","initSettingForm","form","append","btnEdit","on","e","preventDefault","inputData","prompt","youtubeRegex","match","getSettingComponent","attr","alert","btn169","removeClass","addClass","btn43","chkAutoplay","embedItem","currentUrl","newUrl","replace","is","showSettingForm","src","prop","indexOf","jQuery"],"mappings":"CAAA,SAAWA,GACP,GAAIC,GAAUD,EAAEE,QACZC,EAAOF,EAAQG,GAEnBH,GAAQI,WAAoB,SACxBC,KAAM,SAAUC,EAAaC,EAAWC,EAAWP,GAC/CC,EAAK,2BAA4BM,EAEjC,IAAIC,GAASD,EAAUE,KAAK,UACxBC,EAAUF,EAAOG,QACrBX,GAAQY,gBAAgBJ,EAAQE,IAGpCG,gBAAgB,EAEhBC,aAAc,mBAEdC,gBAAiB,SAAUC,EAAMhB,GAC7BC,EAAK,uCAELe,EAAKC,OACD,otBAsBJ,IAAIC,GAAUF,EAAKP,KAAK,oBACxBS,GAAQC,GAAG,QAAS,SAAUC,GAC1BA,EAAEC,gBAEF,IAAIC,GAAYC,OAAO,qCACnBC,EAAe,2IACfC,EAAQH,EAAUG,MAAMD,EACxBC,IAASA,EAAM,GACfzB,EAAQ0B,sBAAsBjB,KAAK,0BAA0BkB,KAAK,MAAO,iCAAmCF,EAAM,IAElHG,MAAM,iCAId,IAAIC,GAASb,EAAKP,KAAK,mBACvBoB,GAAOV,GAAG,QAAS,SAAUC,GACzBA,EAAEC,iBAEFrB,EAAQ0B,sBAAsBjB,KAAK,qBAAqBqB,YAAY,yBAAyBC,SAAS,2BAG1G,IAAIC,GAAQhB,EAAKP,KAAK,kBACtBuB,GAAMb,GAAG,QAAS,SAAUC,GACxBA,EAAEC,iBAEFrB,EAAQ0B,sBAAsBjB,KAAK,qBAAqBqB,YAAY,0BAA0BC,SAAS,0BAG3G,IAAIE,GAAcjB,EAAKP,KAAK,oBAC5BwB,GAAYd,GAAG,QAAS,WACpB,GAAIe,GAAYlC,EAAQ0B,sBAAsBjB,KAAK,0BAC/C0B,EAAaD,EAAUP,KAAK,OAC5BS,EAAUD,EAAWE,QAAQ,UAAW,IAAO,cAAgBJ,EAAYK,GAAG,YAAc,EAAI,EAEpGrC,GAAK,gBAAkBkC,EAAY,YAAcC,GACjDF,EAAUP,KAAK,MAAOS,MAI9BG,gBAAiB,SAAUvB,EAAMT,EAAWP,GACxCC,EAAK,sCAAuCM,EAE5C,IAAI2B,GAAY3B,EAAUE,KAAK,0BAC3BwB,EAAcjB,EAAKP,KAAK,qBACxB+B,EAAMN,EAAUP,KAAK,MAEzBM,GAAYQ,KAAK,UAAWD,EAAIE,QAAQ,uBAIjDC","file":"keditor-component-youtube.min.js","sourcesContent":["(function ($) {\r\n var KEditor = $.keditor;\r\n var flog = KEditor.log;\r\n\r\n KEditor.components['youtube'] = {\r\n init: function (contentArea, container, component, keditor) {\r\n flog('init \"youtube\" component', component);\r\n\r\n var iframe = component.find('iframe');\r\n var wrapper = iframe.parent();\r\n keditor.initIframeCover(iframe, wrapper);\r\n },\r\n\r\n settingEnabled: true,\r\n\r\n settingTitle: 'Youtube Settings',\r\n\r\n initSettingForm: function (form, keditor) {\r\n flog('initSettingForm \"youtube\" component');\r\n\r\n form.append(\r\n '
' +\r\n '
' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n '
' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n '
' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n ' ' +\r\n ' ' +\r\n '
' +\r\n '
' +\r\n '
'\r\n );\r\n\r\n var btnEdit = form.find('.btn-youtube-edit');\r\n btnEdit.on('click', function (e) {\r\n e.preventDefault();\r\n\r\n var inputData = prompt('Please enter Youtube URL in here:');\r\n var youtubeRegex = /^(?:http(?:s)?:\\/\\/)?(?:www\\.)?(?:m\\.)?(?:youtu\\.be\\/|youtube\\.com\\/(?:(?:watch)?\\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\\/))([^\\?&\\\"'>]+)/;\r\n var match = inputData.match(youtubeRegex);\r\n if (match && match[1]) {\r\n keditor.getSettingComponent().find('.embed-responsive-item').attr('src', 'https://www.youtube.com/embed/' + match[1]);\r\n } else {\r\n alert('Your Youtube URL is invalid!');\r\n }\r\n });\r\n\r\n var btn169 = form.find('.btn-youtube-169');\r\n btn169.on('click', function (e) {\r\n e.preventDefault();\r\n\r\n keditor.getSettingComponent().find('.embed-responsive').removeClass('embed-responsive-4by3').addClass('embed-responsive-16by9');\r\n });\r\n\r\n var btn43 = form.find('.btn-youtube-43');\r\n btn43.on('click', function (e) {\r\n e.preventDefault();\r\n\r\n keditor.getSettingComponent().find('.embed-responsive').removeClass('embed-responsive-16by9').addClass('embed-responsive-4by3');\r\n });\r\n\r\n var chkAutoplay = form.find('#youtube-autoplay');\r\n chkAutoplay.on('click', function () {\r\n var embedItem = keditor.getSettingComponent().find('.embed-responsive-item');\r\n var currentUrl = embedItem.attr('src');\r\n var newUrl = (currentUrl.replace(/(\\?.+)+/, '')) + '?autoplay=' + (chkAutoplay.is(':checked') ? 1 : 0);\r\n\r\n flog('Current url: ' + currentUrl, 'New url: ' + newUrl);\r\n embedItem.attr('src', newUrl);\r\n });\r\n },\r\n\r\n showSettingForm: function (form, component, keditor) {\r\n flog('showSettingForm \"youtube\" component', component);\r\n\r\n var embedItem = component.find('.embed-responsive-item');\r\n var chkAutoplay = form.find('#youtube-autoplay');\r\n var src = embedItem.attr('src');\r\n\r\n chkAutoplay.prop('checked', src.indexOf('autoplay=1') !== -1);\r\n }\r\n };\r\n\r\n})(jQuery);\r\n"]}