⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsdate.js

📁 DWR与界面开发 ,对ajax感兴趣的可以看看哦
💻 JS
📖 第 1 页 / 共 2 页
字号:
			BSDate.dateHTML += "<TD style=\"width:15;height:20px;\"><span style=\""+BSPopup_style_frameinput+"\">"+this.bsdate.getMinutes()+"</span></TD>";
			BSDate.dateHTML += "<TD style=\"width:16px;FONT-SIZE: 9pt;FONT-WEIGHT: normal;\" valign=\"top\">";
			BSDate.dateHTML += "<input type=\"button\" onFocus=\"this.blur();\" style=\""+BSPopup_style_framebtnOK2+"\" onclick=\"parent."+this.name+".changeMin(event, 1)\" value=\"5\"/><br/>";
			BSDate.dateHTML += "<input type=\"button\" onFocus=\"this.blur();\" style=\""+BSPopup_style_framebtnOK2+"\" onclick=\"parent."+this.name+".changeMin(event, -1)\" value=\"6\"/>";
			BSDate.dateHTML += "<TD style=\"width:100%;FONT-SIZE: 9pt;FONT-WEIGHT: normal;\" align=\"left\">分</TD>";
		}
		else{
			BSDate.dateHTML += "<TD style=\"width:100%;FONT-SIZE: 9pt;FONT-WEIGHT: normal;\" align=\"left\">&nbsp;</TD>";
		}
		BSDate.dateHTML += "<TD style=\"height:20px;\" valign=\"top\"><input type=\"button\" tabindex=\"2\" onclick=\"parent."+this.name+".toDay(event)\" style=\""+BSPopup_style_framebtnOK+";height:18px;\" value=\"今天\"/></TD>";
		BSDate.dateHTML += "<TD style=\"height:20px;\" valign=\"top\"><input id=\"BSPopup_OKbtn\" tabindex=\"1\" type=\"button\" onclick=\"parent.BSPopup.hide();\" style=\""+BSPopup_style_framebtnOK+";height:18px;\" value=\"确定\"/></TD>";

		BSDate.dateHTML += "</TR>";
		BSDate.dateHTML += "</TABLE>";
		BSDate.dateHTML += "</TD></TR>";
		BSDate.dateHTML += "</TABLE>";
	}

	//展现日期控件
	this.show = function(){
    var lYear=this.bsdate.getFullYear();
    var lMonth=this.bsdate.getMonth()+1;
    if (lMonth < 10){
      lMonth = "0"+lMonth;
    }
    var lDay=this.bsdate.getDate();
    if (lDay < 10){
      lDay = "0"+lDay;
    }
    var lHours=this.bsdate.getHours();
    if (lHours < 10){
      lHours = "0"+lHours;
    }
    var lMins=this.bsdate.getMinutes();
    if (lMins < 10){
      lMins = "0"+lMins;
    }
    var ro = "", rosty="";
    if (this.readonly){
      ro = " readonly=\"readonly\"";
      rosty="color:silver;";
    }
    var st = "",stformt="yyyy-mm-dd hh24:mi:ss";
    if (!this.showTime){
    	st = "display:none;";
    	stformt = "yyyy-mm-dd";
    }
    var tempHTML = "<span class=\"bsdate_frame\" id=\""+this.name+"_frame\" name=\""+this.name+"_frame\">";
    tempHTML += "<nobr>";
    tempHTML += "<input id=\""+this.name+"_input_year\" class=\"bsdate_input\" style=\"width:30px\" type=\"text\" value=\""+lYear+"\" size=\"3\" maxlength=\"4\" onfocus=\"return "+this.name+".dateFocus('year')\" onblur=\"return "+this.name+".dateBlur('year')\" onkeypress=\"return KeyFilter('number');\" onkeydown=\"return "+this.name+".keyDown('year')\""+ro+"/>";
    tempHTML += "<font class=\"bsdate_des\">"+BSDate.cl_resYear+"</font>";
    tempHTML += "<input id=\""+this.name+"_input_month\" class=\"bsdate_input\" style=\"width:15px\" type=\"text\" value=\""+lMonth+"\" size=\"1\" maxlength=\"2\" onfocus=\"return "+this.name+".dateFocus('month')\" onblur=\"return "+this.name+".dateBlur('month')\" onkeypress=\"return KeyFilter('number');\" onkeydown=\"return "+this.name+".keyDown('month')\""+ro+"/>";
    tempHTML += "<font class=\"bsdate_des\">"+BSDate.cl_resMonth+"</font>";
    tempHTML += "<input id=\""+this.name+"_input_day\" class=\"bsdate_input\" style=\"width:15px\" type=\"text\" value=\""+lDay+"\" size=\"1\" maxlength=\"2\" onfocus=\"return "+this.name+".dateFocus('day')\" onblur=\"return "+this.name+".dateBlur('day')\" onkeypress=\"return KeyFilter('number');\" onkeydown=\"return "+this.name+".keyDown('day')\""+ro+"/>";
    tempHTML += "<font class=\"bsdate_des\">"+BSDate.cl_resDay+"</font>";
    tempHTML += "<input id=\""+this.name+"_input_hour\" class=\"bsdate_input\" style=\"width:15px;"+st+"\" type=\"text\" value=\""+lHours+"\" size=\"1\" maxlength=\"2\" onfocus=\"return "+this.name+".dateFocus('hour')\" onblur=\"return "+this.name+".dateBlur('hour')\" onkeypress=\"return KeyFilter('number');\" onkeydown=\"return "+this.name+".keyDown('hour')\""+ro+"/>";
    tempHTML += "<font id=\""+this.name+"_input_mh\" class=\"bsdate_mhdes\"  style=\""+st+"\">:</font>";
    tempHTML += "<input id=\""+this.name+"_input_min\" class=\"bsdate_input\" style=\"width:15px;"+st+"\" type=\"text\" value=\""+lMins+"\" size=\"1\" maxlength=\"2\" onfocus=\"return "+this.name+".dateFocus('min')\" onblur=\"return "+this.name+".dateBlur('min')\" onkeypress=\"return KeyFilter('number');\" onkeydown=\"return "+this.name+".keyDown('min')\""+ro+"/>";
    tempHTML += "<span class=\"bsdate_btn\" id=\""+this.name+"_btn\" name=\""+this.name+"_btn\" onclick=\""+this.name+".showDig(this);return false;\" title=\""+BSDate.cl_resDateTitle+"\" style=\""+rosty+"\">"+BSDate.cl_resDateDrop+"</span>";
    if(typeof(this.name)=="string" && this.name.length>0){
    	tempHTML += "<input type=\"hidden\" value=\""+dateFormat(this.bsdate, stformt)+"\" id=\""+this.elmName+"\" name=\""+this.elmName+"\"/>";
    }
    tempHTML += "</nobr>";
    tempHTML += "</span>";
    document.write(tempHTML);
	}

	//打开下拉列表框
	this.showDig = function(inObjID){
		if (this.readonly){
			return;
		}
    var left = 128;
    this.setDateHTML();
    if (!this.showTime){
    	left = 90;
    }
    BSPopup.document.body.innerHTML=BSDate.dateHTML;
    BSPopup.show(GetDefineX(inObjID)-left, GetDefineY(inObjID)+14, 184, 162, document.body);
	}

	//设置显示日期内容
	this.setInputDate = function(){
    if (document.getElementById(this.elmName) != null){
      var lYear=this.bsdate.getFullYear();
      var lMonth=this.bsdate.getMonth()+1;
      if (lMonth < 10){
        lMonth = "0"+lMonth;
      }
      var lDay=this.bsdate.getDate();
      if (lDay < 10){
        lDay = "0"+lDay;
      }
      var lHours=this.bsdate.getHours();
      if (lHours < 10){
        lHours = "0"+lHours;
      }
      var lMins=this.bsdate.getMinutes();
      if (lMins < 10){
        lMins = "0"+lMins;
	    }

	    var stformt="yyyy-mm-dd hh24:mi:ss";
	    if (!this.showTime){
	    	stformt = "yyyy-mm-dd";
    	}
	    document.getElementById(this.name+"_input_year").value = lYear;
	    document.getElementById(this.name+"_input_month").value = lMonth;
	    document.getElementById(this.name+"_input_day").value = lDay;
	    document.getElementById(this.name+"_input_hour").value = lHours;
	    document.getElementById(this.name+"_input_min").value = lMins;
	    document.getElementById(this.elmName).value = dateFormat(this.bsdate, stformt);
    }
	}

	//输入框失去焦点
	this.dateBlur = function(srcType){
		if (this.readonly){
			return true;
		}
		var src=event.srcElement;
		var lYear=this.bsdate.getFullYear();
		var lMonth=this.bsdate.getMonth()+1;
		var lDay=this.bsdate.getDate();
		var lHours=this.bsdate.getHours();
		var lMins=this.bsdate.getMinutes();

		var val=parseInt(src.value,10);
		if(isNaN(val)){
			val=-1;
		}
		switch(srcType)	{
			case 'year':
				lYear=val==-1?lYear:val;
				break;
			case 'month':
				lMonth=val==-1?lMonth:val;
				break;
			case 'day':
				lDay=val==-1?lDay:val;
				break;
			case 'hour':
				lHours=val==-1?lHours:val;
				break;
			case 'min':
				lMins=val==-1?lMins:val;
				break;
			default:break;
		}
		this.setCurDate(lYear, lMonth, lDay, lHours, lMins);
		return true;
	}
	//输入框聚焦
	this.dateFocus = function (srcType){
		if (this.readonly){
			return true;
		}
		var src=event.srcElement;
		if(src && src.tagName=="INPUT")
		{
			switch(srcType)
			{
				case 'year':
					break;
				case 'month':
					break;
				case 'day':
					break;
				case 'hour':
					break;
				case 'min':
					break;
				default:;
			}
			src.select();
		}
		return true;
	}

	//上下箭头改变文本框内容
	this.keyDown = function (srcType){
		if (this.readonly){
			return true;
		}
		var bRefresh=true;
		var src=event.srcElement;
		var lYear=this.bsdate.getFullYear();
		var lMonth=this.bsdate.getMonth();
		var lDay=this.bsdate.getDate();
		var lHours=this.bsdate.getHours();
		var lMins=this.bsdate.getMinutes();
		var lStep=0;
		switch(event.keyCode){
			case 38://上箭头
				lStep=1;
				break;
			case 40://下箭头
				lStep=-1;
				break;
			case 13://回车
				event.keyCode=9;//Tab
				bRefresh=false;
				break;
			default:bRefresh=false;break;
		}

		switch(srcType)	{
			case 'year':
				lYear+=lStep;
				break;
			case 'month':
				lMonth+=lStep;
				break;
			case 'day':
				lDay+=lStep;
				break;
			case 'hour':
				lHours+=lStep;
				break;
			case 'min':
				lMins+=lStep;
				break;
			default:break;
		}
		if(bRefresh){
			this.setCurDate(lYear, lMonth+1, lDay, lHours, lMins);
			//alert("keyDown:"+lMonth);
		}
		return true;
	}

	//设置修改后的时间
	this.setCurDate = function(lYear, lMonth, lDay, lHours, lMins){
		var hr=false;
		lYear=parseInt(lYear,10);
		lMonth=parseInt(lMonth,10);
		lDay=parseInt(lDay,10);
		lHours=parseInt(lHours,10);
		lMins=parseInt(lMins,10);

		if(!(isNaN(lYear) || isNaN(lMonth) || isNaN(lDay) || isNaN(lHours) || isNaN(lHours))){
			var dt=new Date(lYear, lMonth-1 , lDay, lHours, lMins);
			var dMax=new Date(BSDate.cl_dpMaxYear,BSDate.cl_dpMaxMonth,BSDate.cl_dpMaxDay,23,59);
			var dMin=new Date(BSDate.cl_dpMinYear,BSDate.cl_dpMinMonth,BSDate.cl_dpMinDay,0,0);
			if(dateCompare(dt, dMax)<=0 && dateCompare(dt, dMin)>=0){
				this.bsdate=dt;
			}
			else if (dateCompare(dt, dMax)>0){
				this.bsdate = dMax
			}
			else if (dateCompare(dt, dMin)<0){
				this.bsdate = dMin
			}
			hr=true;
		}
		if(hr){
			this.setInputDate();
		}
		return hr;
	}

	//选择今天
	this.toDay = function(event){
		event.returnValue=false;
		var today = new Date();
		this.bsdate.setYear(today.getFullYear());
		this.bsdate.setMonth(today.getMonth());
		this.bsdate.setDate(today.getDate());
		this.bsdate.setHours(today.getHours());
		this.bsdate.setMinutes(today.getMinutes());
		this.setDateHTML();
		BSPopup.document.body.innerHTML=BSDate.dateHTML;
		return false;
	}

	//选择天
	this.changeDay = function(event, inYear, inMonth, inDay){
		event.returnValue=false;
		this.bsdate.setYear(inYear);
		this.bsdate.setMonth(inMonth);
		this.bsdate.setDate(inDay);
		this.setDateHTML();
		BSPopup.document.body.innerHTML=BSDate.dateHTML;
		return false;
	}

	//改变小时
	this.changeHour = function(event, inHour){
		event.returnValue=false;
		this.bsdate.setHours(this.bsdate.getHours() + inHour);
		this.setDateHTML();
		BSPopup.document.body.innerHTML=BSDate.dateHTML;
		return false;
	}

	//改变分钟
	this.changeMin = function(event, inMin){
		event.returnValue=false;
		this.bsdate.setMinutes(this.bsdate.getMinutes() + inMin);
		this.setDateHTML();
		BSPopup.document.body.innerHTML=BSDate.dateHTML;
		return false;
	}

	//翻月
	this.changeMonth = function(event, arrFlg){
		var dMax=new Date(BSDate.cl_dpMaxYear,BSDate.cl_dpMaxMonth-1,BSDate.cl_dpMaxDay,0,0);
		var dMin=new Date(BSDate.cl_dpMinYear,BSDate.cl_dpMinMonth+1,BSDate.cl_dpMinDay,0,0);
		if (arrFlg){
			//上一月
			if (dateCompare(this.bsdate, dMin)>0){
				this.bsdate.setMonth(this.bsdate.getMonth()-1);
			}
		}
		else{
			if (dateCompare(this.bsdate, dMax)<0){
				this.bsdate.setMonth(this.bsdate.getMonth()+1);
			}
		}
		this.setDateHTML();
		BSPopup.document.body.innerHTML=BSDate.dateHTML;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -