📄 calendar.js
字号:
this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should suppress weeks that are not a part of the current month. False by default. * @config HIDE_BLANK_WEEKS * @type Boolean * @default false */ this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * The image that should be used for the left navigation arrow. * @config NAV_ARROW_LEFT * @type String * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" * @default null */ this.cfg.addProperty("NAV_ARROW_LEFT", { value:null, handler:this.configOptions } ); /** * The image that should be used for the right navigation arrow. * @config NAV_ARROW_RIGHT * @type String * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" * @default null */ this.cfg.addProperty("NAV_ARROW_RIGHT", { value:null, handler:this.configOptions } ); // Locale properties /** * The short month labels for the current locale. * @config MONTHS_SHORT * @type String[] * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] */ this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.configLocale } ); /** * The long month labels for the current locale. * @config MONTHS_LONG * @type String[] * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" */ this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.configLocale } ); /** * The 1-character weekday labels for the current locale. * @config WEEKDAYS_1CHAR * @type String[] * @default ["S", "M", "T", "W", "T", "F", "S"] */ this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.configLocale } ); /** * The short weekday labels for the current locale. * @config WEEKDAYS_SHORT * @type String[] * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] */ this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.configLocale } ); /** * The medium weekday labels for the current locale. * @config WEEKDAYS_MEDIUM * @type String[] * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] */ this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.configLocale } ); /** * The long weekday labels for the current locale. * @config WEEKDAYS_LONG * @type String[] * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] */ this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.configLocale } ); /** * Refreshes the locale values used to build the Calendar. * @method refreshLocale * @private */ var refreshLocale = function() { this.cfg.refireEvent("LOCALE_MONTHS"); this.cfg.refireEvent("LOCALE_WEEKDAYS"); }; this.cfg.subscribeToConfigEvent("START_WEEKDAY", refreshLocale, this, true); this.cfg.subscribeToConfigEvent("MONTHS_SHORT", refreshLocale, this, true); this.cfg.subscribeToConfigEvent("MONTHS_LONG", refreshLocale, this, true); this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR", refreshLocale, this, true); this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT", refreshLocale, this, true); this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM", refreshLocale, this, true); this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG", refreshLocale, this, true); /** * The setting that determines which length of month labels should be used. Possible values are "short" and "long". * @config LOCALE_MONTHS * @type String * @default "long" */ this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } ); /** * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". * @config LOCALE_WEEKDAYS * @type String * @default "short" */ this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } ); /** * The value used to delimit individual dates in a date string passed to various Calendar functions. * @config DATE_DELIMITER * @type String * @default "," */ this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } ); /** * The value used to delimit date fields in a date string passed to various Calendar functions. * @config DATE_FIELD_DELIMITER * @type String * @default "/" */ this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } ); /** * The value used to delimit date ranges in a date string passed to various Calendar functions. * @config DATE_RANGE_DELIMITER * @type String * @default "-" */ this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } ); /** * The position of the month in a month/year date string * @config MY_MONTH_POSITION * @type Number * @default 1 */ this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/year date string * @config MY_YEAR_POSITION * @type Number * @default 2 */ this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day date string * @config MD_MONTH_POSITION * @type Number * @default 1 */ this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/year date string * @config MD_DAY_POSITION * @type Number * @default 2 */ this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day/year date string * @config MDY_MONTH_POSITION * @type Number * @default 1 */ this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/day/year date string * @config MDY_DAY_POSITION * @type Number * @default 2 */ this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/day/year date string * @config MDY_YEAR_POSITION * @type Number * @default 3 */ this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } );};/*** The default handler for the "pagedate" property* @method configPageDate*/YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { this.cfg.setProperty("pagedate", this._parsePageDate(args[0]), true);};/*** The default handler for the "mindate" property* @method configMinDate*/YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) { var val = args[0]; if (typeof val == 'string') { val = this._parseDate(val); this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2])); }};/*** The default handler for the "maxdate" property* @method configMaxDate*/YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) { var val = args[0]; if (typeof val == 'string') { val = this._parseDate(val); this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2])); }};/*** The default handler for the "selected" property* @method configSelected*/YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) { var selected = args[0]; if (selected) { if (typeof selected == 'string') { this.cfg.setProperty("selected", this._parseDates(selected), true); } } if (! this._selectedDates) { this._selectedDates = this.cfg.getProperty("selected"); }};/*** The default handler for all configuration options properties* @method configOptions*/YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { type = type.toUpperCase(); var val = args[0]; this.Options[type] = val;};/*** The default handler for all configuration locale properties* @method configLocale*/YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) { type = type.toUpperCase(); var val = args[0]; this.Locale[type] = val; this.cfg.refireEvent("LOCALE_MONTHS"); this.cfg.refireEvent("LOCALE_WEEKDAYS");};/*** The default handler for all configuration locale field length properties* @method configLocaleValues*/YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) { type = type.toUpperCase(); var val = args[0]; switch (type) { case "LOCALE_MONTHS": switch (val) { case "short": this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat(); break; case "long": this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat(); break; } break; case "LOCALE_WEEKDAYS": switch (val) { case "1char": this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat(); break; case "short": this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat(); break; case "medium": this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat(); break; case "long": this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat(); break; } var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY"); if (START_WEEKDAY > 0) { for (var w=0;w<START_WEEKDAY;++w) { this.Locale.LOCALE_WEEKDAYS.push(this.Locale.LOCALE_WEEKDAYS.shift()); } } break; }};/*** Defines the style constants for the Calendar* @method initStyles*/YAHOO.widget.Calendar.prototype.initStyles = function() { /** * Collection of Style constants for the Calendar * @property Style */ this.Style = { /** * @property Style.CSS_ROW_HEADER */ CSS_ROW_HEADER: "calrowhead", /** * @property Style.CSS_ROW_FOOTER */ CSS_ROW_FOOTER: "calrowfoot", /** * @property Style.CSS_CELL */ CSS_CELL : "calcell", /** * @property Style.CSS_CELL_SELECTED */ CSS_CELL_SELECTED : "selected", /** * @property Style.CSS_CELL_SELECTABLE */ CSS_CELL_SELECTABLE : "selectable", /** * @property Style.CSS_CELL_RESTRICTED */ CSS_CELL_RESTRICTED : "restricted", /** * @property Style.CSS_CELL_TODAY */ CSS_CELL_TODAY : "today", /** * @property Style.CSS_CELL_OOM */ CSS_CELL_OOM : "oom", /** * @property Style.CSS_CELL_OOB */ CSS_CELL_OOB : "previous", /** * @property Style.CSS_HEADER */ CSS_HEADER : "calheader", /** * @property Style.CSS_HEADER_TEXT */ CSS_HEADER_TEXT : "calhead", /** * @property Style.CSS_BODY */ CSS_BODY : "calbody", /** * @property Style.CSS_WEEKDAY_CELL */ CSS_WEEKDAY_CELL : "calweekdaycell", /** * @property Style.CSS_WEEKDAY_ROW */ CSS_WEEKDAY_ROW : "calweekdayrow", /** * @property Style.CSS_FOOTER */ CSS_FOOTER : "calfoot", /** * @property Style.CSS_CALENDAR */ CSS_CALENDAR : "yui-calendar", /** * @property Style.CSS_SINGLE */ CSS_SINGLE : "single", /** * @property Style.CSS_CONTAINER */ CSS_CONTAINER : "yui-calcontainer", /** * @property Style.CSS_NAV_LEFT */ CSS_NAV_LEFT : "calnavleft", /** * @property Style.CSS_NAV_RIGHT */ CSS_NAV_RIGHT : "calnavright", /** * @property Style.CSS_CLOSE */ CSS_CLOSE : "calclose", /** * @property Style.CSS_CELL_TOP */ CSS_CELL_TOP : "calcelltop", /** * @property Style.CSS_CELL_LEFT */ CSS_CELL_LEFT : "calcellleft", /** * @property Style.CSS_CELL_RIGHT */ CSS_CELL_RIGHT : "calcellright", /** * @property Style.CSS_CELL_BOTTOM */ CSS_CELL_BOTTOM : "calcellbottom", /** * @property Style.CSS_CELL_HOVER */ CSS_CELL_HOVER : "calcellhover", /** * @property Style.CSS_CELL_HIGHLIGHT1 */ CSS_CELL_HIGHLIGHT1 : "highlight1", /** * @property Style.CSS_CELL_HIGHLIGHT2 */ CSS_CELL_HIGHLIGHT2 : "highlight2", /** * @property Style.CSS_CELL_HIGHLIGHT3 */ CSS_CELL_HIGHLIGHT3 : "highlight3", /** * @property Style.CSS_CELL_HIGHLIGHT4 */ CSS_CELL_HIGHLIGHT4 : "highlight4" };};/*** Builds the date label that will be displayed in the calendar header or* footer, depending on configuration.* @method buildMonthLabel* @return {String} The formatted calendar month label*/YAHOO.widget.Calendar.prototype.buildMonthLabel = function() { var text = this.Locale.LOCALE_MONTHS[this.cfg.getProperty("pagedate").getMonth()] + " " + this.cfg.getProperty("pagedate").getFullYear(); return text;};/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -