CoreFiles by mySites.guru
joomla-field-module-order.min.js1 lines, 2,148 bytes, from Joomla_4.0.0-alpha9-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha8
md5
a014bb7fd96ad339ae8a7049d13e8aaa
sha1
7a06dfe68d9745a3474545fb23f8e3378182b03b
sha256
ff05f8c7f2762b2f5600c47d57c8cbda3217720ad7ce47ab5d7f0eb819817b2b
"use strict";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 a=this;this.originalPosition=this.linkedFieldElement.value,this.getNewOrder(this.originalPosition),this.linkedFieldElement.addEventListener("change",()=>{a.originalPosition=a.linkedFieldElement.value,a.getNewOrder(a.linkedFieldElement.value)})}writeDynaList(a,b,c,d){let e=0;const f=document.createElement("select");for(const g in this.hasOwnProperty("disabled")&&f.setAttribute("disabled",""),this.getAttribute("onchange")&&f.setAttribute("onchange",this.getAttribute("onchange")),this.getAttribute("size")&&f.setAttribute("size",this.getAttribute("size")),f.classList.add(a.itemClass),f.setAttribute("name",a.name),f.id=a.id,b){if(!b.hasOwnProperty(g))continue;const a=document.createElement("option"),h=b[g];a.value=h[1],a.innerHTML=h[2],(c&&d===h[1]||!c&&0==e)&&a.setAttribute("selected","selected"),f.appendChild(a),e++}this.innerHTML="",this.appendChild(f)}getNewOrder(a){const b=this.getAttribute("data-url"),c=this.getAttribute("data-client-id"),d=this.getAttribute("data-ordering"),e=this.getAttribute("data-name"),f=this.getAttribute("data-client-attr")?this.getAttribute("data-client-attr"):"custom-select",g=`${this.getAttribute("id")}_1`,h=[],i=this;Joomla.request({url:`${b}&client_id=${c}&position=${a}`,method:"GET",perform:!0,headers:{"Content-Type":"application/x-www-form-urlencoded"},onSuccess(a,b){if(a&&(a=JSON.parse(a),0<a.data.length)){for(let b=0;b<a.data.length;++b)h[b]=a.data[b].split(",");i.writeDynaList({name:e,id:g,itemClass:f},h,i.originalPosition,d)}"object"==typeof a.messages&&null!==a.messages&&Joomla.renderMessages(a.messages)}})}});

The same content is in 3 releases, Joomla 4.0.0-alpha8 to 4.0.0-alpha10. See them all, or every version of this file.