CoreFiles by mySites.guru
validate.min.js4 lines, 11,031 bytes, from Joomla_6.3.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 6.2.0-alpha3
md5
bce893c75ed80db805489209a556604a
sha1
dae71967948b094c7f4fb88cc5c896afe08c2c80
sha256
eb080b224498b2d9b05133e2e7057ee92841b84a62ced8e18abf9af701cab10b
const maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\0-\x7F]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=35,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(o){throw new RangeError(errors[o])}function map(o,t){const e=[];let s=o.length;for(;s--;)e[s]=t(o[s]);return e}function mapDomain(o,t){const e=o.split("@");let s="";e.length>1&&(s=e[0]+"@",o=e[1]),o=o.replace(regexSeparators,".");const a=o.split("."),i=map(a,t).join(".");return s+i}function ucs2decode(o){const t=[];let e=0;const s=o.length;for(;e<s;){const a=o.charCodeAt(e++);if(a>=55296&&a<=56319&&e<s){const i=o.charCodeAt(e++);(i&64512)==56320?t.push(((a&1023)<<10)+(i&1023)+65536):(t.push(a),e--)}else t.push(a)}return t}const ucs2encode=o=>String.fromCodePoint(...o),basicToDigit=function(t){return t>=48&&t<58?26+(t-48):t>=65&&t<91?t-65:t>=97&&t<123?t-97:36},digitToBasic=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)},adapt=function(t,e,s){let a=0;for(t=s?floor(t/700):t>>1,t+=floor(t/e);t>baseMinusTMin*26>>1;a+=36)t=floor(t/baseMinusTMin);return floor(a+(baseMinusTMin+1)*t/(t+38))},decode=function(t){const e=[],s=t.length;let a=0,i=128,r=72,n=t.lastIndexOf("-");n<0&&(n=0);for(let c=0;c<n;++c)t.charCodeAt(c)>=128&&error("not-basic"),e.push(t.charCodeAt(c));for(let c=n>0?n+1:0;c<s;){const l=a;for(let d=1,f=36;;f+=36){c>=s&&error("invalid-input");const h=basicToDigit(t.charCodeAt(c++));h>=36&&error("invalid-input"),h>floor((2147483647-a)/d)&&error("overflow"),a+=h*d;const b=f<=r?1:f>=r+26?26:f-r;if(h<b)break;const g=36-b;d>floor(2147483647/g)&&error("overflow"),d*=g}const u=e.length+1;r=adapt(a-l,u,l==0),floor(a/u)>2147483647-i&&error("overflow"),i+=floor(a/u),a%=u,e.splice(a++,0,i)}return String.fromCodePoint(...e)},encode=function(t){const e=[];t=ucs2decode(t);const s=t.length;let a=128,i=0,r=72;for(const l of t)l<128&&e.push(stringFromCharCode(l));const n=e.length;let c=n;for(n&&e.push("-");c<s;){let l=2147483647;for(const d of t)d>=a&&d<l&&(l=d);const u=c+1;l-a>floor((2147483647-i)/u)&&error("overflow"),i+=(l-a)*u,a=l;for(const d of t)if(d<a&&++i>2147483647&&error("overflow"),d===a){let f=i;for(let h=36;;h+=36){const b=h<=r?1:h>=r+26?26:h-r;if(f<b)break;const g=f-b,p=36-b;e.push(stringFromCharCode(digitToBasic(b+g%p,0))),f=floor(g/p)}e.push(stringFromCharCode(digitToBasic(f,0))),r=adapt(i,u,c===n),i=0,++c}++i,++a}return e.join("")},toUnicode=function(t){return mapDomain(t,function(e){return regexPunycode.test(e)?decode(e.slice(4).toLowerCase()):e})},toASCII=function(t){return mapDomain(t,function(e){return regexNonASCII.test(e)?"xn--"+encode(e):e})},punycode={version:"2.3.1",ucs2:{decode:ucs2decode,encode:ucs2encode},decode,encode,toASCII,toUnicode};/**
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */class JFormValidator{constructor(){this.customValidators={},this.handlers=[],this.handlers={},this.removeMarking=this.removeMarking.bind(this),document.addEventListener("click",t=>this.handleInvalidFieldLink(t)),this.inputEmail=()=>{const t=document.createElement("input");return t.setAttribute("type","email"),t.type!=="text"},this.setHandler("username",t=>!/[<|>|"|'|%|;|(|)|&]/i.test(t)),this.setHandler("password",t=>/^\S[\S ]{2,98}\S$/.test(t)),this.setHandler("numeric",t=>/^(\d|-)?(\d|,)*\.?\d*$/.test(t)),this.setHandler("email",t=>{const e=punycode.toASCII(t);return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(e)}),document.querySelectorAll("form").forEach(t=>{t.classList.contains("form-validate")&&this.attachToForm(t)})}get custom(){return this.customValidators}set custom(t){this.customValidators=t}setHandler(t,e,s){const a=s===""?!0:s;this.handlers[t]={enabled:a,exec:e}}getFieldLabel(t){if(t.tagName.toLowerCase()==="fieldset"){const s=t.querySelector("legend");return s?s.textContent.trim().replace(/\s+/g," "):""}const e=t.labels?Array.from(t.labels):[];for(const s of e){const a=s.cloneNode(!0);a.querySelectorAll(".star, .form-control-feedback").forEach(r=>{r.remove()});const i=a.textContent.trim().replace(/\s+/g," ");if(i)return i}return""}getInvalidFieldTarget(t){return t.tagName.toLowerCase()==="fieldset"&&t.querySelector("input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled])")||t}updateInvalidTabs(t,e){t.querySelectorAll("joomla-tab-element").forEach(s=>{const a=Array.from(document.querySelectorAll("button[aria-controls]")).find(r=>r.getAttribute("aria-controls")===s.id);if(!a)return;const i=e.some(r=>s.contains(r));a.classList.toggle("text-danger",i)})}ensureElementId(t,e){if(t.id)return t.id;let s=`form-validation-target-${e}`,a=1;for(;document.getElementById(s);)s=`form-validation-target-${e}-${a}`,a+=1;return t.id=s,s}escapeHtml(t){return t.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"})[e])}handleInvalidFieldLink(t){const e=t.target.closest("a.js-validation-error-link");if(!e)return;const s=document.getElementById(e.dataset.targetId);if(!s)return;t.preventDefault();const a=e.dataset.tabId?document.getElementById(e.dataset.tabId):null;if(a){const i=Array.from(document.querySelectorAll("button[aria-controls]")).find(r=>r.getAttribute("aria-controls")===a.id);i&&i.click()}window.requestAnimationFrame(()=>{s.focus()})}buildInvalidFieldsMessage(t){const e=t.filter(a=>a.tagName.toLowerCase()==="fieldset"&&this.getFieldLabel(a)!==""),s=t.filter(a=>!e.some(i=>i!==a&&i.contains(a))).map((a,i)=>{const r=this.getFieldLabel(a);if(!r)return null;const n=this.getInvalidFieldTarget(a),c=this.ensureElementId(n,i),l=a.closest("joomla-tab-element"),u=l?l.getAttribute("name"):"",d=u?`${u} \u2192 ${r}`:r,f=l&&l.id?` data-tab-id="${this.escapeHtml(l.id)}"`:"";return`<li><a class="js-validation-error-link" href="#${c}" data-target-id="${c}"${f}>${this.escapeHtml(d)}</a></li>`}).filter(a=>a!==null);return s.length?`<ul>${s.join("")}</ul>`:""}markValid(t){const e=t.form.querySelector(`label[for="${t.id}"]`)||document.getElementById(`${t.id}-lbl`);let s;(t.classList.contains("required")||t.getAttribute("required"))&&e&&(s=e.querySelector("span.form-control-feedback")),t.classList.remove("form-control-danger","invalid"),t.classList.add("form-control-success"),t.parentNode.classList.remove("has-danger"),t.parentNode.classList.add("has-success"),t.setAttribute("aria-invalid","false"),s&&s.parentNode.removeChild(s),e&&e.classList.remove("invalid")}markInvalid(t,e){const s=t.form.querySelector(`label[for="${t.id}"]`)||document.getElementById(`${t.id}-lbl`);t.classList.remove("form-control-success","valid"),t.classList.add("form-control-danger","invalid"),t.parentNode.classList.remove("has-success"),t.parentNode.classList.add("has-danger"),t.setAttribute("aria-invalid","true");let a;const i=t.getAttribute("data-validation-text");if(s&&(a=s.querySelector("span.form-control-feedback")),!a){const r=document.createElement("span");r.classList.add("form-control-feedback"),e&&e==="checkbox"?r.innerHTML=i!==null?Joomla.sanitizeHtml(i):Joomla.sanitizeHtml(Joomla.Text._("JLIB_FORM_FIELD_REQUIRED_CHECK")):e&&e==="value"?r.innerHTML=i!==null?Joomla.sanitizeHtml(i):Joomla.sanitizeHtml(Joomla.Text._("JLIB_FORM_FIELD_REQUIRED_VALUE")):r.innerHTML=i!==null?Joomla.sanitizeHtml(i):Joomla.sanitizeHtml(Joomla.Text._("JLIB_FORM_FIELD_INVALID_VALUE")),s&&s.appendChild(r)}s&&s.classList.add("invalid")}removeMarking(t){let e;const s=t.form.querySelector(`label[for="${t.id}"]`)||document.getElementById(`${t.id}-lbl`);s&&(e=s.querySelector("span.form-control-feedback")),t.classList.remove("form-control-danger","form-control-success","remove"),t.classList.add("valid"),t.parentNode.classList.remove("has-danger","has-success"),e&&s&&s.removeChild(e),s&&s.classList.remove("invalid")}handleResponse(t,e,s){const a=e.tagName.toLowerCase();(a!=="button"&&e.value!==void 0||a==="fieldset")&&(t===!1?this.markInvalid(e,s):this.markValid(e))}validate(t){let e;if(t.getAttribute("disabled")==="disabled"||t.getAttribute("display")==="none")return this.handleResponse(!0,t),!0;if(t.getAttribute("required")||t.classList.contains("required"))if(e=t.tagName.toLowerCase(),e==="fieldset"&&(t.classList.contains("radio")||t.classList.contains("checkboxes"))){if(t.querySelector("input:checked")===null)return this.handleResponse(!1,t,"checkbox"),!1}else{if(t.getAttribute("type")==="checkbox"&&t.checked!==!0||e==="select"&&!t.value.length)return this.handleResponse(!1,t,"checkbox"),!1;if(!t.value||t.classList.contains("placeholder"))return this.handleResponse(!1,t,"value"),!1}const s=t.getAttribute("class")&&t.getAttribute("class").match(/validate-([a-zA-Z0-9_-]+)/)?t.getAttribute("class").match(/validate-([a-zA-Z0-9_-]+)/)[1]:"";if(t.getAttribute("pattern")&&t.getAttribute("pattern")!==""){if(t.value.length){const a=new RegExp(`^${t.getAttribute("pattern")}$`).test(t.value);return this.handleResponse(a,t,"empty"),a}return t.hasAttribute("required")||t.classList.contains("required")?(this.handleResponse(!1,t,"empty"),!1):(this.handleResponse(!0,t),!0)}return s===""?(this.handleResponse(!0,t),!0):s&&s!=="none"&&this.handlers[s]&&t.value&&this.handlers[s].exec(t.value,t)!==!0?(this.handleResponse(!1,t,"invalid_value"),!1):(this.handleResponse(!0,t),!0)}isValid(t){let e=!0,s,a,i;const r=[];if(t.nodeName==="FORM"?i=[].slice.call(t.elements):i=t.querySelectorAll("input, textarea, select, button, fieldset"),i.forEach(n=>{this.validate(n)===!1&&(e=!1,r.push(n))}),this.updateInvalidTabs(t,r),Object.keys(this.customValidators).length&&Object.keys(this.customValidators).forEach(n=>{this.customValidators[n].exec()!==!0&&(e=!1)}),!e&&r.length>0){t.getAttribute("data-validation-text")?s=t.getAttribute("data-validation-text"):s=Joomla.Text._("JLIB_FORM_CONTAINS_INVALID_FIELDS");const n=this.buildInvalidFieldsMessage(r);n&&(s=`${s} ${n}`),a={error:[s]},Joomla.renderMessages(a)}return e}attachToForm(t){let e;t.nodeName==="FORM"?e=[].slice.call(t.elements):e=t.querySelectorAll("input, textarea, select, button, fieldset"),e.forEach(s=>{const a=s.tagName.toLowerCase();["input","textarea","select","fieldset"].indexOf(a)>-1&&s.classList.contains("required")&&s.setAttribute("required",""),(a==="input"||a==="button")&&(s.getAttribute("type")==="submit"||s.getAttribute("type")==="image")?s.classList.contains("validate")&&s.addEventListener("click",()=>this.isValid(t)):a!=="button"&&!(a==="input"&&s.getAttribute("type")==="button")&&a!=="fieldset"&&(s.addEventListener("blur",({target:i})=>this.validate(i)),s.addEventListener("focus",({target:i})=>this.removeMarking(i)),s.classList.contains("validate-email")&&this.inputEmail&&s.setAttribute("type","email"))})}}document.formvalidator=new JFormValidator,window.JFormValidator=JFormValidator,window.punycode=punycode;

No other release has this exact content. See every version of this file.