You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
9.7 KiB
1 line
9.7 KiB
14 years ago
|
(function(h){var l=h.telerik;h.validator.addMethod("regex",function(o,q,p){if(this.optional(q)){return true}var r=new RegExp(p).exec(o);return r&&r.index==0&&r[0].length==o.length});h.validator.addMethod("number",function(o,r){var p=l.cultureInfo.numericgroupsize;var q=new l.stringBuilder();q.cat("^-?(?:\\d+|\\d{1,").cat(p).cat("}(?:").cat(l.cultureInfo.numericgroupseparator).cat("\\d{").cat(p).cat("})+)(?:\\").cat(l.cultureInfo.numericdecimalseparator).cat("\\d+)?$");return this.optional(r)||new RegExp(q.string()).test(o)});function b(p,o,q){p.range=[o,q]}function j(o,p){o.regex=p}function c(o){o.required=true}function m(o,p){o.maxlength=p}function e(o,p,q){o[p]=q}function g(r){var o={};for(var q=0;q<r.length;q++){var p=r[q];o[p.FieldName]="#"+p.ValidationMessageId}return o}function d(o){var w={};for(var p=0;p<o.length;p++){var u=o[p];var v={};w[u.FieldName]=v;var s=u.ValidationRules;for(var q=0;q<s.length;q++){var r=s[q];if(r.ErrorMessage){var t=r.ValidationType;switch(r.ValidationType){case"regularExpression":t="regex";break;case"stringLength":t="maxlength";break}v[t]=r.ErrorMessage}}}return w}function k(s){var o=s.ValidationRules;var r={};for(var p=0;p<o.length;p++){var q=o[p];switch(q.ValidationType){case"range":b(r,q.ValidationParameters.minimum,q.ValidationParameters.maximum);break;case"regularExpression":j(r,q.ValidationParameters.pattern);break;case"required":c(r);break;case"stringLength":m(r,q.ValidationParameters.maximumLength);break;default:e(r,q.ValidationType,q.ValidationParameters);break}}return r}function n(s){var p={};for(var o=0;o<s.length;o++){var r=s[o];var q=r.FieldName;p[q]=k(r)}return p}function i(r){var p=h("#"+r.FormId);var o=r.Fields;var q=n(o);var t=g(o);var s=d(o);var u={errorClass:"input-validation-error",errorElement:"span",errorPlacement:function(v,w){var x=t[w.attr("name")];h(x).empty().removeClass("field-validation-valid").addClass("field-validation-error");v.removeClass("input-validation-error").attr("_for_validation_message",x).appendTo(x)},messages:s,rules:q,success:function(w){var v=h(w.attr("_for_validation_message"));h(v).empty().addClass("field-validation-valid").removeClass("field-validation-error")}};p.validate(u)}function a(u,t){for(var o=0,s=u.length;o<s;o++){if(u[o].commands){var p=u[o].commands;for(var q=0,r=p.length;q<r;q++){if(p[q].name==t){return p[q]}}}}return{}}l.editing={};l.editing.initialize=function(p){h.extend(p,this.implementation);var o=h(p.element);if(p.isAjax()){o.delegate(".t-grid-edit","click",l.stopAll(function(q){p.editRow(h(this).closest("tr"))})).delegate(".t-grid-cancel","click",l.stopAll(function(q){p.cancel()})).delegate(".t-grid-delete","click",l.stopAll(function(q){p.deleteRow(h(this).closest("tr"))})).delegate(".t-grid-update","click",l.stopAll(function(q){p.save(this,h.proxy(function(){p.updateRow(h(this).closest("form").closest("tr"))},this))})).delegate(".t-grid-add","click",l.stopAll(function(q){p.addRow()})).delegate(".t-grid-insert","click",l.stopAll(function(q){p.save(this,h.proxy(function(){p.insertRow(h(this).closest("form").closest("tr"))},this))}))}else{o.delegate(".t-grid-delete","click",l.stop(function(q){if(p.editing.confirmDelete!==false&&!confirm(p.localization.deleteConfirmation)){q.preventDefault()}}));p.validation()}o.delegate(":input:not(.t-button)","keydown",l.stop(function(r){var q={13:".t-grid-update, .t-grid-insert",27:".t-grid-cancel"};h(this).closest("tr").find(q[r.keyCode]).click()}))};function f(q){var o=h("#"+q.element.id+"PopUp");if(!o.length){o=h("<div />",{id:q.element.id+"PopUp"}).appendTo(q.element).css({top:0,left:"50%",marginLeft:-90}).tWindow(q.settings).delegate(".t-grid-cancel","click",l.stopAll(function(){o.data("tWindow").close()}))}h.each(["insert","update"],function(r,s){if(q[s]){o.undelegate(".t-grid-"+s,"click").delegate(".t-grid-"+s,"click",l.stopAll(function(t){q[s](t.target,o)}))}});o.find("> .t-content").empty().append(q.content);var p=o.data("tWindow");p.title(q.title);p.open();return o}l.editing.implementation={insertRow:function(o){var p=this.extractValues(o);if(l.trigger(this.element,"save",{mode:
|