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

📄 calendar.js

📁 尚洋仓库管理系统,对仓库
💻 JS
📖 第 1 页 / 共 5 页
字号:
			cell.innerHTML = ":";			cell.className = "colon";			var M = makeTimePart("minute", mins, 0, 59);			//calculating of the step for minutes			M._step = ((cal.timeInterval) && (cal.timeInterval < 60)) ? (cal.timeInterval) : 5; // FIXME: make this part configurable			if (cal.showsTime == "seconds") {				cell = Zapatec.Utils.createElement("td", row);				cell.innerHTML = ":";				cell.className = "colon";				var S = makeTimePart("minute", secs, 0, 59);				S._step = 5;			}			var AP = null;			if (t12) {				AP = makeTimePart("ampm", pm ? "pm" : "am", ["am", "pm"]);				AP.className += " button";			} else				Zapatec.Utils.createElement("td", row).innerHTML = "&nbsp;";			cal.onSetTime = function() {				var hrs = this.currentDate.getHours();				var mins = this.currentDate.getMinutes();				if (this.showsTime == "seconds") {					var secs = cal.currentDate.getSeconds();				}				if (this.timeInterval) {					mins += this.timeInterval - ((mins - 1 + this.timeInterval) % this.timeInterval) - 1;				}				while (mins >= 60) {					mins -= 60;					++hrs;				}				if (this.timeInterval > 60) {					var interval = this.timeInterval / 60;					if (hrs % interval != 0) {						hrs += interval - ((hrs - 1 + interval) % interval) - 1;					}					if (hrs >= 24) {hrs -= 24;}				}			//ALLOWED TIME CHECK				// This part of code seeks for the first enabled time value for this date. 				// It is written for the cases when you change day, month or year and the time value is disabled for the new date.				// So if you only allow 8:00 - 17:00 on Mondays and you change the date to a Monday but the time is 7:00 it will				// automatically move forward to 8:00.				var new_date = new Date(this.currentDate);				if (this.getDateStatus && this.getDateStatus(this.currentDate, this.currentDate.getFullYear(), this.currentDate.getMonth(), this.currentDate.getDate(), hrs, mins)) {				   hours = hrs;				   minutes = mins;				   do {				     if (this.timeInterval) {					 	if (this.timeInterval < 60) {							minutes += this.timeInterval;						} else {							hrs += this.timeInterval / 60;						}					 } else {					 	minutes += 5;					 }				     if (minutes >=60) {						minutes -= 60;						hours += 1;				     }				     if (hours >= 24) {hours -= 24;}					 new_date.setMinutes(minutes);				     new_date.setHours(hours);				     if (!this.getDateStatus(new_date, this.currentDate.getFullYear(), this.currentDate.getMonth(), this.currentDate.getDate(), hours, minutes)) {					 	hrs = hours;				 	 	mins = minutes;				     }				   } while ((hrs != hours) || (mins != minutes));				}			//END OF ALLOWED TIME CHECK				this.currentDate.setMinutes(mins);				this.currentDate.setHours(hrs);				var pm = (hrs >= 12);				if (pm && t12 && hrs != 12) hrs -= 12;				if (!pm && t12 && hrs == 0) hrs = 12;				H.firstChild.data = (hrs < 10) ? ("0" + hrs) : hrs;				M.firstChild.data = (mins < 10) ? ("0" + mins) : mins;				if (this.showsTime == "seconds") {					S.firstChild.data = (secs < 10) ? ("0" + secs) : secs;				}				if (t12)				   AP.firstChild.data = pm ? "pm" : "am";			};			cal.onUpdateTime = function() {				var date = this.currentDate;				var h = parseInt(H.firstChild.data, 10);				if (t12) {					if (/pm/i.test(AP.firstChild.data) && h < 12)						h += 12;					else if (/am/i.test(AP.firstChild.data) && h == 12)						h = 0;				}				var d = date.getDate();				var m = date.getMonth();				var y = date.getFullYear();				date.setHours(h);				date.setMinutes(parseInt(M.firstChild.data, 10));				if (this.showsTime == "seconds") {					date.setSeconds(parseInt(S.firstChild.data, 10));				}				date.setFullYear(y);				date.setMonth(m);				date.setDate(d);				this.dateClicked = false;				this.callHandler();			};		})();		//empty area after the time controls		if (this.monthsInRow != 1) {			cell = Zapatec.Utils.createElement("td", row);			cell.colSpan = ((this.weekNumbers) ? 8 : 7) * (this.monthsInRow - 1) - Math.ceil(emptyColspan);			cell.className = "timetext";			cell.innerHTML = "&nbsp";		}							} else {		this.onSetTime = this.onUpdateTime = function() {};	}	row = Zapatec.Utils.createElement("tr", tfoot);	row.className = "footrow";	cell = hh(Zapatec.Calendar.i18n("SEL_DATE"), this.weekNumbers ? (8 * this.numberMonths) : (7 * this.numberMonths), 300);	cell.className = "ttip";	if (this.isPopup) {		cell.ttip = Zapatec.Calendar.i18n("DRAG_TO_MOVE");		cell.style.cursor = "move";	}	this.tooltips = cell;	div = this.monthsCombo = Zapatec.Utils.createElement("div", this.element);	div.className = "combo";	for (i = 0; i < 12; ++i) {		var mn = Zapatec.Utils.createElement("div");		mn.className = Zapatec.is_ie ? "label-IEfix" : "label";		mn.month = i;		mn.appendChild(window.document.createTextNode(Zapatec.Calendar.i18n(i, "smn")));		div.appendChild(mn);	}	div = this.yearsCombo = Zapatec.Utils.createElement("div", this.element);	div.className = "combo";	for (i = 12; i > 0; --i) {		var yr = Zapatec.Utils.createElement("div");		yr.className = Zapatec.is_ie ? "label-IEfix" : "label";		yr.appendChild(window.document.createTextNode(""));		div.appendChild(yr);	}	div = this.histCombo = Zapatec.Utils.createElement("div", this.element);	div.className = "combo history";	this._init(this.firstDayOfWeek, this.date);	parent.appendChild(this.element);};/** * This function handles keypress events that occur while a popup calendar is * displayed.  The implementation is quite complicated; this function calls * cellClick in order to set the new date as if it was clicked. * * @param ev [Event] the event object * @return false */Zapatec.Calendar._keyEvent = function(ev) {	if (!window.calendar) {		return false;	}	(Zapatec.is_ie) && (ev = window.event);	var cal = window.calendar;	var act = (Zapatec.is_ie || ev.type == "keypress");	var K = ev.keyCode;	var date  = new Date(cal.date);	if (ev.ctrlKey) {		switch (K) {		    case 37: // KEY left			act && Zapatec.Calendar.cellClick(cal._nav_pm);			break;		    case 38: // KEY up			act && Zapatec.Calendar.cellClick(cal._nav_py);			break;		    case 39: // KEY right			act && Zapatec.Calendar.cellClick(cal._nav_nm);			break;		    case 40: // KEY down			act && Zapatec.Calendar.cellClick(cal._nav_ny);			break;		    default:			return false;		}	} else switch (K) {	    case 32: // KEY space (now)		Zapatec.Calendar.cellClick(cal._nav_now);		break;	    case 27: // KEY esc		act && cal.callCloseHandler();		break;	    //Fix for the key navigation		case 37: // KEY left			if (act && !cal.multiple) {				date.setTime(date.getTime() - 86400000);				cal.setDate(date);			}			break;	    case 38: // KEY up			if (act && !cal.multiple) {				date.setTime(date.getTime() - 7 * 86400000);				cal.setDate(date);			}			break;	    case 39: // KEY right			if (act && !cal.multiple) {				date.setTime(date.getTime() + 86400000);				cal.setDate(date);			}			break;	    case 40: // KEY down			if (act && !cal.multiple) {				date.setTime(date.getTime() + 7 * 86400000);				cal.setDate(date);			}			break;	    case 13: // KEY enter		if (act) {			//FIX for Enter key!			Zapatec.Calendar.cellClick(cal.currentDateEl);		}		break;	    default:		return false;	}	return Zapatec.Utils.stopEvent(ev);};/** * (RE)Initializes the calendar to the given date and firstDayOfWeek. * * This function perform the action of actually displaying the day names and * dates in the calendar.  But first, it checks if the passed date fits in the * allowed range, configured by the "minYear", "maxYear", "minMonth" and * "maxMonth" properties of the Calendar object. * * It takes care to highlight special days (calling the * calendar.getDateStatus() function which can be overridden by external * scripts) or to highlight any dates that might be selected (for instance when * multiple dates is on, this function will call _initMultipleDates() to * highlight selected dates accordingly). * * This function is highly optimized for speed, therefore the code in it is not * trivial and what it does might not seem obvious. :-) So, WARNING, this is * voodoo.  If you want to properly understand the code you should analyze it * line by line and try to execute it step by step; use the Venkman JS * debugger. * * @param firstDayOfWeek [int] the first day of week, 0 for Sunday, 1 for Monday, etc. * @param date [Date] the date to initialize the calendar to * * @return */Zapatec.Calendar.prototype._init = function (firstDayOfWeek, date, last) {	var		today = new Date(),		TD = today.getDate(),		TY = today.getFullYear(),		TM = today.getMonth();	//this.table.style.visibility = "hidden";	if (this.getDateStatus && !last) {		var status = this.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate());		var backupDate = new Date(date);		while (((status == true) || (status == "disabled")) && (backupDate.getMonth() == date.getMonth())) {			date.setTime(date.getTime() + 86400000);			var status = this.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate());		}		if (backupDate.getMonth() != date.getMonth()) {			date = new Date(backupDate);			while (((status == true) || (status == "disabled")) && (backupDate.getMonth() == date.getMonth())) {				date.setTime(date.getTime() - 86400000);				var status = this.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate());			}		}		if (backupDate.getMonth() != date.getMonth()) {			last = true;			date = new Date(backupDate);		}	}	var year = date.getFullYear();	var month = date.getMonth();	var rowsOfMonths = Math.floor(this.numberMonths / this.monthsInRow);	var minMonth;	var diffMonth, last_row, before_control;	if (!this.vertical) {		diffMonth = (this.controlMonth - 1);		minMonth = month - diffMonth;	} else {		last_row = ((this.numberMonths - 1) % this.monthsInRow) + 1;		before_control = (this.controlMonth - 1) % this.monthsInRow;		bottom = (before_control >= (last_row) ? (last_row) : (before_control));		diffMonth = (before_control) * (rowsOfMonths - 1) + Math.floor((this.controlMonth - 1) / this.monthsInRow) + bottom;		minMonth = month - diffMonth;	}	var minYear = year;	if (minMonth < 0) {		minMonth += 12;		--minYear;	}	var maxMonth = minMonth + this.numberMonths - 1;	var maxYear = minYear;	if (maxMonth > 11) {		maxMonth -= 12;		++maxYear;	}	function disableControl(ctrl) {		Zapatec.Calendar._del_evs(ctrl);		ctrl.disabled = true;		ctrl.className = "button";		ctrl.innerHTML = "<p>&nbsp</p>";	}	function enableControl(ctrl, sign) {		Zapatec.Calendar._add_evs(ctrl);		ctrl.disabled = false;		ctrl.className = "button nav";		ctrl.innerHTML = sign;	}	if (minYear <= this.minYear) {		if (!this._nav_py.disabled) {			disableControl(this._nav_py);		}	} else {		if (this._nav_py.disabled) {				enableControl(this._nav_py, "&#x00ab;");		}	}	if (maxYear >= this.maxYear) {		if (!this._nav_ny.disabled) {			disableControl(this._nav_ny);		}	} else {		if (this._nav_ny.disabled) {			enableControl(this._nav_ny, "&#x00bb;");		}	}	if (((minYear == this.minYear) && (minMonth <= this.minMonth)) || (minYear < this.minYear)) {		if (!this._nav_pm.disabled) {			disableControl(this._nav_pm);		}	} else {		if (this._nav_pm.disabled) {				enableControl(this._nav_pm, "&#x2039;");		}	}	if (((maxYear == this.maxYear) && (maxMonth >= this.maxMonth)) || (maxYear > this.maxYear)) {		if (!this._nav_nm.disabled) {			disableControl(this._nav_nm);		}	} else {		if (this._nav_nm.disabled) {				enableControl(this._nav_nm, "&#x203a;");		}	}		//FIX for range checking : spreading of the range on 1 month on the both sides;	upperMonth = this.maxMonth + 1;	upperYear = this.maxYear;	if (upperMonth > 11) {		upperMonth -= 12;		++upperYear;	}	bottomMonth = this.minMonth - 1;	bottomYear = this.minYear;	if (bottomMonth < 0) {		bottomMonth += 12;		--bottomYear;	}	maxDate1 = new Date(m

⌨️ 快捷键说明

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