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

📄 bdplite.js

📁 酒店管理系统使用VB开发.数据库采用微软公司的SQL
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*The BDPLite calendar date picker is FREE to use and redistribute, subject to terms oflicense agreement. Please visit http://www.basicdatepicker.com/bdplite/ for moreinformation. Copyright Basic Frame Inc. 2004-2005. All rights reserved. Version 1.1.1959 */BDPLite = function(suppressInit){if(!suppressInit) this.init();var today = new Date();this.todayDate = today.getDate(), this.todayMonth = today.getMonth(), this.todayYear = today.getFullYear(),this.dateCounts = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),this.viewingYear, this.viewingMonth, this.selectedYear,this.selectedMonth, this.selectedDay,this.buttonElement, this.valueElement, this.yearInc, this.params, this.timeout, this.interval, this.popUp,this.popUpShim,this.stayOpen = false, this.isIE, this.isIEWin, this.isOpera, this.isSafari, this.isNS6, this.isIEMac;};BDPLite.prototype.init = function(){var ua = navigator.userAgent.toLowerCase();var isMac = (ua.indexOf("mac") != -1);this.isIE = (ua.indexOf("ie") != -1);this.isOpera = (ua.indexOf("opera") != -1);this.isSafari = (ua.indexOf("safari") != -1);this.isNS6 = (ua.indexOf("netscape6/") != -1);this.isIEWin = (this.isIE && !isMac && !this.isOpera);this.isIEMac = (this.isIE && isMac && !this.isOpera);};BDPLite.prototype.showPopUp = function(buttonElement, valueElement, labelElement, params){this.inputFocusValue = valueElement.value;if(this.params != null && (this.params != params)){/* another popUp is open, close it and open this popup */this.hidePopUp();}else if(this.params == params && this.buttonElement == buttonElement && this.valueElement == valueElement){/* this popUp was reopened, close it */this.hidePopUp();return false;}this.buttonElement = buttonElement;this.valueElement = valueElement;this.params = this.loadParams(params);if(!this.popUp){/* create the popup div */this.popUp = document.createElement("DIV");with(this.popUp){id = "bdpLitePopUp";style.position = "absolute";style.visibility = "hidden";style.zIndex = "1000";}this.popUp.onclick = this.ehPopUpClick;document.body.appendChild(this.popUp);}this.parseDate(this.valueElement.value);this.buildCalendar();var buttonPosition = this.findPosition(this.buttonElement);var leftPosition = this.params.xOffset + buttonPosition.x;var topPosition = this.params.yOffset + buttonPosition.y;this.popUp.style.left = (leftPosition + this.buttonElement.offsetWidth - this.popUp.offsetWidth) + "px";this.popUp.style.top = (topPosition + this.buttonElement.offsetHeight) + "px";if(parseInt(this.popUp.style.left) < 0){this.popUp.style.left = 0;}if(parseInt(this.popUp.style.top) < 0){this.popUp.style.top = 0;}this.popUpShim = this.showShim(this.popUpShim, this.popUp);this.popUp.style.visibility = "visible";document.onclick = this.ehDocumentClick;document.onkeydown = this.ehKeyPress;};BDPLite.prototype.showShim = function(v, o){if(this.isIEWin){if(!v){v = document.createElement("IFRAME");with(v){src = "javascript:false;";style.position = "absolute";style.visibility = "hidden";style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";}  document.body.appendChild(v);}with(v){style.width = o.offsetWidth;style.height = o.offsetHeight;style.top = o.style.top;style.left = o.style.left;style.zIndex = o.style.zIndex - 1;style.visibility = "visible";}}return v;};BDPLite.prototype.hideShim = function(v){if(this.isIEWin){if(v){v.style.visibility = "hidden";}}};BDPLite.prototype.hidePopUp = function(){bdpLite.clearTimers();this.hideShim(this.popUpShim);this.popUp.style.visibility = "hidden";this.reset();document.onclick = null;document.onkeydown = null;};BDPLite.prototype.clearTimers = function(){if(this.timeout) clearTimeout(this.timeout);if(this.interval) clearInterval(this.interval);};BDPLite.prototype.buildCalendar = function(){if(this.viewingMonth == null || this.viewingYear == null){(this.params.visibleDate) ? this.viewingMonth = this.params.visibleDate.getMonth() : this.viewingMonth = this.todayMonth;(this.params.visibleDate) ? this.viewingYear = this.params.visibleDate.getFullYear() : this.viewingYear = this.todayYear;}/* previous/next month */var viewingPrevMonth = this.viewingMonth - 1;var viewingPrevMonthYear = this.viewingYear;if(viewingPrevMonth == -1){viewingPrevMonth = 11;viewingPrevMonthYear--;}var viewingNextMonth = this.viewingMonth + 1;var viewingNextMonthYear = this.viewingYear;if(viewingNextMonth == 12){viewingNextMonth = 0;viewingNextMonthYear++;}var o = "";o += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"bdplPopUp\">";o += "<tr><td>";o += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"bdplTitle\">";o += "<tr>";var monthAndYear = "<th>";var monthName = this.params.culture.monthNames[this.viewingMonth];monthAndYear += monthName;monthAndYear += " ";monthAndYear += this.viewingYear;monthAndYear += "</th>";var prevMonth = "<img src=\"" + this.params.prevMonthImageUrl + "\" border=\"0\" />";var nextMonth = "<img src=\"" + this.params.nextMonthImageUrl + "\" border=\"0\" />";o += "<td onclick=\"bdpLite.viewPrevMonth()\" onmousedown=\"bdpLite.clearTimers();bdpLite.timeout=setTimeout('bdpLite.ehPrevMonthMouseDown()', 400);\" onmouseup=\"bdpLite.clearTimers();\" onmouseout=\"bdpLite.clearTimers();\" class=\"bdplNextPrev\">";o += prevMonth;o += "</td>";o += monthAndYear;o += "<td onclick=\"bdpLite.viewNextMonth()\" onmousedown=\"bdpLite.clearTimers();bdpLite.timeout=setTimeout('bdpLite.ehNextMonthMouseDown()', 400);\" onmouseup=\"bdpLite.clearTimers();\" onmouseout=\"bdpLite.clearTimers();\" class=\"bdplNextPrev\">";o += nextMonth;o += "</td>";o += "</tr>";o += "</table>";/* leap year check */if(((this.viewingYear % 4 == 0) && (this.viewingYear % 100 != 0)) || (this.viewingYear % 400 == 0))this.dateCounts[1] = 29;else this.dateCounts[1] = 28;/* calendar table */o += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"bdplCalendar\">";/* week number header */o += "<thead><tr>";/* day of week headers */var dayPointer = this.params.firstDayOfWeek;for(var i=0; i<7; i++, dayPointer++){if(dayPointer == 7)dayPointer = 0;o += "<th class=\"bdplDayHeader\">";switch(this.params.dayNameFormat){case "Short":o += this.params.culture.dayNamesAbbr[dayPointer];break;case "Full":o += this.params.culture.dayNames[dayPointer];break;case "FirstTwoLetters":o += this.params.culture.dayNames[dayPointer].substring(0,2);break;case "FirstLetter":default:o += this.params.culture.dayNames[dayPointer].substring(0,1);break;}o += "</th>";}o += "</tr></thead>";o += "<tbody><tr>";var column = 0;var startOfMonth = new Date(this.viewingYear,this.viewingMonth,1).getDay();startOfMonth = startOfMonth - this.params.firstDayOfWeek;if(startOfMonth < 0) startOfMonth = 7 + startOfMonth;/* prev month days */for(var i=0; i<startOfMonth; i++, column++)o += this.buildDayCell(viewingPrevMonthYear, viewingPrevMonth, this.dateCounts[viewingPrevMonth] - startOfMonth + i + 1, "prev");var row = 0;/* month days */for(var i=1; i<=this.dateCounts[this.viewingMonth]; i++, column++){o += this.buildDayCell(this.viewingYear, this.viewingMonth, i, "current");if(column == 6)if(i < this.dateCounts[this.viewingMonth]){ o += "</tr><tr>"; row++; column = -1; }}/* next month days */if (column > 0) {for (var i=1; column<7; i++, column++)o += this.buildDayCell(viewingNextMonthYear, viewingNextMonth, i, "next");}/* insure 6th row */for(var y = row; y < 5; y++){o += "</tr><tr>";for(var x=0; x < 7; x++, i++)o += this.buildDayCell(viewingNextMonthYear, viewingNextMonth, i, "next");}o += "</tr></tbody>";o += "</table>";o += "</td></tr>";o += "</table>";this.popUp.innerHTML = o;};BDPLite.prototype.buildDayCell = function(y, m, d, type){var curDate = new Date(y, m, d);var dayOfWeek = curDate.getDay(), dayClassName = "";var isWeekDay = (dayOfWeek != 0 && dayOfWeek != 6);var styleCssClassToUse = null;switch(type){case "current":var isSelectedDay = (this.selectedYear == y && this.selectedMonth == m && this.selectedDay == d);var isTodayDay = (this.viewingYear == this.todayYear && this.viewingMonth == this.todayMonth && this.todayDate == d);if(isSelectedDay && isTodayDay){if(isWeekDay){styleCssClassToUse = "bdplTodayDay bdplSelectedDay bdplDay";}else{styleCssClassToUse = "bdplSelectedDay bdplWeekendDay bdplDay";}}else if(isSelectedDay){if(isWeekDay){styleCssClassToUse = "bdplSelectedDay bdplDay";}else{styleCssClassToUse = "bdplSelectedDay bdplWeekendDay bdplDay";}}else if(isTodayDay){if(isWeekDay){styleCssClassToUse = "bdplTodayDay bdplDay";}else{styleCssClassToUse = "bdplTodayDay bdplWeekendDay bdplDay";}}else{if(isWeekDay){styleCssClassToUse = "bdplDay";}else{styleCssClassToUse = "bdplWeekendDay bdplDay";}}break;case "prev":case "next":if(isWeekDay){styleCssClassToUse = "bdplOtherMonthDay bdplDay";}else{styleCssClassToUse = "bdplOtherMonthDay bdplWeekendDay bdplDay";}break;}var o = "";o += "<td class=\"" + styleCssClassToUse + "\"";var statusText = this.formatDate(curDate);o += " onmouseover=\"window.status = '" + statusText + "';return true;\"";o += " onmouseout=\"window.status = '';return true;\"";o += ">";var onClick = "bdpLite.selectDate(" + this.viewingYear + "," + this.viewingMonth + "," + d + ", true)";if(type == "prev" || type == "next") onClick = "bdpLite.selectDate(" + y + "," + m + "," + d + ", true)";onClick = onClick + ";";o += "<a href=\"javascript:void(0);\" onclick=\"" + onClick.replace("{0}",d) + "\">" + d + "</a>";o += "</td>";return o;};BDPLite.prototype.findPosition = function(eElement, stopElement){var pLeft = 0, pTop = 0;var org = eElement;while (eElement){var aLeft = (eElement.scrollLeft && !this.isOpera) ? eElement.offsetLeft-eElement.scrollLeft : eElement.offsetLeft;var standardsMode = (document.compatMode && document.compatMode != "BackCompat") ? true : false;if(standardsMode && aLeft < 0) aLeft += aLeft *-1;pLeft += aLeft;var aTop = (eElement.scrollTop && !this.isOpera) ? eElement.offsetTop-eElement.scrollTop : eElement.offsetTop;if(standardsMode && aTop < 0) aTop += aTop *-1;pTop += aTop;eElement = eElement.offsetParent;if(eElement  == stopElement)break;}if(stopElement == null){if(!document.all){while (org){if(org.scrollLeft) pLeft -= org.scrollLeft;if(org.scrollTop) pTop -= org.scrollTop;org = org.parentNode;}if (self.pageYOffset && !this.isNS6){pLeft += self.pageXOffset;pTop += self.pageYOffset;}}if(!this.isOpera && !this.isNS6){pLeft += document.body.scrollLeft;pTop += document.body.scrollTop;}if(this.isIEMac){var mmLeft = document.body.currentStyle.marginLeft;var mmTop = document.body.currentStyle.marginTop; if(mmLeft.indexOf("%") != -1){var mpWidth = parseInt(document.body.offsetWidth);var mpHeight = parseInt(document.body.offsetHeight); mmLeft = (parseInt(mmLeft)/100) * mpWidth;mmTop = (parseInt(mmTop)/100) * mpHeight;}pLeft += parseInt(mmLeft); pTop += parseInt(mmTop); }}return {x:pLeft, y:pTop};};BDPLite.prototype.viewNextMonth = function(){var nextMonth = this.viewingMonth + 1;var nextMonthYear = this.viewingYear;if (nextMonth > 11){nextMonth = 0;nextMonthYear++;}this.viewingMonth = nextMonth;this.viewingYear = nextMonthYear;this.buildCalendar();};BDPLite.prototype.viewPrevMonth = function(){var prevMonth = this.viewingMonth - 1;var prevMonthYear = this.viewingYear;if (prevMonth < 0){prevMonth = 11;prevMonthYear--;}this.viewingMonth = prevMonth;this.viewingYear = prevMonthYear;this.buildCalendar();};BDPLite.prototype.clearSelectedDate = function(){var prevFormattedDate = this.valueElement.value;if(prevFormattedDate !=  this.params.nullDateText){this.valueElement.value = this.params.nullDateText;this.clearDate = false;if(this.params.autoPostBack){eval(this.params.postBackFunction);}}if(this.valueElement.style.display != "none"){this.valueElement.focus();}this.hidePopUp();};BDPLite.prototype.selectDate = function(y, m, d, hide){this.selectedYear = y, this.selectedMonth = m, this.selectedDay = d;this.viewingYear = y, this.viewingMonth = m;var prevFormattedDate = this.valueElement.value; var formattedDate = this.formatDate(new Date(this.selectedYear, this.selectedMonth, this.selectedDay));if(prevFormattedDate != formattedDate){this.valueElement.value = formattedDate;this.clearTimers();if(this.params.autoPostBack && hide){eval(this.params.postBackFunction);}if(this.valueElement.style.display != "none"){this.valueElement.focus();}}if(hide){this.hidePopUp();}};BDPLite.prototype.padWithZero = function(num){return (num< 10) ? "0" + num : num;};BDPLite.prototype.trim = function(string){while ((string.substring(0,1) == ' ') || (string.substring(0,1) == '\n') || (string.substring(0,1) == '\r')) { string = string.substring(1,string.length); }while ((string.substring(string.length-1,string.length) == ' ') || (string.substring(string.length-1,string.length) == '\n') || (string.substring(string.length-1,string.length) == '\r')) { string = string.substring(0,string.length-1); }return string;};/* Date Formatting / Parsing ---------------------------------------- */BDPLite.prototype.formatDate = function(date){if(date){var y = date.getFullYear(), m = date.getMonth(), d = date.getDate(), dow = date.getDay();var finalDate = this.params.dateFormat;finalDate = finalDate.replace("yyyy",y);finalDate = finalDate.replace("yy",this.padWithZero(y%100));finalDate = finalDate.replace("dddd","{0}");finalDate = finalDate.replace("ddd","{1}");finalDate = finalDate.replace("dd","{2}");finalDate = finalDate.replace("d","{3}");finalDate = finalDate.replace("MMMM","{4}");finalDate = finalDate.replace("MMM","{5}");finalDate = finalDate.replace("MM","{6}");finalDate = finalDate.replace("M","{7}");finalDate = finalDate.replace("{0}",this.params.culture.dayNames[dow]);finalDate = finalDate.replace("{1}",this.params.culture.dayNamesAbbr[dow]);finalDate = finalDate.replace("{2}",this.padWithZero(d));finalDate = finalDate.replace("{3}",d);finalDate = finalDate.replace("{4}",this.params.culture.monthNames[m]);finalDate = finalDate.replace("{5}",this.params.culture.monthNamesAbbr[m]);finalDate = finalDate.replace("{6}",this.padWithZero(m+1));finalDate = finalDate.replace("{7}",m+1);return finalDate;}else return null;};BDPLite.prototype.parseDate = function(valueString){if(valueString && valueString != this.params.nullDateText){var format = this.params.dateFormat;var i_value = 0, i_format = 0;var c, token;var x,y;var year = null, month = null, date = null;while(i_format < format.length){/* get next token from format string */c = format.charAt(i_format);token = "";while((format.charAt(i_format) == c) && (i_format < format.length)){token += format.charAt(i_format++);}switch(token){case "d" :case "dd" :date = this.getInt(valueString, i_value, token.length, 2);if(!date) return null;i_value += date.length;date = this.parsePaddedInt(date);break;case "ddd" :for(var i=0; i<this.params.culture.dayNamesAbbr.length; i++){var dayName = this.params.culture.dayNamesAbbr[i];if(valueString.substring(i_value,i_value+dayName.length).toLowerCase() == dayName.toLowerCase()){i_value += dayName.length;break;}}break;case "dddd" :for(var i=0; i<this.params.culture.dayNames.length; i++){var dayName = this.params.culture.dayNames[i];if(valueString.substring(i_value,i_value+dayName.length).toLowerCase() == dayName.toLowerCase()){i_value += dayName.length;break;}}break; case "M" :case "MM":month = this.getInt(valueString,i_value,token.length,2);if(!month) return null;i_value += month.length;month = this.parsePaddedInt(month)-1;break;case "MMM" :for(var i=0; i<this.params.culture.monthNamesAbbr.length; i++){var monthName = this.params.culture.monthNamesAbbr[i];if(valueString.substring(i_value,i_value+monthName.length).toLowerCase() == monthName.toLowerCase()){month = i;i_value += monthName.length;break;}}break;case "MMMM" :for(var i=0; i<this.params.culture.monthNames.length; i++){var monthName = this.params.culture.monthNames[i];if(valueString.substring(i_value,i_value+monthName.length).toLowerCase() == monthName.toLowerCase()){month = i;i_value += monthName.length;break;}}break;case "yy" :case "yyyy" :if(token == "yyyy") {x = 1;y = 4;}if(token == "yy") {x = 2;y = 2;}year = this.getInt(valueString, i_value, x, y);if(year != null){i_value += year.length;if (year.length==2){if (year > 50) { year=1900+(year-0); }else { year=2000+(year-0); }}}break;default :i_value += token.length;}}if(date == null || month == null || year == null || isNaN(date) || isNaN(month) || isNaN(year)){return null;}else{this.selectDate(year, month, date);return new Date(year, month, date);}}else return null;};BDPLite.prototype.isInteger = function(val){var digits="1234567890";for (var i=0; i < val.length; i++) {if (digits.indexOf(val.charAt(i))==-1) { return false; }}return true;};BDPLite.prototype.getInt = function(str,i,minlength,maxlength){for(var x=maxlength; x>=minlength; x--){var valuePart = str.substring(i, i + x);if(valuePart.length < minlength) { return null; }if(this.isInteger(valuePart)){for(var y=0; y<valuePart.length; y++){if(valuePart.charAt(y) != "0")return valuePart;else break;}}}return null;};BDPLite.prototype.parsePaddedInt = function(valuePart){if(valuePart.length > 1 && valuePart.substring(0,1) == "0")return valuePart.substring(1, valuePart.length);else return valuePart;};/* Event Handlers -------------------------------------------------------------- */BDPLite.prototype.ehKeyPress = function(e){if(!e) e = window.event;if(e.keyCode == 9) bdpLite.hidePopUp();};BDPLite.prototype.ehPopUpClick = function(e){bdpLite.stayOpen = true;};BDPLite.prototype.ehDocumentClick = function(){if(!bdpLite.stayOpen){bdpLite.hidePopUp();}else {bdpLite.stayOpen = false;}};BDPLite.prototype.ehPrevMonthMouseDown = function(){bdpLite.interval = setInterval("bdpLite.viewPrevMonth()",200);};BDPLite.prototype.ehNextMonthMouseDown = function(){bdpLite.interval = setInterval("bdpLite.viewNextMonth()",200);};BDPLite.prototype.ehFocus = function(valueElement){this.inputFocusValue = valueElement.value;};BDPLite.prototype.ehBlur = function(buttonElement, valueElement, params){bdpLite.buttonElement = buttonElement;bdpLite.valueElement = valueElement;bdpLite.params = bdpLite.loadParams(params);if(bdpLite.valueElement.value != bdpLite.inputFocusValue){if(bdpLite.params.autoPostBack){eval(bdpLite.params.postBackFunction);}}bdpLite.reset();};BDPLite.prototype.reset = function(){this.selectedMonth = null;this.selectedDay = null;this.selectedYear = null;this.viewingMonth = null;this.viewingYear = null;this.params = null;};BDPLite.prototype.loadParams = function(params){params.culture = eval(params.culture);params.firstDayOfWeek = params.culture.firstDayOfWeek;return params;};/* (Public) Helper Methods ----------------------------------------------------- */BDPLite.prototype.getSelectedDate = function(bdplId){var bdpltu = (bdplId) ? BDPLiteLoadControl(bdplId) : this;return bdpltu.parseDate(bdpltu.valueElement.value)};function BDPLiteLoadControl(bdplId){var bdpl = new BDPLite(true);bdpl.params = bdpl.loadParams(eval(bdplId + "Params"));bdpl.valueElement = document.getElementById(bdplId + "_textBox");bdpl.buttonElement =  document.getElementById(bdplId + "_image");return bdpl;};

⌨️ 快捷键说明

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