WebCalendarjs兼容ie和火狐js日历插件.docx

上传人:b****7 文档编号:8951983 上传时间:2023-02-02 格式:DOCX 页数:30 大小:23.71KB
下载 相关 举报
WebCalendarjs兼容ie和火狐js日历插件.docx_第1页
第1页 / 共30页
WebCalendarjs兼容ie和火狐js日历插件.docx_第2页
第2页 / 共30页
WebCalendarjs兼容ie和火狐js日历插件.docx_第3页
第3页 / 共30页
WebCalendarjs兼容ie和火狐js日历插件.docx_第4页
第4页 / 共30页
WebCalendarjs兼容ie和火狐js日历插件.docx_第5页
第5页 / 共30页
点击查看更多>>
下载资源
资源描述

WebCalendarjs兼容ie和火狐js日历插件.docx

《WebCalendarjs兼容ie和火狐js日历插件.docx》由会员分享,可在线阅读,更多相关《WebCalendarjs兼容ie和火狐js日历插件.docx(30页珍藏版)》请在冰豆网上搜索。

WebCalendarjs兼容ie和火狐js日历插件.docx

WebCalendarjs兼容ie和火狐js日历插件

varcal;  

varisFocus=false;//是否为焦点  

varpickMode={  

   "second":

1,  

   "minute":

2,  

   "hour":

3,  

   "day":

4,  

   "month":

5,  

   "year":

6 };  

      

vartopY=0,leftX=0; //自定义定位偏移量2007-02-11由寒羽枫添加  

//选择日期→由寒羽枫2007-06-10添加,通过ID来选日期  

functionSelectDateById(id,strFormat,x,y)  

{  

   varobj=document.getElementById(id);  

   if(obj==null){returnfalse;}  

   obj.focus();  

   if(obj.onclick!

=null){obj.onclick();}  

   elseif(obj.click!

=null){obj.click();}  

   else{SelectDate(obj,strFormat,x,y)}  

}  

 

//选择日期→由寒羽枫2006-06-25添加  

functionSelectDate(obj,strFormat,x,y)  

{  

 

   leftX=(x==null)?

leftX:

x;  

   topY =(y==null)?

topY:

y;//自定义定位偏移量2007-02-11由寒羽枫添加   

   if(document.getElementById("ContainerPanel")==null){InitContainerPanel();}  

   vardate=newDate();  

   varby=date.getFullYear()-50; //最小值→50年前  

   varey=date.getFullYear()+50; //最大值→50年后  

   //cal=newCalendar(by,ey,1,strFormat);   //初始化英文版,0为中文版  

   cal=(cal==null)?

newCalendar(by,ey,0):

cal;   //不用每次都初始化2006-12-03修正  

   cal.DateMode=pickMode["second"];//复位  

     if(strFormat.indexOf('s')<0){cal.DateMode=pickMode["minute"];}//精度为分  

     if(strFormat.indexOf('m')<0){cal.DateMode=pickMode["hour"];}//精度为时  

     if(strFormat.indexOf('h')<0){cal.DateMode=pickMode["day"];}//精度为日  

     if(strFormat.indexOf('d')<0){cal.DateMode=pickMode["month"];}//精度为月  

     if(strFormat.indexOf('M')<0){cal.DateMode=pickMode["year"];}//精度为年  

     if(strFormat.indexOf('y')<0){cal.DateMode=pickMode["second"];}//默认精度为秒  

   cal.dateFormatStyleOld=cal.dateFormatStyle;  

   cal.dateFormatStyle=strFormat;  

   cal.show(obj);  

}  

/**//**//**//**//**//**//**//** 

 *返回日期 

 *@paramdthedelimiter 

 *@parampthepatternofyourdate 

 2006-06-25由寒羽枫修改为根据用户指定的style来确定; 

 */ 

