📄 calendar.js
字号:
* @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 (YAHOO.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 = YAHOO.util.Dom.get(container); if (!this.oDomContainer.id) { this.oDomContainer.id = YAHOO.util.Dom.generateId(); } if (!id) { id = this.oDomContainer.id + "_t"; } this.id = id; this.containerId = this.oDomContainer.id; this.initEvents(); this.today = new Date(); YAHOO.widget.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(); YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); YAHOO.util.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 (YAHOO.util.Dom.inDocument(this.oDomContainer)) { if (useIframe) { var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); if (pos == "absolute" || pos == "relative") { if (!YAHOO.util.Dom.inDocument(this.iframe)) { this.iframe = document.createElement("iframe"); this.iframe.src = "javascript:false;"; YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { YAHOO.util.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(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key); if (!close) { this.removeTitleBar(); } else { this.createTitleBar(" "); } } }, /** * Default handler for the "close" property * @method configClose */ configClose : function(type, args, obj) { var close = args[0], title = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key); if (close) { if (!title) { this.createTitleBar(" "); } this.createCloseButton(); } else { this.removeCloseButton(); if (!title) { this.removeTitleBar(); } } }, /** * Initializes Calendar's built-in CustomEvents * @method initEvents */ initEvents : function() { var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; /** * Fired before a selection is made * @event beforeSelectEvent */ this.beforeSelectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT); /** * Fired when a selection is made * @event selectEvent * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. */ this.selectEvent = new YAHOO.util.CustomEvent(defEvents.SELECT); /** * Fired before a selection is made * @event beforeDeselectEvent */ this.beforeDeselectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT); /** * Fired when a selection is made * @event deselectEvent * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. */ this.deselectEvent = new YAHOO.util.CustomEvent(defEvents.DESELECT); /** * Fired when the Calendar page is changed * @event changePageEvent */ this.changePageEvent = new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE); /** * Fired before the Calendar is rendered * @event beforeRenderEvent */ this.beforeRenderEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER); /** * Fired when the Calendar is rendered * @event renderEvent */ this.renderEvent = new YAHOO.util.CustomEvent(defEvents.RENDER); /** * Fired when the Calendar is reset * @event resetEvent */ this.resetEvent = new YAHOO.util.CustomEvent(defEvents.RESET); /** * Fired when the Calendar is cleared * @event clearEvent */ this.clearEvent = new YAHOO.util.CustomEvent(defEvents.CLEAR); /** * Fired just before the Calendar is to be shown * @event beforeShowEvent */ this.beforeShowEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SHOW); /** * Fired after the Calendar is shown * @event showEvent */ this.showEvent = new YAHOO.util.CustomEvent(defEvents.SHOW); /** * Fired just before the Calendar is to be hidden * @event beforeHideEvent */ this.beforeHideEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_HIDE); /** * Fired after the Calendar is hidden * @event hideEvent */ this.hideEvent = new YAHOO.util.CustomEvent(defEvents.HIDE); /** * Fired just before the CalendarNavigator is to be shown * @event beforeShowNavEvent */ this.beforeShowNavEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SHOW_NAV); /** * Fired after the CalendarNavigator is shown * @event showNavEvent */ this.showNavEvent = new YAHOO.util.CustomEvent(defEvents.SHOW_NAV); /** * Fired just before the CalendarNavigator is to be hidden * @event beforeHideNavEvent */ this.beforeHideNavEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_HIDE_NAV); /** * Fired after the CalendarNavigator is hidden * @event hideNavEvent */ this.hideNavEvent = new YAHOO.util.CustomEvent(defEvents.HIDE_NAV);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -