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

📄 calendar.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
*/Calendar._EVENT_TYPES = {	BEFORE_SELECT : "beforeSelect", 	SELECT : "select",	BEFORE_DESELECT : "beforeDeselect",	DESELECT : "deselect",	CHANGE_PAGE : "changePage",	BEFORE_RENDER : "beforeRender",	RENDER : "render",	BEFORE_DESTROY : "beforeDestroy",	DESTROY : "destroy",	RESET : "reset",	CLEAR : "clear",	BEFORE_HIDE : "beforeHide",	HIDE : "hide",	BEFORE_SHOW : "beforeShow",	SHOW : "show",	BEFORE_HIDE_NAV : "beforeHideNav",	HIDE_NAV : "hideNav",	BEFORE_SHOW_NAV : "beforeShowNav",	SHOW_NAV : "showNav",	BEFORE_RENDER_NAV : "beforeRenderNav",	RENDER_NAV : "renderNav"};/*** The set of default style constants for the Calendar* @property YAHOO.widget.Calendar._STYLES* @final* @static* @private* @type Object*/Calendar._STYLES = {	CSS_ROW_HEADER: "calrowhead",	CSS_ROW_FOOTER: "calrowfoot",	CSS_CELL : "calcell",	CSS_CELL_SELECTOR : "selector",	CSS_CELL_SELECTED : "selected",	CSS_CELL_SELECTABLE : "selectable",	CSS_CELL_RESTRICTED : "restricted",	CSS_CELL_TODAY : "today",	CSS_CELL_OOM : "oom",	CSS_CELL_OOB : "previous",	CSS_HEADER : "calheader",	CSS_HEADER_TEXT : "calhead",	CSS_BODY : "calbody",	CSS_WEEKDAY_CELL : "calweekdaycell",	CSS_WEEKDAY_ROW : "calweekdayrow",	CSS_FOOTER : "calfoot",	CSS_CALENDAR : "yui-calendar",	CSS_SINGLE : "single",	CSS_CONTAINER : "yui-calcontainer",	CSS_NAV_LEFT : "calnavleft",	CSS_NAV_RIGHT : "calnavright",	CSS_NAV : "calnav",	CSS_CLOSE : "calclose",	CSS_CELL_TOP : "calcelltop",	CSS_CELL_LEFT : "calcellleft",	CSS_CELL_RIGHT : "calcellright",	CSS_CELL_BOTTOM : "calcellbottom",	CSS_CELL_HOVER : "calcellhover",	CSS_CELL_HIGHLIGHT1 : "highlight1",	CSS_CELL_HIGHLIGHT2 : "highlight2",	CSS_CELL_HIGHLIGHT3 : "highlight3",	CSS_CELL_HIGHLIGHT4 : "highlight4"};Calendar.prototype = {	/**	* The configuration object used to set up the calendars various locale and style options.	* @property Config	* @private	* @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty.	* @type Object	*/	Config : null,	/**	* The parent CalendarGroup, only to be set explicitly by the parent group	* @property parent	* @type CalendarGroup	*/		parent : null,	/**	* The index of this item in the parent group	* @property index	* @type Number	*/	index : -1,	/**	* The collection of calendar table cells	* @property cells	* @type HTMLTableCellElement[]	*/	cells : null,	/**	* The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].	* @property cellDates	* @type Array[](Number[])	*/	cellDates : null,	/**	* The id that uniquely identifies this Calendar.	* @property id	* @type String	*/	id : null,	/**	* The unique id associated with the Calendar's container	* @property containerId	* @type String	*/	containerId: null,	/**	* The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.	* @property oDomContainer	* @type HTMLElement	*/	oDomContainer : null,	/**	* A Date object representing today's date.	* @property today	* @type Date	*/	today : null,	/**	* The list of render functions, along with required parameters, used to render cells. 	* @property renderStack	* @type Array[]	*/	renderStack : null,	/**	* A copy of the initial render functions created before rendering.	* @property _renderStack	* @private	* @type Array	*/	_renderStack : null,	/**	* A reference to the CalendarNavigator instance created for this Calendar.	* Will be null if the "navigator" configuration property has not been set	* @property oNavigator	* @type CalendarNavigator	*/	oNavigator : null,	/**	* The private list of initially selected dates.	* @property _selectedDates	* @private	* @type Array	*/	_selectedDates : null,	/**	* A map of DOM event handlers to attach to cells associated with specific CSS class names	* @property domEventMap	* @type Object	*/	domEventMap : null,	/**	 * Protected helper used to parse Calendar constructor/init arguments.	 *	 * As of 2.4.0, Calendar supports a simpler constructor 	 * signature. This method reconciles arguments	 * received in the pre 2.4.0 and 2.4.0 formats.	 * 	 * @protected	 * @method _parseArgs	 * @param {Array} Function "arguments" array	 * @return {Object} Object with id, container, config properties containing	 * the reconciled argument values.	 **/	_parseArgs : function(args) {		/*		   2.4.0 Constructors signatures		   new Calendar(String)		   new Calendar(HTMLElement)		   new Calendar(String, ConfigObject)		   new Calendar(HTMLElement, ConfigObject)		   Pre 2.4.0 Constructor signatures		   new Calendar(String, String)		   new Calendar(String, HTMLElement)		   new Calendar(String, String, ConfigObject)		   new Calendar(String, HTMLElement, ConfigObject)		 */		var nArgs = {id:null, container:null, config:null};		if (args && args.length && args.length > 0) {			switch (args.length) {				case 1:					nArgs.id = null;					nArgs.container = args[0];					nArgs.config = null;					break;				case 2:					if (Lang.isObject(args[1]) && !args[1].tagName && !(args[1] instanceof String)) {						nArgs.id = null;						nArgs.container = args[0];						nArgs.config = args[1];					} else {						nArgs.id = args[0];						nArgs.container = args[1];						nArgs.config = null;					}					break;				default: // 3+					nArgs.id = args[0];					nArgs.container = args[1];					nArgs.config = args[2];					break;			}		} else {		}		return nArgs;	},	/**	* Initializes the Calendar widget.	* @method init	*	* @param {String} id optional The id of the table element that will represent the Calendar widget. As of 2.4.0, this argument is optional.	* @param {String | HTMLElement} container The id of the container div element that will wrap the Calendar table, or a reference to a DIV element which exists in the document.	* @param {Object} config optional The configuration object containing the initial configuration values for the Calendar.	*/	init : function(id, container, config) {		// Normalize 2.4.0, pre 2.4.0 args		var nArgs = this._parseArgs(arguments);		id = nArgs.id;		container = nArgs.container;		config = nArgs.config;		this.oDomContainer = Dom.get(container);		if (!this.oDomContainer.id) {			this.oDomContainer.id = Dom.generateId();		}		if (!id) {			id = this.oDomContainer.id + "_t";		}		this.id = id;		this.containerId = this.oDomContainer.id;		this.initEvents();		this.today = new Date();		DateMath.clearTime(this.today);		/**		* The Config object used to hold the configuration variables for the Calendar		* @property cfg		* @type YAHOO.util.Config		*/		this.cfg = new YAHOO.util.Config(this);		/**		* The local object which contains the Calendar's options		* @property Options		* @type Object		*/		this.Options = {};		/**		* The local object which contains the Calendar's locale settings		* @property Locale		* @type Object		*/		this.Locale = {};		this.initStyles();		Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER);		Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE);		this.cellDates = [];		this.cells = [];		this.renderStack = [];		this._renderStack = [];		this.setupConfig();		if (config) {			this.cfg.applyConfig(config, true);		}		this.cfg.fireQueue();	},	/**	* Default Config listener for the iframe property. If the iframe config property is set to true, 	* renders the built-in IFRAME shim if the container is relatively or absolutely positioned.	* 	* @method configIframe	*/	configIframe : function(type, args, obj) {		var useIframe = args[0];			if (!this.parent) {			if (Dom.inDocument(this.oDomContainer)) {				if (useIframe) {					var pos = Dom.getStyle(this.oDomContainer, "position");										if (pos == "absolute" || pos == "relative") {												if (!Dom.inDocument(this.iframe)) {							this.iframe = document.createElement("iframe");							this.iframe.src = "javascript:false;";								Dom.setStyle(this.iframe, "opacity", "0");								if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) {								Dom.addClass(this.iframe, "fixedsize");							}								this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild);						}					}				} else {					if (this.iframe) {						if (this.iframe.parentNode) {							this.iframe.parentNode.removeChild(this.iframe);						}						this.iframe = null;					}				}			}		}	},	/**	* Default handler for the "title" property	* @method configTitle	*/	configTitle : function(type, args, obj) {		var title = args[0];		// "" disables title bar		if (title) {			this.createTitleBar(title);		} else {			var close = this.cfg.getProperty(DEF_CFG.CLOSE.key);			if (!close) {				this.removeTitleBar();			} else {				this.createTitleBar("&#160;");			}		}	},		/**	* Default handler for the "close" property	* @method configClose	*/	configClose : function(type, args, obj) {		var close = args[0],			title = this.cfg.getProperty(DEF_CFG.TITLE.key);			if (close) {			if (!title) {				this.createTitleBar("&#160;");			}			this.createCloseButton();		} else {			this.removeCloseButton();			if (!title) {				this.removeTitleBar();			}		}	},	/**	* Initializes Calendar's built-in CustomEvents	* @method initEvents	*/	initEvents : function() {		var defEvents = Calendar._EVENT_TYPES,			CE = YAHOO.util.CustomEvent,			cal = this; // To help with minification		/**		* Fired before a selection is made		* @event beforeSelectEvent		*/		cal.beforeSelectEvent = new CE(defEvents.BEFORE_SELECT); 		/**		* Fired when a selection is made		* @event selectEvent		* @param {Array}	Array of Date field arrays in the format [YYYY, MM, DD].		*/		cal.selectEvent = new CE(defEvents.SELECT);			/**		* Fired before a selection is made		* @event beforeDeselectEvent		*/		cal.beforeDeselectEvent = new CE(defEvents.BEFORE_DESELECT);			/**		* Fired when a selection is made		* @event deselectEvent		* @param {Array}	Array of Date field arrays in the format [YYYY, MM, DD].		*/		cal.deselectEvent = new CE(defEvents.DESELECT);			/**		* Fired when the Calendar page is changed		* @event changePageEvent		*/		cal.changePageEvent = new CE(defEvents.CHANGE_PAGE);			/**		* Fired before the Calendar is rendered		* @event beforeRenderEvent		*/		cal.beforeRenderEvent = new CE(defEvents.BEFORE_RENDER);			/**		* Fired when the Calendar is rendered		* @event renderEvent

⌨️ 快捷键说明

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