/** * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */const debounce=(i,r=250,t)=>(...d)=>clearTimeout(t,t=setTimeout(i,r,...d));((i,r,t)=>{t.unpublishModule=e=>{const o="index.php?option=com_modules&task=modules.unpublish&format=json",n=e.getAttribute("data-module-id");t.request({url:`${o}&cid=${n}`,method:"POST",headers:{"Content-Type":"application/json"},onSuccess:()=>{const s=e.closest(".module-wrapper");s.parentNode.removeChild(s),t.renderMessages({message:[t.Text._("COM_CPANEL_UNPUBLISH_MODULE_SUCCESS")]})},onError:()=>{t.renderMessages({error:[t.Text._("COM_CPANEL_UNPUBLISH_MODULE_ERROR")]})}})};const d=()=>{const e=r.getElementById("content");e&&[].slice.call(e.querySelectorAll(".unpublish-module")).forEach(n=>{n.addEventListener("click",({target:s})=>t.unpublishModule(s))}),r.removeEventListener("DOMContentLoaded",d)};r.addEventListener("DOMContentLoaded",d),{$gridBox:null,gridAutoRows:0,gridRowGap:10,resizeGridItem(e,o,n){const s=e.querySelector(".card");if(s){const l=s.getBoundingClientRect().height+n,a=Math.ceil(l/(o+n));e.style.gridRowEnd=`span ${a}`}},resizeAllGridItems(){[].slice.call(this.$gridBox.children).forEach(o=>{this.resizeGridItem(o,this.gridAutoRows,this.gridRowGap)})},initialise(){this.$gridBox=r.querySelector("#cpanel-modules .card-columns");const e=i.getComputedStyle(this.$gridBox);this.gridAutoRows=parseInt(e.getPropertyValue("grid-auto-rows"),10)||this.gridAutoRows,this.gridRowGap=parseInt(e.getPropertyValue("grid-row-gap"),10)||this.gridRowGap,this.resizeAllGridItems(),i.addEventListener("load",()=>this.resizeAllGridItems()),i.addEventListener("joomla:menu-toggle",()=>{setTimeout(()=>this.resizeAllGridItems(),330)}),i.addEventListener("resize",debounce(()=>this.resizeAllGridItems(),50))}}.initialise()})(window,document,window.Joomla);