Current File : /home/pacjaorg/.trash/media.1/system/js/fields/joomla-field-module-order.min.js
/**
 * @package         Joomla.JavaScript
 * @copyright       (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
 * @license         GNU General Public License version 2 or later; see LICENSE.txt
 */customElements.define("joomla-field-module-order",class extends HTMLElement{constructor(){super(),this.linkedFieldSelector="",this.linkedFieldElement="",this.originalPosition="",this.writeDynaList.bind(this),this.getNewOrder.bind(this)}connectedCallback(){if(this.linkedFieldSelector=this.getAttribute("data-linked-field")||"jform_position",!this.linkedFieldSelector)throw new Error("No linked field defined!");if(this.linkedFieldElement=document.getElementById(this.linkedFieldSelector),!this.linkedFieldElement)throw new Error("No linked field defined!");const t=this;this.originalPosition=this.linkedFieldElement.value,this.getNewOrder(this.originalPosition),this.linkedFieldElement.addEventListener("change",()=>{t.originalPosition=t.linkedFieldElement.value,t.getNewOrder(t.linkedFieldElement.value)})}writeDynaList(t,d,o,c){let r=0;const e=document.createElement("select");this.hasAttribute("disabled")&&e.setAttribute("disabled",""),this.getAttribute("onchange")&&e.setAttribute("onchange",this.getAttribute("onchange")),this.getAttribute("size")&&e.setAttribute("size",this.getAttribute("size")),e.classList.add(t.itemClass),e.setAttribute("name",t.name),e.id=t.id;for(const a in d){if(!d.hasOwnProperty(a))continue;const i=document.createElement("option"),n=d[a];i.value=n[1],i.innerHTML=Joomla.sanitizeHtml(n[2]),(o&&c===n[1]||!o&&r===0)&&i.setAttribute("selected","selected"),e.appendChild(i),r+=1}this.innerHTML="",this.appendChild(e)}getNewOrder(t){const d=this.getAttribute("data-url"),o=this.getAttribute("data-client-id"),c=this.getAttribute("data-ordering"),r=this.getAttribute("data-name"),e=this.getAttribute("data-client-attr")?this.getAttribute("data-client-attr"):"form-select",a=`${this.getAttribute("data-id")}`,i=`${this.getAttribute("data-module-id")}`,n=[],u=this;Joomla.request({url:`${d}&client_id=${o}&position=${t}&module_id=${i}`,method:"GET",perform:!0,headers:{"Content-Type":"application/x-www-form-urlencoded"},onSuccess(l){if(l){let h;try{h=JSON.parse(l)}catch(s){console.error(s)}if(h.data.length>0){for(let s=0;s<h.data.length;s+=1)n[s]=h.data[s].split(",");u.writeDynaList({name:r,id:a,itemClass:e},n,u.originalPosition,c)}}typeof l.messages=="object"&&l.messages!==null&&Joomla.renderMessages(l.messages)}})}});
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

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