String.prototype.toDate=function(style){  

 vary=this.substring(style.indexOf('y'),style.lastIndexOf('y')+1);//年  

 varM=this.substring(style.indexOf('M'),style.lastIndexOf('M')+1);//月  

 vard=this.substring(style.indexOf('d'),style.lastIndexOf('d')+1);//日  

 varh=this.substring(style.indexOf('h'),style.lastIndexOf('h')+1);//时  

 varm=this.substring(style.indexOf('m'),style.lastIndexOf('m')+1);//分  

 vars=this.substring(style.indexOf('s'),style.lastIndexOf('s')+1);//秒  

 

 if(s==null||s==""||isNaN(s)){s=newDate().getSeconds();}  

 if(m==null||m==""||isNaN(m)){m=newDate().getMinutes();}  

 if(h==null||h==""||isNaN(h)){h=newDate().getHours();}  

 if(d==null||d==""||isNaN(d)){d=newDate().getDate();}  

 if(M==null||M==""||isNaN(M)){M=newDate().getMonth()+1;}  

 if(y==null||y==""||isNaN(y)){y=newDate().getFullYear();}  

 vardt;  

 eval("dt=newDate('"+y+"','"+(M-1)+"','"+d+"','"+h+"','"+m+"','"+s+"')");  

 returndt;  

}  

 

/**//**//**//**//**//**//**//** 

 *格式化日期 

 *@param  dthedelimiter 

 *@param  pthepatternofyourdate 

 *@author meizz 

 */ 

Date.prototype.format=function(style){  

 varo={  

   "M+":

this.getMonth()+1,//month  

   "d+":

this.getDate(),     //day  

   "h+":

this.getHours(),    //hour  

   "m+":

this.getMinutes(),  //minute  

   "s+":

this.getSeconds(),  //second  

   "w+":

"天一二三四五六".charAt(this.getDay()),  //week  

   "q+":

Math.floor((this.getMonth()+3)/3), //quarter  

   "S" :

this.getMilliseconds()//millisecond  

 }  

 if(/(y+)/.test(style)){  

   style=style.replace(RegExp.$1,  

   (this.getFullYear()+"").substr(4-RegExp.$1.length));  

 }  

 for(varkino){  

   if(newRegExp("("+k+")").test(style)){  

     style=style.replace(RegExp.$1,  

       RegExp.$1.length==1?

o[k]:

  

       ("00"+o[k]).substr((""+o[k]).length));  

   }  

 }  

 returnstyle;  

}  

 

//2007-09-14 由寒羽枫添加返回所选日期  

Calendar.prototype.ReturnDate=function(dt){  

   if(this.dateControl!

=null){this.dateControl.value=dt;}  

   calendar.hide();  

   if(this.dateControl.onchange==null){return;}    

   //将onchange转成其它函数,以免触发验证事件  

   varev=this.dateControl.onchange.toString();//找出函数的字串  

   ev=ev.substring(  

           ((ev.indexOf("ValidatorOnChange();")>0)?

ev.indexOf("ValidatorOnChange();")+20:

ev.indexOf("{")+1)  

               ,ev.lastIndexOf("}"));//去除验证函数ValidatorOnChange();  

   varfun=newFunction(ev);    //重新定义函数  

   this.dateControl.changeEvent=fun;   

   this.dateControl.changeEvent();//触发自定义changeEvent函数  

}  

 

/**//**//**//**//**//**//**//** 

 *日历类 

 *@param  beginYear1990 

 *@param  endYear  2010 

 *@param  lang     0(中文)|1(英语)可自由扩充 

 *@param  dateFormatStyle "yyyy-MM-dd"; 

 *@version2006-04-01 

 *@author KimSoft(jinqinghua[at]) 

 *@update 

 */ 

