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

📄 calendarff.js

📁 仿招聘网站 SSH框架 ajax功能
💻 JS
📖 第 1 页 / 共 2 页
字号:
            wmcTempObj = wmcDateTbl.rows[0].cells[day-1-i];
            wmcTempObj.onclick = null;
            wmcTempObj.style.color="#ccc";
            wmcTempObj.style.cursor="default";
            wmcTempObj.style.backgroundColor="";
            wmcTempObj.innerHTML=(length[_preMonth]-(i));
        }
        dayIndex = 1;
        
        for(;rowIndex<6;){
            while(cellIndex < 7){  
                wmcTempObj = wmcDateTbl.rows[rowIndex].cells[cellIndex];
                wmcTempObj.onclick=null;
                wmcTempObj.style.color="#ccc";
                wmcTempObj.style.cursor="default";
                wmcTempObj.style.backgroundColor="";
                wmcTempObj.innerHTML = dayIndex;
                cellIndex++;
                dayIndex++;
            }
            cellIndex = 0;            
            rowIndex ++;
        }
        
        wmcTop.rows[0].cells[2].id = this.wmcTopYearTd;
        wmcTop.rows[0].cells[2].value = year;
        wmcTop.rows[0].cells[2].innerHTML=year+this.defaults.yearText;	
        wmcTop.rows[0].cells[3].id= this.wmcTopMonthTd;
        wmcTop.rows[0].cells[3].value = month
        wmcTop.rows[0].cells[3].innerHTML=month+this.defaults.monthText;
    	var wmcShadow = this.$(this.wmcShadowDiv);
        wmcShadow.innerHTML = year;     
	},
	showCalendar: function(ele) {
	    this.currentEventEle = ele;
		this.currentInput = this.$(ele.inputEleID);
		if(this.currentInput){
		    //this.currentInput.blur();		
		    this.setDateFromField();
		    var inputXY = this.getPosition(this.currentInput);		
		    this.$(this.wmcMain).style.display="";
		    this.$(this.wmcMain).style.top = inputXY.y + this.currentInput.offsetHeight + "px";
		    this.$(this.wmcMain).style.left = inputXY.x +"px";
		}
	},
	hideCalendar :function(){
	    this.$(this.wmcMain).style.top = "-1px";
		this.$(this.wmcMain).style.left = "-300px";
	},
	checkExternalClick: function(evt) {
		var wmcTop =parseInt(this.$(this.wmcMain).style.top,10);
		var target = evt.srcElement || evt.target;
		while(target){
		    if(this.noCheckHide==true || target.id==this.wmcMain || target == this.currentInput || target == this.currentEventEle || target.id==this.wmcYearMonthLayerDiv){		        
		        this.noCheckHide=false;
		        return;
		    }
		    target = target.parentNode;
		}
		this.hideCalendar();
	},
	prevYearMonth : function(obj,type){
	    var year=wmcClass._self.$(wmcClass._self.wmcTopTbl).rows[0].cells[2].value;
	    var month=wmcClass._self.$(wmcClass._self.wmcTopTbl).rows[0].cells[3].value;
	    if(type=="y"){	        year--;	        
	    }else{
	        month--;
	        if(month<1){		        month=12;		        year--;				        }
	    }
	    this.currentYear = year;
	    this.currentMonth = month;
	    wmcClass._self.adjustDate();
	},
	nextYearMonth : function(obj,type){
	    var year=parseInt(wmcClass._self.$(wmcClass._self.wmcTopTbl).rows[0].cells[2].innerHTML,10);
	    var month=parseInt(wmcClass._self.$(wmcClass._self.wmcTopTbl).rows[0].cells[3].innerHTML,10);
	    if(type=="y"){	        year++;	        
	    }else{
	        month++;	        if(month>12){		        month=1;		        year++;    			        }
	    }
	    this.currentYear = year;
	    this.currentMonth = month;
	    wmcClass._self.adjustDate();
	},
	getDefaultDate :function(){
		return new Date();
	},
	setDateFor:function(control,date){
//		var inst = this._getInst(control._calId);
//		if (inst) {
//			inst._setDate(date);
//		} 
	},
	setDateFromField:function(){
	    if(this.currentInput){
	        var currentDate = "";	        
	        if(this.currentInput.tagName.toLowerCase()=="input" && this.currentInput.type.toLowerCase() == "text"){
	            if(dateValidator.isValid(this.currentInput.value))
	                currentDate = this.currentInput.value.split('-');
	        }else{
	            if(dateValidator.isValid(this.currentInput.innerHTML))
	                currentDate = this.currentInput.innerHTML.split('-');
	        }
	        if (currentDate.length == 3) {
		        this.currentDay = parseInt(currentDate[2],10);
		        this.currentMonth = parseInt(currentDate[1], 10);
		        this.currentYear = parseInt(currentDate[0], 10);
	        }
	        else {
		        var date = this.getDefaultDate();
		        this.currentDay = date.getDate();
		        this.currentMonth = date.getMonth()+1;
		        this.currentYear = date.getFullYear();
	        }
	        this.selectedDate.Day = this.currentDay;
	        this.selectedDate.Month = this.currentMonth;
	        this.selectedDate.Year = this.currentYear;
	        this.adjustDate();
	    }
	},
	setDate: function(date) {
		this.selectedDate.Day = this.currentDay = date.getDate();
		this.selectedDate.Month = this.currentMonth = date.getMonth()+1;
		this.selectedDate.Year = this.currentYear = date.getFullYear();
		this.adjustDate();
	},	
	getDate: function() {
		return new Date(this.currentYear, this.currentMonth, this.currentDay);
	},
	gotoToday:function(){
		this.currentDay=this.today.Day;
		this.currentMonth=this.today.Month;
		this.currentYear=this.today.Year;
		//this.adjustDate();
		this.selectDate(this.currentDay);
	},
	selectDate:function(day){
	    if(this.currentInput){
	        var tagName = this.currentInput.tagName.toLowerCase();
	        if(tagName=="input" && this.currentInput.type.toLowerCase() == "text"){
	            this.currentInput.value = this.currentYear+"-"+this.currentMonth+"-"+day;
	        }else{
	            if(tagName=="span" || tagName=="div")
	                this.currentInput.innerHTML = this.currentYear+"-"+this.currentMonth+"-"+day;
	        }
	        this.hideCalendar();
	    }
	},
    renderExecuteHistory : function(message){
        var historyDiv = this.$("dExecuteHistory")
        
        if(historyDiv){
            historyDiv.appendChild(document.createTextNode(message));
            historyDiv.appendChild(document.createElement('BR'));
            historyDiv.scrollTop += 50;
        }
    },
    $:function(id){
        if(typeof(id) == "string")return document.getElementById(id);        else return id;
    },
    mouseOver :function(obj){
        obj.className='wmc_mover';
    },
    mouseOut :function(obj){ 
        if(obj.className=='wmc_mover')obj.className=''; 
    },
    ymLayerMouseOver:function(ele){
        if(ele.style.color==''){    		
	        ele.style.backgroundColor="#909eff";		
	        ele.style.color='black';	
        }else{
	        ele.style.backgroundColor='';		
	        ele.style.color='';
        }
    },
    ymLayerDelayShow:function(){
        var obj = this.$(this.wmcYearMonthLayerDiv);
        if(wmcClass.timer_YMLayer!=null)clearTimeout(wmcClass.timer_YMLayer);	
        obj.style.display='block';
    },
    ymLayerDelayHidden:function(obj){
        if(obj==null)obj = this.$(this.wmcYearMonthLayerDiv);
        wmcClass.timer_YMLayer=window.setTimeout(function (){
	        obj.style.display='none';
        },500);
    },
    startMove:function(){
        var evt = window.event || arguments[0];
        var dragEle=this.$(this.wmcMain);
        var dragElePos=this.getPosition(dragEle),mousePos = this.getMouseCoords(evt);
        dragEle.setAttribute("startLeft",mousePos.x-dragElePos.x);
        dragEle.setAttribute("startTop",mousePos.y-dragElePos.y);
        dragEle.setAttribute("isMouseDown","true")
    },
    move:function(){
        var dragEle = this.$(this.wmcMain);        
        var startX=dragEle.getAttribute("startLeft"),startY=dragEle.getAttribute("startTop");
        var isMouseDown=dragEle.getAttribute("isMouseDown");
        var evt = window.event || arguments[0];
        if(isMouseDown=="true"){
            var mousePos = this.getMouseCoords(evt);        
	        dragEle.style.left=mousePos.x-startX + "px";		
	        dragEle.style.top=mousePos.y-startY+ "px";
        }
    },    
    stopMove:function(){
        var dragEle=this.$(this.wmcMain);
        dragEle.setAttribute("isMouseDown","false")
    },
    setPosition : function(ele,top,left){
        ele.style.top=top + "px";	
        ele.style.left=left + "px";
    },
    getPosition : function(e){
        var left = 0,top = 0,tempLW=0,tempTW=0;    
        while (e.offsetParent){
            if(e.currentStyle){
                tempLW = parseInt(e.currentStyle.borderLeftWidth,10);
                tempTW = parseInt(e.currentStyle.borderTopWidth,10);
            }
            left += e.offsetLeft + (isNaN(tempLW)?0:tempLW);
            top  += e.offsetTop  + (isNaN(tempTW)?0:tempTW);
            e     = e.offsetParent;
        }
        if(e.currentStyle){
            tempLW = parseInt(e.currentStyle.borderLeftWidth,10);
            tempTW = parseInt(e.currentStyle.borderTopWidth,10);
        }
        left += e.offsetLeft + (isNaN(tempLW)?0:tempLW);
        top  += e.offsetTop  + (isNaN(tempTW)?0:tempTW);
        return {x:left, y:top};  
    },
    getMouseCoords:function(ev){
        if(ev.pageX || ev.pageY){
            return {x:ev.pageX, y:ev.pageY};
        }
        return {
            x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
            y:ev.clientY + document.body.scrollTop  - document.body.clientTop
        };
    },
    bindEventFor:function(ele){
        if(wmcClass.isReady){
            this.$(ele.eventEle).inputEleID = ele.inputEle;
            this.registerEventHandler(this.$(ele.eventEle),ele.eventType,function(){wmcClass._self.showCalendar(this)});
        }else
            wmcClass.readyList.push(ele);
    },
    registerClickFor: function(ele){        var e={};        e.inputEle = ele;
        e.eventEle = ele
        e.eventType = "click";		if (wmcClass.isReady)			this.registerEventHandler(this.$(ele),"click",function(){wmcClass._self.showCalendar(this)});		else			wmcClass.readyList.push(e);
    },
    registerEventHandler : function(oTarget, sEventType, fnHandler){
        if (oTarget.addEventListener) {
            this.addEventHandler(oTarget, sEventType, fnHandler);
        } else {
            oTarget["on" + sEventType] = fnHandler;
        }
    },
    addEventHandler : function(oTarget, sEventType, fnHandler){
        if (oTarget.addEventListener) {
            oTarget.addEventListener(sEventType, fnHandler, false);
        } else if (oTarget.attachEvent) {
            oTarget.attachEvent("on" + sEventType, fnHandler);
        } else {
            oTarget["on" + sEventType] = fnHandler;
        }
    },
    extend:function(target, source, replace) {
	    for(var prop in source) {
		    if(replace == false && target[prop] != null) { continue; }
		    target[prop] = source[prop];
	    }
	    return target;
    }
}
new wmcClass();





⌨️ 快捷键说明

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