Current File : /home/pacjaorg/wpt.pacja.org/km/media/plg_media-action_rotate/js/rotate.min.js
/**
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */let activated=!1;const rotate=(a,t)=>{let e=document.createElement("canvas");a>=0&&a<45||a>=135&&a<225||a>=315&&a<=360?(e.width=t.naturalWidth,e.height=t.naturalHeight):(e.width=t.naturalHeight,e.height=t.naturalWidth);const r=e.getContext("2d");r.clearRect(0,0,e.width,e.height),r.translate(e.width/2,e.height/2),r.rotate(a*Math.PI/180),r.drawImage(t,-t.naturalWidth/2,-t.naturalHeight/2);const o=Joomla.MediaManager.Edit.original.extension.toLowerCase()==="jpg"?"jpeg":Joomla.MediaManager.Edit.original.extension.toLowerCase(),i=document.getElementById("jform_rotate_quality").value;Joomla.MediaManager.Edit.current.contents=e.toDataURL(`image/${o}`,i),t.width=e.width,t.height=e.height,t.src="",requestAnimationFrame(()=>requestAnimationFrame(()=>{t.src=Joomla.MediaManager.Edit.current.contents})),document.getElementById("jform_rotate_a").value=a,window.dispatchEvent(new Event("mediaManager.history.point")),e=null},initRotate=a=>{activated||(document.getElementById("jform_rotate_a").addEventListener("change",({target:t})=>{rotate(parseInt(t.value,10),a),t.value=0,[].slice.call(document.querySelectorAll("#jform_rotate_distinct label")).forEach(e=>{e.classList.remove("active"),e.classList.remove("focus")})}),[].slice.call(document.querySelectorAll("#jform_rotate_distinct [type=radio]")).forEach(t=>{t.addEventListener("click",({target:e})=>{rotate(parseInt(e.value,10),a),[].slice.call(document.querySelectorAll("#jform_rotate_distinct label")).forEach(r=>{r.classList.remove("active"),r.classList.remove("focus")})})}),activated=!0)};window.addEventListener("media-manager-edit-init",()=>{Joomla.MediaManager.Edit.plugins.rotate={Activate(a){return new Promise(t=>{initRotate(a),t()})},Deactivate(){return new Promise(a=>{a()})}}},{once:!0});
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!