RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>Java>列表

日历控件

来源: 作者: 时间:2007-09-18 点击:


var cw = WebCalendar.calendar.clientWidth, ch = WebCalendar.calendar.clientHeight;
var dw = document.body.clientWidth, dl = document.body.scrollLeft, dt = document.body.scrollTop;

try{
if (WebCalendar.objExport.value.trim() != ""){
WebCalendar.dateStyle = WebCalendar.objExport.value.trim().match(WebCalendar.dateReg);
if (WebCalendar.dateStyle == null)
{
WebCalendar.thisYear = new Date().getFullYear();
WebCalendar.thisMonth = new Date().getMonth()+ 1;
WebCalendar.thisDay = new Date().getDate();
WebCalendar.thisHour = new Date().getHours();
WebCalendar.thisMinute = new Date().getMinutes();
WebCalendar.thisSecond = new Date().getSeconds();
writeCalendar(); return false;
}
else
{
if(/^(y{4})(-|\/)(M{1,2})\2(d{1,2})$/.test(WebCalendar.format) ||
/^(y{4})(-|\/)(M{1,2})\2(d{1,2}) (HH:mm:ss)$/.test(WebCalendar.format))
{
WebCalendar.thisYear = parseInt(WebCalendar.dateStyle[1], 10);
WebCalendar.thisMonth = parseInt(WebCalendar.dateStyle[3], 10);
WebCalendar.thisDay = parseInt(WebCalendar.dateStyle[4], 10);
WebCalendar.thisHour = parseInt(WebCalendar.dateStyle[5], 10);
WebCalendar.thisMinute = parseInt(WebCalendar.dateStyle[6], 10);
WebCalendar.thisSecond = parseInt(WebCalendar.dateStyle[7], 10);
}
else
{
WebCalendar.thisYear = parseInt(WebCalendar.dateStyle[1], 10);
WebCalendar.thisMonth = parseInt(WebCalendar.dateStyle[2], 10);
WebCalendar.thisDay = parseInt(WebCalendar.dateStyle[3], 10);
WebCalendar.thisHour = parseInt(WebCalendar.dateStyle[4], 10);
WebCalendar.thisMinute = parseInt(WebCalendar.dateStyle[5], 10);
WebCalendar.thisSecond = parseInt(WebCalendar.dateStyle[6], 10);
}
WebCalendar.inputDate = parseInt(WebCalendar.thisDay, 10) +"/"+ parseInt(WebCalendar.thisMonth, 10) +"/"+
parseInt(WebCalendar.thisYear, 10);
writeCalendar();
WebCalendar.isOpen = true;
}
} else {
WebCalendar.thisYear = new Date().getFullYear();
WebCalendar.thisMonth = new Date().getMonth()+ 1;
WebCalendar.thisDay = new Date().getDate();
WebCalendar.thisHour = new Date().getHours();
WebCalendar.thisMinute = new Date().getMinutes();
WebCalendar.thisSecond = new Date().getSeconds();
writeCalendar(); WebCalendar.isOpen = true; }
} catch(e){ writeCalendar(); WebCalendar.isOpen = true; }
}
else
{
hiddenCalendar();
}
}

function funBindTo(target) //将日历绑至某一控件下
{
var t = target.offsetTop, h = target.clientHeight, l = target.offsetLeft, p = target.type;
var o = WebCalendar.calendar.style;

while (target = target.offsetParent)
{t += target.offsetTop; l += target.offsetLeft; }

var cw = parseInt(o.width), ch = parseInt(o.height);
var dw = document.body.clientWidth, dl = document.body.scrollLeft, dt = document.body.scrollTop, dh = document.body.clientHeight;

if (dh + dt - t - h >= ch)
o.top = (p=="image")? t + h : t + h + 6;
else
o.top = (t - dt < ch) ? ((p=="image")? t + h : t + h + 6) : (t - ch);
if (dw + dl - l >= cw)
o.left = l;
else
o.left = (dw >= cw) ? dw - cw + dl : dl;
}

function funMonthSelect() //月份的下拉框
{
var m = isNaN(parseInt(WebCalendar.thisMonth, 10)) ? new Date().getMonth() + 1 : parseInt(WebCalendar.thisMonth);
var e = WebCalendar.iframe.document.forms[0].tmpMonthSelect;
for (var i=1; i<13; i++) e.options.add(new Option(i, i)); // +"月"
e.style.display = ""; e.value = m; e.focus(); window.status = e.style.top; //??
}

function funYearSelect() //年份的下拉框
{
var n = WebCalendar.yearFall;
var e = WebCalendar.iframe.document.forms[0].tmpYearSelect;
var y = isNaN(parseInt(WebCalendar.thisYear, 10)) ? new Date().getFullYear() : parseInt(WebCalendar.thisYear);

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
Google Adsense
相关文章