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.
Readarr/NzbDrone.Web/Scripts/2010.3.1318/telerik.grid.min.js

1 line
15 KiB

(function(e){var b=e.telerik;var c=/"\\\/Date\((.*?)\)\\\/"/g;function d(f){return new Function("data",("var p=[];with(data){p.push('"+unescape(f).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 a(f){return(f!=null?f+"":"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}b.grid=function(f,g){this.element=f;this.groups=[];this.editing={};this.filterBy="";this.groupBy="";this.orderBy="";e.extend(this,g);this.sorted=e.grep(this.columns,function(i){return i.order});this.$tbody=e("> .t-grid-content > table tbody",f);this.scrollable=this.$tbody.length>0;if(!this.scrollable){this.$tbody=e("> table > tbody",f);this.$header=e("> table > thead tr",f);this.$footer=e("> table > tfoot",f)}else{this.$header=e("> .t-grid-header tr",f);this.$footer=e("> .t-grid-footer",f)}this.$footerWrap=this.$footer.find(".t-footer-template-wrap");var l=this.$headerWrap=e("> .t-grid-header > .t-grid-header-wrap",f);e("> .t-grid-content",f).bind("scroll",function(){l.scrollLeft(this.scrollLeft)});this.$tbody.delegate(".t-hierarchy-cell .t-plus, .t-hierarchy-cell .t-minus","click",b.stopAll(function(p){var o=e(p.target);var n=o.hasClass("t-plus");o.toggleClass("t-minus",n).toggleClass("t-plus",!n);var i=o.closest("tr.t-master-row");if(this.detail&&!i.next().hasClass("t-detail-row")){e(new b.stringBuilder().cat('<tr class="t-detail-row">').rep('<td class="t-group-cell"></td>',i.find(".t-group-cell").length).cat('<td class="t-hierarchy-cell"></td>').cat('<td class="t-detail-cell" colspan="').cat(this.$header.find("th:not(.t-group-cell,.t-hierarchy-cell):visible").length).cat('">').cat(this.displayDetails(this.dataItem(i))).cat("</td></tr>").string()).insertAfter(i)}b.trigger(this.element,n?"detailViewExpand":"detailViewCollapse",{masterRow:i[0],detailRow:i.next(".t-detail-row")[0]});i.next().toggle(n)},this));this.$pager=e("> .t-pager-wrapper .t-pager",f).add(this.$footer.find(".t-pager"));this.$pager.delegate(".t-state-disabled","click",b.preventDefault).delegate(".t-link:not(.t-state-disabled)","mouseenter",b.hover).delegate(".t-link:not(.t-state-disabled)","mouseleave",b.leave).delegate("input[type=text]","keydown",e.proxy(this.pagerKeyDown,this));this.$footer.add(e("> .t-pager-wrapper",f)).delegate(".t-refresh","click",e.proxy(this.refreshClick,this));e(f).delegate(".t-button","hover",b.preventDefault);if(this.sort){this.$header.delegate(".t-link","hover",function(){e(this).toggleClass("t-state-hover")})}var m="tr:not(.t-grouping-row,.t-detail-row,.t-no-data,:has(>.t-edit-container))";if(this.selectable){var k=this.$tbody[0];var j=this;this.$tbody.delegate(m,"click",function(i){if(this.parentNode==k){j.rowClick(i)}}).delegate(m,"hover",function(){if(this.parentNode==k){e(this).toggleClass("t-state-hover")}})}if(this.isAjax()){this.$pager.delegate(".t-link:not(.t-state-disabled)","click",b.stop(this.pagerClick,this));if(this.sort){this.$header.delegate(".t-link","click",b.stop(this.headerClick,this))}}for(var h=0;h<this.plugins.length;h++){b[this.plugins[h]].initialize(this)}b.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});this.createColumnMappings()};b.grid.prototype={rowClick:function(h){var g=e(h.target);if(!g.is(":button,a,:input,a>.t-icon")){h.stopPropagation();var f=g.closest("tr").addClass("t-state-selected").siblings().removeClass("t-state-selected").end();b.trigger(this.element,"rowSelect",{row:f[0]})}},$rows:function(){return this.$tbody.find("> tr:not(.t-grouping-row,.t-detail-row)")},expandRow:function(f){e(f).find("> td .t-plus, > td .t-expand").click()},collapseRow:function(f){e(f).find("> td .t-minus, > td .t-collapse").click()},headerClick:function(f){f.preventDefault();this.toggleOrder(this.$columns().index(e(f.target).closest("th")));this.sort(this.sortExpr())},refreshClick:function(g,f){if(e(f).is(".t-loading")){return}if(this.isAjax()){g.preventDefault();this.ajaxRequest(true)}},sort:function(f){this.orderBy=f;this.ajaxRequest()},columnFromTitle:function(g){g=e.trim(g);var f=e.grep(this.$columns(),function(h){return e.trim(e(h).text())==g})[0];if(f){return this.columns[this.$columns().index(f)]}return e.grep(this.columns,function(h){return h.title==g})[0]},columnFromMember:function(f){var g=e.grep(this.columns,function(h){return h.member==f})[0];if(!g){g=e.grep(this.columns,function(i){var h="."+i.member;return f.substr(f.length-h.length)==h})[0]}return g},toggleOrder:function(f){f=typeof f=="number"?this.columns[f]:f;var h="asc";if(f.order=="asc"){h="desc"}else{if(f.order=="desc"){h=null}}f.order=h;var g=e.inArray(f,this.sorted);if(this.sortMode=="single"&&g<0){e.each(this.sorted,function(){this.order=null});this.sorted=[]}if(g<0&&h){this.sorted.push(f)}if(!h){this.sorted.splice(g,1)}},sortExpr:function(){return e.map(this.sorted,function(f){return f.member+"-"+f.order}).join("~")},pagerKeyDown:function(f){if(f.keyCode==13){var g=this.sanitizePage(e(f.target).val());if(g!=this.currentPage){this.pageTo(g)}else{e(f.target).val(g)}}},isAjax:function(){return this.ajax||this.ws||this.onDataBinding},url:function(f){return(this.ajax||this.ws)[f]},pagerClick:function(k){k.preventDefault();var g=e(k.target).closest(".t-link");var h=this.currentPage;var i=g.find(".t-icon");if(i.hasClass("t-arrow-next")){h++}else{if(i.hasClass("t-arrow-last")){h=this.totalPages()}else{if(i.hasClass("t-arrow-prev")){h--}else{if(i.hasClass("t-arrow-first")){h=1}else{var f=g.text();if(f=="..."){var j=g.parent().children().index(g);if(j==0){h=parseInt(g.next().text())-1}else{h=parseInt(g.prev().text())+1}}else{h=parseInt(f)}}}}}this.pageTo(isFinite(h)?h:this.currentPage)},pageTo:function(f){this.currentPage=f;if(this.isAjax()){this.ajaxRequest()}else{this.serverRequest()}},ajaxOptions:function(g){var f={type:"POST",dataType:"text",dataFilter:function(i,j){return i.replace(c,"new Date($1)")},error:e.proxy(function(j,i){if(b.ajaxError(this.element,"error",j,i)){return}},this),complete:e.proxy(this.hideBusy,this),success:e.proxy(function(j,k,i){try{j=eval("("+j+")")}catch(l){if(!b.ajaxError(this.element,"error",i,"parseeror")){alert("Error! The requested URL did not return JSON.")}return}j=j.d||j;if(g.hasErrors&&g.hasErrors(j)){g.displayErrors(j);return}this.total=j.total||j.Total||0;this.dataBind(j.data||j.Data)},this)};e.extend(f,g);var h=this.ws?f.data.state={}:f.data;h[this.queryString.page]=this.currentPage;h[this.queryString.size]=this.pageSize;h[this.queryString.orderBy]=this.orderBy||"";h[this.queryString.groupBy]=this.groupBy;h[this.queryString.filter]=(this.filterBy||"").replace(/\"/g,'\\"');if(this.ws){f.data=b.toJson(f.data);f.contentType="application/json; charset=utf-8"}return f},showBusy:function(){this.busyTimeout=setTimeout(e.proxy(function(){e(".t-pager-wrapper",this.element).find(".t-status .t-icon").addClass("t-loading")},this),100)},hideBusy:function(){clearTimeout(this.busyTimeout);e(".t-pager-wrapper",this.element).find(".t-status .t-icon").removeClass("t-loading")},serverRequest:function(){location.href=b.formatString(unescape(this.urlFormat),this.currentPage,this.orderBy||"~",this.groupBy||"~",encodeURIComponent(this.filterBy)||"~")},ajaxRequest:function(){var f={page:this.currentPage,sortedColumns:this.sorted,filteredColumns:e.grep(this.columns,function(g){return g.filters})};if(b.trigger(this.element,"dataBinding",f)){return}if(!this.ajax&&!this.ws){return}this.showBusy();e.ajax(this.ajaxOptions({data:e.extend({},f.data),url:this.url("selectUrl")}))},valueFor:function(f){if(f.type=="Date"){return new Function("data","var value = data."+f.member+'; if (!value) return null; return value instanceof Date? value : new Date(parseInt(value.replace(/\\/Date\\((.*?)\\)\\//, "$1")));')}return new Function("data","return data"+(f.member?"."+f.member:"")+";")},displayFor:function(g){if(!g.template){var f=g.value;if(g.format||g.type=="Date"){f=function(h){var i=g.value(h);return i==null?"":b.formatString(g.format||"{0:G}",i)}}return g.encoded===false?f:function(h){return a(f(h))}}return d(g.template)},createColumnMappings:function(){e.each(this.columns,e.proxy(function(f,g){if(g.member!==undefined){g.value=this.valueFor(g);g.display=this.displayFor(g);g.edit=g.type!="Date"?g.value:g.display}else{if(g.template){g.display=this.displayFor(g);g.readonly=true}}},this));if(this.detail){this.displayDetails=d(this.detail.template)}},bindData:function(g,k,m){Array.prototype.push.apply(this.data,g);var o=Math.min(this.pageSize,g.length);o=this.pageSize?o:g.length;if(e.browser.msie){e(this.element).find(".t-grid-content colgroup:first col").css("display","")}for(var p=0;p<o;p++){var f=e.trim((this.detail?"t-master-row":"")+(p%2==1?" t-alt":""));if(f){k.cat('<tr class="').cat(f).cat('">')}else{k.cat("<tr>")}k.rep('<td class="t-group-cell"></td>',m).catIf('<td class="t-hierarchy-cell"><a class="t-icon t-plus" href="#" /></td>',this.detail);for(var h=0,l=this.columns.length;h<l;h++){var n=this.columns[h];k.cat("<td").cat(n.attr).catIf(' class="t-last"',h==l-1).cat(">");var j=n.display;if(j){k.cat(j(g[p]))}this.appendCommandHtml(n.commands,k);k.cat("</td>")}k.cat("</tr>")}},appendCommandHtml:function(h,i){if(h){var f=this.localization;var g=function(j,k){k.cat('<span class="t-icon t-').cat(j.name).cat('" ').cat(j.imageAttr).cat("></span>")};e.each(h,function(){var l=this.buttonType;var k="";switch(l){case"Image":k=" t-button-icon ";break;case"ImageAndText":k=" t-button-icontext ";break;case"BareImage":k=" t-button-icon t-button-bare ";break;default:k=" ";break}var j=i.cat('<a href="#" class="t-button').cat(k).cat("t-grid-").cat(this.name).cat('" ').cat(this.attr).cat(">");if(l=="Image"){g(this,j)}else{if(l=="ImageAndText"){g(this,j);j.cat(f[this.name])}else{j.cat(f[this.name])}}j.cat("</a>")})}},normalizeColumns:function(){},dataItem:function(f){return this.data[this.$tbody.find("> tr:not(.t-grouping-row,.t-detail-row,.t-grid-new-row)").index(e(f))]},bindTo:function(k){var h=new b.stringBuilder();var j=this.groups.length+this.columns.length+(this.detail?1:0);if(k&&k.length){this.normalizeColumns(j);if(typeof k[0].HasSubgroups!="undefined"){for(var f=0,g=k.length;f<g;f++){this.bindGroup(k[f],j,h,0)}}else{this.bindData(k,h)}}else{h.cat("<tr class='t-no-data'>").cat("<td colspan='").cat(j).cat("'>").cat(this.noRecordsTemplate?this.noRecordsTemplate:this.localization.noRecords).cat("</td></tr>")}this.$tbody.html(h.string());if(this.onRowDataBound){var m=jQuery.grep(this.$tbody[0].rows,function(i){return !e(i).hasClass("t-grouping-row")});for(var f=0,g=this.data.length;f<g;f++){b.trigger(this.element,"rowDataBound",{row:m[f],dataItem:this.data[f]})}}},updatePager:function(){var f=this.totalPages(this.total);var h=this.currentPage;this.$pager.find(".t-arrow-next").parent().add(this.$pager.find(".t-arrow-last").parent()).toggleClass("t-state-disabled",h>=f).removeClass("t-state-hover");this.$pager.find(".t-arrow-prev").parent().add(this.$pager.find(".t-arrow-first").parent()).toggleClass("t-state-disabled",h==1).removeClass("t-state-hover");var g=this.localization;this.$pager.find(".t-page-i-of-n").each(function(){this.innerHTML=new b.stringBuilder().cat(g.page).cat('<input type="text" value="').cat(h).cat('" /> ').cat(b.formatString(g.pageOf,f)).string()});this.$pager.find(".t-numeric").each(e.proxy(function(j,i){this.numericPager(i,h,f)},this));this.$pager.parent().find(".t-status-text").text(b.formatString(g.displayingItems,this.firstItemInPage(),this.lastItemInPage(),this.total))},numericPager:function(g,m,n){var k=10;var i=1;if(m>k){var f=(m%k);i=(f==0)?(m-k)+1:(m-f)+1}var j=(i+k)-1;j=Math.min(j,n);var h=new b.stringBuilder();if(i>1){h.cat('<a class="t-link">...</a>')}for(var l=i;l<=j;l++){if(l==m){h.cat('<span class="t-state-active">').cat(l).cat("</span>")}else{h.cat('<a class="t-link">').cat(l).cat("</a>")}}if(j<n){h.cat('<a class="t-link">...</a>')}g.innerHTML=h.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(g,f){var h=f.split("-");var i=this.columnFromMember(h[0]);if(i){i.order=h[1];this.sorted.push(i)}},this));this.$columns().each(e.proxy(function(g,k){var h=this.columns[g].order;var f=e(k).children(".t-link");var j=f.children(".t-icon");if(!h){j.hide()}else{if(j.length==0){j=e('<span class="t-icon"/>').appendTo(f)}j.toggleClass("t-arrow-up",h=="asc").toggleClass("t-arrow-down",h=="desc").show()}},this))},sanitizePage:function(g){var f=parseInt(g,10);if(isNaN(f)||f<1){return this.currentPage}return Math.min(f,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(f){this.data=[];this.bindTo(f);this.updatePager();this.updateSorting();b.trigger(this.element,"dataBound");b.trigger(this.element,"repaint")},rebind:function(g){this.sorted=[];this.filterBy="";this.currentPage=1;e.each(this.columns,function(){this.order=null;this.filters=[]});e(".t-filter-options",this.element).find('input[type="text"], select').val("").removeClass("t-state-error");for(var i in g){var h=new RegExp(b.formatString("({0})=([^&]*)",i),"g");if(h.test(this.ajax.selectUrl)){this.ajax.selectUrl=this.ajax.selectUrl.replace(h,"$1="+g[i])}else{var f=new b.stringBuilder();f.cat(this.ajax.selectUrl);if(this.ajax.selectUrl.indexOf("?")<0){f.cat("?")}else{f.cat("&")}this.ajax.selectUrl=f.cat(i).cat("=").cat(g[i]).string()}}this.ajaxRequest()}};e.fn.tGrid=function(f){return b.create(this,{name:"tGrid",init:function(g,h){return new b.grid(g,h)},options:f,success:function(g){if(g.$tbody.find("tr.t-no-data").length){g.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?"},queryString:{page:"page",size:"size",orderBy:"orderBy",groupBy:"groupBy",filter:"filter"}}})(jQuery);