CoreFiles by mySites.guru
showon.es6.min.js1 lines, 2,614 bytes, from Joomla_4.0.0-beta5-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta4
md5
3ee9383d243e027c09cad70e6e655ed0
sha1
c08ae2fd65387e83493dd9295527b83209de9aab
sha256
e061a16e7164fb6d5c423d3137b9720c633933603d4f86cf3b6e560b44f2dd88
(a=>{'use strict';class b{constructor(b){const c=this;this.container=b||a,this.fields={},this.showonFields=[].slice.call(this.container.querySelectorAll("[data-showon]")),this.showonFields.length&&(this.showonFields.forEach(a=>{const b=a.getAttribute("data-showon")||"",d=JSON.parse(b);let e;d.length&&(e=[].slice.call(c.container.querySelectorAll(`[name="${d[0].field}"], [name="${d[0].field}[]"]`)),!this.fields[d[0].field]&&(this.fields[d[0].field]={origin:[],targets:[]}),e.forEach(a=>{-1===this.fields[d[0].field].origin.indexOf(a)&&this.fields[d[0].field].origin.push(a)}),this.fields[d[0].field].targets.push(a),1<d.length&&d.forEach((b,f)=>{0===f||(e=[].slice.call(c.container.querySelectorAll(`[name="${b.field}"], [name="${b.field}[]"]`)),!this.fields[d[0].field]&&(this.fields[d[0].field]={origin:[],targets:[]}),e.forEach(a=>{-1===this.fields[d[0].field].origin.indexOf(a)&&this.fields[d[0].field].origin.push(a)}),-1===this.fields[d[0].field].targets.indexOf(a)&&this.fields[d[0].field].targets.push(a))}))}),this.linkedOptions=this.linkedOptions.bind(this),Object.keys(this.fields).forEach(a=>{this.fields[a].origin.length&&this.fields[a].origin.forEach(b=>{c.linkedOptions(a),b.addEventListener("change",()=>{c.linkedOptions(a)}),b.addEventListener("keyup",()=>{c.linkedOptions(a)}),b.addEventListener("click",()=>{c.linkedOptions(a)})})}))}linkedOptions(b){this.fields[b].targets.forEach(c=>{const d=JSON.parse(c.getAttribute("data-showon"))||[];let e,f=!0;d.forEach((c,g)=>{const h=c||{};h.valid=0,this.fields[b].origin.forEach(b=>{if(b.name===c.field){const c=b.id;if(b.getAttribute("type")&&-1!==["checkbox","radio"].indexOf(b.getAttribute("type").toLowerCase())){if(!b.checked)return;e=a.getElementById(c).value}else e=a.getElementById(c).value,null===e&&"select"===b.tagName.toLowerCase()&&(e=[]);"object"==typeof e||(e=JSON.parse(`["${e}"]`)),e.forEach(a=>{"="===h.sign&&-1!==h.values.indexOf(a)&&(h.valid=1),"!="===h.sign&&-1===h.values.indexOf(a)&&(h.valid=1)})}}),""===h.op?0===h.valid&&(f=!1):("AND"===h.op&&2>h.valid+d[g-1].valid&&(f=!1,h.valid=0),"OR"===h.op&&0<h.valid+d[g-1].valid&&(f=!0,h.valid=1))}),"option"===c.tagName?c.disabled=!f:f?c.classList.remove("hidden"):c.classList.add("hidden")})}}a.addEventListener("DOMContentLoaded",()=>{new b(a)}),a.addEventListener("joomla:updated",({target:a})=>{if(a.classList.contains("subform-repeatable-group")){const b=[].slice.call(a.querySelectorAll("[data-showon]")),c=new RegExp(`\\[${a.dataset.baseName}X\\]`,"g"),d=`[${a.dataset.group}]`;b.forEach(a=>{const b=a.dataset.showon.replace(c,d);a.dataset.showon=b})}new b(a)})})(document);

The same content is in 5 releases, Joomla 4.0.0-beta2 to 4.0.0-beta6. See them all, or every version of this file.