`

JSCalendar.js

阅读更多
来自互联网

<!--
<!--
/**
*
* JSCalendar
*
* Author           :H.Z. Shang (Jack)
* Email            :shhongzhang@cntomorrow.com
* Site             :http://www.cntomorrow.com:3310
* Version          :1.0.1
* Finished Date    :2003-3-2
* Beijing Huasun Mingtian Tech. Co., Ltd.
* No CopyRight,Can be modified by you if you want improve it's function!!!!
* LET'S MAKE IT BETTER TOGETHER!
* HISTORY:
*  1. [2003-3-4 by Jack] ²ÉÓÃIFRAMEÐÞÕýÁ˻ᱻҳÃæSELECT¶ÔÏóµ²×¡µÄBUG!
*  2. [2003-3-4 by Jack] Ôö¼ÓÁËÇå¿Õ¿Ø¼þÖµµÄ¹¦ÄÜ
*  3. [2003-3-5 by Jack] ÐÞÕýÁ˵±Óû§·­Äê¡¢·­ÔÂʱԭÊäÈë¿òÖµ±»¸²¸ÇµÄÇé¿ö
*  4. [2003-3-5 by Jack] ͨ¹ýʹÓÃDXImageTransform.Microsoft.ShadowÀ´ÊµÏÖIFRAMEµÄÒõӰЧ¹û
*                        ¸ÃÂ˾µÖ»ÄÜÔÚIE5.5ÏÂʹÓÿɼӿì³ÌÐòÔËÐÐËٶȣ¬ÔÚIE5.0Öл¹ÊÇʹÓÃÔ­À´µÄ²úÉúÒõÓ°µÄ·½·¨
*  5. [2003-3-6 by Jack] Ôö¼ÓÁËÁíÍâÒ»ÖÖÉú³É¸Ã¿Ø¼þµÄ·½·¨£º<script>createDateBox("Name", "2003-3-6")</script>
*                        ÆäÖеڶþ¸ö²ÎÊýΪ¿ÉÑ¡²ÎÊý
*/

var _cldTabIFrame = null;
var _cldTabIFrame2 = null;

var _cldTabFrm = null;
var _cldMonthMenuFrm = null;
var _curCldTabRltvObj = null;
var _bCanHide = true;
var _bHaveUpdated = false;
var _bHaveShown = false;

var _bHaveSelectNewValue = false;

var _dCurYear = null;
var _dCurMonth = null;
var _dCurDate = null;

var _curCldTabRltvObjValue = "";

/**
  * ÔÚ¸ÃÈÕÀú¿Ø¼þÖУ¬ÎÒ²ÉÓÃÁ˸ø¿Õ¼äÖÜΧ¼ÓÉÏÒõÓ°²ãÀ´ÔöÇ¿¿Ø¼þµÄÊÓ¾õ¸Ð¡£
  * _nShadowLength ±äÁ¿É趨ÁËÒõÓ°²ãµÄ³¤¶È£¬Ä¬ÈÏֵΪ 4£»
  * ʹÓÃÒõÓ°²ã½«ÏàÓ¦µÄÖÍ»º³ÌÐòµÄÔËÐÐËٶȣ¬Èç¹ûÄãÏëµÃµ½½Ï¿ìµÄÔËÐÐËٶȣ¬Ç뽫¸ÃÖµÉèΪ 0
  */
var _nShadowLength = 0;

/**
  * _sNeededFilePath ±äÁ¿É趨ÁËJSCalendar¿Ø¼þËùÐèµÄËùÓÐÎļþµÄλÖÃ
  * µ±Ä㽫ÄãµÄÓ¦Óò¿Êðµ½Ó¦Ó÷þÎñÆ÷ÉϺó£¬ÄãÐèÒª¸ø¸Ä±äÁ¿É趨ÏàÓ¦µÄÖµ¡£
  * ÀýÈ磺
  *  _sNeededFilePath = "/MyWebAPP/comm/js/JSCalendar/";
  *
  * ¸Ã±äÁ¿µÄÖµ±ØÐëÕýÈ·ÉèÖ㬷ñÔò³ÌÐòÔÚÔËÐÐÖпÉÄܳöÏÖ´íÎó£¡
  */

var _sNeededImagesFilePath = "../images/";
var _sNeededCSSFilePath = "../style/";


var _sBrowserVersion = navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE") + 5,navigator.appVersion.indexOf("Windows") - 2);
var _bBrowserVer55 = _sBrowserVersion >= 5.5 ? true : false;

/**
  * ¶¨ÒåËùÐèͼƬ
  *
  */
var _imgReset1 = new Image();
_imgReset1.src = _sNeededImagesFilePath + "reset1.gif";
var _imgReset2 = new Image();
_imgReset2.src = _sNeededImagesFilePath + "reset2.gif";
var _imgBtnYear = new Image();
_imgBtnYear.src = _sNeededImagesFilePath + "btnYears.gif";
var _imgBgToday1 = new Image();
_imgBgToday1.src = _sNeededImagesFilePath + "bgToday1.gif";

var _monthDays = new Array(12);
    _monthDays[ 0] = 31;
    _monthDays[ 1] = 28;
    _monthDays[ 2] = 31;
    _monthDays[ 3] = 30;
    _monthDays[ 4] = 31;
    _monthDays[ 5] = 30;
    _monthDays[ 6] = 31;
    _monthDays[ 7] = 31;
    _monthDays[ 8] = 30;
    _monthDays[ 9] = 31;
    _monthDays[10] = 30;
    _monthDays[11] = 31;

var _weeks = new Array(7);   
_weeks[0] = "ÈÕ";
_weeks[1] = "Ò»";
_weeks[2] = "¶þ";
_weeks[3] = "Èý";
_weeks[4] = "ËÄ";
_weeks[5] = "Îå";
_weeks[6] = "Áù";
var _months = new Array(12);
_months[ 0] = "Ò»ÔÂ";
_months[ 1] = "¶þÔÂ";
_months[ 2] = "ÈýÔÂ";
_months[ 3] = "ËÄÔÂ";
_months[ 4] = "ÎåÔÂ";
_months[ 5] = "ÁùÔÂ";
_months[ 6] = "ÆßÔÂ";
_months[ 7] = "°ËÔÂ";
_months[ 8] = "¾ÅÔÂ";
_months[ 9] = "Ê®";
_months[10] = "ʮһÔÂ";
_months[11] = "Ê®¶þÔÂ";

var _dftD = new Date();
document.write("<IFRAME id=frm name=frm style='display:none'></IFRAME>");

function JSCalendar(rltvO, year, month, date){

if(_bHaveUpdated && rltvO == _curCldTabRltvObj) return;
if(rltvO.tagName != "INPUT"){alert("JSCalendar 1.0 alerts you:\n\n INPUT element(object) must be required!");return};

hideCldTabFrm();

//rltvO.readOnly = true;
rltvO.style.cursor = "default";
rltvO.style.textAlign = "center";
_curCldTabRltvObjValue = rltvO.value;
_bHaveSelectNewValue = false;
//------------------------------------------------------------------------------
this.createCldTabFrm = createCldTabFrm;
this.fillCldTabFrm = fillCldTabFrm;
this.placeCldTabFrm = placeCldTabFrm;
//------------------------------------------------------------------------------

this._rltvO = (rltvO == null ? document.body : rltvO);
var _oldDate = rltvO.value;
var _oldDateType = "From Input!";
try{
  if(_oldDate == "") throw "";
  var d = _oldDate.split("-");
  var _tmpDate = getValidateDate(_oldDate);
  this._year  = _tmpDate.getFullYear();
  this._month = _tmpDate.getMonth();
  this._date  = _tmpDate.getDate();
}catch(e){
  _debug("Error was be catched:" + e.description);
  _oldDateType = "From default or current date!";
  this._year = (year == null ? _dftD.getFullYear() : year);
  this._month = (month == null ? _dftD.getMonth() : month - 1);;
  this._date = (date == null ? _dftD.getDate() : date);
}
//alert(this._year + "-" + (this._month + 1) + "-" + this._date );
_dCurYear = this._year;
_dCurMonth = this._month;
_dCurDate = this._date;

if(_cldTabIFrame == null)
  this.createCldTabFrm();
 
//alert(_cldTabIFrame2)
_cldTabIFrame2.style.display = "inline";

_debug(_oldDateType + "[]" + this._year + "-" + (this._month + 1) + "-" + this._date);
this.fillCldTabFrm(this._year, this._month, this._date);
if(!_bHaveShown || rltvO != _curCldTabRltvObj) this.placeCldTabFrm();

//_cldTabIFrame2.style.display = "inline";

if(!_bBrowserVer55){
  removeShadowDiv();
  MakeDivShadowEffect(_cldTabFrm, '#aaaaaa', _nShadowLength);
}
_curCldTabRltvObj = this._rltvO;

_bHaveUpdated = true;
_bHaveShown = true;
}
function createCldTabFrm(){
var _sz = "<HTML>"
   + "<HEAD><link href='" +_sNeededCSSFilePath + "JSCalendar.css' rel=stylesheet type='text/css'></HEAD>"
   + "<BODY onselectstart='return false;' leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 style='cursor:default;background-color:transparent;border:0px solid black;scroll:no'>"
   + "</BODY></HTML>";
_cldTabIFrame = frm;//document.all("frm");//document.createElement("IFRAME");
_cldTabIFrame2 = document.all("frm");
_cldTabIFrame2.style.position = "absolute";

//_cldTabIFrame2.document.body.scroll = "no";
//_cldTabIFrame2.style.pixelWidth = /*_innerTabFrmRect.right - _innerTabFrmRect.left*/  //375 + _nShadowLength;
//_cldTabIFrame2.style.pixelHeight = /*_innerTabFrmRect.bottom - _innerTabFrmRect.top*/ 165 + _nShadowLength;
//_cldTabIFrame2.allowTransparency = true;
if(_bBrowserVer55)
  _cldTabIFrame2.style.filter = "progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#aaaaaa,strength=" + _nShadowLength + ")";

_cldTabIFrame.document.open("text/html","replace");
_cldTabIFrame.document.write(_sz);
_cldTabIFrame.document.close();
_cldTabFrm = _cldTabIFrame.document.createElement("TABLE");
_cldTabFrm.id = "JACKSHANGJIELOVEFEIFEI"
_cldTabFrm.style.position = "absolute";
_cldTabFrm.className = "calendar";
_cldTabFrm.border = 0;
_cldTabFrm.height = 165;
_cldTabFrm.style.pixelWidth = 220;
_cldTabFrm.cellSpacing = 1;
_cldTabFrm.cellPadding = 1;
_cldTabFrm.bgColor = "ffffff";
_cldTabFrm.attachEvent("onmouseover", whenMouseOverCldTabFrm);
_cldTabFrm.attachEvent("onmouseout", whenMouseOutCldTabFrm);
// Create Calendar Control header
var _TR = _cldTabFrm.insertRow();
var _TD = _TR.insertCell();
_TD.colSpan = 7;
_TD.align = "center";
_TD.innerHTML = "&nbsp;";//"<b>JS Calendar 1.0 by Jack</b>"; 
// Create main block
for(var i = 0; i < 7; i++){
  _TR = _cldTabFrm.insertRow();
  for(var j = 0; j < 7; j++){
   _TD = _TR.insertCell();
   _TD.style.cursor = "default";
   _TD.align = "center";
   _TD.width = 50;
   //_TD.style.border = "1px solid black";
   _TD.innerHTML = "*";
   if(i != 0){
    _TD.style.cursor = "hand";
    _TD.attachEvent("onmouseover", whenMouseOverDateItem);
    _TD.attachEvent("onmouseout", whenMouseOutDateItem);
    _TD.attachEvent("onclick", whenClickDateItem);
   }
   if(i == 0) _TD.innerHTML = "<b>" + _weeks[j] + "</b>";
   if(i == 0 && (j == 0 || j == 6)) _TD.className = "tdHoliday";
  }
}
// Create footer
_TR = _cldTabFrm.insertRow(2);
_TD = _TR.insertCell();
_TD.colSpan = 7;
_TD.height = 1;
_TD.bgColor = "black";
_TR = _cldTabFrm.insertRow();
_TD = _TR.insertCell();
_TD.colSpan = 7;
_TD.innerHTML = "<table cellspacing=0 cellpadding=0 class=calendar style='border:0px solid;width:100%'>"
  + "<tr><td title=   'Ñ¡Ôñ½ñÌì'style='cursor:hand'onclick=\"parent._bHaveSelectNewValue=true;parent.setTargetFormaValue(" + _dftD.getFullYear() + "," + (_dftD.getMonth() + 1) + "," + _dftD.getDate() + ");parent.hideCldTabFrm();return;parent.fillCldTabFrm(" + _dftD.getFullYear() + "," + _dftD.getMonth() + "," + _dftD.getDate() + ");\">"
  + "<b>&nbsp;<img src='" + _imgBgToday1.src + "' width=30px>½ñÌì: " + _dftD.getFullYear() + "-" + (_dftD.getMonth() + 1) + "-" + _dftD.getDate()
  + "</td>"
  + "<td width=30px>"
  + "<img style='cursor:hand' onclick=parent.resetTargetValue() title='Reset the target value.' src='" + _imgReset1.src + "' onmouseover=this.src='" + _imgReset2.src + "' onmouseout=this.src='" + _imgReset1.src + "'></td>"
  + "<td align=right class=smallFont></td></tr></table>";

_cldTabIFrame.document.body.insertBefore(_cldTabFrm);
}

function fillCldTabFrm(year, month, date){
//return;
var dCurDate = 0;
var dNextMonthDate = 1;
var iDateStartRow = 3;
//var _d = new Date(this._year, this._month, 1);
var _d = new Date(year, month, 1);
//alert(year + "-" + month + "-" + date);
var _day = _d.getDay();
var _td = null;

_dCurYear = year;
_dCurMonth = month;
_dCurDate = date;

if (((_dCurYear % 4 == 0) && !(_dCurYear % 100 == 0))
  ||(_dCurYear % 400 == 0)) _monthDays[1] = 29;
else _monthDays[1] = 28;
  
_cldTabFrm.rows(0).cells(0).innerHTML
  = "<table bgcolor=420042 class=calendar style=\"color:white;font-weight:bolder;border:0px solid;width:100%;height:20px;\" cellspacing=0 cellpadding=0>"
  + "<tr><td>"
  + "&nbsp;<a style='cursor:hand' title='Last Month' onclick=\"parent.switchLastMonth()\"><<</a>"
  + "</td>"
  + "<td align=center vAlign=middle>"
  + "<map name=mapForBtnYears><area title='Next Year' onclick=parent.switchLastYear() shape=rect coords=0,0,10,5><area title='Last Year' onclick=parent.switchNextYear() shape=rect coords=0,5,10,15></map>" 
  + "" + _months[_dCurMonth] + " , " + _dCurYear
  + "&nbsp;<img border=0 align=absMiddle src='" + _imgBtnYear.src + "' style='height:12px;width:10px' usemap=#mapForBtnYears>&nbsp;"
  + "</td>"
  + "<td align=right>"
  + "<a style='cursor:hand' title='Next Month' onclick=\"parent.switchNextMonth()\">>></a>&nbsp"
  + "</td></tr></table>"
  
_day = (_day == 0 ? 7 : _day);

for(var i = _day - 1, dlt = 0; i >= 0; i--){
  _td = _cldTabFrm.rows(iDateStartRow).cells(i);
  //_td.disabled = true;
  _td.className = "lastMonth";
  _td.title = "";
  _td.name = "LASTMONTH";
  _td.style.backgroundColor = "transparent";
  _td.style.border = "0px solid";
  var _nextMonth = _dCurMonth - 1;
  if(_nextMonth < 0) _nextMonth = 11;
  _td.innerText = (_monthDays[_nextMonth] - (dlt++));
}
//alert(_cldTabFrm.rows.length);
i = _day;
for(var d = 1, iRow = iDateStartRow; d <= _monthDays[_dCurMonth] || iRow < 9; ){
  for(; i < 7; i++){
   dCurDate = d++;
   _td = _cldTabFrm.rows(iRow).cells(i);
   _td.disabled = false;
   _td.className = "normal";
   _td.name = "CURRENTMONTH";
   _td.style.backgroundColor = "transparent";
   _td.style.border = "0px solid";
   if(i == 0 || i == 6) _td.className = "tdHoliday";
   if(d - 1 > _monthDays[_dCurMonth]){
    dCurDate = dNextMonthDate++;
    //_td.disabled = true;
    _td.className = "nextMonth";
    _td.name = "NEXTMONTH";
   }
   //if(dCurDate < 10) dCurDate = "0" + dCurDate;
   _td.innerHTML = dCurDate;

   if(dCurDate == _dCurDate && _td.name == "CURRENTMONTH"){
    //_cldTabFrm.rows(iRow).cells(i).style.backgroundColor = "620662";
    //_cldTabFrm.rows(iRow).cells(i).background = "bgCurDate.gif";
    _cldTabFrm.rows(iRow).cells(i).className = "tdCurDate";
   }
   if(dCurDate == _dftD.getDate()
    && _dCurMonth == _dftD.getMonth()
    && _dCurYear == _dftD.getFullYear()
    && _td.name == "CURRENTMONTH"){
    _cldTabFrm.rows(iRow).cells(i).className = "tdToday";
    if(dCurDate == _dCurDate)
     _cldTabFrm.rows(iRow).cells(i).className = "tdTodayCurDate";
   }
   if(dCurDate == _dftD.getDate() && dCurDate == _dCurDate && _td.name == "CURRENTMONTH"){
    //_td.style.backgroundColor = "#663366";
    //_td.style.border = "1px solid gray";
    //_cldTabFrm.rows(iRow).cells(i).className = "tdTodayCurDate";
   }
  
  }
  i = 0;
  iRow++;
}
}
function placeCldTabFrm(){

var _rect = this._rltvO.getBoundingClientRect();
var _bodyWidth = document.body.clientWidth;
var _bodyHeight = document.body.clientHeight;

var _tmp = _cldTabIFrame;
//alert(_bodyHeight);
_cldTabIFrame = _cldTabIFrame2;

var _innerTabFrmRect = _cldTabFrm.getBoundingClientRect();
//_debug(_innerTabFrmRect.right + "," + _innerTabFrmRect.left)

_cldTabIFrame2.style.pixelWidth = /*_innerTabFrmRect.right - _innerTabFrmRect.left*/  220 + (_bBrowserVer55 ? 0 : _nShadowLength);
_cldTabIFrame2.style.pixelHeight = /*_innerTabFrmRect.bottom - _innerTabFrmRect.top*/ 165+ (_bBrowserVer55 ? 0 : _nShadowLength);

_cldTabIFrame.style.pixelLeft = _rect.left - 2 + document.body.scrollLeft;
_cldTabIFrame.style.pixelTop = _rect.bottom - 2 + document.body.scrollTop;

var _cldTabFrmRect = _cldTabIFrame.getBoundingClientRect();
 
if(_cldTabFrmRect.right > _bodyWidth){
  _cldTabIFrame.style.pixelLeft -= (_cldTabFrmRect.right - _bodyWidth + _nShadowLength);
}

if(_cldTabFrmRect.bottom > _bodyHeight){
  //alert("dd");
  _cldTabIFrame.style.pixelTop = _rect.top - _nShadowLength;
  _cldTabIFrame.style.pixelTop -= (_cldTabFrmRect.bottom - _cldTabFrmRect.top - document.body.scrollTop);
}

//alert(_cldTabIFrame.style.pixelWidth);
_cldTabIFrame = _tmp;
//if(
}

function whenMouseOverCldTabFrm(){
_bCanHide = false;
}

function whenMouseOutCldTabFrm(){
_bCanHide = true;
}

function getNextDate(year, month, date){
if(date == null) date = 1;
if(date > _monthDays[month + 1]) date = _monthDays[month + 1];
return new Date(year, month + 1, date);
}

function getLastDate(year, month, date){
if(date == null) date = 1;
if(date > _monthDays[month - 1]) date = _monthDays[month - 1];
return new Date(year, month - 1, date);
}
function switchLastMonth(bLast){
if(bLast == null) bLast = true;
var _tmpdate = null;
_tmpdate = bLast ? getLastDate(_dCurYear, _dCurMonth, _dCurDate) : getNextDate(_dCurYear, _dCurMonth, _dCurDate);
//_curCldTabRltvObj.value = _tmpdate.getFullYear() + "-" + (_tmpdate.getMonth() + 1) + "-" + _tmpdate.getDate();
setTargetFormaValue(_tmpdate.getFullYear(), _tmpdate.getMonth() + 1, _tmpdate.getDate());
_bHaveUpdated = false;
//JSCalendar(_curCldTabRltvObj);
fillCldTabFrm(_tmpdate.getFullYear(), _tmpdate.getMonth(), _tmpdate.getDate());;
}
function switchNextMonth(){
switchLastMonth(false);
}
function switchLastYear(){
//_curCldTabRltvObj.value = (_dCurYear * 1 + 1) + "-" + (_dCurMonth + 1) + "-" + _dCurDate;
setTargetFormaValue(_dCurYear * 1 + 1, _dCurMonth * 1 + 1, _dCurDate);
_bHaveUpdated = false;
//JSCalendar(_curCldTabRltvObj);
fillCldTabFrm(_dCurYear * 1 + 1, _dCurMonth * 1, _dCurDate);
}
function switchNextYear(){
//_curCldTabRltvObj.value = (_dCurYear - 1) + "-" + (_dCurMonth + 1) + "-" + _dCurDate;
setTargetFormaValue(_dCurYear * 1 - 1, _dCurMonth * 1 + 1, _dCurDate);
_bHaveUpdated = false;
//JSCalendar(_curCldTabRltvObj);
fillCldTabFrm(_dCurYear * 1 - 1, _dCurMonth * 1, _dCurDate);
}
function whenMouseOverDateItem(){
var e = _cldTabIFrame.event.srcElement;
var _tmpdate = null;
if(e.tagName == "TD"){
  if(e.name == "LASTMONTH"){
   _tmpdate = getLastDate(_dCurYear, _dCurMonth);
   e.title = "Last : " + _tmpdate.getFullYear() + "-" + (_tmpdate.getMonth() + 1) + "-" + e.innerText;
   return;
  }
  if(e.name == "NEXTMONTH"){
   _tmpdate = getNextDate(_dCurYear, _dCurMonth);
   e.title = "Next : " + _tmpdate.getFullYear() + "-" + (_tmpdate.getMonth() + 1) + "-" + e.innerText;
   return;
  }

  var sCurDate = _dCurYear + "-" + (_dCurMonth + 1) + "-" + e.innerText;
  e.title = "µ±Ç°ÈÕÆÚ : " + sCurDate;
 
  e.style.backgroundColor = "#EFEFEF";
  /*È¥³ýonmouseoverʼþ¶ÔtextµÄ¸ºÖµ ÍõÓÂ*/
  //setTargetFormaValue(_dCurYear, _dCurMonth + 1, e.innerText);
}
}

function resetTargetValue(){
//_curCldTabRltvObj.value = ;
_bHaveSelectNewValue = true;
hideCldTabFrm();
}

function setTargetFormaValue(year, month, date){
var _year, _month, _date;
_year = year;
_month = month * 1;
_date = date * 1;
if(_month < 10) _month = "0" + _month;
if(_date < 10) _date = "0" + _date;

_curCldTabRltvObj.value = _year + "-" + _month + "-" + _date;
}

function whenMouseOutDateItem(){
var e = _cldTabIFrame.event.srcElement;
if(e.tagName == "TD")
  e.style.backgroundColor = "";
}
function whenClickDateItem(){
var e = _cldTabIFrame.event.srcElement;
var _tmpdate = null;
var _month = null;
var _date = null;
if(e.tagName == "TD"){
  _bHaveUpdated = false;
  if(e.name == "LASTMONTH"){
   _tmpdate = getLastDate(_dCurYear, _dCurMonth);
   setTargetFormaValue(_tmpdate.getFullYear(), _tmpdate.getMonth() + 1, e.innerText);
   fillCldTabFrm(_tmpdate.getFullYear(), _tmpdate.getMonth(), e.innerText);
   /* new */ //JSCalendar(_curCldTabRltvObj);
   return;
  }
  if(e.name == "NEXTMONTH"){
   _tmpdate = getNextDate(_dCurYear, _dCurMonth);
   setTargetFormaValue(_tmpdate.getFullYear(), _tmpdate.getMonth() + 1, e.innerText);
   /* new */ //JSCalendar(_curCldTabRltvObj);
   fillCldTabFrm(_tmpdate.getFullYear(), _tmpdate.getMonth(), e.innerText);
   return;
  }
  /*¶ÔtextµÄ¸ºÖµ¼ÓÈëµ½onclickʼþÖÐ ÍõÓÂ*/
  setTargetFormaValue(_dCurYear, _dCurMonth + 1, e.innerText);
  _bHaveSelectNewValue = true;
  hideCldTabFrm();
}
}

function hideCldTabFrm(){
//try{
if(!_bHaveSelectNewValue)
  if(_cldTabIFrame == null || !_bCanHide) return;
//alert(_cldTabIFrame); 
var oFiredObj = null;
try{
  oFiredObj = event.srcElement;
}catch(e){
  oFiredObj = _cldTabIFrame.event.srcElement;
}
if(oFiredObj == _curCldTabRltvObj) return;
//alert(_curCldTabRltvObj);//
 
_cldTabIFrame2.style.display = "none";
_bHaveUpdated = false;
_bHaveShown = false;
removeShadowDiv();
//alert(_bHaveSelectNewValue);
if(!_bHaveSelectNewValue)
  _curCldTabRltvObj.value = _curCldTabRltvObjValue;
//}catch(e){_debug(e.description);}
}

function removeShadowDiv(){
try{
  var arrShadowDiv = eval("window.document.arr" + _cldTabFrm.id);
  for(var i = 0; i < arrShadowDiv.length; i++)
   arrShadowDiv[i].removeNode(true);
}catch(e){_debug(e.description);}
}

function getValidateDate(sDate){
if(sDate == null) return new Date();
if(sDate.indexOf("-") == -1){
  if(isNaN(sDate)) return new Date();
  if(sDate * 1 > 9999 || sDate * 1 < 1000) return new Date();
  return new Date(sDate, 0, 1);
}
 
var tmp = sDate.split("-");
if(isNaN(tmp[0]) || isNaN(tmp[1]) || isNaN(tmp[2])
  || tmp[0] > 9999 || tmp[0] < 1000
  || tmp[1] > 12 || tmp[1] < 1
  || tmp[2] > 31 || tmp[2] < 1)
  return new Date();
return new Date(tmp[0], tmp[1] - 1, tmp[2]);
}

//var tst = getValidateDate("2000-7-310");
//alert(tst.getFullYear() + "-" + (tst.getMonth() + 1) + "-" + tst.getDate());

function createDateBox(sBoxName, sDfltValue){
var _d = getValidateDate(sDfltValue);
var _month = _d.getMonth() + 1;
var _date = _d.getDate();
if(_month * 1 < 10) _month = "0" + _month;
if(_date * 1 < 10) _date = "0" + _date;
sDfltValue = _d.getFullYear() + "-" + _month + "-" + _date;

var _str = "<INPUT READONLY STYLE='border:1px solid gray;text-align:center;cursor:default;' NAME='" + sBoxName + "' VALUE='" + sDfltValue + "' ONCLICK=JSCalendar(this)>";
document.write(_str);
}

function MakeDivShadowEffect(divObj, color, nLength)
{
//alert(divObj);
var tmpstr = "window.document.arr" + divObj.id + " = new Array();";
eval(tmpstr);
//alert( tmpstr );
var arrShadowDiv = eval("window.document.arr" + divObj.id);
//window.document.arrJACKSHANGJIELOVEFEIFEI = new Array();
//var arrShadowDiv = window.document.arrJACKSHANGJIELOVEFEIFEI;
//alert(arrShadowDiv.length);
var _rect = divObj.getBoundingClientRect();
for( i = nLength; i > 0; i --)
{
  var rect = _cldTabIFrame.document.createElement( "DIV" );
  rect.style.position = "absolute";
  rect.style.left = (divObj.style.posLeft + i ) + "px";
  rect.style.top = (divObj.style.posTop + i ) + "px";
  rect.style.width = divObj.offsetWidth + "px";
  rect.style.height = divObj.offsetHeight + "px";
  rect.style.backgroundColor = color;
  var opacity = 1 - i / (i + 1);
  //alert(rect.style.width);
  rect.style.filter = 'alpha(opacity=' + (100 * opacity) + ')';
  rect.style.zIndex = divObj.style.zIndex - 1;
  //alert(divObj.tagName);
  //divObj.insertAdjacentElement("beforeEnd", rect);
  _cldTabIFrame.document.body.insertBefore(rect);
  arrShadowDiv[arrShadowDiv.length] = rect;
  //alert( i );
}
}

function _debug(s){
return;
//var o = new Option(s, s);
//_debugLst.add(o);
form1._debugLst.options[form1._debugLst.length] = new Option(s, s, 0, 0);
form1._debugLst.options[form1._debugLst.length - 1].selected = true;
//_debugLst.item(_debugLst.length - 1).selected = true;
}
document.onclick = hideCldTabFrm;
//createCldTabFrm();
//-->
分享到:
评论

相关推荐

    漂亮的jQuery事件日历插件calendar.js

    **jQuery事件日历插件calendar.js详解** 在网页设计中,日历插件是一个非常实用的元素,尤其在处理日期相关的交互时。"漂亮的jQuery事件日历插件calendar.js"正是这样一个工具,它能帮助开发者轻松地在网页上集成...

    SimpleCalendar.js日历插件.zip

    SimpleCalendar.js是一款功能丰富的JavaScript日历插件,它专为网页设计者和开发者提供了一种简单易用的方式来添加日历功能。这个插件的核心特点在于它不仅提供了基本的日期选择功能,还支持显示农历日期以及相关的...

    simplecalendar.js记录事件的日历插件

    "simplecalendar.js"是一款轻量级、易用且功能丰富的JavaScript日历插件,专为开发者设计,用于快速集成到各种Web应用中,实现事件记录与展示的功能。本文将深入探讨其核心特点、使用方法以及如何自定义和扩展。 一...

    日历年月日时分秒控件myCalendar.js

    `myCalendar.js`是一款小巧而功能强大的JavaScript库,专为创建日历年月日时分秒控件而设计。本文将深入探讨`myCalendar.js`的原理、使用方法及其在实际项目中的应用。 一、`myCalendar.js`概述 `myCalendar.js`的...

    轻量级的原生js日历插件calendar.js使用指南.docx

    `calendar.js`是一个轻量级的JavaScript日历插件,旨在提供一个简单且高效的方式来在网页上展示和选择日期。这个插件允许用户通过点击特定的文字或按钮,弹出一个日历窗口,方便他们进行日期选择。该插件具有良好的...

    日历插件calendar.js

    本文将深入探讨名为"calendar.js"的JavaScript日历插件,它允许用户轻松地设置开始日期和结束日期,并提供了丰富的回调和事件设置功能,使得在手机页面上的应用更加便捷。 首先,让我们理解什么是calendar.js。...

    lunarCalendar.js

    输入阳历日期转化为阴历日期(支持到2100年)

    beehive.calendar.js v0.1 javascript实现的google日历.zip

    《beehive.calendar.js v0.1:JavaScript实现的Google日历详解》 在Web开发领域,JavaScript作为一种强大的客户端脚本语言,被广泛应用于构建交互性强、用户体验良好的动态网页。Google日历作为一款功能丰富的在线...

    时间控件Calendar.js的实例

    `Calendar.js`是一个轻量级的JavaScript库,专门用于创建交互式、易于定制的日历组件。它允许用户方便地选择日期,提供了丰富的自定义选项以适应不同的设计需求。通过这个实例,我们可以学习如何在网页中集成`...

    jscalendar.rar

    虽然描述中提到大部分是CSS,但**jscalendar** 作为JavaScript控件,肯定也包含JavaScript代码。JavaScript是一种广泛使用的客户端脚本语言,它允许在用户浏览器上动态更新内容,处理用户交互,如点击事件、表单验证...

    SimpleCalendar.js简单带农历节日的日历插件

    在技术实现上,SimpleCalendar.js可能基于JavaScript的Date对象进行扩展,利用农历转换算法将公历日期转换为农历,并查找对应的节日信息。日历的显示部分可能通过DOM操作动态生成,以确保在不同屏幕尺寸下都能保持...

    calendar.js

    这是一款非常好用的日期公农历转换,公农历节日查询,节气查询,天干地支查询等融为一体的js文件,作者是:https://github.com/jjonline/calendar.js【githup地址】。 文件中被我加入了公农历节日的查询功能。 使用...

    SimpleCalendar.js简单带农历节日的日历插件.zip

    总的来说,"SimpleCalendar.js简单带农历节日的日历插件"是一个集成了前端技术的实践项目,对于学习JavaScript开发、前端设计和日历应用的实现都有很好的参考价值。通过研究这个插件,开发者不仅可以提升编程技能,...

    jscalendar简中,非常好用,功能极多的时间控件

    jscalendar是一款强大且灵活的JavaScript日历控件,专为网页应用设计,提供了丰富的功能,使得用户在网页上处理日期和时间时能够获得便捷的操作体验。这款控件支持简体中文,使得中文用户能够更直观地理解和使用,极...

    Calendar.js控件

    "Calendar.js控件"是一个JavaScript库,专门设计用来创建交互式的日期选择器。这个控件包含三个JavaScript脚本和一个CSS样式文件,旨在提供一种高效、易用且美观的方式来处理日期输入。 1. **JavaScript脚本**: -...

    webcalendar.js控件及其使用说明

    WebCalendar.js是一款强大的JavaScript日历控件,专为ASP.NET开发者设计,允许在网页中轻松集成日期选择功能。这个控件具有高度可定制性,能够适应各种网页设计需求,同时提供用户友好的交互体验。 首先,让我们...

    JavaScript写的calendar.js

    JavaScript编写的`calendar.js`是一种常见的用于在网页中实现日期选择功能的脚本。这个库通常包含了一系列函数和方法,允许用户以交互式的方式选择日期,常见于表单输入、事件预订或者时间轴展示等场景。`calendar....

    js 日历文件 calendar.js

    返回当前日期和时间 ... &lt;img id="imgIssued" src="../Images/calendar.gif" width="20px" height="19px" style="cursor: pointer;" alt="选择日期" onclick="return Calendar('txtIssued','imgIssued');" /&gt;

Global site tag (gtag.js) - Google Analytics