CoreFiles by mySites.guru
validate.min.js1 lines, 6,138 bytes, from Joomla_4.0.0-alpha5-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha3
md5
0b4539df836c039aa0892f7e20726268
sha1
6cd676c855fa2cce4b5b6d2afcc6c8e9c7527b7d
sha256
04f9567a07d1f71b35ebc0e0f7644d697ec7642e07fce4e2e2b8bf246a1ec469
var _createClass=function(){function e(e,t){for(var a=0;a<t.length;a++){var s=t[a];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(t,a,s){return a&&e(t.prototype,a),s&&e(t,s),t}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}!function(e){"use strict";var t=function(){function t(){var a=this;_classCallCheck(this,t),this.customValidators={},this.handlers=[],this.handlers={},this.removeMarking=this.removeMarking.bind(this),this.inputEmail=function(){var t=e.createElement("input");return t.setAttribute("type","email"),"text"!==t.type},this.setHandler("username",function(e){return!new RegExp("[<|>|\"|'|%|;|(|)|&]","i").test(e)}),this.setHandler("password",function(e){return/^\S[\S ]{2,98}\S$/.test(e)}),this.setHandler("numeric",function(e){return/^(\d|-)?(\d|,)*\.?\d*$/.test(e)}),this.setHandler("email",function(e){var 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(function(e){e.classList.contains("form-validate")&&a.attachToForm(e)})}return _createClass(t,[{key:"setHandler",value:function(e,t,a){var s=""===a||a;this.handlers[e]={enabled:s,exec:t}}},{key:"markValid",value:function(e){var t=e.form.querySelector('label[for="'+e.id+'"]'),a=void 0;(e.classList.contains("required")||e.getAttribute("required"))&&t&&(a=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"),a&&a.parentNode.removeChild(a),t&&t.classList.remove("invalid")}},{key:"markInvalid",value:function(t,a){var s=t.form.querySelector('label[for="'+t.id+'"]');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");var r=void 0,i=t.getAttribute("data-validation-text");if(s&&(r=s.querySelector("span.form-control-feedback")),!r){var n=e.createElement("span");n.classList.add("form-control-feedback"),n.innerHTML=a&&"checkbox"===a?i||Joomla.JText._("JLIB_FORM_FIELD_REQUIRED_CHECK"):a&&"value"===a?i||Joomla.JText._("JLIB_FORM_FIELD_REQUIRED_VALUE"):i||Joomla.JText._("JLIB_FORM_FIELD_INVALID_VALUE"),s&&s.appendChild(n)}s&&s.classList.add("invalid")}},{key:"removeMarking",value:function(e){var t=void 0,a=e.form.querySelector('label[for="'+e.id+'"]');a&&(t=a.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&&a&&a.removeChild(t),a&&a.classList.remove("invalid")}},{key:"handleResponse",value:function(e,t,a){"button"!==t.tagName.toLowerCase()&&void 0!==t.value&&(!1===e?this.markInvalid(t,a):this.markValid(t))}},{key:"validate",value:function(e){var t=void 0;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}var a=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){var s=new RegExp("^"+e.getAttribute("pattern")+"$").test(e.value);return this.handleResponse(s,e,"empty"),s}return e.attr("required")||e.hasClass("required")?(this.handleResponse(!1,e,"empty"),!1):(this.handleResponse(!0,e),!1)}return""===a?(this.handleResponse(!0,e),!0):a&&"none"!==a&&this.handlers[a]&&e.value&&!0!==this.handlers[a].exec(e.value,e)?(this.handleResponse(!1,e,"invalid_value"),!1):(this.handleResponse(!0,e),!0)}},{key:"isValid",value:function(e){var t=this,a=!0,s=void 0,r=[];return[].slice.call(e.querySelectorAll("input, textarea, select, button")).forEach(function(e){!1===t.validate(e)&&(a=!1,r.push(e))}),Object.keys(this.customValidators).length&&Object.keys(this.customValidators).foreach(function(e){!0!==t.customValidators[e].exec()&&(a=!1)}),!a&&r.length>0&&(s={error:[e.getAttribute("data-validation-text")?e.getAttribute("data-validation-text"):Joomla.JText._("JLIB_FORM_CONTAINS_INVALID_FIELDS")]},Joomla.renderMessages(s)),a}},{key:"attachToForm",value:function(e){var t=this,a=[];[].slice.call(e.querySelectorAll("input, textarea, select, button, fieldset")).forEach(function(s){var r=s.tagName.toLowerCase();["input","textarea","select","fieldset"].indexOf(r)>-1&&s.classList.contains("required")&&s.setAttribute("required",""),"input"!==r&&"button"!==r||"submit"!==s.getAttribute("type")&&"image"!==s.getAttribute("type")?"button"===r||"input"===r&&"button"===s.getAttribute("type")||("fieldset"!==r&&(s.addEventListener("blur",function(e){return t.validate(e.target)}),s.addEventListener("focus",function(e){return t.removeMarking(e.target)}),s.classList.contains("validate-email")&&t.inputEmail&&s.setAttribute("type","email")),a.push(s)):s.classList.contains("validate")&&s.addEventListener("click",function(){return t.isValid(e)})})}},{key:"custom",get:function(){return this.customValidators},set:function(e){this.customValidators=e}}]),t}();e.addEventListener("DOMContentLoaded",function a(){e.formvalidator=new t,e.removeEventListener("DOMContentLoaded",a)})}(document);

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