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

1 line
23 KiB
JavaScript

(function(h){var c=h.telerik,j=/^\/Date\((.*?)\)\/$/;var g=function(l){this.formId=l;this._isBuild=false;var n="tUnobtrusiveValidation";var m="tUnobtrusiveContainer";var k=this.unobtrusive={adapters:[],parseElement:function(o,r){var p=h(o),q=p.parents("form")[0],t,s,u;if(!q){return}t=k.validationInfo(q);t.options.rules[o.name]=s={};t.options.messages[o.name]=u={};h.each(this.adapters,function(){var v="data-val-"+this.name,w=p.attr(v),x={};if(w!==undefined){v+="-";h.each(this.params,function(){x[this]=p.attr(v+this)});this.adapt({element:o,form:q,message:w,params:x,rules:s,messages:u})}});if(!r){t.attachValidation()}},parse:function(o){h(o).find(":input[data-val=true]").each(function(){k.parseElement(this,true)});h("form").each(function(){var p=k.validationInfo(this);if(p){p.attachValidation()}})},onError:function(o,r){var q=h(this).find("[data-valmsg-for='"+r[0].name+"']"),p=h.parseJSON(q.attr("data-valmsg-replace"))!==false;q.removeClass("field-validation-valid").addClass("field-validation-error");o.data(m,q);if(p){q.empty();o.removeClass("input-validation-error").appendTo(q)}else{o.hide()}},onErrors:function(o,r){var q=h(this).find("[data-valmsg-summary=true]"),p=q.find("ul");if(p&&p.length&&r.errorList.length){p.empty();q.addClass("validation-summary-errors").removeClass("validation-summary-valid");h.each(r.errorList,function(){h("<li />").html(this.message).appendTo(p)})}},onSuccess:function(o){var q=o.data(m),p=h.parseJSON(q.attr("data-valmsg-replace"));if(q){q.addClass("field-valiion-valid").removeClass("field-validation-error");o.removeData(m);if(p){q.empty()}}},validationInfo:function(o){var q=h(o),p=q.data(n);if(!p){p={options:{errorClass:"input-validation-error",errorElement:"span",errorPlacement:h.proxy(k.onError,o),invalidHandler:h.proxy(k.onErrors,o),messages:{},rules:{},success:h.proxy(k.onSuccess,o)},attachValidation:function(){q.validate(this.options)},validate:function(){q.validate();return q.valid()}};q.data(n,p)}return p}}};g.prototype={build:function(){if(this._isBuild){return}this._isBuild=true;var o=[];function m(r,q,p){r.rules[q]=p;if(r.message){r.messages[q]=r.message}}function n(p){return p.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function l(p){return p.substr(0,p.lastIndexOf(".")+1)}function k(q,p){if(q.indexOf("*.")===0){q=q.replace("*.",p)}return q}o=this.unobtrusive.adapters;o.add=function(r,q,p){if(!p){p=q;q=[]}this.push({name:r,params:q,adapt:p});return this};o.addBool=function(q,p){return this.add(q,function(r){m(r,p||q,true)})};o.addMinMax=function(s,q,u,p,r,t){return this.add(s,[r||"min",t||"max"],function(x){var v=x.params.min,w=x.params.max;if(v&&w){m(x,p,[v,w])}else{if(v){m(x,q,v)}else{if(w){m(x,u,w)}}}})};o.addSingleVal=function(q,r,p){return this.add(q,[r||"val"],function(s){m(s,p||q,s.params[r])})};o.addSingleVal("accept","exts").addSingleVal("regex","pattern");o.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");o.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");o.add("equalto",["other"],function(q){var p=h(q.form).find(":input[name="+q.params.other+"]")[0];m(q,"equalTo",p)});o.add("required",function(p){if(p.element.tagName.toUpperCase()!=="INPUT"||p.element.type.toUpperCase()!=="CHECKBOX"){m(p,"required",true)}});o.add("remote",["url","type","additionalfields"],function(r){var p={url:r.params.url,type:r.params.type||"GET",data:{}},q=l(r.element.name);h.each(n(r.params.additionalfields||r.element.name),function(s,u){var t=k(u,q);p.data[t]=function(){return h(r.form).find(":input[name='"+t+"']").val()}});m(r,"remote",p)});if(h.validator.unobtrusive&&h.validator.unobtrusive.adapters){h.extend(o,h.validator.unobtrusive.adapters)}h.validator.addMethod("regex",function(p,r,q){if(this.optional(r)){return true}var s=new RegExp(q).exec(p);return s&&s.index==0&&s[0].length==p.length});h.validator.addMethod("number",function(p,s){var q=c.cultureInfo.numericgroupsize;var r=new c.stringBuilder();r.cat("^-?(?:\\d+|\\d{1,").cat(q).cat("}(?:").cat(c.cultureInfo.numericgroupseparator).cat("\\d{").cat(q).cat("})+)(?:\\").cat(c.cultureInfo.numericdecimalseparator).cat("\\d+)?$");return this.optional(s)||new RegExp(r.string()).test(p)})},parse:function(){this.build();this.unobtrusive.parse(this.formId)}};var f=function(k){this.validationMetaData=k};f.prototype={build:function(o){h.validator.addMethod("regex",function(A,C,B){if(this.optional(C)){return true}var D=new RegExp(B).exec(A);return D&&D.index==0&&D[0].length==A.length});h.validator.addMethod("number",function(A,D){var B=c.cultureInfo.numericgroupsize;var C=new c.stringBuilder();C.cat("^-?(?:\\d+|\\d{1,").cat(B).cat("}(?:").cat(c.cultureInfo.numericgroupseparator).cat("\\d{").cat(B).cat("})+)(?:\\").cat(c.cultureInfo.numericdecimalseparator).cat("\\d+)?$");return this.optional(D)||new RegExp(C.string()).test(A)});function t(B,A,C){B.range=[A,C]}function p(A,B){A.regex=B}function z(A){A.required=true}function v(A,B){A.maxlength=B}function m(A,B,C){A[B]=C}function x(D){var A={};for(var C=0;C<D.length;C++){var B=D[C];A[B.FieldName]="#"+B.ValidationMessageId}return A}function n(A){var I={};for(var B=0;B<A.length;B++){var G=A[B];var H={};I[G.FieldName]=H;var E=G.ValidationRules;for(var C=0;C<E.length;C++){var D=E[C];if(D.ErrorMessage){var F=D.ValidationType;switch(D.ValidationType){case"regularExpression":F="regex";break;case"stringLength":F="maxlength";break}H[F]=D.ErrorMessage}}}return I}function y(F){var D=F.ValidationRules;var E={};for(var A=0;A<D.length;A++){var C=D[A];switch(C.ValidationType){case"range":var B=(typeof(C.ValidationParameters.minimum)=="undefined")?C.ValidationParameters.min:C.ValidationParameters.minimum;var G=(typeof(C.ValidationParameters.maximum)=="undefined")?C.ValidationParameters.max:C.ValidationParameters.maximum;t(E,B,G);break;case"regularExpression":case"regex":p(E,C.ValidationParameters.pattern);break;case"required":z(E);break;case"stringLength":v(E,C.ValidationParameters.maximumLength);break;case"length":v(E,C.ValidationParameters.max);break;default:m(E,C.ValidationType,C.ValidationParameters);break}}return E}function w(E){var B={};for(var A=0;A<E.length;A++){var D=E[A];var C=D.FieldName;B[C]=y(D)}return B}var k=h("#"+o.FormId);var s=o.Fields;var l=w(s);var r=x(s);var u=n(s);var q={errorClass:"input-validation-error",errorElement:"span",errorPlacement:function(A,B){var C=r[B.attr("name")];if(C){h(C).empty().removeClass("field-validation-valid").addClass("field-validation-error");A.removeClass("input-validation-error").attr("_for_validation_message",C).appendTo(C)}},messages:u,rules:l,success:function(A){h(A.attr("_for_validation_message")).empty().addClass("field-validation-valid").removeClass("field-validation-error")}};k.validate(q)},parse:function(){this.build(this.validationMetaData)}};c.editing={};function b(){h(document.body).find("div.t-grid").each(function(){var k=h(this).data("tGrid");if(k&&k.cancel){k.cancel()}})}function a(l,k,m){for(var n in k){if(h.isPlainObject(k[n])){a(l,k,m?prefx+"."+n:n)}else{l[m?m+"."+n:n]=k[n]}}}function i(k){for(var o in k){var n=o.indexOf(".");if(n>-1){var m=o.substring(0,n);var l=k[m]||{};l[o.substring(n+1)]=k[o];k[m]=i(l);delete k[o]}}return k}function d(l){var m,k,n;for(m in l){k=l[m];if(typeof k==="string"){n=j.exec(k);if(n){l[m]=new Date(parseInt(n[1]))}}else{if(h.isPlainObject(k)){d(k)}}}}c.editing.initialize=function(l){h.extend(l,this.implementation);var k=h(l.element);l.modelBinder=new c.grid.ModelBinder();l.formViewBinder=new c.grid.FormViewBinder({date:function(u,r){var t=l.columnFromMember(u);var s=t?t.format:"";return c.formatString(s||"{0:G}",r)}});if(l.isAjax()){if(l.editing.mode=="InCell"){d(l.editing.defaultDataItem||{});l.changeLog=new c.grid.ChangeLog(l.pageSize||(l.data&&l.data.length)||0);h(l.element).bind("dataBound",function(){l.changeLog.clear()});l.cellEditor=new c.grid.CellEditor({columns:l.columns,cellIndex:function(r){return r.index()},id:l.formId(),bind:h.proxy(l.formViewBinder.bind,l.formViewBinder),validate:h.proxy(l.validation,l)});k.delegate(".t-grid-save-changes:not(.t-state-disabled)","click",c.stopAll(function(r){l.submitChanges()}));k.delegate(".t-grid-cancel-changes","click",c.stopAll(function(r){l.cancelChanges()}));l.hasChanges=function(){return l.changeLog.dirty()};l.submitChanges=function(){if(l.changeLog.dirty()){var r=l.changeLog.inserted;var t=h.grep(l.changeLog.updated,function(v){return v!=undefined});var s=h.grep(l.changeLog.deleted,function(v){return v!=undefined});if(c.trigger(l.element,"submitChanges",{inserted:r,updated:t,deleted:s})){return}var u=l.ws?{inserted:h.map(r,function(v){return l._convert(v)}),updated:h.map(t,function(v){return l._convert(v)}),deleted:h.map(s,function(v){return l._convert(v)})}:l.changeLog.serialize(r,t,s);l.sendValues(u,"updateUrl")}};l.cancelChanges=function(){l.changeLog.clear();l.dataBind(l.data.slice(0));l.valid=true};l.cellIndex=function(r){return h(r).parent().find("td:not(.t-group-cell,.t-hierarchy-cell)").index(r)};l.rowIndex=function(r){return h(r).parent().find("tr:not(.t-detail-row,.t-grouping-row)").index(r)};var o;l.valid=true;l.editCell=function(u){var r=l.columns[l.cellIndex(u)];if(l.valid&&(r&&!r.readonly)){l.td=u;u=h(u);var t=u.parent();var v=l.rowIndex(t);var s=l.changeLog.get(v)||l.dataItem(t);o=u.find(".t-dirty");l.cellEditor.edit(u,s);c.trigger(l.element,"edit",{mode:t.hasClass("t-grid-new-row")?"insert":"edit",form:l.form()[0],dataItem:s,cell:u[0]})}};l.saveCell=function(u){l.valid=l.validate();if(l.valid){u=h(u);var t=u.parent();var s=l.dataItem(t);var v=i(l.modelBinder.bind(u));var r=false;if(c.trigger(l.element,"save",{mode:t.hasClass("t-grid-new-row")?"insert":"edit",dataItem:s,values:v,form:l.form()[0],cell:u[0]})){return}if(t.hasClass("t-grid-new-row")){l.changeLog.insert(l.rowIndex(t),v)}else{r=l.changeLog.update(l.rowIndex(t),s,v)}l.cellEditor.display(u,v);if(r||t.hasClass("t-grid-new-row")){o=h('<span class="t-dirty" />')}if(o&&o.length){o.prependTo(l.td)}l.td=null}};l.td=null;l.$tbody.delegate("td:not(.t-grid-edit-cell)",l.editing.beginEdit||"click",function(r){l.editCell(this)});h(document).mousedown(function(r){if(l.td&&!h.contains(l.td,r.target)&&l.td!=r.target&&!h(r.target).closest(".t-animation-container").length){l.saveCell(l.td)}})}else{if(l.editing.beginEdit){l.$tbody.delegate("tr:not(.t-detail-row,.t-grouping-row,.t-grid-edit-row,.t-group-footer)",l.editing.beginEdit,function(r){if(!h(r.target).is(":button,a,:input,a>.t-icon")){l.editRow(h(this))}})}}k.delegate(".t-grid-edit","click",c.stopAll(function(r){l.editRow(h(this).closest("tr"))})).delegate(".t-grid-delete","click",c.stopAll(function(r){l.deleteRow(h(this).closest("tr"))})).delegate(".t-grid-add","click",c.stopAll(function(r){l.addRow()}))}else{k.delegate(".t-grid-delete","click",c.stop(function(r){if(l.editing.confirmDelete!==false&&!confirm(l.localization.deleteConfirmation)){r.preventDefault()}}));l.validation()}l.errorView=new c.grid.ErrorView();var q=new c.grid.DataCellBuilder({columns:l.columns});var m=h.grep(l.columns,function(r){return r.commands&&h.grep(r.commands,function(s){return s.name=="edit"})[0]})[0];var n=new c.grid.FormContainerBuilder({html:function(){return unescape(l.editing.editor)},insert:function(){return m.insert()},edit:function(){return m.edit()}});var p=l.editing.mode;if(p=="InLine"){l.rowEditor=new c.grid.Editor({id:l.formId(),cancel:q.display,edit:q.edit,insert:q.insert,groups:(l.groups||[]).length,details:l.detail})}else{if(p=="InForm"){l.rowEditor=new c.grid.Editor({id:l.formId(),cancel:q.display,groups:(l.groups||[]).length,details:l.detail,edit:function(){return'<td colspan="'+l.columns.length+'">'+n.edit()+"</td>"},insert:function(){return'<td colspan="'+l.columns.length+'">'+n.insert()+"</td>"}})}else{if(p=="PopUp"){l.rowEditor=new c.grid.PopUpEditor({id:l.formId(),edit:n.edit,container:l.element,settings:l.editing.popup,insert:n.insert,editTitle:l.localization.edit,insertTitle:l.localization.insert})}else{q=new c.grid.CellBuilder({columns:l.columns});l.rowEditor=new c.grid.Editor({id:l.formId(),cancel:q.display,edit:q.edit,insert:q.insert})}}}k.delegate(":input:not(.t-button):not(textarea)","keydown",function(s){if(s.keyCode==13||s.keyCode==27){s.preventDefault();var r={13:".t-grid-update, .t-grid-insert",27:".t-grid-cancel"};h(this).closest("tr").find(r[s.keyCode]).click()}})};c.editing.implementation={editFor:function(l){var m=this.localization;if(l.commands){var o=h.grep(l.commands,function(q){return q.name=="edit"})[0];if(o){var p=c.grid.ButtonBuilder.create(h.extend({text:m.update},o,{name:"update"}));var n=c.grid.ButtonBuilder.create(h.extend({text:m.cancel},o,{name:"cancel"}));var k=p.build()+n.build();return function(){return k}}else{return function(){return""}}}else{if(!l.readonly&&l.editor){return function(){return unescape(l.editor)}}}return this.displayFor(l)},insertFor:function(l){var m=this.localization;if(l.commands){var o=h.grep(l.commands,function(q){return q.name=="edit"})[0];if(o){var p=c.grid.ButtonBuilder.create(h.extend({text:m.insert},o,{name:"insert"}));var n=c.grid.ButtonBuilder.create(h.extend({text:m.cancel},o,{name:"cancel"}));var k=p.build()+n.build();return function(){return k}}else{return function(){return""}}}else{return this.editFor(l)}},insertRow:function(k){if(this.validate()){var l=this.extractValues(k);if(c.trigger(this.element,"save",{mode:"insert",values:l,form:this.form()[0]})){return}this.sendValues(l,"insertUrl")}},updateRow:function(k){if(this.validate()){var l=this.dataItem(k.data("tr")||k);var m=this.extractValues(k);if(c.trigger(this.element,"save",{mode:"edit",dataItem:l,values:m,form:this.form()[0]})){return}this.sendValues(h.extend(l,m),"updateUrl")}},deleteRow:function(k){var l=this.dataItem(k);if(this.editing.mode!="InCell"){if(c.trigger(this.element,"delete",{dataItem:l})){return}if(this.editing.confirmDelete===false||confirm(this.localization.deleteConfirmation)){this.sendValues(l,"deleteUrl")}}else{if(this.editing.confirmDelete===false||confirm(this.localization.deleteConfirmation)){this.changeLog.erase(this.rowIndex(k),l);this.cancelRow(k);k.hide()}}},editRow:function(k){var m=this.dataItem(k);if(this.editing.mode!="InCell"){b();var n=this.rowEditor.edit(k,m);var l=this.form();l.undelegate(".t-grid-update").delegate(".t-grid-update","click",c.stopAll(h.proxy(function(){this.updateRow(n)},this))).undelegate(".t-grid-cancel").delegate(".t-grid-cancel","click",c.stopAll(h.proxy(function(){this.cancelRow(k)},this)));this.formViewBinder.bind(n,m);c.trigger(this.element,"edit",{mode:"edit",form:l[0],dataItem:m});this.validation()}else{if(this.valid){this.rowEditor.edit(k,m);this.td=row.find(":input:visible:first").focus().closest("td")[0];this.validation()}}},form:function(){return h("#"+this.formId())},addRow:function(){var n=h.extend(true,{},this.editing.defaultDataItem);if(this.editing.mode!="InCell"){b();var p=this.rowEditor.insert(this.$tbody,n);var l=this.form();l.undelegate(".t-grid-insert").delegate(".t-grid-insert","click",c.stopAll(h.proxy(function(){this.insertRow(p)},this))).undelegate(".t-grid-cancel").delegate(".t-grid-cancel","click",c.stopAll(h.proxy(function(){this.cancelRow(p)},this)));c.trigger(this.element,"edit",{mode:"insert",form:l[0]});this.validation()}else{if(this.valid){var m=this.rowEditor.insert(this.$tbody,n);this.changeLog.insert(n);this.td=m.find(":input:enabled:visible:first").focus().closest("td")[0];for(var k=this.columns.length-1;k>=0;k--){if(!this.columns[k].readonly){var o=m.children().eq(k);if(o[0]!=this.td){o.prepend('<span class="t-dirty" />')}}}this.validation()}}},extractValues:function(k){return this.modelBinder.bind(k)},cancelRow:function(k){if(!k.length){return}var l=this.dataItem(k);this.rowEditor.cancel(k,l);c.trigger(this.element,"rowDataBound",{row:k[0],dataItem:l})},validate:function(){var k=this.form();if(k.length){return k.validate().form()}return true},cancel:function(){this.cancelRow(this.$tbody.find(">.t-grid-edit-row"))},_convert:function(o){for(var l in o){var k=o[l];if(k instanceof Date){var n=this.columnFromMember(l);var m="{0:G}";if(n&&n.format){m=n.format}o[l]=this.ws?"\\/Date("+k.getTime()+")\\/":c.formatString(m,k)}if(k==undefined){delete o[l]}}return o},sendValues:function(n,k){if(this.editing.mode!="InCell"||!this.ws){this._convert(n);for(var l in this.dataKeys){var m=this.valueFor({member:l})(n);if(m!=undefined){n[this.ws?l:this.dataKeys[l]]=m}}}h.ajax(this.ajaxOptions({data:this.ws?(this.editing.mode=="InCell"?n:{value:n}):n,url:this.url(k),hasErrors:h.proxy(this.hasErrors,this),displayErrors:h.proxy(this.displayErrors,this)}))},displayErrors:function(k){this.errorView.bind(h("#"+this.formId()),k.modelState)},hasErrors:function(k){var l=k.modelState;var m=false;if(l){h.each(l,function(n,o){if("errors" in o){m=true;return false}})}return m},formId:function(){return h(this.element).attr("id")+"form"},validation:function(){this.validator().parse()},validator:function(){if(this.validationMetadata){return new f(this.validationMetadata)}else{return new g(h("#"+this.formId()))}}};c.grid.ModelBinder=function(){this.binders={":input:not(.t-input):not(:radio),:radio:checked":function(){return h(this).val()},":checkbox":function(){return h(this).is(":checked")},".t-datepicker :input":function(){return h(this).data("tDatePicker").value()},".t-numerictextbox :input":function(){return h(this).data("tTextBox").value()},".t-editor textarea:hidden":function(){var k=h(this).closest(".t-editor").data("tEditor");if(k.encoded){return k.encodedValue()}return k.value()}};this.bind=function(k){var l={};h.each(this.binders,function(m,n){k.find(m).each(function(){if(!this.disabled){l[this.name]=n.call(this)}})});return l}};c.grid.FormViewBinder=function(m){this.converters=m||{};this.binders={":input:not(:radio)":function(n){h(this).val(n)},":checkbox":function(n){h(this).attr("checked",n==true)},":radio":function(o){var n=h(this).val();if(typeof o=="boolean"){n=n.toLowerCase()}if(n==o.toString()){h(this).attr("checked",true)}}};function l(n){return function(o){h(this).data(n).value(o)}}function k(){return function(n){h(this).closest(".t-editor").data("tEditor").value(n)}}this.binders[".t-numerictextbox :input"]=l("tTextBox");this.binders[".t-dropdown :input:hidden"]=l("tDropDownList");this.binders[".t-combobox :input:hidden"]=l("tComboBox");this.binders[".t-editor textarea:hidden"]=k();this.evaluate=function(o,r){if(r!=null){var n=o,p=false,t=r.split(".");while(t.length){var u=t.shift();if(n!=null&&typeof(n[u])!="undefined"){n=n[u];p=true}else{if(p){p=false;break}}}if(p&&!h.isPlainObject(n)){var q=j.exec(n);if(q){n=new Date(parseInt(q[1]))}var s=c.getType(n);if(s in this.converters){n=this.converters[s](r,n)}return n}}};this.bind=function(p,o){var n;h.each(this.binders,h.proxy(function(q,r){p.find(q).each(h.proxy(function(t,u){var s=this.evaluate(o,u.name);if(s!=n){r.call(u,s)}},this))},this))}};c.grid.CellBuilder=function(k){function l(n,m){return h.map(k.columns,function(p,o){return"<td "+(p.attr?p.attr:"")+(o==k.columns.length-1?' class="t-last">':">")+p[o==0?m:"display"](n)+"</td>"}).join("")}this.edit=function(m){return l(m,"edit")};this.insert=function(m){return l(m,"insert")};this.display=function(m){return l(m,"display")}};c.grid.DataCellBuilder=function(k){function l(n,m){return h.map(k.columns,function(p,o){return"<td "+(p.attr?p.attr:"")+(o==k.columns.length-1?' class="t-last">':">")+p[m](n)+"</td>"}).join("")}this.edit=function(m){return l(m,"edit")};this.insert=function(m){return l(m,"insert")};this.display=function(m){return l(m,"display")}};c.grid.FormContainerBuilder=function(k){function l(m){return'<div class="t-edit-form-container">'+k.html()+k[m]()+"</div>"}this.edit=function(){return l("edit")};this.insert=function(){return l("insert")}};function e(k){return h("<form />",{className:"t-edit-form",id:k}).submit(c.preventDefault)}c.grid.PopUpEditor=function(m){var l;function k(){var o=l.data("tWindow");o&&o.close();l.remove()}function n(p,o){l=h("<div />",{id:m.container.id+"PopUp"}).appendTo(m.container).css({top:0,left:"50%",marginLeft:-90}).tWindow(m.settings).find(".t-window-content").append(m[o](p)).wrapInner(e(m.id)).end();h(m.container).one("dataBound",k);l.find("t-close").bind("close",c.stopAll(k)).end().data("tWindow").open().title(m[o+"Title"]);return l}this.edit=function(o,p){o.addClass("t-grid-edit-row");return n(p,"edit").data("tr",o)};this.insert=function(o,p){return n(p,"insert")};this.cancel=function(o){o.removeClass("t-grid-edit-row");k()}};c.grid.Editor=function(m){var l=(m.groups||0);function k(n,o,p){var q=n.find(".t-group-cell,.t-hierarchy-cell");n.addClass("t-grid-edit-row").empty().append(q).append(m[p](o)).closest("table").wrap(function(){if(!h(this).parent().is("form")){return e(m.id)}})}this.cancel=function(n,o){if(n.is(".t-grid-new-row")){n.remove()}else{k(n,o,"cancel");n.removeClass("t-grid-edit-row")}};this.insert=function(p,o){var q='<tr class="t-grid-new-row">'+new Array(l+1).join('<td class="t-group-cell" />')+((m.details)?'<td class="t-hierarchy-cell"/>':"")+"</tr>";var n=h(q);p.prepend(n);k(n,o,"insert");return n};this.edit=function(n,o){k(n,o,"edit");return n}};c.grid.CellEditor=function(k){this.edit=function(n,m){var l=k.columns[k.cellIndex(n)];if(!l.readonly){n.parent().addClass("t-grid-edit-row").end().empty().html(l.edit(m)).closest("table").wrap(function(){if(!h(this).parent().is("form")){return e(k.id)}});k.bind(n,m);k.validate();n.find(":input:visible:first").trigger("focusin").focus();n.addClass("t-grid-edit-cell")}return !l.readonly};this.display=function(n,m){var l=k.columns[k.cellIndex(n)];n.removeClass("t-grid-edit-cell").empty().html(l.display(m)).parent().removeClass("t-grid-edit-row")}};c.grid.ChangeLog=function(l){this.insert=function(m,o){if(o==undefined){o=m;this.inserted.splice(0,0,o)}else{var n=this.inserted[m];if(n===undefined){this.inserted.splice(0,0,o)}else{h.extend(n,o)}}};this.get=function(n){var m=this.inserted[n];if(this.inserted[n]){return m}return this.updated[n-this.inserted.length]};this.update=function(s,p,o){s=s-this.inserted.length;var t=this.updated[s]||p||{};var r=false;for(var m in o){var q=t[m],n=o[m];if(q instanceof Date){if(n.getTime()!==q.getTime()){r=true}}else{if(n!==q){r=true}}}if(r){this.updated[s]=h.extend({},t,o)}return r};this.erase=function(n,p){var m=this.inserted[n];if(m){this.inserted.splice(n,1)}else{n=n-this.inserted.length;var o=this.updated[n];if(o){delete this.updated[n]}this.deleted[n]=p}};this.clear=function(){this.updated=new Array(l);this.deleted=new Array(l);this.inserted=[]};function k(n,r,t){var u={};for(var s=0,o=0;s<n.length;s++){var q=n[s];if(t(q)){for(var m in q){var p=q[m],v=r+"["+o+"]."+m;if(h.isPlainObject(p)){a(u,p,v)}else{u[v]=p}}o++}}return u}this.serialize=function(m,o,n){return h.extend({},k(m,"inserted",function(){return true}),k(o,"updated",function(p){return p!==undefined}),k(n,"deleted",function(p){return p!==undefined}))};this.dirty=function(){if(this.inserted.length){return true}for(var m=0;m<this.updated.length;m++){if(this.updated[m]){return true}}for(m=0;m<this.deleted.length;m++){if(this.deleted[m]){return true}}return false};this.clear()};c.grid.ErrorView=function(){this.bind=function(k,l){k.find("span[id$=_validationMessage]").removeClass("field-validation-error").addClass("field-validation-valid").html("").end().find(".input-validation-error").removeClass("input-validation-error").addClass("valid");h.each(l,function(o,m){if("errors" in m&&m.errors[0]){var n=o;o=o.replace(".","_");k.find("#"+o+'_validationMessage, [data-valmsg-for="'+n+'"]').html(m.errors[0]).removeClass("field-validation-valid").removeClass("field-valiion-valid").addClass("field-validation-error").end().find("#"+o).removeClass("valid").addClass("input-validation-error")}})}}})(jQuery);