Radarr/packages/TelerikMvcExtensions.2011.3.../content/Scripts/2011.3.1115/telerik.calendar.min.js

1 line
15 KiB
JavaScript

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