mirror of https://github.com/lidarr/Lidarr
1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
(function(c){var b=c.telerik;function a(g,f,d){var e=new b.datetime();if(g){e=new b.datetime(g.toDate())}if(f.value>e.value){e=new b.datetime(f.value)}else{if(d.value<e.value){e=new b.datetime(d.value)}}return b.datetime.firstDayOfMonth(e)}c.extend(b,{calendar:function(d,e){this.element=d;c.extend(this,e);this.currentView=b.calendar.views[0];this.viewedMonth=a(this.selectedDate,this.minDate,this.maxDate);var f=new b.stringBuilder().cat('<a href="#" class="t-link t-nav-prev ').catIf("t-state-disabled",this.currentView.compare(this.viewedMonth,this.minDate,false)<=0).cat('">').cat('<span class="t-icon t-arrow-prev"></span></a><a href="#" class="t-link t-nav-fast">').cat(b.calendar.views[0].title(this.viewedMonth)).cat("</a>").cat('<a href="#" class="t-link t-nav-next ').catIf("t-state-disabled",this.currentView.compare(this.viewedMonth,this.maxDate,true)>=0).cat('"><span class="t-icon t-arrow-next"></span></a>');c(".t-header",this.element).html(f.string());c(".t-nav-next:not(.t-state-disabled)",d).live("click",c.proxy(this.navigateToFuture,this));c(".t-nav-prev:not(.t-state-disabled)",d).live("click",c.proxy(this.navigateToPast,this));c(".t-nav-fast:not(.t-state-disabled)",d).live("click",c.proxy(this.navigateUp,this));c(".t-link.t-state-disabled",d).live("click",b.preventDefault);c("td:not(.t-state-disabled):has(.t-link)",d).live("mouseenter",b.hover).live("mouseleave",b.leave).live("click",c.proxy(this.navigateDown,this));b.bind(this,{change:this.onChange,load:this.onLoad})}});b.calendar.prototype={stopAnimation:false,updateSelection:function(){var g=b.datetime.firstDayOfMonth(this.viewedMonth);var f=new b.datetime(g.value).date(32).date(0);if(this.selectedDate===null||!b.calendar.isInRange(this.selectedDate,g,f)){var e=a(this.selectedDate,this.minDate,this.maxDate);this.goToView(0,e)}var d=this;var h=c(".t-content td:not(.t-other-month)",this.element).removeClass("t-state-selected");if(this.selectedDate!==null){h.filter(function(){return(parseInt(c(this).text(),10)==d.selectedDate.date())}).addClass("t-state-selected")}},value:function(){if(arguments.length==0){return this.selectedDate===null?null:this.selectedDate.toDate()}if(arguments.length==1){this.selectedDate=arguments[0]===null?null:arguments[0].value?arguments[0]:new b.datetime(arguments[0])}else{if(arguments.length>1){this.selectedDate=new b.datetime(arguments[0],arguments[1],arguments[2])}}this.updateSelection();return this},overlay:function(d){if(!d){return c(".t-overlay",this.element).remove()}c("<div/>").addClass("t-overlay").css({opacity:0,width:this.element.offsetWidth,height:this.element.offsetHeight,position:"absolute",top:0,left:0,zIndex:3,backgroundColor:"#fff"}).appendTo(this.element)},goToView:function(d,e){if(d<0||b.calendar.views.length<=d){return}if(typeof e!="undefined"){this.viewedMonth=b.datetime.firstDayOfMonth(e)}this.currentView=b.calendar.views[d];c(".t-nav-prev",this.element).toggleClass("t-state-disabled",this.currentView.compare(e,this.minDate,false)<=0);c(".t-nav-next",this.element).toggleClass("t-state-disabled",this.currentView.compare(e,this.maxDate,true)>=0);c(".t-nav-fast",this.element).html(this.currentView.title(this.viewedMonth)).toggleClass("t-state-disabled",d==b.calendar.views.length-1);c(".t-content",this.element).html(this.currentView.body(this.viewedMonth,this.minDate,this.maxDate,this.selectedDate,this.urlFormat,this.dates)).toggleClass("t-meta-view",d==1||d==2);return this},navigateVertically:function(e,g,h,p){this.viewedMonth=b.datetime.firstDayOfMonth(g);this.currentView=b.calendar.views[e];this.overlay(true);var o=c(".t-content",this.element);var f=o.outerWidth();var m=o.outerHeight();var i=o.css("font-size");var q=o.css("line-height");if(q==="normal"){q=parseInt(i)*1.5}o.find("td").removeClass("t-state-hover");c(".t-nav-fast",this.element).html(this.currentView.title(g)).toggleClass("t-state-disabled",e==b.calendar.views.length-1);c(".t-nav-prev",this.element).toggleClass("t-state-disabled",this.currentView.compare(this.viewedMonth,this.minDate,false)<=0);c(".t-nav-next",this.element).toggleClass("t-state-disabled",this.currentView.compare(this.viewedMonth,this.maxDate,true)>=0);var r=c('<table class="t-content" cellspacing="0"></table>').html(this.currentView.body(g,this.minDate,this.maxDate,this.selectedDate,this.urlFormat,this.dates)).toggleClass("t-meta-view",e==1||e==2);var d=this;var l={fontSize:i,lineHeight:q,top:0,left:0,width:f,height:m,opacity:1};var k;if(h){k=b.fx._wrap(o).css({overflow:"hidden",position:"relative"});r.wrap(c("<div/>").addClass("t-animation-container").css(c.extend({position:"absolute",zIndex:1,fontSize:1,lineHeight:1,width:p.outerWidth(),height:p.outerHeight(),opacity:0},p.position()))).parent().insertAfter(o);if(!this.stopAnimation){r.parent().animate({fontSize:i,lineHeight:q,top:0,left:0,width:f,height:m,opacity:1},"normal",function(){r.appendTo(d.element);k.remove();d.overlay(false)})}else{o.remove();r.appendTo(d.element);k.remove();d.overlay(false)}}else{r.insertBefore(o);k=b.fx._wrap(r).css({overflow:"hidden",position:"relative"});var j;if(e!=0){j=b.calendar.views[e].verticalDate(this.viewedMonth)}var n={top:(Math.floor(j/4)*m)/3,left:((j%4)*f)/4};o.wrap(c("<div/>").addClass("t-animation-container").css(c.extend({position:"absolute"},l))).parent().insertAfter(r);if(!this.stopAnimation){o.parent().animate(c.extend({fontSize:1,lineHeight:1,width:48,height:54,opacity:0},n),"normal",function(){r.appendTo(d.element);k.remove();d.overlay(false)})}else{o.remove();r.appendTo(d.element);k.remove();d.overlay(false)}}b.trigger(this.element,"navigate",{direction:h})},navigateHorizontally:function(d,f,h){this.viewedMonth=b.datetime.firstDayOfMonth(b.calendar.fitDateToRange(f,this.minDate,this.maxDate));this.currentView=b.calendar.views[d];c(".t-nav-fast",this.element).html(this.currentView.title(f)).toggleClass("t-state-disabled",d==b.calendar.views.length-1);c(".t-nav-prev",this.element).toggleClass("t-state-disabled",this.currentView.compare(this.viewedMonth,this.minDate,false)<=0);c(".t-nav-next",this.element).toggleClass("t-state-disabled",this.currentView.compare(this.viewedMonth,this.maxDate,true)>=0);this.overlay(true);var g=c('<table class="t-content" cellspacing="0"></table>').html(this.currentView.body(f,this.minDate,this.maxDate,this.selectedDate,this.urlFormat,this.dates)).toggleClass("t-meta-view",d==1||d==2);var e=c(".t-content",this.element);var k=e.outerWidth();e.add(g).css({width:k,"float":"left"});var j=b.fx._wrap(e).css({position:"relative",width:k*2,"float":"left",left:(h?0:-200)});g[h?"insertAfter":"insertBefore"](e);var i=this;if(!this.stopAnimation){j.animate({left:(h?-200:0)},"normal",function(){g.appendTo(i.element);j.remove();i.overlay(false)})}else{e.remove();g.appendTo(i.element);j.remove();i.overlay(false)}b.trigger(this.element,"navigate",{direction:h})},navigateUp:function(f){if(f){f.preventDefault()}var d=this.currentView.index;this.navigateVertically(d+1,this.viewedMonth,false)},navigateDown:function(m,k,d){var g=c(c(m.target).hasClass("t-input")?k:m.target);var n=g.text();var l=d||this.currentView.index;var f=g.attr("href");if(f&&(f.charAt(f.length-1)=="#")){m.preventDefault()}if(l==0){var j=parseInt(n,10);var i=this.viewedMonth.month();if(g.parent().hasClass("t-other-month")){i+=(j<15?1:-1)}var h=new b.datetime(this.viewedMonth.year(),i,j);if(!this.selectedDate||(this.selectedDate.value>h.value||h.value>this.selectedDate.value)){if(b.trigger(this.element,"change",{previousDate:this.selectedDate===null?null:this.selectedDate.toDate(),date:h.toDate()})){return this}this.selectedDate=h}this.updateSelection()}else{if(l!=0){b.calendar.views[l].verticalDate(this.viewedMonth,n)}this.viewedMonth=b.calendar.fitDateToRange(this.viewedMonth,this.minDate,this.maxDate);this.navigateVertically(l-1,this.viewedMonth,true,g.add(g.parent()).filter("td"))}},navigateToPast:function(f){if(f){f.preventDefault()}var d=this.currentView.index;if(d==0){this.viewedMonth.date(1).date(-1)}else{this.viewedMonth.addYear(-Math.pow(10,d-1))}this.navigateHorizontally(d,this.viewedMonth,false)},navigateToFuture:function(f){if(f){f.preventDefault()}var d=this.currentView.index;if(d==0){this.viewedMonth.date(32).date(1)}else{this.viewedMonth.addYear(Math.pow(10,d-1))}this.navigateHorizontally(d,this.viewedMonth,true)}};c.fn.tCalendar=function(d){return b.create(this,{name:"tCalendar",init:function(e,f){return new b.calendar(e,f)},options:d})};c.fn.tCalendar.defaults={selectedDate:null,minDate:new b.datetime(1899,11,31),maxDate:new b.datetime(2100,0,1)};c.extend(b.calendar,{views:[{index:0,title:function(d){return new b.stringBuilder().cat(b.cultureInfo.months[d.month()]).cat(" ").cat(d.year()).string()},body:function(g,p,m,l,k,o){var v=(new b.stringBuilder()).cat('<thead><tr class="t-week-header">');var h=b.cultureInfo.firstDayOfWeek;var f=b.cultureInfo.days;var u=b.cultureInfo.abbrDays;f=f.slice(h).concat(f.slice(0,h));u=u.slice(h).concat(u.slice(0,h));for(var j=0;j<7;j++){v.cat('<th scope="col" abbr="').cat(u[j]).cat('" title="').cat(f[j]).cat('">').cat(f[j].charAt(0)).cat("</th>")}v.cat("</tr></thead><tbody>");var q=b.datetime.firstVisibleDay(g);var d=g.month();var s=l===null?false:g.year()==l.year();var t;for(var r=0;r<6;r++){v.cat("<tr>");for(var e=0;e<7;e++){t=q.month()!=d?"t-other-month":(s&&q.month()==l.month()&&q.date()==l.date())?" t-state-selected":"";v.cat("<td").catIf(' class="'+t+'"',t).cat(">");if(b.calendar.isInRange(q,p,m)){v.cat('<a href="');var n="#";if(k){if(o){n=b.calendar.isInCollection(q,o)?b.calendar.formatUrl(k,q):"#"}else{n=b.calendar.formatUrl(k,q)}}v.cat(n).cat('" class="t-link').cat(n!="#"?" t-action-link":"").cat('" title="').cat(b.datetime.format(q.toDate(),b.cultureInfo.longDate)).cat('">').cat(q.date()).cat("</a>")}else{v.cat(" ")}v.cat("</td>");b.datetime.modify(q,b.datetime.msPerDay)}v.cat("</tr>")}v.cat("</tbody>");return v.string()},compare:function(e,d){var g;var j=e.month();var f=e.year();var i=d.month();var h=d.year();if(f>h){g=1}else{if(f<h){g=-1}else{g=j==i?0:j>i?1:-1}}return g},firstLastDay:function(f,d,e){return d?b.datetime.firstDayOfMonth(f):new b.datetime(f.year(),f.month()+1,0)},navCheck:function(e,d,f){return f?new b.datetime(d.year(),d.month()+1,d.date()).value-e.value<=0:e.value<d.value}},{index:1,title:function(d){return d.year()},body:function(e,d,f){return b.calendar.metaView(true,e,function(){var g=[];var k=0;var j=11;if(d.year()==f.year()){k=d.month();j=f.month()}else{if(e.year()==d.year()){k=d.month()}else{if(e.year()==f.year()){j=f.month()}}}for(var h=0;h<12;h++){if(h>=k&&h<=j){g.push(b.cultureInfo.abbrMonths[h])}else{g.push(" ")}}return g})},compare:function(d,e){return d.year()>e.year()?1:d.year()<e.year()?-1:0},verticalDate:function(d,e){if(!e){return d.month()}d.month(c.inArray(e,b.cultureInfo.abbrMonths))},firstLastDay:function(d,e){return new b.datetime(d.year(),e?0:11,1)},navCheck:function(f,d,g){var e=this.compare(f,d);return g?e==1:e==-1}},{index:2,title:function(e){var d=e.year()-e.year()%10;return d+"-"+(d+9)},body:function(e,d,f){return b.calendar.metaView(false,e,function(){var h=[];var g=d.year();var k=f.year();var j=e.year()-e.year()%10-1;for(var l=0;l<12;l++){h.push(j+l>=g&&j+l<=k?j+l:" ")}return h})},compare:function(e,d,g){var h=e.year();var f=(h-h%10);var i=(h-h%10+9);return b.calendar.check(f,i,d,g)},verticalDate:function(d,e){if(!e){return d.year()%10+1}d.year(e)},firstLastDay:function(d,e){return new b.datetime(d.year()-d.year()%10+(e?0:9),0,1)},navCheck:function(f,d,g){var e=this.compare(d,f,g);return g?e==-1:e==1}},{index:3,title:function(e){var d=e.year()-e.year()%100;return d+"-"+(d+99)},body:function(e,d,f){return b.calendar.metaView(false,e,function(){var j=e.year()-e.year()%100;var g=[];for(var k=-1;k<11;k++){var h=j+k*10;if((h+10)>=d.year()&&h<=f.year()){g.push(h+"-<br />"+(h+9)+" ")}else{g.push(" <br /> ")}}return g})},compare:function(e,d,f){var g=e.year();var i=(g-g%100);var h=(g-g%100+99);return b.calendar.check(i,h,d,f)},verticalDate:function(d,e){if(!e){return Math.ceil(d.year()/10)%10+1}d.year(e.substring(0,e.indexOf("-")))},firstLastDay:function(d,e){return e?new b.datetime(d.year()-(d.year()%100),0,1):new b.datetime(d.year()-(d.year()%100)+99,0,1)},navCheck:function(f,d,g){var e=this.compare(d,f,g);return g?e==-1:e==1}}],check:function(g,h,d,e){var f=function(i){return i<d.year()?-1:i>d.year()?1:0};return e?f(h):f(g)},html:function(g,e,d,h,i,f){g=g||new b.datetime();d=d||c.fn.tCalendar.defaults.minDate;h=h||c.fn.tCalendar.defaults.maxDate;return new b.stringBuilder().cat('<div class="t-widget t-calendar">').cat('<div class="t-header">').cat('<a href="#" class="t-link t-nav-prev">').cat('<span class="t-icon t-arrow-prev"></span></a><a href="#" class="t-link t-nav-fast">').cat(b.calendar.views[0].title(g)).cat("</a>").cat('<a href="#" class="t-link t-nav-next"><span class="t-icon t-arrow-next"></span></a>').cat("</div>").cat('<table class="t-content" cellspacing="0">').cat(b.calendar.views[0].body(g,d,h,e,i,f)).cat("</table></div>").string()},metaView:function(h,k,e){var f=new b.stringBuilder();var j=e();f.cat("<tr>");for(var d=0,g=j.length;d<g;d++){f.catIf("</tr><tr>",d>0&&d%4==0).cat("<td").catIf(' class="t-other-month"',(d==0||d==g-1)&&h==false).cat(">");if(j[d]!==" "&&j[d]!==" <br /> "){f.cat('<a href="#" class="t-link">').cat(j[d]).cat("</a>")}else{f.cat(j[d])}f.cat("</td>")}f.cat("</tr>");return f.string()},isInRange:function(f,d,e){if(!f){return false}return d.value-f.value<=0&&e.value-f.value>=0},fitDateToRange:function(f,d,e){if(f.value<d.value){f=new b.datetime(d.value)}if(f.value>e.value){f=new b.datetime(e.value)}return f},isInCollection:function(g,d){var e=d[g.year()];if(e){var f=e[g.month()];if(f&&c.inArray(g.date(),f)!=-1){return true}}return false},findTarget:function(i,l,k,g){var d=function(m,n){return c.grep(m,function(o){return c(o).children().eq(0).text().indexOf(n)>-1})[0]};var e=g?"last":"first";var j=c(".t-content:"+e+" td:has(> .t-link)",k).removeClass("t-state-focus");var f;if(l==0){f=c(d(j.filter(":not(.t-other-month)"),i.date()))}else{if(l==1){f=c(d(j,b.cultureInfo.abbrMonths[i.month()]))}else{if(l==2||l==3){var h=i.year();f=c(d(j,l==2?h:h-(h%10)));if(f.length==0&&l==3){f=c(d(j,h-(h%10)+99))}}}}return f},focusDate:function(g,d,f,e){b.calendar.findTarget(g,d,f,e).addClass("t-state-focus")},formatUrl:function(d,e){return d.replace("{0}",b.datetime.format(e.toDate(),b.cultureInfo.shortDate))}});c.extend(b.formatters,{date:b.datetime.format})})(jQuery); |