mirror of https://github.com/lidarr/Lidarr
1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
|
(function(e){var g=e.telerik;var d=function(i){this.formId=i;this._isBuild=false;var k="tUnobtrusiveValidation";var j="tUnobtrusiveContainer";var h=this.unobtrusive={adapters:[],parseElement:function(l,o){var m=e(l),n=m.parents("form")[0],q,p,r;if(!n){return}q=h.validationInfo(n);q.options.rules[l.name]=p={};q.options.messages[l.name]=r={};e.each(this.adapters,function(){var s="data-val-"+this.name,t=m.attr(s),u={};if(t!==undefined){s+="-";e.each(this.params,function(){u[this]=m.attr(s+this)});this.adapt({element:l,form:n,message:t,params:u,rules:p,messages:r})}});if(!o){q.attachValidation()}},parse:function(l){e(l).find(":input[data-val=true]").each(function(){h.parseElement(this,true)});e("form").each(function(){var m=h.validationInfo(this);if(m){m.attachValidation()}})},onError:function(l,o){var n=e(this).find("[data-valmsg-for='"+o[0].name+"']"),m=e.parseJSON(n.attr("data-valmsg-replace"))!==false;n.removeClass("field-validation-valid").addClass("field-validation-error");l.data(j,n);if(m){n.empty();l.removeClass("input-validation-error").appendTo(n)}else{l.hide()}},onErrors:function(l,o){var n=e(this).find("[data-valmsg-summary=true]"),m=n.find("ul");if(m&&m.length&&o.errorList.length){m.empty();n.addClass("validation-summary-errors").removeClass("validation-summary-valid");e.each(o.errorList,function(){e("<li />").html(this.message).appendTo(m)})}},onSuccess:function(l){var n=l.data(j),m=e.parseJSON(n.attr("data-valmsg-replace"));if(n){n.addClass("field-valiion-valid").removeClass("field-validation-error");l.removeData(j);if(m){n.empty()}}},validationInfo:function(l){var n=e(l),m=n.data(k);if(!m){m={options:{errorClass:"input-validation-error",errorElement:"span",errorPlacement:e.proxy(h.onError,l),invalidHandler:e.proxy(h.onErrors,l),messages:{},rules:{},success:e.proxy(h.onSuccess,l)},attachValidation:function(){n.validate(this.options)},validate:function(){n.validate();return n.valid()}};n.data(k,m)}return m}}};d.prototype={build:function(){if(this._isBuild){return}this._isBuild=true;var j=[];function h(m,l,k){m.rules[l]=k;if(m.message){m.messages[l]=m.message}}function i(k){return k.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}j=this.unobtrusive.adapters;j.add=function(m,l,k){if(!k){k=l;l=[]}this.push({name:m,params:l,adapt:k});return this};j.addBool=function(l,k){return this.add(l,function(m){h(m,k||l,true)})};j.addMinMax=function(n,l,p,k,m,o){return this.add(n,[m||"min",o||"max"],function(s){var q=s.params.min,r=s.params.max;if(q&&r){h(s,k,[q,r])}else{if(q){h(s,l,q)}else{if(r){h(s,p,r)}}}})};j.addSingleVal=function(l,m,k){return this.add(l,[m||"val"],function(n){h(n,k||l,n.params[m])})};j.addSingleVal("accept","exts").addSingleVal("regex","pattern");j.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");j.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");j.add("equalto",["other"],function(l){var k=e(l.form).find(":input[name="+l.params.other+"]")[0];h(l,"equalTo",k)});j.add("required",function(k){if(k.element.tagName.toUpperCase()!=="INPUT"||k.element.type.toUpperCase()!=="CHECKBOX"){h(k,"required",true)}});j.add("remote",["url","type","fields"],function(k){var l={url:k.params.url,type:k.params.type||"GET",data:{}};e.each(i(k.params.fields||k.element.name),function(m,n){l.data[n]=function(){return e(k.form).find(":input[name='"+n+"']").val()}});h(k,"remote",l)});if(e.validator.unobtrusive&&e.validator.unobtrusive.adapters){e.extend(j,e.validator.unobtrusive.adapters)}e.validator.addMethod("regex",function(k,m,l){if(this.optional(m)){return true}var n=new RegExp(l).exec(k);return n&&n.index==0&&n[0].length==k.length});e.validator.addMethod("number",function(k,n){var l=g.cultureInfo.numericgroupsize;var m=new g.stringBuilder();m.cat("^-?(?:\\d+|\\d{1,").cat(l).cat("}(?:").cat(g.cultureInfo.numericgroupseparator).cat("\\d{").cat(l).cat("})+)(?:\\").cat(g.cultureInfo.numericdecimalseparator).cat("\\d+)?$");return this.optional(n)||new RegExp(m.string()).test(k)})},parse:function(){this.build();this.unobtrusive.parse(
|