- md5
- b4e86ba9bf1092e0ab8055e2b54dd84f
- sha1
- 3d455ae92afe153a1431974e4c769ba9dcadf7c1
- sha256
- 18f689e6f6b7978e5c5360ad449719b6ad6c715bcec2be2d217c44608d763e0a
import p 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,a;const d=()=>{t.cropX.addEventListener("change",({currentTarget:e})=>{a.setData({x:parseInt(e.value,10)})}),t.cropY.addEventListener("change",({currentTarget:e})=>{a.setData({y:parseInt(e.value,10)})}),t.cropWidth.addEventListener("change",({currentTarget:e})=>{a.setData({width:parseInt(e.value,10)})}),t.cropHeight.addEventListener("change",({currentTarget:e})=>{a.setData({height:parseInt(e.value,10)})}),t.aspectRatio.addEventListener("change",({currentTarget:e})=>{a.setAspectRatio(e.value)}),n=!0},s=e=>{const o=e.naturalWidth/e.naturalHeight;!Number.isNaN(o)&&Number.isFinite(o)&&(t.cropAspectRatioOption.value=o),a=new p(e,{viewMode:1,responsive:!0,restore:!0,autoCrop:!0,movable:!1,zoomable:!1,rotatable:!1,autoCropArea:1,crop(r){t.cropX.value=Math.round(r.detail.x),t.cropY.value=Math.round(r.detail.y),t.cropWidth.value=Math.round(r.detail.width),t.cropHeight.value=Math.round(r.detail.height);const i=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/${i}`,c),window.dispatchEvent(new Event("mediaManager.history.point"))}}),n||d(),a.setAspectRatio(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(o=>{s(e),o()})},Deactivate(e){return new Promise(o=>{e.cropper&&(e.cropper.destroy(),a=null),o()})}}},{once:!0});
The same content is in 101 releases, Joomla 5.1.1-rc1 to 6.1.0-alpha2. See them all, or every version of this file.