CoreFiles by mySites.guru
showon.es6.min.js1 lines, 2,803 bytes, from Joomla_4.0.0-alpha5-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha3
md5
6555c936dd83b7c8b82dc40aa592e8bc
sha1
87b32f532d8f1352f5d043c1a246c7f8a05a1c28
sha256
3f725d062b35a611c59da461db013d36244df2a22577ceac01f36b3fc8e1c6b2
Joomla=window.Joomla||{},Joomla.setcollapse=((e,t,i)=>{document.getElementById(`collapse-${t}`)||(document.getElementById("container-collapse").innerHTML=`<div class="collapse fade" id="collapse-${t}"><iframe class="iframe" src="${e}" height="${i}" width="100%"></iframe></div>`)}),(e=>{"use strict";class t{constructor(t){const i=this;this.container=t||e,this.fields={},this.showonFields=[].slice.call(this.container.querySelectorAll("[data-showon]")),this.showonFields.length&&(this.showonFields.forEach(e=>{const t=e.getAttribute("data-showon")||"",s=JSON.parse(t);let l;s.length&&(l=[].slice.call(i.container.querySelectorAll(`[name="${s[0].field}"], [name="${s[0].field}[]"]`)),this.fields[s[0].field]||(this.fields[s[0].field]={origin:[],targets:[]}),l.forEach(e=>{-1===this.fields[s[0].field].origin.indexOf(e)&&this.fields[s[0].field].origin.push(e)}),this.fields[s[0].field].targets.push(e),s.length>1&&s.forEach((t,a)=>{0!==a&&(l=[].slice.call(i.container.querySelectorAll(`[name="${t.field}"], [name="${t.field}[]"]`)),this.fields[s[0].field]||(this.fields[s[0].field]={origin:[],targets:[]}),l.forEach(e=>{-1===this.fields[s[0].field].origin.indexOf(e)&&this.fields[s[0].field].origin.push(e)}),-1===this.fields[s[0].field].targets.indexOf(e)&&this.fields[s[0].field].targets.push(e))}))}),this.linkedOptions=this.linkedOptions.bind(this),Object.keys(this.fields).forEach(e=>{this.fields[e].origin.length&&this.fields[e].origin.forEach(t=>{i.linkedOptions(e),t.addEventListener("change",()=>{i.linkedOptions(e)})})}))}linkedOptions(t){this.fields[t].targets.forEach(i=>{const s=JSON.parse(i.getAttribute("data-showon"))||[];let l,a=!0;s.forEach((i,o)=>{const n=i||{};n.valid=0,this.fields[t].origin.forEach(t=>{if(t.name!==i.field)return;const s=t.id;if(t.getAttribute("type")&&-1!==["checkbox","radio"].indexOf(t.getAttribute("type").toLowerCase())){if(!t.checked)return;l=e.getElementById(s).value}else null===(l=e.getElementById(s).value)&&"select"===t.tagName.toLowerCase()&&(l=[]);"object"!=typeof l&&(l=JSON.parse(`["${l}"]`)),l.forEach(e=>{"="===n.sign&&-1!==n.values.indexOf(e)&&(n.valid=1),"!="===n.sign&&-1===n.values.indexOf(e)&&(n.valid=1)})}),""===n.op?0===n.valid&&(a=!1):("AND"===n.op&&n.valid+s[o-1].valid<2&&(a=!1),"OR"===n.op&&n.valid+s[o-1].valid>0&&(a=!0))}),i.style.display=a?"block":"none"})}}e.addEventListener("DOMContentLoaded",()=>{new t(e)}),e.addEventListener("joomla:updated",e=>{const i=e.target;if(i.classList.contains("subform-repeatable-group")){const e=[].slice.call(i.querySelectorAll("[data-showon]")),t=i.getAttribute("data-baseName"),s=i.getAttribute("data-group"),l=new RegExp(`\\[${t}\\]\\[${t}X\\]`,"g"),a=`[${t}][${s}]`;e.forEach(e=>{const t=e.getAttribute("data-showon").replace(l,a);e.setAttribute("data-showon",t)})}new t(e.target)})})(document);

The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.