Lidarr/NzbDrone.Web/Scripts/2010.3.1110/telerik.calendar.min.js

1 line
14 KiB
JavaScript

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