functionCalendar(beginYear,endYear,lang,dateFormatStyle){  

 this.beginYear=1950;  

 this.endYear=2050;  

 this.lang=0;           //0(中文)|1(英文)  

 this.dateFormatStyle="yyyy-MM-ddhh:

mm:

ss";  

 

 if(beginYear!

=null&&endYear!

=null){  

   this.beginYear=beginYear;  

   this.endYear=endYear;  

 }  

 if(lang!

=null){  

   this.lang=lang  

 }  

 

 if(dateFormatStyle!

=null){  

   this.dateFormatStyle=dateFormatStyle  

 }  

 

 this.dateControl=null;  

 this.panel=this.getElementById("calendarPanel");  

 this.container=this.getElementById("ContainerPanel");  

 this.form =null;  

 

 this.date=newDate();  

 this.year=this.date.getFullYear();  

 this.month=this.date.getMonth();  

    

 this.day=this.date.getDate();  

 this.hour=this.date.getHours();  

 this.minute=this.date.getMinutes();  

 this.second=this.date.getSeconds();  

 

 this.colors={  

 "cur_word"     :

"#FFFFFF", //当日日期文字颜色  

 "cur_bg"       :

"#00FF00", //当日日期单元格背影色  

 "sel_bg"       :

"#FFCCCC", //已被选择的日期单元格背影色2006-12-03寒羽枫添加    

 "sun_word"     :

"#FF0000", //星期天文字颜色    

 "sat_word"     :

"#0000FF", //星期六文字颜色    

 "td_word_light":

"#333333", //单元格文字颜色    

 "td_word_dark" :

"#CCCCCC", //单元格文字暗色    

 "td_bg_out"    :

"#EFEFEF", //单元格背影色  

 "td_bg_over"   :

"#FFCC00", //单元格背影色  

 "tr_word"      :

"#FFFFFF", //日历头文字颜色    

 "tr_bg"        :

"#666666", //日历头背影色  

 "input_border" :

"#CCCCCC", //input控件的边框颜色    

 "input_bg"     :

"#EFEFEF"  //input控件的背影色  

 }  

/*//2008-01-29放到了show,因为要做pickMode判断 

 this.draw(); 

 this.bindYear(); 

 this.bindMonth(); 

 */ 

 //this.changeSelect();  

 //this.bindData();//2006-12-30由民工.砖家注释  

}  

 

/**//**//**//**//**//**//**//** 

 *日历类属性(语言包,可自由扩展) 

 */ 

Calendar.language={  

 "year"  :

[[""],[""]],  

 "months":

[["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],  

       ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]  

        ],  

 "weeks" :

[["日","一","二","三","四","五","六"],  

       ["SUN","MON","TUR","WED","THU","FRI","SAT"]  

        ],  

 "hour" :

[["时"],["H"]],  

 "minute" :

[["分"],["M"]],  

 "second" :

[["秒"],["S"]],  

 "clear" :

[["清空"],["CLS"]],  

 "today" :

[["今天"],["TODAY"]],  

 "pickTxt" :

[["确定"],["OK"]],//pickMode精确到年、月时把今天变成“确定”  

 "close" :

[["关闭"],["CLOSE"]]  

}  

 

Calendar.prototype.draw=function(){  

 calendar=this;  

 

 varmvAry=[];  

 //mvAry[mvAry.length] =' 

0px;">';//因不能嵌套,2006-12-01由寒羽枫改用Div  

 mvAry[mvAry.length] =' 

0px;">';  

 mvAry[mvAry.length] ='   

12px;">';  

 mvAry[mvAry.length] ='     ';  

 mvAry[mvAry.length] ='       

1pxsolid'+calendar.colors["input_border"]+';background-color:

'+calendar.colors["input_bg"]+';width:

16px;height:

20px;';  

 if(calendar.DateMode>pickMode["month"]){mvAry[mvAry.length] ='display:

none;';}//pickMode精确到年时隐藏“月”  

 mvAry[mvAry.length] ='"name="prevMonth"type="button"id="prevMonth"value="<"/>';  

 mvAry[mvAry.length] ='       

12px;">

12px;';  

 if(calendar.DateMode>pickMode["month"]){mvAry[mvAry.length] ='display:

none;';}//pickMode精确到年时隐藏“月”  

 mvAry[mvAry.length] ='">';  

 mvAry[mvAry.length] ='       

1pxsolid'+calendar.colors["input_border"]+';background-color:

'+calendar.colors["input_bg"]+';width:

16px;height:

20px;';  

 if(calendar.DateMode>pickMode["month"]){mvAry[mvAry.length] ='display:

none;';}//pickMode精确到年时隐藏“月”  

 mvAry[mvAry.length] ='"name="nextMonth"type="button"id="nextMonth"value=">"/>';  

 mvAry[mvAry.length] ='     ';  

 mvAry[mvAry.length] ='   ';  

 mvAry[mvAry.length] ='   

0pxsolid#CCCCCC;background-color:

#FFFFFF;font-size:

12px;';  

 if(calendar.DateMode>=pickMode["month"]){mvAry[mvAry.length] ='display:

none;';}//pickMode精确到年、月时隐藏“天”  

 mvAry[mvAry.length] ='"border="0"cellpadding="3"cellspacing="1">';  

 mvAry[mvAry.length] ='     ';  

 for(vari=0;i<7;i++){  

   mvAry[mvAry.length] ='     

normal;backgro

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 农学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1