- md5
- 12e41b6988a30920bc8311574621e08d
- sha1
- bab300fafcf77f91c89050e3ca461fade961809c
- sha256
- bc4ae0a623c0aed475cc0fc74afdf929a78b695322d5b48ef275bd64ba97af94
(e=>{"use strict";const t=()=>{e.formvalidator=new class{constructor(){this.customValidators={},this.handlers=[],this.handlers={},this.removeMarking=this.removeMarking.bind(this),this.inputEmail=(()=>{const t=e.createElement("input");return t.setAttribute("type","email"),"text"!==t.type}),this.setHandler("username",e=>!new RegExp("[<|>|\"|'|%|;|(|)|&]","i").test(e)),this.setHandler("password",e=>/^\S[\S ]{2,98}\S$/.test(e)),this.setHandler("numeric",e=>/^(\d|-)?(\d|,)*\.?\d*$/.test(e)),this.setHandler("email",e=>{const t=window.punycode.toASCII(e);return/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(t)}),[].slice.call(e.querySelectorAll("form")).forEach(e=>{e.classList.contains("form-validate")&&this.attachToForm(e)})}get custom(){return this.customValidators}set custom(e){this.customValidators=e}setHandler(e,t,s){const a=""===s||s;this.handlers[e]={enabled:a,exec:t}}markValid(e){const t=e.form.querySelector(`label[for="${e.id}"]`);let s;(e.classList.contains("required")||e.getAttribute("required"))&&t&&(s=t.querySelector("span.form-control-feedback")),e.classList.remove("form-control-danger"),e.classList.remove("invalid"),e.classList.add("form-control-success"),e.parentNode.classList.remove("has-danger"),e.parentNode.classList.add("has-success"),e.setAttribute("aria-invalid","false"),s&&s.parentNode.removeChild(s),t&&t.classList.remove("invalid")}markInvalid(t,s){const a=t.form.querySelector(`label[for="${t.id}"]`);let i;t.classList.remove("form-control-success"),t.classList.remove("valid"),t.classList.add("form-control-danger"),t.classList.add("invalid"),t.parentNode.classList.remove("has-success"),t.parentNode.classList.add("has-danger"),t.setAttribute("aria-invalid","true");const r=t.getAttribute("data-validation-text");if(a&&(i=a.querySelector("span.form-control-feedback")),!i){const t=e.createElement("span");t.classList.add("form-control-feedback"),t.innerHTML=s&&"checkbox"===s?r||Joomla.JText._("JLIB_FORM_FIELD_REQUIRED_CHECK"):s&&"value"===s?r||Joomla.JText._("JLIB_FORM_FIELD_REQUIRED_VALUE"):r||Joomla.JText._("JLIB_FORM_FIELD_INVALID_VALUE"),a&&a.appendChild(t)}a&&a.classList.add("invalid")}removeMarking(e){let t;const s=e.form.querySelector(`label[for="${e.id}"]`);s&&(t=s.querySelector("span.form-control-feedback")),e.classList.remove("form-control-danger"),e.classList.remove("form-control-success"),e.classList.remove("invalid"),e.classList.add("valid"),e.parentNode.classList.remove("has-danger"),e.parentNode.classList.remove("has-success"),t&&s&&s.removeChild(t),s&&s.classList.remove("invalid")}handleResponse(e,t,s){"button"!==t.tagName.toLowerCase()&&void 0!==t.value&&(!1===e?this.markInvalid(t,s):this.markValid(t))}validate(e){let t;if("disabled"===e.getAttribute("disabled")||"none"===e.getAttribute("display"))return this.handleResponse(!0,e),!0;if(e.getAttribute("required")||e.classList.contains("required"))if("fieldset"===(t=e.tagName.toLowerCase())&&(e.classList.contains("radio")||e.classList.contains("checkboxes"))){if(!e.querySelector("input:checked").length)return this.handleResponse(!1,e,"checkbox"),!1}else{if("checkbox"===e.getAttribute("type")&&0!==!e.checked.length||"select"===t&&!e.value.length)return this.handleResponse(!1,e,"checkbox"),!1;if(!e.value||e.classList.contains("placeholder"))return this.handleResponse(!1,e,"value"),!1}const s=e.getAttribute("class")&&e.getAttribute("class").match(/validate-([a-zA-Z0-9_-]+)/)?e.getAttribute("class").match(/validate-([a-zA-Z0-9_-]+)/)[1]:"";if(e.getAttribute("pattern")&&""!==e.getAttribute("pattern")){if(e.value.length){const t=new RegExp(`^${e.getAttribute("pattern")}$`).test(e.value);return this.handleResponse(t,e,"empty"),t}return e.attr("required")||e.hasClass("required")?(this.handleResponse(!1,e,"empty"),!1):(this.handleResponse(!0,e),!1)}return""===s?(this.handleResponse(!0,e),!0):s&&"none"!==s&&this.handlers[s]&&e.value&&!0!==this.handlers[s].exec(e.value,e)?(this.handleResponse(!1,e,"invalid_value"),!1):(this.handleResponse(!0,e),!0)}isValid(e){let t,s,a=!0;const i=[];return[].slice.call(e.querySelectorAll("input, textarea, select, button")).forEach(e=>{!1===this.validate(e)&&(a=!1,i.push(e))}),Object.keys(this.customValidators).length&&Object.keys(this.customValidators).foreach(e=>{!0!==this.customValidators[e].exec()&&(a=!1)}),!a&&i.length>0&&(s={error:[t=e.getAttribute("data-validation-text")?e.getAttribute("data-validation-text"):Joomla.JText._("JLIB_FORM_CONTAINS_INVALID_FIELDS")]},Joomla.renderMessages(s)),a}attachToForm(e){const t=[];[].slice.call(e.querySelectorAll("input, textarea, select, button, fieldset")).forEach(s=>{const a=s.tagName.toLowerCase();["input","textarea","select","fieldset"].indexOf(a)>-1&&s.classList.contains("required")&&s.setAttribute("required",""),"input"!==a&&"button"!==a||"submit"!==s.getAttribute("type")&&"image"!==s.getAttribute("type")?"button"===a||"input"===a&&"button"===s.getAttribute("type")||("fieldset"!==a&&(s.addEventListener("blur",e=>this.validate(e.target)),s.addEventListener("focus",e=>this.removeMarking(e.target)),s.classList.contains("validate-email")&&this.inputEmail&&s.setAttribute("type","email")),t.push(s)):s.classList.contains("validate")&&s.addEventListener("click",()=>this.isValid(e))})}},e.removeEventListener("DOMContentLoaded",t)};e.addEventListener("DOMContentLoaded",t)})(document);
No other release has this exact content. See every version of this file.