📄 calendar.js
字号:
{
datepicker.firstChild.lastChild.appendChild(document.createElement("td"));
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.selectedDate.setMonth("+i+");this.parentNode.parentNode.parentNode.parentNode.parentNode.lowerCard()");
datepicker.firstChild.lastChild.lastChild.appendChild(document.createTextNode(months[i++]));
datepicker.firstChild.lastChild.lastChild.onmouseover=new Function("this.className=\"Calendar CalendarHoverCell\"");
datepicker.firstChild.lastChild.lastChild.onmouseout=new Function("this.className=this.type");
}
}
container.appendChild(datepicker);
Picker.call(container);
return container;
}
function DayPicker(selectedDate)
{
var container=document.createElement("div");
container.style.cssText="position:absolute;width:179px;height:150px;overflow:hidden;";
var month=selectedDate.getMonth();
container.title=months[month];
var date=new Date();
date.setTime(selectedDate.getTime());
while(date.getDate()!=1)
{
date.setHours(date.getHours()-24);
}
while(date.getDay()!=0)
{
date.setHours(date.getHours()-24);
}
var datepicker=document.createElement("table");
datepicker.style.cssText="position:relative;width:179px;height:150px;overflow:hidden;text-align:center;font-size:15px;";
datepicker.appendChild(document.createElement("tbody"));
datepicker.cellSpacing="0";
datepicker.border="0";
datepicker.firstChild.appendChild(document.createElement("tr"));
var weekdays=new String("日一二三四五六");
for(var days=0;days<7;days++){
datepicker.firstChild.lastChild.appendChild(document.createElement("td"));
datepicker.firstChild.lastChild.lastChild.appendChild(document.createTextNode(weekdays.charAt(days)));
}
for(var weeks=0;weeks<6;weeks++)
{
datepicker.firstChild.appendChild(document.createElement("tr"));
for(var days=0;days<7;days++)
{
datepicker.firstChild.lastChild.appendChild(document.createElement("td"));
datepicker.firstChild.lastChild.lastChild.appendChild(document.createTextNode(date.getDate().toString()));
if(date.getMonth()==month)
{
datepicker.firstChild.lastChild.lastChild.className="Calendar CalendarCell";
datepicker.firstChild.lastChild.lastChild.type="Calendar CalendarCell"
datepicker.firstChild.lastChild.lastChild.onmouseover=new Function("this.className=\"Calendar CalendarHoverCell\"");
datepicker.firstChild.lastChild.lastChild.onmouseout=new Function("this.className=this.type");
datepicker.firstChild.lastChild.lastChild.value=new Date();
datepicker.firstChild.lastChild.lastChild.value.setTime(date.getTime());
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.onSelect(this.value)");
}
else
{
datepicker.firstChild.lastChild.lastChild.className="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.type="Calendar CalendarDisabledCell";
if(date>selectedDate)datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.nextCard()");
else datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.lastCard()");
}
date.setHours(date.getHours()+24);
}
}
//container.selectedDate.setMonth();
//container.onSelect=new EventHandler();
//container.onSelect["+="](function(v){alert(v)});
container.appendChild(datepicker);
Picker.call(container);
return container;
}
function Picker()
{
var d=500;
this.slideinLeft=new StoryBoard(d);
this.slideinLeft.appendAnimation(new Animation(this.style,"left",function(t){return (179-Math.floor(t/d*179))+"px"}));
this.slideoutLeft=new StoryBoard(d);
this.slideoutLeft.appendAnimation(new Animation(this.style,"left",function(t){return (-Math.floor(t/d*179))+"px"}));
this.slideinRight=new StoryBoard(d);
this.slideinRight.appendAnimation(new Animation(this.style,"left",function(t){return (-179+Math.floor(t/d*179))+"px"}));
this.slideoutRight=new StoryBoard(d);
this.slideoutRight.appendAnimation(new Animation(this.style,"left",function(t){return (Math.floor(t/d*179))+"px"}));
this.hide=new StoryBoard(d);
if(this.style.opacity!==undefined)
this.hide.appendAnimation(new Animation(this.style,"opacity",function(t){return (d-t)/d}));
else if(isIE)
this.hide.appendAnimation(new Animation(this.style,"filter",function(t){return "alpha(opacity="+Math.floor((d-t)/5)+")";}));
else if(isFF)
this.hide.appendAnimation(new Animation(this.style,"MozOpacity",function(t){return (d-t)/d}));
else if(isSa)
this.hide.appendAnimation(new Animation(this.style,"KHTMLOpacity",function(t){return (d-t)/d}));
this.show=new StoryBoard(d);
if(this.style.opacity!==undefined)
this.show.appendAnimation(new Animation(this.style,"opacity",function(t){return (t)/d}));
else if(isIE)
this.show.appendAnimation(new Animation(this.style,"filter",function(t){return "alpha(opacity="+Math.floor((t)/d*100)+")";}));
else if(isFF)
this.show.appendAnimation(new Animation(this.style,"MozOpacity",function(t){return (t)/d}));
else if(isSa)
this.show.appendAnimation(new Animation(this.style,"KHTMLOpacity",function(t){return (t)/d}));
}
function Opacity(){
if(this.style.opacity!==undefined)
this.style.opacity=0;
else if(isIE)
this.style.filter="alpha(opacity=0)";
else if(isFF)
this.style.MozOpacity=0;
else if(isSa)
this.style.KHTMLOpacity=0;
}
body.Card=[DayPicker,MonthPicker,YearPicker,TenyearPicker,HandredyearPicker];
body.Type=type||0;
body.appendChild(new body.Card[body.Type](container.selectedDate));
title.innerHTML=body.firstChild.title;
with(Calendar.events)
{
body.nextCard=nextCardBuilder(title,Opacity);
body.lastCard=lastCardBuilder(title,Opacity);
body.upperCard=upperCardBuilder(title,Opacity);
body.lowerCard=lowerCardBuilder(title,Opacity);
}
//body.firstChild.hide.start();
container.onSelect=new EventHandler();
//container.onSelect["+="](function(v){alert(v)});
return container;
}
Calendar.events={};
Calendar.events.lowerCardBuilder=function(title,Opacity){
return function(){
if(this.Type>0)--(this.Type);
else return;
this.appendChild(new this.Card[this.Type](this.parentNode.selectedDate));
Opacity.call(this.lastChild);
title.innerHTML=this.lastChild.title;
var me=this;
this.firstChild.hide.start();
this.lastChild.show.start();
setTimeout(function(){me.removeChild(me.firstChild);},1000);
}
}
Calendar.events.upperCardBuilder=function(title,Opacity){
return function(){
if(this.Type<4)++(this.Type);
else return;
this.appendChild(new this.Card[this.Type](this.parentNode.selectedDate));
Opacity.call(this.lastChild);
title.innerHTML=this.lastChild.title;
var me=this;
this.firstChild.hide.start();
this.lastChild.show.start();
setTimeout(function(){me.removeChild(me.firstChild);},1000);
}
}
Calendar.events.lastCardBuilder=function(title,Opacity){
return function(){
switch(this.Type)
{
case 0:this.parentNode.selectedDate.setMonth(this.parentNode.selectedDate.getMonth()-1);break;
case 1:this.parentNode.selectedDate.setFullYear(this.parentNode.selectedDate.getFullYear()-1);break;
case 2:this.parentNode.selectedDate.setFullYear(this.parentNode.selectedDate.getFullYear()-10);break;
case 3:this.parentNode.selectedDate.setFullYear(this.parentNode.selectedDate.getFullYear()-100);break;
case 4:this.parentNode.selectedDate.setFullYear(this.parentNode.selectedDate.getFullYear()-1000);break;
default:return;
}
this.appendChild(new this.Card[this.Type](this.parentNode.selectedDate));
title.innerHTML=this.lastChild.title;
this.lastChild.slideinRight.start();
this.firstChild.slideoutRight.start();
var me=this;
setTimeout(function(){me.removeChild(me.firstChild);},500);
}
}
Calendar.events.nextCardBuilder=function(title,Opacity){
return function(){
switch(this.Type)
{
case 0:this.parentNode.selectedDate.setMonth(this.parentNode.selectedDate.getMonth()+1);break;
case 1:this.parentNode.selectedDate.setFullYear(this.parentNode.selectedDate.getFullYear()+1);break;
case 2:this.parentNode.selectedDate.setFullYear(this.parentNode.selectedDate.getFullYear()+10);break;
case 3:this.parentNode.selectedDate.setFullYear(this.parentNode.selectedDate.getFullYear()+100);break;
case 4:this.parentNode.selectedDate.setFullYear(this.parentNode.selectedDate.getFullYear()+1000);break;
default:return;
}
this.appendChild(new this.Card[this.Type](this.parentNode.selectedDate));
title.innerHTML=this.lastChild.title;
this.lastChild.slideinLeft.start();
this.firstChild.slideoutLeft.start();
var me=this;
setTimeout(function(){me.removeChild(me.firstChild);},500);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -