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

1 line
14 KiB

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