您好,欢迎光临本网站![请登录][注册会员]  
文件名称: js的日历时间控件
  所属分类: Java
  开发工具:
  文件大小: 157kb
  下载次数: 0
  上传时间: 2011-09-08
  提 供 者: caoliju********
 详细说明: js的日历时间控件 if(typeof Control=="undefined"){Control={}}Control.DatePicker=Class.create({initialize:function(element,options){this.element=$(element);if(dp=this.element.retrieve("datepicker")){dp.destroy()}this.wrapper=this.element.wrap(new Element("div"));this.wrapper.style.position="relative";options=Object.extend({datePicker:true,timePicker:false},options||{});if(window.Protoplasm!=undefined){var basePath=Protoplasm.base("datepicker");if(basePath){if(!options.icon){if(options.dat ePicker){options.icon=basePath+"calendar.png"}else{options.icon=basePath+"clock.png"}}Protoplasm.loadStylesheet("datepicker.css","datepicker")}}this.handlers={onClick:options.onClick,onHover:options.onHover,onSelect:options.onSelect};this.options=Object.extend(options||{},{onClick:this.pickerClicked.bind(this),onHover:this.dateHover.bind(this),onSelect:this.datePicked.bind(this)});var locale=this.options&&this.options.locale?this.options.locale:"en_US";try{this.setLocale(new Control.DatePicker.i18n(locale))}catch(e){var re=/datepicker.js$/;var base=$$("head script[src]").find(function(s){return s.src.match(re)}).src.replace(re,"");new Ajax.Request(base+"locales/"+locale+".js",{onSuccess:function(transport){eval(transport.responseText);this.setLocale(new Control.DatePicker.i18n(locale))}.bind(this),onFailure:function(transport){this.setLocale(new Control.DatePicker.i18n("en_US"))}.bind(this)})}this.datepicker=null;this.originalValue=null;this.hideTimeout=null;if(this.options.icon){this.element.style.background="url("+this.options.icon+") right center no-repeat #FFF";this.oldPadding=this.element.style.paddingRight;this.element.style.paddingRight="20px"}this.listeners=[];this.listeners.push(this.element.on("click",this.toggle.bindAsEventListener(this)));this.listeners.push(this.element.on("keydown",this.keyHandler.bindAsEventListener(this)));this.listeners.push(document.on("keydown",this.docKeyHandler.bindAsEventListener(this)));this.hidePickerListener=null;this.pickerActive=false;this.element.store("datepicker",this);this.destructor=Event.on(window,"unload",this.destroy.bind(this))},setLocale:function(a){this.i18n=a;this.options=this.i18n.inheritOptions(this.options);if(this.options.timePicker&&this.options.datePicker){this.options.currentFormat=this.options.dateTimeFormat}else{if(this.options.timePicker){this.options.currentFormat=this.options.timeFormat}else{this.options.currentFormat=this.options.dateFormat}}this.options.date=Control.DatePicker.DateFormat.parseFormat(this.element.value,this.options.currentFormat)},destroy:function(){for(var a=0;a-1){throw ("Locale available but not loaded")}var c=b.charAt(2)=="_"?b.substring(0,2):b;var a=(Control.DatePicker.Locale[b]||Control.DatePicker.Locale[c]);this.opts=Object.clone(a||{});var d=a?Control.DatePicker.Language[a.language]:null;if(d){Object.extend(this.opts,d)}},opts:null,inheritOptions:function(a){if(!this.opts){this.setLocale("en_US")}return Object.extend(this.opts,a||{})},tr:function(a){return this.opts&&this.opts.strings?this.opts.strings[a]||a:a}};Control.DatePicker.Locale={};with(Control.DatePicker){Locale.es=i18n.createLocale("eu","es");Locale.en=i18n.createLocale("us","en");Locale.en_GB=i18n.createLocale("eu","en");Locale.en_AU=Locale.en_GB;Locale.de=i18n.createLocale("eu","de");Locale.es_iso8601=i18n.createLocale("iso8601","es");Locale.en_iso8601=i18n.createLocale("iso8601","en");Locale.de_iso8601=i18n.createLocale("iso8601","de")}Control.DatePicker.Language={es:{months:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Augosto","Septiembre","Octubre","Novimbre","Diciembre"],days:["Do","Lu","Ma","Mi","Ju","Vi","Sa"],strings:{Now:"Ahora",Today:"Hoy",Time:"Hora","Exact minutes":"Minuto exacto","Select Date and Time":"Selecciona Dia y Hora","Select Time":"Selecciona Hora","Open calendar":"Abre calendario"}},de:{months:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],days:["So","Mo","Di","Mi","Do","Fr","Sa"],strings:{Now:"Jetzt",Today:"Heute",Time:"Zeit","Exact minutes":"Exakte minuten","Select Date and Time":"Zeit und Datum Auswählen","Select Time":"Zeit Auswählen","Open calendar":"Kalender öffnen"}}};Control.DatePicker.Panel=Class.create({initialize:function(options){try{this.i18n=new Control.DatePicker.i18n(options&&options.locale?options.locale:"en_US");options=this.i18n.inheritOptions(options)}catch(e){this.i18n=new Control.DatePicker.i18n()}this.options=Object.extend({className:"datepickerControl",closeOnToday:true,selectToday:true,datePicker:true,timePicker:false,use24hrs:false,firstWeekDay:0,weekend:[0,6],months:["January","February","March","April","May","June","July","August","September","October","November","December"],days:["Su","Mo","Tu","We","Th","Fr","Sa"]},options||{});with(this.options){if(isNaN(firstWeekDay*1)){firstWeekDay=0}else{firstWeekDay=firstWeekDay%7}}this.keysCaptured=false;this.calendarCont=null;this.currentDate=this.options.date?this.options.date:new Date();this.dayOfWeek=0;this.minInterval=5;this.selectedDay=null;this.selectedHour=null;this.selectedMinute=null;this.selectedAmPm=null;this.currentDays=[];this.hourCells=[];this.minuteCells=[];this.otherMinutes=null;this.amCell=null;this.pmCell=null;this.element=this.createPicker();this.selectDate(this.currentDate)},createPicker:function(){var a=document.createElement("div");a.style.position="absolute";a.className=this.options.className;this.calendarCont=this.drawCalendar(a,this.currentDate);Event.observe(a,"click",this.clickHandler.bindAsEventListener(this));Event.observe(a,"dblclick",this.dblClickHandler.bindAsEventListener(this));this.documentKeyListener=this.keyHandler.bindAsEventListener(this);if(this.options.captureKeys){this.captureKeys()}return a},tr:function(a){return this.i18n.tr(a)},captureKeys:function(){Event.observe(document,"keydown",this.documentKeyListener,true);this.keysCaptured=true},releaseKeys:function(){Event.stopObserving(document,"keydown",this.documentKeyListener,true);this.keysCaptured=false},setDate:function(a){if(a){while(this.element.firstChild){this.element.removeChild(this.element.firstChild)}this.calendarCont=this.drawCalendar(this.element,a)}},drawCalendar:function(a,d){var l=a;if(!this.options.datePicker){var n=document.createElement("table");n.cellSpacing=0;n.cellPadding=0;n.border=0}else{var n=this.createCalendar(d)}var m=this.options.use24hrs?6:7;if(this.options.timePicker){var e;if(this.options.timePickerAdjacent&&this.options.datePicker){var q=0;var b=document.createElement("table");b.cellSpacing=0;b.cellPadding=0;b.border=0;row=b.insertRow(0);cell=row.insertCell(0);cell.vAlign="top";cell.appendChild(n);l=cell;cell=row.insertCell(1);cell.style.width="5px";cell=row.insertCell(2);cell.vAlign="top";e=document.createElement("table");e.cellSpacing=0;e.cellPadding=0;e.border=0;cell.appendChild(e);a.appendChild(b);row=e.insertRow(q++);row.className="monthLabel";cell=row.insertCell(0);cell.colSpan=m;cell.innerHTML=this.tr("Time");row=e.insertRow(q++);cell=row.insertCell(0);cell.colSpan=m;cell.style.height="1px"}else{a.appendChild(n);e=n;var q=n.rows.length;if(this.options.datePicker){row=e.insertRow(q++);cell=row.insertCell(0);cell.colSpan=m;var p=document.createElement("hr");Element.setStyle(p,{color:"gray",backgroundColor:"gray",height:"1px",border:"0",marginTop:"3px",marginBottom:"3px",padding:"0"});cell.appendChild(p)}}var k=this.options.use24hrs?4:2;for(var g=0;g"+this.tr("Exact minutes")+":";cell=row.insertCell(1);cell.className="otherminute";var f=document.createElement("input");f.type="text";f.maxLength=2;f.style.width="2em";var c=null;f.onkeyup=function(i){if(!isNaN(f.value)){c=setTimeout(function(){this.currentDate.setMinutes(f.value);this.dateChanged(this.currentDate)}.bind(this),500)}}.bindAsEventListener(this);f.onkeydown=function(i){if(i.keyCode==Event.KEY_RETURN){if(this.options.onSelect){this.options.onSelect(this.currentDate)}}if(c){clearTimeout(c)}}.bindAsEventListener(this);f.onclick=f.select;f.onfocus=this.releaseKeys.bindAsEventListener(this);f.onblur=this.captureKeys.bindAsEventListener(this);this.otherMinutes=f;cell.appendChild(f);if(!this.options.use24hrs){cell=row.insertCell(2)}row=e.insertRow(q++);cell=row.insertCell(0);cell.colSpan=m;p=document.createElement("hr");Element.setStyle(p,{color:"gray",backgroundColor:"gray",height:"1px",border:"0",marginTop:"3px",marginBottom:"3px",padding:"0"});cell.appendChild(p);row=e.insertRow(q++);cell=row.insertCell(0);cell.colSpan=m;selectButton=document.createElement("input");selectButton.type="button";if(this.options.datePicker){selectButton.value=this.tr("Select Date and Time")}else{selectButton.value=this.tr("Select Time")}selectButton.onclick=function(i){this.options.onSelect&&this.options.onSelect(this.currentDate)}.bindAsEventListener(this);cell.appendChild(selectButton)}else{l.appendChild(n)}return l},createCalendar:function(d){this.currentDate=d;this.currentDays=[];var l=new Date();var b=new Date(d.getFullYear()-1,d.getMonth(),1);var a=new Date(d.getFullYear(),d.getMonth()-1,1);var h=new Date(d.getFullYear(),d.getMonth()+1,1);var n=new Date(d.getFullYear()+1,d.getMonth(),1);var q;var o;var p=0;var k=document.createElement("table");k.cellSpacing=0;k.cellPadding=0;k.border=0;q=k.insertRow(p++);q.className="monthLabel";o=q.insertCell(0);o.colSpan=7;o.innerHTML=this.monthName(d.getMonth())+" "+d.getFullYear();q=k.insertRow(p++);q.className="navigation";o=q.insertCell(0);o.className="navbutton";o.title=this.monthName(b.getMonth())+" "+b.getFullYear();o.onclick=this.movePreviousYearListener();o.innerHTML="<<";o=q.insertCell(1);o.className="navbutton";o.title=this.monthName(a.getMonth())+" "+a.getFullYear();o.onclick=this.movePreviousMonthListener();o.innerHTML="<";o=q.insertCell(2);o.colSpan=3;o.className="navbutton";o.title=l.getDate()+" "+this.monthName(l.getMonth())+" "+l.getFullYear();o.onclick=this.dateClickedListener(l,true);if(this.options.timePicker){o.innerHTML=this.tr("Now")}else{o.innerHTML=this.tr("Today")}o=q.insertCell(3);o.className="navbutton";o.title=this.monthName(h.getMonth())+" "+h.getFullYear();o.onclick=this.moveNextMonthListener();o.innerHTML=">";o=q.insertCell(4);o.className="navbutton";o.title=this.monthName(n.getMonth())+" "+n.getFullYear();o.onclick=this.moveNextYearListener();o.innerHTML=">>";q=k.insertRow(p++);q.className="dayLabel";for(var g=0;g<7;++g){o=q.insertCell(g);o.width="14%";o.innerHTML=this.dayName((this.options.firstWeekDay+g)%7)}q=null;var c=new Date(d.getFullYear(),d.getMonth(),1);var m=c.getDay();var f=0;if(m!=this.options.firstWeekDay){q=k.insertRow(p++);q.className="calendarRow";c.setDate(c.getDate()-((m-this.options.firstWeekDay+7)%7));m=c.getDay();while(c.getMonth()!=d.getMonth()){o=q.insertCell(q.cells.length);this.assignDayClasses(o,"dayothermonth",c);o.innerHTML=c.getDate();o.onclick=this.dateClickedListener(c);c.setDate(c.getDate()+1);m=c.getDay()}}while(c.getMonth()==d.getMonth()){if(m==this.options.firstWeekDay){q=k.insertRow(p++);q.className="calendarRow"}o=q.insertCell(q.cells.length);this.assignDayClasses(o,"day",c);o.innerHTML=c.getDate();o.onclick=this.dateClickedListener(c);this.currentDays[c.getDate()]=o;c.setDate(c.getDate()+1);m=c.getDay()}if(m!=this.options.firstWeekDay){do{o=q.insertCell(q.cells.length);this.assignDayClasses(o,"dayothermonth",c);o.innerHTML=c.getDate();var e=new Date(c.getTime());o.onclick=this.dateClickedListener(c);c.setDate(c.getDate()+1);m=c.getDay()}while(c.getDay()!=this.options.firstWeekDay)}return k},movePreviousMonthListener:function(){return function(a){var b=new Date(this.currentDate.getFullYear(),this.currentDate.getMonth()-1,this.currentDate.getDate(),this.currentDate.getHours(),this.currentDate.getMinutes());if(b.getMonth()!=(this.currentDate.getMonth()+11)){b.setDate(0)}this.selectDate(b)}.bindAsEventListener(this)},moveNextMonthListener:function(){return function(b){var a=new Date(this.currentDate.getFullYear(),this.currentDate.getMonth()+1,this.currentDate.getDate(),this.currentDate.getHours(),this.currentDate.getMinutes());if(a.getMonth()!=(this.currentDate.getMonth()+1)){a.setDate(0)}this.selectDate(a)}.bindAsEventListener(this)},moveNextYearListener:function(){return function(a){var b=new Date(this.currentDate.getFullYear()+1,this.currentDate.getMonth(),this.currentDate.getDate(),this.currentDate.getHours(),this.currentDate.getMinutes());if(b.getMonth()!=this.currentDate.getMonth()){b.setDate(0)}this.selectDate(b)}.bindAsEventListener(this)},movePreviousYearListener:function(){return function(b){var a=new Date(this.currentDate.getFullYear()-1,this.currentDate.getMonth(),this.currentDate.getDate(),this.currentDate.getHours(),this.currentDate.getMinutes());if(a.getMonth()!=this.currentDate.getMonth()){a.setDate(0)}this.selectDate(a)}.bindAsEventListener(this)},dateClickedListener:function(a,b){var c=new Date(a.getTime());return function(d){if(!b){c.setHours(this.currentDate.getHours());c.setMinutes(this.currentDate.getMinutes())}this.dateClicked(c)}.bindAsEventListener(this)},hourClickedListener:function(a){return function(b){this.hourClicked(a)}.bindAsEventListener(this)},minuteClickedListener:function(a){return function(b){this.currentDate.setMinutes(a);this.dateClicked(this.currentDate)}.bindAsEventListener(this)},amClickedListener:function(){return function(a){if(this.selectedAmPm==this.pmCell){this.currentDate.setHours(this.currentDate.getHours()-12);this.dateClicked(this.currentDate)}}.bindAsEventListener(this)},pmClickedListener:function(){return function(a){if(this.selectedAmPm==this.amCell){this.currentDate.setHours(this.currentDate.getHours()+12);this.dateClicked(this.currentDate)}}.bindAsEventListener(this)},assignDayClasses:function(a,d,c){var b=new Date();Element.addClassName(a,d);if(c.getFullYear()==b.getFullYear()&&c.getMonth()==b.getMonth()&&c.getDate()==b.getDate()){Element.addClassName(a,"today")}if(this.options.weekend.include(c.getDay())){Element.addClassName(a,"weekend")}},monthName:function(a){return this.options.months[a]},dayName:function(a){return this.options.days[a]},dblClickHandler:function(a){if(this.options.onSelect){this.options.onSelect(this.currentDate)}Event.stop(a)},clickHandler:function(a){if(this.options.onClick){this.options.onClick()}Event.stop(a)},hoverHandler:function(a){if(this.options.onHover){this.options.onHover(date)}},keyHandler:function(c){var d=0;switch(c.keyCode){case Event.KEY_RETURN:if(this.options.onSelect){this.options.onSelect(this.currentDate)}break;case Event.KEY_LEFT:d=-1;break;case Event.KEY_UP:d=-7;break;case Event.KEY_RIGHT:d=1;break;case Event.KEY_DOWN:d=7;break;case 33:var b=new Date(this.currentDate.getFullYear(),this.currentDate.getMonth()-1,this.currentDate.getDate());d=-this.getDaysOfMonth(b);break;case 34:d=this.getDaysOfMonth(this.currentDate);break;case 13:this.dateClicked(this.currentDate);break;default:return}if(d!=0){var a=new Date(this.currentDate.getFullYear(),this.currentDate.getMonth(),this.currentDate.getDate()+d);a.setHours(this.currentDate.getHours());a.setMinutes(this.currentDate.getMinutes());this.selectDate(a)}Event.stop(c);return false},getDaysOfMonth:function(a){var b=new Date(a.getFullYear(),a.getMonth()+1,0);return b.getDate()},getNextMonth:function(c,b,a){if(p_Month==11){return[0,b+1]}else{return[c+1,b]}},getPrevMonth:function(c,b,a){if(p_Month==0){return[11,b-1]}else{return[c-1,b]}},dateClicked:function(a){if(a){if(!this.options.timePicker&&this.options.onSelect){this.options.onSelect(a)}this.selectDate(a)}},dateChanged:function(a){if(a){if((!this.options.timePicker||!this.options.datePicker)&&this.options.onHover){this.options.onHover(a)}this.selectDate(a)}},hourClicked:function(a){if(!this.options.use24hrs){if(a==12){if(this.selectedAmPm==this.amCell){a=0}}else{if(this.selectedAmPm==this.pmCell){a+=12}}}this.currentDate.setHours(a);this.dateClicked(this.currentDate)},selectDate:function(b){if(b){if(this.options.datePicker){if(b.getMonth()!=this.currentDate.getMonth()||b.getFullYear()!=this.currentDate.getFullYear()){this.setDate(b)}else{this.currentDate=b}if(b.getDate()9?"":"0")+a},compareDates:function(e,f,c,d){var b=Control.DatePicker.DateFormat.parseFormat(e,f);var a=Control.DatePicker.DateFormat.parseFormat(c,d);if(b==0||a==0){return -1}else{if(b>a){return 1}}return 0},format:function(L,G){var P=Control.DatePicker.DateFormat.LZ;var l=Control.DatePicker.DateFormat.MONTH_NAMES;var x=Control.DatePicker.DateFormat.DAY_NAMES;G=G+"";var n="";var w=0;var J="";var f="";var j=L.getYear()+"";var g=L.getMonth()+1;var I=L.getDate();var p=L.getDay();var o=L.getHours();var A=L.getMinutes();var r=L.getSeconds();var u,v,b,t,N,e,F,D,B,q,Q,o,O,i,a,C;var z=new Object();if(j.length<4){j=""+(j-0+1900)}z.y=""+j;z.yyyy=j;z.yy=j.substring(2,4);z.M=g;z.MM=P(g);z.MMM=l[g-1];z.NNN=l[g+11];z.d=I;z.dd=P(I);z.E=x[p+7];z.EE=x[p];z.H=o;z.HH=P(o);if(o==0){z.h=12}else{if(o>12){z.h=o-12}else{z.h=o}}z.hh=P(z.h);if(o>11){z.K=o-12}else{z.K=o}z.k=o+1;z.KK=P(z.K);z.kk=P(z.k);if(o>11){z.a="PM"}else{z.a="AM"}z.m=A;z.mm=P(A);z.s=r;z.ss=P(r);while(w=e;a--){var b=f.substring(d,d+a);if(b.length70){k=1900+(k-0)}else{k=2000+(k-0)}}}else{if(f=="MMM"||f=="NNN"){v=0;for(var q=0;q11)){v=q+1;if(v>12){v-=12}A+=e.length;break}}}if((v<1)||(v>12)){return 0}}else{if(f=="EE"||f=="E"){for(var q=0;q12)){return 0}A+=v.length}else{if(f=="dd"||f=="d"){u=w(C,A,f.length,2);if(u==null||(u<1)||(u>31)){return 0}A+=u.length}else{if(f=="hh"||f=="h"){d=w(C,A,f.length,2);if(d==null||(d<1)||(d>12)){return 0}A+=d.length}else{if(f=="HH"||f=="H"){d=w(C,A,f.length,2);if(d==null||(d<0)||(d>23)){return 0}A+=d.length}else{if(f=="KK"||f=="K"){d=w(C,A,f.length,2);if(d==null||(d<0)||(d>11)){return 0}A+=d.length}else{if(f=="kk"||f=="k"){d=w(C,A,f.length,2);if(d==null||(d<1)||(d>24)){return 0}A+=d.length;d--}else{if(f=="mm"||f=="m"){r=w(C,A,f.length,2);if(r==null||(r<0)||(r>59)){return 0}A+=r.length}else{if(f=="ss"||f=="s"){p=w(C,A,f.length,2);if(p==null||(p<0)||(p>59)){return 0}A+=p.length}else{if(f=="a"){if(C.substring(A,A+2).toLowerCase()=="am"){l="AM"}else{if(C.substring(A,A+2).toLowerCase()=="pm"){l="PM"}else{return 0}}A+=2}else{if(C.substring(A,A+f.length)!=f){return 0}else{A+=f.length}}}}}}}}}}}}}}if(A!=C.length){return 0}if(v==2){if(((k%4==0)&&(k0!=0))||(k%400==0)){if(u>29){return 0}}else{if(u>28){return 0}}}if((v==4)||(v==6)||(v==9)||(v==11)){if(u>30){return 0}}if(d<12&&l=="PM"){d=d-0+12}else{if(d>11&&l=="AM"){d-=12}}var a=new Date(k,v-1,u,d,r,p);return a},parse:function(b,m){if(m){return Control.DatePicker.DateFormat.parseFormat(b,m)}else{var h=(arguments.length==2)?arguments[1]:false;var n=new Array("y-M-d","MMM d, y","MMM d,y","y-MMM-d","d-MMM-y","MMM d");var c=new Array("M/d/y","M-d-y","M.d.y","MMM-d","M/d","M-d");var o=new Array("d/M/y","d-M-y","d.M.y","d-MMM","d/M","d-M");var a=[n,h?o:c,h?c:o];var k=null;for(var g=0;g
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: js java net 日历控件
 输入关键字,在本站1000多万海量源码库中尽情搜索: