sonarr-repo-only/NzbDrone.Web/Scripts/2011.2.712/telerik.grid.editing.min.js

1 line
26 KiB
JavaScript
Raw Normal View History

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