-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.validate.unobtrusive.extensions.min.js
1 lines (1 loc) · 6.8 KB
/
jquery.validate.unobtrusive.extensions.min.js
1
!function(n){function e(n,e){var a=e[0];a._mvcct_form_expando_||(a._mvcct_form_expando_=!0,t.push(e),1==t.length&&setTimeout(function(){for(;t.length;){var n=t.pop();n[0]._mvcct_form_expando_=!1,r(n),n.removeData("unobtrusiveValidation")}}))}function r(e){var r=e.data("unobtrusiveValidation");if(r){var t=e.validate(),a=e[0].elements;n.each(r.options.rules,function(e,u){if(void 0==t.settings.rules[e]){var l={};n.extend(l,u),l.messages=r.options.messages[e],n(a.namedItem(e)).rules("add",l)}else n.each(u,function(u,l){if(void 0==t.settings.rules[e][u]){var i={};i[u]=l,i.messages=r.options.messages[e][u],n(a.namedItem(e)).rules("add",i)}})})}}var t=[];n.validator.unobtrusive.parseDynamic=function(r){var t=n(r).first().closest("form");(t.length||n(r).find("form").length)&&(n.validator.unobtrusive.parse(r),t.length&&e(r,t))},n.validator.unobtrusive.parseElementDynamic=function(r){var t=n(r).first().closest("form");0!=t.length&&(n.validator.unobtrusive.parseElement(r,!0),e(r,t))};var a=window.mvcct||{},u=a.enhancer;u&&u.register(function(e,r){r?(n.validator.unobtrusive.parse(document),n("form").removeData("unobtrusiveValidation")):n.validator.unobtrusive.parseDynamic(e)},!0,null,"unobtrusive validation",void 0,"unobtrusive-validation")}(jQuery),function(n){function e(n){return parseInt(n.attr("data-val-correcttype-type"))+(n.attr("data-is-range")||"range"==n.attr("type")?10:0)}function r(e,t){var a=e.name,u=null,l=a.lastIndexOf(".");if(0>l?u=t:r=a.substring(0,l+1)+t,!r)return null;var i=n("[name='"+u+"']");return i.length>0?i[0]:null}function t(n,e){if(!e)return[];e=e.split(" ");for(var t=[],a=0;a<e.length;a++)t.push(r(n,e[a]));return t}function a(n){var e=n.split("-W"),r=parseInt(e[0]),t=parseInt(e[1]),a=new Date(r,0,1+7*(t-1)),u=a.getDay(),l=a;return 4>=u?l.setDate(a.getDate()-a.getDay()+1):l.setDate(a.getDate()+8-a.getDay()),l}function u(n){if(!x){var e=m.Globalize();s||(s=o.enhancer.getSupport().Html5InputSupport);var r=e.locale().attributes.language,t=e.cldr.get("main/"+r).numbers["symbols-numberSystem-latn"];f=s.number>2?new RegExp("^[+-.0-9]*$"):new RegExp("^[\\"+t.plusSign+"\\"+t.minusSign+"\\"+t.decimal+"0-9]*$"),c=s.range>2?new RegExp("^[+-.0-9]*$"):new RegExp("^[\\"+t.plusSign+"\\"+t.minusSign+"\\"+t.decimal+"0-9]*$"),v=e.dateParser({raw:"HH:mm:ss"}),d=e.dateParser({raw:"yyyy-MM-ddTHH:mm:ss"}),p=e.dateParser({raw:"yyyy-MM"}),g=s.week>2?function(n){return n}:a,h=s.week>2?function(n){return n}:function(n){return m.parse("week",n)},weekFormatter=s.week>2?function(n){return n}:function(n){return m.format("week",n)},w=function(n,e){return n?e?n+parseFloat(e):n:null},y=function(n,e){return n?e?new Date(n.getTime()+parseInt(e)):n:null};var u=document.createElement("INPUT");u.setAttribute("type","week"),b=s.week>2?function(n,e){if(!n)return null;if(!e)return n;var r=parseInt(e)/6048e5;return 0==r?n:(u.value=n,r>0?u.stepUp(r):u.stepDown(-r),u.value)}:y,E[0]=function(n){return n},k[0]=E[0],_[0]=function(n){return n},I[0]=E[0],E[1]=E[2]=E[3]=function(n){return m.parse("number",n)},k[1]=k[2]=k[3]=D,_[1]=_[2]=_[3]=w,I[1]=I[2]=I[3]=function(n){return m.format("number",n)},E[11]=E[12]=E[13]=function(n){return m.parse("range",n)},k[11]=k[12]=k[13]=D,_[11]=_[12]=_[13]=w,I[11]=I[12]=I[13]=function(n){return m.format("range",n)},E[4]=function(n){return m.parse("time",n)},k[4]=v,I[4]=function(n){return m.format("time",n)},E[5]=function(n){return m.parse("date",n)},k[5]=d,I[5]=function(n){return m.format("date",n)},E[6]=function(n){return m.parse("datetime",n)},k[6]=d,_[4]=_[5]=_[6]=y,I[6]=function(n){return m.format("datetime",n)},E[7]=h,k[7]=g,_[7]=b,I[7]=weekFormatter,E[8]=function(n){return m.parse("month",n)},k[8]=p,_[8]=y,I[8]=function(n){return m.format("month",n)},x=!0}}function l(n,e,r){n.rules[e]=r,n.message&&(n.messages[e]=n.message)}function i(e,r,t){if(r)for(var a=0;a<r.length;a++)m.dependency("main",r[a],e,t?["blur"]:["blur","keyup"],function(e,r){n(e).closest("form").validate().element(e)})}var o=window.mvcct=window.mvcct||{},s=null,m=o.enhancer;s=m?null:Html5InputSupport={number:4,range:4,date:4,month:4,week:4,time:4,datetime:4,email:4,search:4,tel:4,url:4,color:4};var f=null,c=null;n.validator.attributeRules=function(){},n.validator.globalization={};var v,d,p,g,h,y,b,w,x=!1,D=parseFloat,E=[null,null,null,null,null,null,null,null,null,null,null,null,null,null],k=[null,null,null,null,null,null,null,null,null,null,null,null,null,null],_=[null,null,null,null,null,null,null,null,null,null,null,null,null,null],I=[null,null,null,null,null,null,null,null,null,null,null,null,null,null],M=n.validator;n.validator.methods.minE=function(r,t,a){m||u();var l=e(n(t));if(!r)return!0;var i=E[l],o=a[1];if(o&&n(t).is(":focus"))return!0;var s=k[l];if(o){var f=i(r),c=s(a[0]);return c>f&&n(t).val(I[l](c)),!0}return i(r)>=s(a[0])},n.validator.methods.maxE=function(r,t,a){m||u();var l=e(n(t));if(!r)return!0;var i=E[l],o=a[1];if(o&&n(t).is(":focus"))return!0;var s=k[l];if(o){var f=i(r),c=s(a[0]);return f>c&&n(t).val(I[l](c)),!0}return i(r)<=s(a[0])},n.validator.methods.rangeE=function(r,t,a){m||u();var l=e(n(t));if(!r)return!0;var i=E[l],o=a[2];if(o&&n(t).is(":focus"))return!0;var s=k[l];if(o){var f=i(r),c=s(a[0]);return c>f?n(t).val(I[l](c)):(c=s(a[1]),f>c&&n(t).val(I[l](c))),!0}return i(r)<=s(a[1])&&i(r)>=s(a[0])},n.validator.methods.correcttype=function(r,t,a){if(m||u(),!r)return!0;var l=e(n(t)),i=E[l],o=i(r);return(o||0===o)&&(!("number"==typeof o)||(10>l?f.test(r):c.test(r)))&&(1!=l&&2!=l&&11!=l&&12!=l||o%1===0)&&(1!=l&&11!=l||o>=0)},n.validator.methods.drange=function(r,t,a){if(m||u(),!r)return!0;var l=e(n(t)),i=a[0],o=a[1],s=a[2],f=a[3],c=a[4];if(c&&n(t).is(":focus"))return!0;for(var v,d,p,g,h,y=E[l],b=_[l],w=y(r),x=0;x<i.length;x++){var D=i[x].value;if(D&&(D=y(D),D&&(D=b(D,o[x]),!c||v>=D||(v=D),D>w))){if(!c)return!1;p=!0,h=!0}}for(var x=0;x<s.length;x++){var D=s[x].value;if(D&&(D=y(D),D&&(D=b(D,f[x]),!c||D>=d||(d=D),w>D))){if(!c)return!1;p=!0,g=!0}}if(c&&p){if(v>d)return!1;g?n(t).val(I[l](d)):h&&n(t).val(I[l](v))}return!0};var S=M.unobtrusive.adapters,R=0;for(R=0;R<S.length&&"range"!=S[R].name;R++);delete S[R],S.addMinMax=function(n,e,r,t,a,u){return this.add(n,[a||"min",u||"max","go"],function(n){var a=n.params.min,u=n.params.max,i="true"==n.params.go;!a&&0!==a||!u&&0!==u?a||0===a?l(n,e,[a,i]):(u||0===u)&&l(n,r,[u,i]):l(n,t,[a,u,i])})},S.addCorrecttype=function(n,e,r){return this.add(n,[r||"type"],function(n){var r=n.params.type;l(n,e,r)})},S.addCorrecttype("correcttype","correcttype"),S.addMinMax("range","minE","maxE","rangeE"),m&&(S.addDRange=function(n,e,r,a,u,o){return this.add(n,[r,a,u,o,"go"],function(n){var s=n.element,m=t(s,n.params[r]),f=t(s,n.params[u]);i(s,m,n.params.go),i(s,f,n.params.go);var c=n.params[a].split(" "),v=n.params[o].split(" "),d="true"==n.params.go;l(n,e,[m,c,f,v,d])})},S.addDRange("drange","drange","dmins","dminds","dmaxs","dmaxds"),m.register(null,!1,u,"html5 globalized fallback",void 0,"unobtrusive-validation"))}(jQuery);