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.
Prowlarr/packages/TelerikMvcExtensions.2011.2.../content/Scripts/2011.2.712/telerik.calendar.min.js

1 line
15 KiB

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