芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/chocholayucatan.gob.mx/media/plg_media-action_crop/js/crop.min.js
let formElements,instance,activated=!1;const addListeners=()=>{formElements.cropX.addEventListener("change",(({currentTarget:e})=>{instance.setData({x:parseInt(e.value,10)})})),formElements.cropY.addEventListener("change",(({currentTarget:e})=>{instance.setData({y:parseInt(e.value,10)})})),formElements.cropWidth.addEventListener("change",(({currentTarget:e})=>{instance.setData({width:parseInt(e.value,10)})})),formElements.cropHeight.addEventListener("change",(({currentTarget:e})=>{instance.setData({height:parseInt(e.value,10)})})),formElements.aspectRatio.addEventListener("change",(({currentTarget:e})=>{instance.setAspectRatio(e.value)})),activated=!0},init=e=>{const t=e.naturalWidth/e.naturalHeight;!Number.isNaN(t)&&Number.isFinite(t)&&(formElements.cropAspectRatioOption.value=t),instance=new Cropper(e,{viewMode:1,responsive:!0,restore:!0,autoCrop:!0,movable:!1,zoomable:!1,rotatable:!1,autoCropArea:1,crop(e){formElements.cropX.value=Math.round(e.detail.x),formElements.cropY.value=Math.round(e.detail.y),formElements.cropWidth.value=Math.round(e.detail.width),formElements.cropHeight.value=Math.round(e.detail.height);const t="jpg"===Joomla.MediaManager.Edit.original.extension?"jpeg":Joomla.MediaManager.Edit.original.extension,a=formElements.cropQuality.value;Joomla.MediaManager.Edit.current.contents=this.cropper.getCroppedCanvas().toDataURL(`image/${t}`,a),window.dispatchEvent(new Event("mediaManager.history.point"))}}),activated||(formElements.cropX.addEventListener("change",(({currentTarget:e})=>{instance.setData({x:parseInt(e.value,10)})})),formElements.cropY.addEventListener("change",(({currentTarget:e})=>{instance.setData({y:parseInt(e.value,10)})})),formElements.cropWidth.addEventListener("change",(({currentTarget:e})=>{instance.setData({width:parseInt(e.value,10)})})),formElements.cropHeight.addEventListener("change",(({currentTarget:e})=>{instance.setData({height:parseInt(e.value,10)})})),formElements.aspectRatio.addEventListener("change",(({currentTarget:e})=>{instance.setAspectRatio(e.value)})),activated=!0),instance.setAspectRatio(formElements.cropAspectRatioOption.value)};window.addEventListener("media-manager-edit-init",(()=>{formElements={aspectRatio:document.getElementById("jform_aspectRatio"),cropHeight:document.getElementById("jform_crop_height"),cropWidth:document.getElementById("jform_crop_width"),cropY:document.getElementById("jform_crop_y"),cropX:document.getElementById("jform_crop_x"),cropQuality:document.getElementById("jform_crop_quality"),cropAspectRatioOption:document.querySelector(".crop-aspect-ratio-option")},Joomla.MediaManager.Edit.plugins.crop={Activate:e=>new Promise((t=>{init(e),t()})),Deactivate:e=>new Promise((t=>{e.cropper&&(e.cropper.destroy(),instance=null),t()}))}}),{once:!0});