jsMonthView1.1。对日期的判断更加精准,另外增加了自定义属性的
来源:岁月联盟
时间:2003-07-11
var theTextObject = this.Source;
if (theTextObject == null){
return;
}
var theName = this.Name;
var theYearObject = document.all.item(theName + "_YearList");
var theMonthObject = document.all.item(theName + "_MonthList");
var tmpYear = theYear;
var tmpMonth = theMonth;
var tmpDay = 1;
if (tmpMonth < 0){
tmpYear--;
tmpMonth = 11;
}
if (tmpMonth > 11){
tmpYear++;
tmpMonth = 0;
}
if (tmpYear < this.MinYear){
tmpYear = this.MinYear;
}
if (tmpYear > this.MaxYear){
tmpYear = this.MaxYear;
}
if (theDay < 1){
tmpDay = 1;
}else{
tmpDay = this.GetMonthDays(tmpYear, tmpMonth);
if (theDay < tmpDay){
tmpDay = theDay;
}
}
theYearObject.value = tmpYear;
theMonthObject.value = tmpMonth;
this.setDayList(tmpYear, tmpMonth, tmpDay);
theTextObject.value = this.SetDateFormat(tmpYear, tmpMonth, tmpDay);
theTextObject.select();
}
this.UpdateMonthGrid = function(theObject){ //run this.CreateMonthGrid() by theObject
var theTextObject = this.Source;
if (theTextObject == null){
return;
}
var theName = this.Name;
var theYearObject = document.all.item(theName + "_YearList");
var theMonthObject = document.all.item(theName + "_MonthList");
var theDayObject = document.all.item(theName + "_DayList");
var tmpName = theObject.id.substr(theObject.id.lastIndexOf("_"));
switch (tmpName){
case "_goPreviousMonth": //go previous month button
theObject.disabled = true;
this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10) - 1, parseInt(theDayObject.value, 10));
theObject.disabled = false;
break;
case "_goNextMonth": //go next month button
theObject.disabled = true;
this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10) + 1, parseInt(theDayObject.value, 10));
theObject.disabled = false;
break;
case "_YearList": //year list
this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10));
break;
case "_MonthList": //month list
this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10));
break;
default:
return;
}
}
this.DeleteMonthGrid = function( ){ //check document focus, if blur this.Source then delete this
var theName = this.Name;
var theDivObject = document.all.item(theName + "_MonthView");
if (theDivObject == null){
return;
}
var tmpObject = document.activeElement;
while (tmpObject != null){
if (tmpObject == this.Source){
return;
}
//if (tmpObject.id == theName + "_MonthView"){
// return;
/