D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
guruglobalpreschool.com
/
admin
/
assets
/
libs
/
pristinejs
/
Filename :
pristine.min.js
back
Copy
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).Pristine=r()}(this,(function(){"use strict";var e={required:"This field is required",email:"This field requires a valid e-mail address",number:"This field requires a number",integer:"This field requires an integer value",url:"This field requires a valid website URL",tel:"This field requires a valid telephone number",maxlength:"This fields length must be < ${1}",minlength:"This fields length must be > ${1}",min:"Minimum value for this field is ${1}",max:"Maximum value for this field is ${1}",pattern:"Please match the requested format"};function r(e){var r=arguments;return this.replace(/\${([^{}]*)}/g,(function(e,t){return r[t]}))}function t(e){return e.pristine.self.form.querySelectorAll('input[name="'+e.getAttribute("name")+'"]:checked').length}var n={classTo:"form-group",errorClass:"has-danger",successClass:"has-success",errorTextParent:"form-group",errorTextTag:"div",errorTextClass:"text-help"},i=["required","min","max","minlength","maxlength","pattern"],s=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,a={},o=function(r,t){t.name=r,t.msg||(t.msg=e[r]),void 0===t.priority&&(t.priority=1),a[r]=t};function l(e,t,s){var o=this;function l(e,r,t,n){var i=a[t];if(i&&(e.push(i),n)){var s=n.split(",");s.unshift(null),r[t]=s}}function u(e){for(var t,n=[],i=!0,s=0;e.validators[s];s++){var a=e.validators[s],o=e.params[a.name]?e.params[a.name]:[];if(o[0]=e.input.value,!a.fn.apply(e.input,o)){if(i=!1,(t=a.msg)&&t.constructor&&t.call&&t.apply)n.push(a.msg(e.input.value,o));else{var l=e.messages[a.name]||a.msg;n.push(r.apply(l,o))}if(!0===a.halt)break}}return e.errors=n,i}function f(e){if(e.errorElements)return e.errorElements;var r=function(e,r){for(;(e=e.parentElement)&&!e.classList.contains(r););return e}(e.input,o.config.classTo),t=null,n=null;return(t=o.config.classTo===o.config.errorTextParent?r:r.querySelector("."+o.config.errorTextParent))&&((n=t.querySelector(".pristine-error"))||((n=document.createElement(o.config.errorTextTag)).className="pristine-error "+o.config.errorTextClass,t.appendChild(n),n.pristineDisplay=n.style.display)),e.errorElements=[r,n]}function c(e){var r=f(e),t=r[0],n=r[1];t&&(t.classList.remove(o.config.successClass),t.classList.add(o.config.errorClass)),n&&(n.innerHTML=e.errors.join("<br/>"),n.style.display=n.pristineDisplay||"")}function p(e){var r=function(e){var r=f(e),t=r[0],n=r[1];return t&&(t.classList.remove(o.config.errorClass),t.classList.remove(o.config.successClass)),n&&(n.innerHTML="",n.style.display="none"),r}(e)[0];r&&r.classList.add(o.config.successClass)}return function(e,r,t){e.setAttribute("novalidate","true"),o.form=e,o.config=function(e,r){for(var t in r)t in e||(e[t]=r[t]);return e}(r||{},n),o.live=!(!1===t),o.fields=Array.from(e.querySelectorAll("input:not([type^=hidden]):not([type^=submit]), select, textarea")).map(function(e){var r=[],t={},n={};return[].forEach.call(e.attributes,(function(e){if(/^data-pristine-/.test(e.name)){var s=e.name.substr(14);if(s.endsWith("-message"))return void(n[s.slice(0,s.length-8)]=e.value);"type"===s&&(s=e.value),l(r,t,s,e.value)}else~i.indexOf(e.name)?l(r,t,e.name,e.value):"type"===e.name&&l(r,t,e.value)})),r.sort((function(e,r){return r.priority-e.priority})),o.live&&e.addEventListener(~["radio","checkbox"].indexOf(e.getAttribute("type"))?"change":"input",function(e){o.validate(e.target)}.bind(o)),e.pristine={input:e,validators:r,params:t,messages:n,self:o}}.bind(o))}(e,t,s),o.validate=function(e,r){r=e&&!0===r||!0===e;var t=o.fields;!0!==e&&!1!==e&&(e instanceof HTMLElement?t=[e.pristine]:(e instanceof NodeList||e instanceof(window.$||Array)||e instanceof Array)&&(t=Array.from(e).map((function(e){return e.pristine}))));for(var n=!0,i=0;t[i];i++){var s=t[i];u(s)?!r&&p(s):(n=!1,!r&&c(s))}return n},o.getErrors=function(e){if(!e){for(var r=[],t=0;t<o.fields.length;t++){var n=o.fields[t];n.errors.length&&r.push({input:n.input,errors:n.errors})}return r}return e.tagName&&"select"===e.tagName.toLowerCase()?e.pristine.errors:e.length?e[0].pristine.errors:e.pristine.errors},o.addValidator=function(e,r,t,n,i){e instanceof HTMLElement?(e.pristine.validators.push({fn:r,msg:t,priority:n,halt:i}),e.pristine.validators.sort((function(e,r){return r.priority-e.priority}))):console.warn("The parameter elem must be a dom element")},o.addError=function(e,r){(e=e.length?e[0]:e).pristine.errors.push(r),c(e.pristine)},o.reset=function(){for(var e=0;o.fields[e];e++)o.fields[e].errorElements=null;Array.from(o.form.querySelectorAll(".pristine-error")).map((function(e){e.parentNode.removeChild(e)})),Array.from(o.form.querySelectorAll("."+o.config.classTo)).map((function(e){e.classList.remove(o.config.successClass),e.classList.remove(o.config.errorClass)}))},o.destroy=function(){o.reset(),o.fields.forEach((function(e){delete e.input.pristine})),o.fields=[]},o.setGlobalConfig=function(e){n=e},o}return o("text",{fn:function(e){return!0},priority:0}),o("required",{fn:function(e){return"radio"===this.type||"checkbox"===this.type?t(this):void 0!==e&&""!==e},priority:99,halt:!0}),o("email",{fn:function(e){return!e||s.test(e)}}),o("number",{fn:function(e){return!e||!isNaN(parseFloat(e))},priority:2}),o("integer",{fn:function(e){return!e||/^\d+$/.test(e)}}),o("minlength",{fn:function(e,r){return!e||e.length>=parseInt(r)}}),o("maxlength",{fn:function(e,r){return!e||e.length<=parseInt(r)}}),o("min",{fn:function(e,r){return!e||("checkbox"===this.type?t(this)>=parseInt(r):parseFloat(e)>=parseFloat(r))}}),o("max",{fn:function(e,r){return!e||("checkbox"===this.type?t(this)<=parseInt(r):parseFloat(e)<=parseFloat(r))}}),o("pattern",{fn:function(e,r){var t=r.match(new RegExp("^/(.*?)/([gimy]*)$"));return!e||new RegExp(t[1],t[2]).test(e)}}),l.addValidator=function(e,r,t,n,i){o(e,{fn:r,msg:t,priority:n,halt:i})},l}));