1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-23 08:13:01 +00:00
Lidarr/NzbDrone.Web/Scripts/2010.2.825/telerik.calendar.min.js
2010-10-02 12:01:43 -07:00

1 line
No EOL
15 KiB
JavaScript

(function(c){var a=c.telerik;var b=/d{1,4}|M{1,4}|yy(?:yy)?|([Hhmstf])\1*|"[^"]*"|'[^']*'/g;c.extend(a,{calendar:function(e,f){this.element=e;c.extend(this,f);this.currentView=a.calendar.views[0];var d=new a.datetime();this.viewedMonth=a.datetime.firstDayOfMonth(this.selectedDate||(a.calendar.isInRange(d,this.minDate,this.maxDate)?d:this.minDate));c(".t-nav-next:not(.t-state-disabled)",e).live("click",c.proxy(this.navigateToFuture,this));c(".t-nav-prev:not(.t-state-disabled)",e).live("click",c.proxy(this.navigateToPast,this));c(".t-nav-fast:not(.t-state-disabled)",e).live("click",c.proxy(this.navigateUp,this));c(".t-link.t-state-disabled",e).live("click",a.preventDefault);c("td:not(.t-state-disabled):has(.t-link)",e).live("mouseenter",a.hover).live("mouseleave",a.leave).live("click",c.proxy(this.navigateDown,this));a.bind(this,{change:this.onChange,load:this.onLoad})}});c.extend(a.cultureInfo,{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbrDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],abbrMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longTime:"h:mm:ss tt",longDate:"dddd, MMMM dd, yyyy",shortDate:"M/d/yyyy",shortTime:"h:mm tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",generalDateShortTime:"M/d/yyyy h:mm tt",generalDateTime:"M/d/yyyy h:mm:ss tt",sortableDateTime:"yyyy'-'MM'-'ddTHH':'mm':'ss",universalSortableDateTime:"yyyy'-'MM'-'dd HH':'mm':'ss'Z'",monthYear:"MMMM, yyyy",monthDay:"MMMM dd",today:"today",tomorrow:"tomorrow",yesterday:"yesterday",next:"next",last:"last",year:"year",month:"month",week:"week",day:"day",am:"AM",pm:"PM",dateSeparator:"/",timeSeparator:":"});a.calendar.prototype={stopAnimation:false,updateSelection:function(){var h=new a.datetime();var f=a.datetime.firstDayOfMonth(this.viewedMonth);var e=new a.datetime(f.value).date(32).date(0);if(this.selectedDate===null||!a.calendar.isInRange(this.selectedDate,f,e)){this.goToView(0,a.datetime.firstDayOfMonth(this.selectedDate||(a.calendar.isInRange(h,this.minDate,this.maxDate)?h:this.minDate)))}var d=this;var g=c(".t-content td:not(.t-other-month)",this.element).removeClass("t-state-selected");if(this.selectedDate!==null){g.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 a.datetime(arguments[0])}else{if(arguments.length>1){this.selectedDate=new a.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||a.calendar.views.length<=d){return}if(typeof e!="undefined"){this.viewedMonth=a.datetime.firstDayOfMonth(e)}this.currentView=a.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==a.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=a.datetime.firstDayOfMonth(g);this.currentView=a.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==a.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=a.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=a.fx._wrap(r).css({overflow:"hidden",position:"relative"});var j;if(e!=0){j=a.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)}}a.trigger(this.element,"navigate",{direction:h})},navigateHorizontally:function(d,f,h){this.viewedMonth=a.datetime.firstDayOfMonth(a.calendar.fitDateToRange(f,this.minDate,this.maxDate));this.currentView=a.calendar.views[d];c(".t-nav-fast",this.element).html(this.currentView.title(f)).toggleClass("t-state-disabled",d==a.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=a.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)}a.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 a.datetime(this.viewedMonth.year(),i,j);if(!this.selectedDate||(this.selectedDate.value>h.value||h.value>this.selectedDate.value)){if(a.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){a.calendar.views[l].verticalDate(this.viewedMonth,n)}this.viewedMonth=a.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 a.create(this,{name:"tCalendar",init:function(e,f){return new a.calendar(e,f)},options:d})};c.fn.tCalendar.defaults={selectedDate:null,minDate:new a.datetime(1899,11,31),maxDate:new a.datetime(2100,0,1)};c.extend(a.calendar,{views:[{index:0,title:function(d){return new a.stringBuilder().cat(a.cultureInfo.months[d.month()]).cat(" ").cat(d.year()).string()},body:function(f,n,k,j,h,m){var s=(new a.stringBuilder()).cat('<thead><tr class="t-week-header">');for(var g=0;g<7;g++){s.cat('<th scope="col" abbr="').cat(a.cultureInfo.abbrDays[g]).cat('" title="').cat(a.cultureInfo.days[g]).cat('">').cat(a.cultureInfo.days[g].charAt(0)).cat("</th>")}s.cat("</tr></thead><tbody>");var o=a.datetime.firstVisibleDay(f);var d=f.month();var q=j===null?false:f.year()==j.year();var r;for(var p=0;p<6;p++){s.cat("<tr>");for(var e=0;e<7;e++){r=o.month()!=d?"t-other-month":(q&&o.month()==j.month()&&o.date()==j.date())?" t-state-selected":"";s.cat("<td").catIf(' class="'+r+'"',r).cat(">");if(a.calendar.isInRange(o,n,k)){s.cat('<a href="');var l="#";if(h){if(m){l=a.calendar.isInCollection(o,m)?a.calendar.formatUrl(h,o):"#"}else{l=a.calendar.formatUrl(h,o)}}s.cat(l).cat('" class="t-link').cat(l!="#"?" t-action-link":"").cat('">').cat(o.date()).cat("</a>")}else{s.cat("&nbsp;")}s.cat("</td>");a.datetime.modify(o,a.datetime.msPerDay)}s.cat("</tr>")}s.cat("</tbody>");return s.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?a.datetime.firstDayOfMonth(f):new a.datetime(f.year(),f.month()+1,0)},navCheck:function(e,d,f){return f?new a.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 a.calendar.metaView(true,e,function(){var g=[];for(var h=0;h<12;h++){if(e.year()<=d.year()){h<d.month()?g.push("&nbsp;"):g.push(a.cultureInfo.abbrMonths[h])}else{if(e.year()>=f.year()){h>f.month()?g.push("&nbsp;"):g.push(a.cultureInfo.abbrMonths[h])}else{g.push(a.cultureInfo.abbrMonths[h])}}}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,a.cultureInfo.abbrMonths))},firstLastDay:function(d,e){return new a.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 a.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:"&nbsp;")}return h})},compare:function(e,d,g){var h=e.year();var f=(h-h%10);var i=(h-h%10+9);return a.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 a.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 a.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)+"&nbsp;")}else{g.push("&nbsp;<br />&nbsp;")}}return g})},compare:function(e,d,f){var g=e.year();var i=(g-g%100);var h=(g-g%100+99);return a.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 a.datetime(d.year()-(d.year()%100),0,1):new a.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)},pad:function(d){if(d<10){return"0"+d}return d},standardFormat:function(d){var e=a.cultureInfo;var f={d:e.shortDate,D:e.longDate,F:e.fullDateTime,g:e.generalDateShortTime,G:e.generalDateTime,m:e.monthDay,M:e.monthDay,s:e.sortableDateTime,t:e.shortTime,T:e.longTime,u:e.universalSortableDateTime,y:e.monthYear,Y:e.monthYear};return f[d]},formatDate:function(u,e){var o=a.cultureInfo;var r=u.getDate();var g=u.getDay();var q=u.getMonth();var i=u.getFullYear();var n=u.getHours();var k=u.getMinutes();var j=u.getSeconds();var t=u.getMilliseconds();var p=a.calendar.pad;var v={d:r,dd:p(r),ddd:o.abbrDays[g],dddd:o.days[g],M:q+1,MM:p(q+1),MMM:o.abbrMonths[q],MMMM:o.months[q],yy:p(i%100),yyyy:i,h:n%12||12,hh:p(n%12||12),H:n,HH:p(n),m:k,mm:p(k),s:j,ss:p(j),f:Math.floor(t/100),ff:Math.floor(t/10),fff:t,tt:n<12?o.am:o.pm};e=e||"G";e=a.calendar.standardFormat(e)?a.calendar.standardFormat(e):e;return e.replace(b,function(d){return d in v?v[d]:d.slice(1,d.length-1)})},html:function(g,e,d,h,i,f){g=g||new a.datetime();d=d||c.fn.tCalendar.defaults.minDate;h=h||c.fn.tCalendar.defaults.maxDate;return new a.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(a.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(a.calendar.views[0].body(g,d,h,e,i,f)).cat("</table></div>").string()},metaView:function(h,k,e){var f=new a.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]!=="&nbsp;"&&j[d]!=="&nbsp;<br />&nbsp;"){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 a.datetime(d.value)}if(f.value>e.value){f=new a.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,a.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){a.calendar.findTarget(g,d,f,e).addClass("t-state-focus")},formatUrl:function(d,e){return d.replace("{0}",a.calendar.formatDate(e.toDate(),a.cultureInfo.shortDate))}});c.extend(a.formatters,{date:a.calendar.formatDate})})(jQuery);