Sonarr/packages/TelerikMvcExtensions.2011.2.../content/Scripts/2011.2.712/telerik.grid.min.js

1 line
28 KiB
JavaScript

(function(e){var d={TAB:9,ENTER:13,ESC:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,SPACEBAR:32,PAGEUP:33,PAGEDOWN:34,F12:123};var k=e.telerik;var c=/"+\\\/Date\((.*?)\)\\\/"+/g;var g="tr:not(.t-grouping-row,.t-group-footer,.t-detail-row,.t-no-data,.t-footer-template):visible",f=">td:not(.t-group-cell,.t-hierarchy-cell)",a=g+f+":first";FOCUSED="t-state-focused";k.scripts.push("telerik.grid.js");function h(l){return new Function("data",("var p=[];with(data){p.push('"+unescape(l).replace(/[\r\t\n]/g," ").replace(/'(?=[^#]*#>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<#=(.+?)#>/g,"',$1,'").split("<#").join("');").split("#>").join("p.push('")+"');}return p.join('');"))}function j(l){return(l!=null?l+"":"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}k.grid=function(l,m){this.element=l;this.groups=[];this.editing={};this.filterBy="";this.groupBy="";this.orderBy="";e.extend(this,m);this.sorted=e.grep(this.columns,function(t){return t.order});this.$tbody=e("> .t-grid-content > table > tbody",l);this.scrollable=this.$tbody.length>0;if(!this.scrollable){this.$tbody=e("> table > tbody",l);this.$header=e("> table > thead tr",l);this.$footer=e("> table > tfoot",l)}else{e("> .t-grid-content",l).tScrollable();this.$header=e("> .t-grid-header tr",l);this.$footer=e("> .t-grid-footer",l)}this.$headerWrap=e("> .t-grid-header > .t-grid-header-wrap",l);this.$footerWrap=e("> .t-grid-footer > .t-grid-footer-wrap",l);var r=this.$headerWrap.add(this.$footerWrap);var p=this;e("> .t-grid-content",l).bind("scroll",function(){if(p.pageOnScroll){var t=this.scrollTop+this.clientHeight;if(t===this.scrollHeight&&p.currentPage<p.totalPages()){p.pageTo(p.currentPage+1)}}r.scrollLeft(this.scrollLeft)});if(this.rowTemplate){this.rowTemplate=h(this.rowTemplate)}this.$tbody.delegate(".t-hierarchy-cell .t-plus, .t-hierarchy-cell .t-minus","click",k.stopAll(function(x){var v=e(x.target);var u=v.hasClass("t-plus");v.toggleClass("t-minus",u).toggleClass("t-plus",!u);var t=v.closest("tr.t-master-row");if(this.detail&&!t.next().hasClass("t-detail-row")){var w=0;e.each(this.columns,function(){if(!this.hidden){w++}});e(new k.stringBuilder().cat('<tr class="t-detail-row">').rep('<td class="t-group-cell"></td>',t.find(".t-group-cell").length).cat('<td class="t-hierarchy-cell"></td>').cat('<td class="t-detail-cell" colspan="').cat(w).cat('">').cat(this.displayDetails(this.dataItem(t))).cat("</td></tr>").string()).insertAfter(t)}k.trigger(this.element,u?"detailViewExpand":"detailViewCollapse",{masterRow:t[0],detailRow:t.next(".t-detail-row")[0]});t.next().toggle(u)},this));this.$pager=e("> .t-grid-pager .t-pager",l);var q=new k.dropDown({effects:k.fx.slide.defaults(),onClick:e.proxy(function(t){this.changePageSize(e(t.item).text());q.close()},this)});q.dataBind(m.pageSizesInDropDown||[]);e(document.documentElement).bind("mousedown",function(u){var t=q.$element[0];if(!e.contains(t,u.target)){q.close()}});this.$pager.delegate(".t-state-disabled","click",k.preventDefault).delegate(".t-link:not(.t-state-disabled)","mouseenter",k.hover).delegate(".t-link:not(.t-state-disabled)","mouseleave",k.leave).delegate("input[type=text]","keydown",e.proxy(this.pagerKeyDown,this)).delegate(".t-page-size .t-dropdown-wrap","click",function(){var t=e(this);q.open({offset:t.offset(),outerHeight:t.outerHeight(),outerWidth:t.outerWidth(),zIndex:k.getElementZIndex(this)})});e("> .t-grid-pager",l).delegate(".t-refresh","click",e.proxy(this.refreshClick,this));e(l).delegate(".t-button","hover",k.preventDefault);if(this.sort){this.$header.delegate("a.t-link","hover",function(){e(this).toggleClass("t-state-hover")})}var s="tr:not(.t-grouping-row,.t-detail-row,.t-no-data,:has(>.t-edit-container))";if(this.selectable){var n=this.$tbody[0];this.$tbody.delegate(s,"click",function(t){if(this.parentNode==n){p.rowClick(t)}}).delegate(s,"hover",function(t){if(this.parentNode==n){if(t.type=="mouseenter"){e(this).addClass("t-state-hover")}else{e(this).removeClass("t-state-hover")}}})}if(this.isAjax()||this.operationMode==="client"){this.$pager.delegate(".t-link:not(.t-state-disabled)","click",k.stop(this.pagerClick,this));if(this.sort){this.$header.delegate("a.t-link","click",k.stop(this.headerClick,this))}}for(var o=0;o<this.plugins.length;o++){k[this.plugins[o]].initialize(this)}k.bind(this,{columnResize:this.onColumnResize,columnReorder:this.onColumnReorder,"delete":this.onDelete,detailViewExpand:this.onDetailViewExpand,detailViewCollapse:this.onDetailViewCollapse,dataBinding:this.onDataBinding,dataBound:this.onDataBound,edit:this.onEdit,error:this.onError,load:this.onLoad,rowSelect:this.onRowSelect,rowDataBound:this.onRowDataBound,save:this.onSave,submitChanges:this.onSubmitChanges});this.initializeColumns();if(this.keyboardNavigation){this.initializeNavigation()}if(this.isAjax()||this.operationMode==="client"){this._dataSource()}};k.grid.prototype={initializeNavigation:function(){var l=this,o=e(l.element).attr("tabIndex",0),m="keydown",n=e.proxy(l._keyDown,l);l._initNavigationMouseEvents();o.bind({focus:function(p){var q=l.current();if(q){q.addClass(FOCUSED)}else{if(q=l.$tbody.find("td."+FOCUSED).eq(0),q.length){l._current=q}else{l.current(o.find(a))}}},focusout:function(){if(l._current){l._current.removeClass(FOCUSED)}},keydown:n});if(l.editing&&l.editing.mode=="PopUp"){o.bind("edit",function(p){e(p.form).bind(m,n)});e("#"+l.formId()+":visible").bind(m,n)}if(l.pageOnScroll){o.bind("dataBinding",function(){var r=l.current(),p=r?r.parent().index(g)-1:0,q=r?r.index():0;o.one("dataBound",function(){var s=l.$tbody.find(g);l._focusGridElement();if(l._current){l._current.removeClass(FOCUSED)}l._current=s.eq(p).children().eq(q).addClass(FOCUSED)})})}},_keyDown:function(y){var q=this,m=e(q.element),u=q.$tbody,o=m.closest(".t-rtl").length,x=y.keyCode,p="dataBound",v=e.proxy(q.current,q),B=v(),A=q.$pager.length>0,C=q.selectable,r=u.has("tr>td>.t-grid-select").length>0,z=e(y.target),l=!z.is(":button,a,:input,a>.t-icon"),s=q.editRow,t=false,n;if(!B){if(q.editing&&q.editing.mode=="PopUp"){B=q._current=m.find(a)}else{return}}n=B.index();if(!e.browser.msie){l=l&&z[0]===m[0]}if(l){if(A&&d.PAGEUP==x){if(!q.pageOnScroll){m.one(p,function(){v(m.find(a));q._focusGridElement()})}if(q.currentPage<q.totalPages()){q.pageTo(q.currentPage+1)}t=true}else{if(A&&d.PAGEDOWN==x){if(!q.pageOnScroll){m.one(p,function(){v(m.find(a));q._focusGridElement()});q.pageTo(Math.max(q.currentPage-1,1))}t=true}else{if(d.UP===x){v(B?B.parent().prevAll(g).last().children(":eq("+n+"),:eq(0)").last():m.find(a));t=true}else{if(d.DOWN===x){v(B?B.parent().nextAll(g).first().children(":eq("+n+"),:eq(0)").last():m.find(a));t=true}else{if(d.LEFT===x){if(B){if(o){B=B.next()}else{B=B.prev(":not(.t-group-cell, .t-hierarchy-cell)")}}else{B=m.find(a)}v(B);t=true}else{if(d.RIGHT===x){if(B){if(o){B=B.prev(":not(.t-group-cell, .t-hierarchy-cell)")}else{B=B.next()}}else{B=m.find(a)}v(B);t=true}else{if((C||r)&&d.SPACEBAR==x){t=true;var w=B.parent().find(".t-grid-select:first").andSelf();if(r&&w[1]){location.href=w[1].href}else{if(C){w.click()}}}}}}}}}}if(!t&&s&&!z.is(":button,a,a>.t-icon")){t=q._handleEditing(y)}if(t){y.preventDefault();y.stopPropagation()}},_handleEditing:function(A){var p=this,y=A.keyCode,w=e.proxy(p.current,p),B=e.proxy(p._clearInputSelection,p),v=e.proxy(p._focusGridElement,p),D=w(),n=e(p.element),o=p.$tbody,q=D.parent(),m=q.index(),x,r=false,t="td.t-grid-edit-cell",u=":input:visible:first",l=p.isAjax(),C=q.closest("tr.t-grid-new-row")[0],E=p.editing.mode==="InCell",z=p.editing.mode==="PopUp",s=q.closest("tr.t-grid-edit-row")[0]||(z&&e("#"+p.formId()+":visible").length);if(d.ENTER==y||d.F12==y){r=true;if(s){B(D.find(u)[0]);if(E){x=p.validate();if(!x){D.find(u).focus();return}if(D.is(t)){p.saveCell(D[0])}else{q.find(t).each(function(){p.saveCell(this)});p.editCell(D[0])}if(p.valid){v()}}else{if(l){n.one("dataBound",function(){var F=e(this).data("tGrid");F._current=F.$tbody.children().eq(m).find(f).eq(0);v()});if(z){e(".t-grid-update,.t-grid-insert","#"+p.formId()).click()}else{if(C){p.insertRow(q)}else{p.updateRow(q)}}}else{if(p.validate()){if(z){q=e("#"+p.formId())}q.find(".t-grid-update,.t-grid-insert").click()}}}}else{if(E){o.find(t).each(function(){p.saveCell(this)});p.editCell(D[0])}else{if(l){p.editRow(q);w(q.children().eq(0));if(z){q=e("#"+p.formId())}q.find(u).focus()}else{location.href=q.find(".t-grid-edit:first").attr("href")}}}}else{if(d.ESC==y&&s){r=true;B(D.find(u)[0]);if(E&&D.is(t)){p.cancelCell(D);v()}else{if(l){if(z){e(".t-grid-cancel","#"+this.formId()).click()}else{p.cancelRow(q)}w(q.find(f).eq(0));v()}else{if(z){q=e("#"+p.formId())}location.href=q.find(".t-grid-cancel:first").attr("href")}}}else{if(s&&E&&d.TAB==y){r=true;B(D.find(u)[0]);p.saveCell(D);if(p.valid){v();w(A.shiftKey?D.prev():D.next())}}}}return r},_initNavigationMouseEvents:function(){var r=this,o=r.$tbody,l=g+f,p=e.browser,q="click",u="mousedown",m,t,n,v=".t-grid-edit-row",s=":button,a,:input,a>.t-icon";if(p.msie){o.delegate(l,q,function(w){t=e(w.target),n=e(w.currentTarget),m=r._current;if(n.closest("tbody")[0]!==o[0]){return}if(t.is(s)){if(!(m&&!n.parent().is(v))){if(m){m.removeClass(FOCUSED)}r._current=n}}else{if(m&&m[0]===n[0]){r._current=null}r.current(n);w.preventDefault()}})}else{o.delegate(l,u,function(w){t=e(w.target),n=e(w.currentTarget),m=r._current;if(n.closest("tbody")[0]!==o[0]){return}if(t.is(s)){if(!(m&&!n.parent().is(v))){if(m){m.removeClass(FOCUSED)}r._current=n}}else{r.current(n)}})}},_clearInputSelection:function(m){if(!m){return}var l=e.browser,n;if(l.msie&&parseInt(l.version)==8){n=m.createTextRange();n.moveStart("textedit",1);n.select()}},_focusGridElement:function(){var l=e.browser;if(l.msie&&parseInt(l.version)<9){e("body",document).focus()}this.element.focus()},current:function(m){var l=this,n=l._current;if(m!==undefined&&m.length){if(!n||n[0]!==m[0]){m.addClass(FOCUSED);if(n){n.removeClass(FOCUSED)}l._current=m;l._scrollTo(m.parent()[0])}}else{return l._current}},_scrollTo:function(m){var p=this.$tbody.closest("div.t-grid-content")[0];if(!m||!p){return}var l=m.offsetTop,r=m.offsetHeight,q=p.scrollTop,n=p.clientHeight,o=l+r;p.scrollTop=q>l?l:o>(q+n)?o-n:q},_transformParams:function(n){var m=this,l=m._isServerOperation();params={},filter=e.isFunction(m.filterExpr)?m.filterExpr():"";if(l){if(n.page){params[m.queryString.page]=n.page}if(n.pageSize){params[m.queryString.size]=n.pageSize}if(n.sort&&n.sort.length){params[m.queryString.orderBy]=e.map(n.sort,function(o){return o.field+"-"+o.dir}).join("~")}if(filter!==""){params[m.queryString.filter]=filter}if(m.groupBy){params[m.queryString.groupBy]=m.groupBy}if(n.aggregates&&n.aggregates.length){params.aggregates=e.map(m.columns,function(o){if(o.aggregates){return o.member+"-"+o.aggregates.join("-")}}).join("~")}}delete n.page;delete n.pageSize;delete n.sort;delete n.filter;delete n.group;delete n.aggregates;params=e.extend(params,n);if(m.ws){params=k.toJson({state:params})}return params},_dataSourceOptions:function(){var n=this,l=this.pageSize>0,m,o=n.data||[];remoteOperations=n._isServerOperation(),deserializer={translateGroup:function(p){return{value:p.Key,hasSubgroups:p.HasSubgroups,aggregates:p.Aggregates,items:p.HasSubgroups?e.map(p.Items,e.proxy(this.translateGroup,this)):p.Items}},flatGroups:function(p){if(p.HasSubgroups){return this.flatGroups(p.Items)}return p.Items},convert:function(p){return p.d||p},mergeChanges:function(q,t,p){var s,w,v,r=[],u,x=n.dataSource;e.each(p,function(z,y){for(w=0,v=q.length;w<v;w++){if(y===x.id(q[w])){q.splice(w,1);break}}});e.each(t,function(y,z){s=x.id(this);u=false;for(w=0,v=q.length;w<v;w++){if(s===x.id(q[w])){e.extend(true,q[w],z);u=true;break}}if(!u){r.push(z)}});return q.concat(r)},data:function(q){var r=n.dataSource,t=r.data(),s=r.page()-1,u=r.pageSize(),p=n.deletedIds||[];n.deletedIds=[];if(q){q=this.convert(q);q=!e.isArray(q)?q.data||q.Data:q;if(t&&t.length&&!remoteOperations&&r.id){if(q.length&&typeof q[0].HasSubgroups!="undefined"&&!remoteOperations){q=e.map(q,e.proxy(this.flatGroups,this))}return this.mergeChanges(t,q,p)}}return q},total:function(p){if(p){p=this.convert(p);return !e.isArray(p)?p.total||p.Total:p.length}return 0},groups:function(p){p=this.data(p);return e.map(p,e.proxy(this.translateGroup,this))},aggregates:function(p){p=this.convert(p);return p.aggregates||{}}};m={serverSorting:remoteOperations,serverPaging:remoteOperations,serverFiltering:remoteOperations,serverGrouping:remoteOperations,serverAggregates:remoteOperations,page:l?n.currentPage:undefined,pageSize:l?n.pageSize:undefined,aggregates:n.aggregates,change:e.proxy(n._dataChange,n)};if(remoteOperations||(n.isAjax()&&!o.length)){e.extend(m,{transport:{dialect:{read:e.proxy(n._transformParams,this)},read:{type:"POST",dataType:"text",dataFilter:function(p,q){try{return eval("("+p.replace(c,"new Date($1)")+")")}catch(r){if(!k.ajaxError(n.element,"error",{},"parseeror")){alert("Error! The requested URL did not return JSON.")}}},contentType:n.ws?"application/json; charset=utf-8":undefined,complete:e.proxy(n.hideBusy,n)}},deserializer:deserializer})}else{if(o.length){e.extend(m,{data:{data:n.data,total:n.total},deserializer:deserializer})}}return m},_dataSource:function(){var l=this;l.dataSource=new k.DataSource(l._dataSourceOptions())},_mapAggregates:function(m){var l={};for(var n in m){l[n.replace(/^\w/,function(o){return o.toUpperCase()})]=m[n]}return l},rowClick:function(n){var m=e(n.target);if(!m.is(":button,a,:input,a>.t-icon")){n.stopPropagation();var l=m.closest("tr").addClass("t-state-selected").siblings().removeClass("t-state-selected").end();k.trigger(this.element,"rowSelect",{row:l[0]})}},$rows:function(){return this.$tbody.find("> tr:not(.t-grouping-row,.t-detail-row)")},expandRow:function(l){e(l).find("> td .t-plus, > td .t-expand").click()},collapseRow:function(l){e(l).find("> td .t-minus, > td .t-collapse").click()},headerClick:function(l){l.preventDefault();this.toggleOrder(this.$columns().index(e(l.target).closest("th")));this.sort(this.sortExpr())},refreshClick:function(m,l){if(e(l).is(".t-loading")){return}if(this.isAjax()){m.preventDefault();if(!this._isServerOperation()){this.dataSource.read()}else{this.ajaxRequest(true)}}},sort:function(l){this.orderBy=l;this.ajaxRequest()},columnFromTitle:function(m){m=e.trim(m);var l=e.grep(this.$columns(),function(n){return e.trim(e(n).text())==m})[0];if(l){return this.columns[this.$columns().index(l)]}return e.grep(this.columns,function(n){return n.title==m})[0]},columnFromMember:function(l){var m=e.grep(this.columns,function(n){return n.member==l})[0];if(!m){m=e.grep(this.columns,function(o){var n="."+o.member;return l.substr(l.length-n.length)==n})[0]}return m},toggleOrder:function(l){l=typeof l=="number"?this.columns[l]:l;var n="asc";if(l.order=="asc"){n="desc"}else{if(l.order=="desc"){n=null}}l.order=n;var m=e.inArray(l,this.sorted);if(this.sortMode=="single"&&m<0){e.each(this.sorted,function(){this.order=null});this.sorted=[]}if(m<0&&n){this.sorted.push(l)}if(!n){this.sorted.splice(m,1)}},sortExpr:function(){return e.map(this.sorted,function(l){return l.member+"-"+l.order}).join("~")},pagerKeyDown:function(l){if(l.keyCode==13){var m=this.sanitizePage(e(l.target).val());if(m!=this.currentPage){this.pageTo(m)}else{e(l.target).val(m)}}},isAjax:function(){return this.ajax||this.ws||this.onDataBinding},url:function(l){return(this.ajax||this.ws)[l]},pagerClick:function(q){q.preventDefault();var m=e(q.target).closest(".t-link");var n=this.currentPage;var o=m.find(".t-icon");if(o.hasClass("t-arrow-next")){n++}else{if(o.hasClass("t-arrow-last")){n=this.totalPages()}else{if(o.hasClass("t-arrow-prev")){n--}else{if(o.hasClass("t-arrow-first")){n=1}else{var l=m.text();if(l=="..."){var p=m.parent().children().index(m);if(p==0){n=parseInt(m.next().text())-1}else{n=parseInt(m.prev().text())+1}}else{n=parseInt(l)}}}}}this.pageTo(isFinite(n)?n:this.currentPage)},changePageSize:function(m){var l=parseInt(m,10);if(isNaN(l)||l<1){return this.pageSize}l=Math.max(l,1);this.currentPage=1;this.pageSize=l;if(this.isAjax()){this.ajaxRequest()}else{this.serverRequest()}},pageTo:function(l){this._pagingInProgress=true;this.currentPage=l;if(this.isAjax()){this.ajaxRequest()}else{this.serverRequest()}},_dataChange:function(){var m=this.dataSource;this.total=m.total();this.aggregates=m.aggregates();var l=m.view();if(this.pageOnScroll&&this._pagingInProgress===true){l=(this.data||[]).concat(l);this._pagingInProgress=false}this._current=null;this._populate(l)},_populate:function(l){this.data=[];this.bindTo(l);this.bindFooter();this.updatePager();this.updateSorting();k.trigger(this.element,"dataBound");k.trigger(this.element,"repaint")},ajaxOptions:function(m){var l={type:"POST",dataType:"text",dataFilter:function(o,p){return o.replace(c,"new Date($1)")},error:e.proxy(function(p,o){if(k.ajaxError(this.element,"error",p,o)){return}},this),complete:e.proxy(this.hideBusy,this),success:e.proxy(function(p,q,o){try{p=eval("("+p+")")}catch(r){if(!k.ajaxError(this.element,"error",o,"parseeror")){alert("Error! The requested URL did not return JSON.")}return}p=p.d||p;if(m.hasErrors&&m.hasErrors(p)){if(!k.trigger(this.element,"error",{XMLHttpRequest:o,textStatus:"modelstateerror",modelState:p.modelState})){m.displayErrors(p)}return}this.dataSource.success(p)},this)};e.extend(l,m);var n=this.ws?l.data.state={}:l.data;n[this.queryString.page]=this.currentPage;n[this.queryString.size]=this.pageSize;n[this.queryString.orderBy]=this.orderBy||"";n[this.queryString.groupBy]=this.groupBy;n[this.queryString.filter]=(this.filterBy||"").replace(/\"/g,'\\"');n[this.queryString.aggregates]=e.map(this.columns,function(o){if(o.aggregates){return o.member+"-"+o.aggregates.join("-")}}).join("~");if(this.ws){l.data=k.toJson(l.data);l.contentType="application/json; charset=utf-8"}return l},showBusy:function(){this.busyTimeout=setTimeout(e.proxy(function(){e("> .t-grid-pager .t-status .t-icon",this.element).addClass("t-loading")},this),100)},hideBusy:function(){clearTimeout(this.busyTimeout);e("> .t-grid-pager .t-status .t-icon",this.element).removeClass("t-loading")},serverRequest:function(){if(this.operationMode==="client"){this.ajaxRequest()}else{location.href=k.formatString(unescape(this.urlFormat),this.currentPage,this.orderBy||"~",this.groupBy||"~",encodeURIComponent(this.filterBy)||"~",this.pageSize||"~")}},_isServerOperation:function(){return this.operationMode!=="client"},ajaxRequest:function(n){var p=this,o=p.pageSize,m=p.currentPage,l=e.map(p.columns,function(r){return e.map(r.aggregates||[],function(s){return{field:r.member,aggregate:s}})});if(m>1&&p.pageOnScroll&&!p._pagingInProgress){o=m*p.pageSize;m=1}var q={page:m,sortedColumns:p.sorted,filteredColumns:e.grep(p.columns,function(r){return r.filters})};if(k.trigger(p.element,"dataBinding",q)){return}if(!p.ajax&&!p.ws&&this.operationMode!=="client"){return}if(p.dataSource.transport.options&&p.dataSource.transport.options.read){p.dataSource.transport.options.read.url=this.url("selectUrl")}if(p._isServerOperation()){p.showBusy()}p.dataSource.query(e.extend({page:m,pageSize:o,sort:e.map(p.sorted,function(r){return{field:r.member,dir:r.order}}),filter:e.map(e.grep(p.columns,function(r){return r.filters}),function(r){return e.map(r.filters,function(t){if(r.type=="Number"){t.value=parseFloat(t.value)}else{if(r.type=="Date"){var s=r.format?/\{0(:([^\}]+))?\}/.exec(r.format)[2]:k.cultureInfo.shortDate;t.value=k.datetime.parse({value:t.value,format:s}).toDate()}}return{field:r.member,operator:t.operator,value:t.value}})}),group:e.map(p.groups,function(r){return{field:r.member,dir:r.order,aggregates:l}}),aggregates:l},e.extend({},q.data,n)))},valueFor:function(l){if(l.type=="Date"){return new Function("data","var value = data."+l.member+'; if (!value) return null; return value instanceof Date? value : new Date(parseInt(value.replace(/\\/Date\\((.*?)\\)\\//, "$1")));')}return new Function("data","return data"+(l.member?"."+l.member:"")+";")},displayFor:function(l){var n=this.localization;if(l.commands){var o=e.map(l.commands,function(p){var q=k.grid.ButtonBuilder.create(e.extend({text:n[p.name]},p));return q.build()}).join("");return function(){return o}}if(!l.template){var m=l.value||function(){return""};if(l.format||l.type=="Date"){m=function(p){var q=l.value(p);return q==null?"":k.formatString(l.format||"{0:G}",q)}}return l.encoded===false?m:function(p){return j(m(p))}}return h(l.template)},insertFor:function(l){return this.displayFor(l)},editFor:function(l){return this.displayFor(l)},initializeColumns:function(){e.each(this.columns,e.proxy(function(n,o){if(o.member!==undefined){o.value=this.valueFor(o)}else{o.readonly=true}o.insert=this.insertFor(o);o.edit=this.editFor(o);o.display=this.displayFor(o);if(o.footerTemplate){o.footer=h(o.footerTemplate)}if(o.groupFooterTemplate){this.showGroupFooter=true;o.groupFooter=h(o.groupFooterTemplate)}o.groupHeader=h("<#= Title #>: <#= Key #>");if(o.groupHeaderTemplate){o.groupHeader=h(o.groupHeaderTemplate)}},this));var m=this.columns.length-1;while(m>=0){var l=this.columns[m];if(l.hidden){m--;continue}if(!l.attr){l.attr=' class="t-last"';break}else{if(l.attr.indexOf("class")==-1){l.attr+=' class="t-last"';break}else{l.attr=l.attr.replace('class="','class="t-last ');break}}m--}if(this.detail){this.displayDetails=h(this.detail.template)}},bindData:function(m,p,r){Array.prototype.push.apply(this.data,m);var t=this.pageOnScroll?m.length:Math.min(this.pageSize,m.length);var q=this.columns.length;t=this.pageSize?t:m.length;if(e.browser.msie){e(this.element).find(".t-grid-content colgroup:first col").css("display","")}for(var u=0;u<t;u++){var l=e.trim((this.detail?"t-master-row":"")+(u%2==1?" t-alt":""));if(l){p.cat('<tr class="').cat(l).cat('">')}else{p.cat("<tr>")}p.rep('<td class="t-group-cell"></td>',r).catIf('<td class="t-hierarchy-cell"><a class="t-icon t-plus" href="#" /></td>',this.detail);if(this.rowTemplate){p.cat('<td colspan="').cat(q).cat('">').cat(this.rowTemplate(m[u])).cat("</td>")}else{for(var n=0,o=this.columns.length;n<o;n++){var s=this.columns[n];p.cat("<td").cat(s.attr).cat(">").cat(s.display(m[u]));p.cat("</td>")}}p.cat("</tr>")}},normalizeColumns:function(){},dataItem:function(l){return this.data[this.$tbody.find("> tr:not(.t-grouping-row,.t-detail-row,.t-grid-new-row,.t-group-footer)").index(e(l))]},_colspan:function(){return this.groups.length+this.columns.length+(this.detail?1:0)},bindTo:function(q){var o=new k.stringBuilder();var p=this._colspan();if(q&&q.length){this.normalizeColumns(p);if(typeof q[0].hasSubgroups!="undefined"){for(var m=0,n=q.length;m<n;m++){this.bindGroup(q[m],p,o,0)}}else{this.bindData(q,o)}}else{o.cat("<tr class='t-no-data'>").cat("<td colspan='").cat(p).cat("'>").cat(this.noRecordsTemplate?this.noRecordsTemplate:this.localization.noRecords).cat("</td></tr>")}this.$tbody.html(o.string());if(this.onRowDataBound){var r=jQuery.grep(this.$tbody[0].rows,function(l){return !e(l).hasClass("t-grouping-row")});for(var m=0,n=this.data.length;m<n;m++){k.trigger(this.element,"rowDataBound",{row:r[m],dataItem:this.data[m]})}}},updatePager:function(){var l=this.totalPages(this.total);var n=this.currentPage;var o=this.pageSize;this.$pager.find(".t-arrow-next").parent().add(this.$pager.find(".t-arrow-last").parent()).toggleClass("t-state-disabled",n>=l).removeClass("t-state-hover");this.$pager.find(".t-arrow-prev").parent().add(this.$pager.find(".t-arrow-first").parent()).toggleClass("t-state-disabled",n==1).removeClass("t-state-hover");var m=this.localization;this.$pager.find(".t-page-i-of-n").each(function(){this.innerHTML=new k.stringBuilder().cat(m.page).cat('<input type="text" value="').cat(n).cat('" /> ').cat(k.formatString(m.pageOf,l)).string()});this.$pager.find(".t-page-size").each(function(){var p='<div style="width: 50px;" class="t-dropdown t-header"><div class="t-dropdown-wrap t-state-default"><span class="t-input">'+o+'</span><span class="t-select"><span class="t-icon t-arrow-down">select</span></span></div></div>';this.innerHTML=p});this.$pager.find(".t-numeric").each(e.proxy(function(q,p){this.numericPager(p,n,l)},this));this.$pager.parent().find(".t-status-text").text(k.formatString(m.displayingItems,this.firstItemInPage(),this.lastItemInPage(),this.total))},numericPager:function(m,s,t){var q=10;var o=1;if(s>q){var l=(s%q);o=(l==0)?(s-q)+1:(s-l)+1}var p=(o+q)-1;p=Math.min(p,t);var n=new k.stringBuilder();if(o>1){n.cat('<a class="t-link">...</a>')}for(var r=o;r<=p;r++){if(r==s){n.cat('<span class="t-state-active">').cat(r).cat("</span>")}else{n.cat('<a class="t-link">').cat(r).cat("</a>")}}if(p<t){n.cat('<a class="t-link">...</a>')}m.innerHTML=n.string()},$columns:function(){return this.$header.find("th:not(.t-hierarchy-cell,.t-group-cell)")},updateSorting:function(){this.sorted=[];e.each(this.orderBy.split("~"),e.proxy(function(m,l){var n=l.split("-");var o=this.columnFromMember(n[0]);if(o){o.order=n[1];this.sorted.push(o)}},this));this.$columns().each(e.proxy(function(m,p){var n=this.columns[m].order;var l=e(p).children("a.t-link");var o=l.children(".t-icon");if(!n){o.hide()}else{if(o.length==0){o=e('<span class="t-icon"/>').appendTo(l)}o.toggleClass("t-arrow-up",n=="asc").toggleClass("t-arrow-down",n=="desc").html("("+(n=="asc"?this.localization.sortedAsc:this.localization.sortedDesc)+")").show()}},this))},sanitizePage:function(m){var l=parseInt(m,10);if(isNaN(l)||l<1){return this.currentPage}return Math.min(l,this.totalPages())},totalPages:function(){return Math.ceil(this.total/this.pageSize)},firstItemInPage:function(){return this.total>0?(this.currentPage-1)*this.pageSize+1:0},lastItemInPage:function(){return Math.min(this.currentPage*this.pageSize,this.total)},dataBind:function(l){this.dataSource.success(l)},bindFooter:function(){var l=this,n=l.$footer.find("td:not(.t-group-cell,.t-hierarchy-cell)"),m=l.aggregates;e.each(l.columns,function(o){if(this.footer){n.eq(o).html(this.footer(l._mapAggregates(m[this.member]||{})))}})},rebind:function(l){this.sorted=[];this.orderBy="";this.filterBy="";this.currentPage=1;e.each(this.columns,function(){this.order=null;this.filters=null});e(".t-filter-options",this.element).find('input[type="text"], select').val("").removeClass("t-state-error").end().find("div.t-formatted-value").html("");e(".t-grid-filter",this.element).removeClass("t-active-filter");this.ajaxRequest(l)}};k.grid.ButtonBuilder=function(l){this.classNames=["t-button","t-grid-"+l.name];this.content=function(){return l.text};this.build=function(){return'<a href="#" class="'+this.classNames.join(" ")+'" '+(l.attr?l.attr:"")+">"+this.content()+"</a>"}};k.grid.ButtonBuilder.create=function(l){return new (i[l.buttonType])(l)};function b(m,l){return'<span class="t-icon t-'+m+'"'+(l?l:"")+"></span>"}k.grid.ImageButtonBuilder=function(l){k.grid.ButtonBuilder.call(this,l);this.classNames.push("t-button-icon");this.content=function(){return b(l.name,l.imageAttr)}};k.grid.ImageTextButtonBuilder=function(l){k.grid.ButtonBuilder.call(this,l);this.classNames.push("t-button-icontext");this.content=function(){return'<span class="t-icon t-'+l.name+'"'+(l.imageAttr?l.imageAttr:"")+"></span>"+l.text}};k.grid.BareImageButtonBuilder=function(l,m){k.grid.ImageButtonBuilder.call(this,l,m);this.classNames.push("t-button-icon","t-button-bare")};var i={Text:k.grid.ButtonBuilder,ImageAndText:k.grid.ImageTextButtonBuilder,Image:k.grid.ImageButtonBuilder,BareImage:k.grid.BareImageButtonBuilder};e.fn.tGrid=function(l){return k.create(this,{name:"tGrid",init:function(m,n){return new k.grid(m,n)},options:l,success:function(m){if(m.$tbody.find("tr.t-no-data").length){m.ajaxRequest()}}})};e.fn.tGrid.defaults={columns:[],plugins:[],currentPage:1,pageSize:10,localization:{addNew:"Add new record","delete":"Delete",cancel:"Cancel",insert:"Insert",update:"Update",select:"Select",pageOf:"of {0}",displayingItems:"Displaying items {0} - {1} of {2}",edit:"Edit",noRecords:"No records to display.",page:"Page ",filter:"Filter",filterClear:"Clear Filter",filterShowRows:"Show rows with value that",filterAnd:"And",filterStringEq:"Is equal to",filterStringNe:"Is not equal to",filterStringStartsWith:"Starts with",filterStringSubstringOf:"Contains",filterStringEndsWith:"Ends with",filterNumberEq:"Is equal to",filterNumberNe:"Is not equal to",filterNumberLt:"Is less than",filterNumberLe:"Is less than or equal to",filterNumberGt:"Is greater than",filterNumberGe:"Is greater than or equal to",filterDateEq:"Is equal to",filterDateNe:"Is not equal to",filterDateLt:"Is before",filterDateLe:"Is before or equal to",filterDateGt:"Is after",filterDateGe:"Is after or equal to",filterEnumEq:"Is equal to",filterEnumNe:"Is not equal to",filterBoolIsTrue:"is true",filterBoolIsFalse:"is false",filterSelectValue:"-Select value-",filterOpenPopupHint:"Open the calendar popup",groupHint:"Drag a column header and drop it here to group by that column",deleteConfirmation:"Are you sure you want to delete this record?",sortedAsc:"sorted ascending",sortedDesc:"sorted descending",ungroup:"ungroup"},queryString:{page:"page",size:"size",orderBy:"orderBy",groupBy:"groupBy",filter:"filter",aggregates:"aggregates"}}})(jQuery);