📄 sync.calendarselect.js
字号:
enabled = this.component.isRenderEnabled(), span = document.createElement("span"); this._monthSelect = document.createElement("select"); for (i = 0; i < 12; ++i) { option = document.createElement("option"); option.appendChild(document.createTextNode(this._msg["Month." + i])); this._monthSelect.appendChild(option); } if (!enabled) { this._monthSelect.disabled = true; } span.appendChild(this._monthSelect); span.appendChild(document.createTextNode(" ")); this._yearDecSpan = document.createElement("span"); this._yearDecSpan.style.cursor = "pointer"; img = document.createElement("img"); img.src = this._icons.decrement ? this._icons.decrement : this.client.getResourceUrl("Extras", "image/calendar/Decrement.gif"); img.alt = "-"; this._yearDecSpan.appendChild(img); span.appendChild(this._yearDecSpan); this._yearField = document.createElement("input"); this._yearField.type = "text"; this._yearField.style.textAlign = "center"; this._yearField.maxLength = 4; this._yearField.size = 5; if (!enabled) { this._yearField.readOnly = true; } span.appendChild(this._yearField); this._yearIncSpan = document.createElement("span"); this._yearIncSpan.style.cursor = "pointer"; img = document.createElement("img"); img.src = this._icons.increment ? this._icons.increment : this.client.getResourceUrl("Extras", "image/calendar/Increment.gif"); img.alt = "+"; this._yearIncSpan.appendChild(img); span.appendChild(this._yearIncSpan); return span; }, _createWeek: function(line) { var day = 1 - this._monthData.firstCellPosition + (7 * line); var rowDiv = document.createElement("div"); rowDiv.style.cssText = "position:absolute;overflow:hidden;cursor:pointer;"; rowDiv.style.width = this._rowWidth + "px"; rowDiv.style.height = this._cellHeight + "px"; for (var x = 0; x < this._xSize; ++x, ++day) { var cellDiv = document.createElement("div"); cellDiv._cellIndex = 7 * line + x; cellDiv.style.cssText = "position:absolute;text-align:right;"; cellDiv.style.left = (x * (this._cellWidth + this._hCellSpacing)) + "px"; cellDiv.style.width = this._renderedCellWidth + "px"; cellDiv.style.height = this._renderedCellHeight + "px"; Echo.Sync.Border.render(this._dateBorder, cellDiv); cellDiv.style.padding = "2px 4px"; cellDiv.style.overflow = "hidden"; var displayDay; if (day < 1) { cellDiv.style.color = this._dateAdjacentForeground; displayDay = this._monthData.daysInPreviousMonth + day; } else if (day > this._monthData.daysInMonth) { cellDiv.style.color = this._dateAdjacentForeground; displayDay = day - this._monthData.daysInMonth; } else { if (this._date.day == day) { Echo.Sync.Color.render(this._dateSelectedBackground, cellDiv, "backgroundColor"); Echo.Sync.Color.render(this._dateSelectedForeground, cellDiv, "color"); Echo.Sync.FillImage.render(this._dateSelectedBackgroundImage, cellDiv); Echo.Sync.Border.render(this._dateSelectedBorder, cellDiv); } displayDay = day; } cellDiv.appendChild(document.createTextNode(displayDay)); rowDiv.appendChild(cellDiv); } return rowDiv; }, _getCell: function(cellIndex) { return this._dayContainerDiv.childNodes[Math.floor(cellIndex / 7)].childNodes[cellIndex % 7]; }, _loadRenderData: function() { this._font = this.component.render("font", Extras.Sync.CalendarSelect.DEFAULT_FONT); // Default Cell Style this._dateBackground = this.component.render("dateBackground", Extras.Sync.CalendarSelect.DEFAULT_DATE_BACKGROUND); this._dateBorder = this.component.render("dateBorder", Extras.Sync.CalendarSelect.DEFAULT_DATE_BORDER); this._dateBackgroundImage = this.component.render("dateBackgroundImage", Extras.Sync.CalendarSelect.DEFAULT_DATE_BACKGROUND); this._dateForeground = this.component.render("dateForeground", Extras.Sync.CalendarSelect.DEFAULT_DATE_FOREGROUND); // Selected Cell Style this._dateSelectedBackground = this.component.render("selectedDateBackground", Extras.Sync.CalendarSelect.DEFAULT_SELECTED_DATE_BACKGROUND); this._dateSelectedBackgroundImage = this.component.render("selectedDateBackgroundImage"); this._dateSelectedBorder = this.component.render("selectedDateBorder"); this._dateSelectedForeground = this.component.render("selectedDateForeground", Extras.Sync.CalendarSelect.DEFAULT_SELECTED_DATE_FOREGROUND); // Rollover Cell Style this._dateRolloverBackground = this.component.render("rolloverDateBackground"); this._dateRolloverBackgroundImage = this.component.render("rolloverDateBackgroundImage"); this._dateRolloverBorder = this.component.render("rolloverDateBorder"); this._dateRolloverForeground = this.component.render("rolloverDateForeground"); if (!this._dateRolloverBackground) { this._dateRolloverBackground = Echo.Sync.Color.adjust(this._dateBackground, 0x20, 0x20, 0x20); } // Adjacent Cell Style this._dateAdjacentForeground = this.component.render("adjacentMonthDateForeground", Extras.Sync.CalendarSelect.DEFAULT_ADJACENT_MONTH_DATE_FOREGROUND); this._dateAdjacentBackground = this.component.render("adjacentMonthDateBackground"); // Measure size of date cell text var cellMeasure = document.createElement("span"); cellMeasure.appendChild(document.createTextNode("96")); Echo.Sync.Font.render(this._font, cellMeasure); var cellBounds = new Core.Web.Measure.Bounds(cellMeasure); // FIXME hardcoded this._padding = { top: 2, bottom: 2, left: 4, right: 4 }; this._borderSize = { top: 1, bottom: 1, left: 1, right: 1 }; // Calculate cell size this._cellWidth = cellBounds.width + this._padding.left + this._padding.right + this._borderSize.left + this._borderSize.right; if (this._cellWidth * 7 < this._monthYearWidth) { this._cellWidth = Math.ceil(this._monthYearWidth / 7); } this._cellHeight = cellBounds.height + this._padding.top + this._padding.bottom + this._borderSize.top + this._borderSize.bottom; this._hCellSpacing = 0; this._vCellSpacing = 0; this._headerHeight = cellBounds.height; this._headerMargin = 0; this._xSize = 7; this._ySize = 6; this._rowWidth = this._xSize * this._cellWidth + (this._xSize - 1) * this._hCellSpacing; this._calendarHeight = this._ySize * this._cellHeight + (this._ySize - 1) * this._vCellSpacing + this._headerHeight + this._headerMargin; this._renderedCellWidth = this._cellWidth - this._borderSize.left - this._borderSize.right - this._padding.left - this._padding.right; this._renderedCellHeight = this._cellHeight - this._borderSize.top - this._borderSize.bottom - this._padding.top - this._padding.bottom; }, _processDateRolloverEnter: function(e) { if (!this.client || !this.client.verifyInput(this.component) || e.target._cellIndex == null || this._animation) { return; } if (this._rolloverCellIndex != null) { this._setCellStyle(this._rolloverCellIndex, false); } this._rolloverCellIndex = e.target._cellIndex; this._setCellStyle(this._rolloverCellIndex, true); }, _processDateRolloverExit: function(e) { if (this._rolloverCellIndex) { this._setCellStyle(this._rolloverCellIndex, false); this._rolloverCellIndex = null; } }, _processDateSelect: function(e) { if (!this.client || !this.client.verifyInput(this.component) || e.target._cellIndex == null || this._animation) { return; } this._setDate(this._monthData.getCellDate(e.target._cellIndex)); }, _processMonthSelect: function(e) { if (!this.client || !this.client.verifyInput(this.component)) { this._monthSelect.selectedIndex = this._date.month; return; } this._setDate({ year: this._date.year, month: this._monthSelect.selectedIndex, day: this._date.day }); }, _processYearChange: function(e) { var newValue = parseInt(this._yearField.value, 10); if (!this.client || !this.client.verifyInput(this.component) || isNaN(newValue)) { this._yearField.value = this._date.year; return; } this._setDate({ year: newValue, month: this._date.month, day: this._date.day }); }, _processYearKeyUp: function(e) { if (e.keyCode == 13) { this._processYearChange(e); } }, _processYearDecrement: function(e) { if (!this.client || !this.client.verifyInput(this.component)) { return; } this._setDate({ year: this._date.year - 1, month: this._date.month, day: this._date.day }); }, _processYearIncrement: function(e) { if (!this.client || !this.client.verifyInput(this.component)) { return; } this._setDate({ year: this._date.year + 1, month: this._date.month, day: this._date.day }); }, _rangeCheck: function(date) { if (date.year < Extras.Sync.CalendarSelect.MINIMUM_YEAR) { date.year = Extras.Sync.CalendarSelect.MINIMUM_YEAR; } else if (date.year > Extras.Sync.CalendarSelect.MAXIMUM_YEAR) { date.year = Extras.Sync.CalendarSelect.MAXIMUM_YEAR; } }, renderAdd: function(update, parentElement) { this._msg = Extras.Sync.CalendarSelect.resource.get(this.component.getRenderLocale());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -