CoreFiles by mySites.guru
showon.es6.min.js1 lines, 2,697 bytes, from Joomla_4.0.0-alpha9-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha8
md5
02422247140e74085df1a94f97c8f9d1
sha1
5fe11d1a866c00b435524a995d7fc52585a5c4d8
sha256
b4ba2d22fa344dec765012c3883cb3426fb1f8969089de5a469f933ecef248d7
(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),"OR"===h.op&&0<h.valid+d[g-1].valid&&(f=!0))}),"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-alpha9 to 4.0.0-alpha10. See them all, or every version of this file.