- md5
- 502cc711a6736e30f1ed8081097f11e9
- sha1
- 2ff6a986201707deeadec1156b6952899c0f9e99
- sha256
- 46b2d22fdf62adf34837d68cb1790b3ad975868e41cfa13aba7e13c258bb98cb
import s from"cropper-module";/**
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/let t,n=!1,r;const i=e=>{if(typeof e!="string"||!e.trim())return NaN;if(e.includes("/")){const[a,o]=e.split("/").map(parseFloat);return isNaN(a)||isNaN(o)||o===0?NaN:a/o}return parseFloat(e)},d=()=>{t.cropX.addEventListener("change",({currentTarget:e})=>{r.setData({x:parseInt(e.value,10)})}),t.cropY.addEventListener("change",({currentTarget:e})=>{r.setData({y:parseInt(e.value,10)})}),t.cropWidth.addEventListener("change",({currentTarget:e})=>{r.setData({width:parseInt(e.value,10)})}),t.cropHeight.addEventListener("change",({currentTarget:e})=>{r.setData({height:parseInt(e.value,10)})}),t.aspectRatio.addEventListener("change",({currentTarget:e})=>{r.setAspectRatio(i(e.value))}),n=!0},l=e=>{const a=e.naturalWidth/e.naturalHeight;!Number.isNaN(a)&&Number.isFinite(a)&&(t.cropAspectRatioOption.value=a),r=new s(e,{viewMode:1,responsive:!0,restore:!0,autoCrop:!0,movable:!1,zoomable:!1,rotatable:!1,autoCropArea:1,crop(o){t.cropX.value=Math.round(o.detail.x),t.cropY.value=Math.round(o.detail.y),t.cropWidth.value=Math.round(o.detail.width),t.cropHeight.value=Math.round(o.detail.height);const p=Joomla.MediaManager.Edit.original.extension.toLowerCase()==="jpg"?"jpeg":Joomla.MediaManager.Edit.original.extension.toLowerCase(),c=t.cropQuality.value;Joomla.MediaManager.Edit.current.contents=this.cropper.getCroppedCanvas().toDataURL(`image/${p}`,c),window.dispatchEvent(new Event("mediaManager.history.point"))}}),n||d(),r.setAspectRatio(i(t.cropAspectRatioOption.value))};window.addEventListener("media-manager-edit-init",()=>{t={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){return new Promise(a=>{l(e),a()})},Deactivate(e){return new Promise(a=>{e.cropper&&(e.cropper.destroy(),r=null),a()})}}},{once:!0});
The same content is in 32 releases, Joomla 6.1.0-alpha3 to 6.3.0-alpha1. See them all, or every version of this file.