CoreFiles by mySites.guru
showon.es6.min.js1 lines, 2,717 bytes, from Joomla_4.0.0-alpha12-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha11
md5
869a7c18ce869842c9444e34918b368a
sha1
33fb0bf0531daf1a5b674063d12b2e81df2b3f6e
sha256
fa019bf6fec152cd37376ccd56ec4e1696ac7e4b78f5325e31cd8db336abae30
(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=\"".concat(d[0].field,"\"], [name=\"").concat(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=\"".concat(b.field,"\"], [name=\"").concat(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)})})}))}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("[\"".concat(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:c.style.display=f?"block":"none"})}}a.addEventListener("DOMContentLoaded",()=>{new b(a)}),a.addEventListener("joomla:updated",a=>{const c=a.target;if(c.classList.contains("subform-repeatable-group")){const a=[].slice.call(c.querySelectorAll("[data-showon]")),b=c.getAttribute("data-baseName"),d=c.getAttribute("data-group"),e=new RegExp("\\[".concat(b,"\\]\\[").concat(b,"X\\]"),"g"),f="[".concat(b,"][").concat(d,"]");a.forEach(a=>{const b=a.getAttribute("data-showon").replace(e,f);a.setAttribute("data-showon",b)})}new b(a.target)})})(document);

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