devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
120 lines (88 loc) • 3.67 kB
JavaScript
var registerComponent = require("../../core/component_registrator"),
SchedulerTimeline = require("./ui.scheduler.timeline"),
dateUtils = require("../../core/utils/date");
var TIMELINE_CLASS = "dx-scheduler-timeline-month",
DAY_IN_MILLISECONDS = 86400000;
var toMs = dateUtils.dateToMilliseconds;
var SchedulerTimelineMonth = SchedulerTimeline.inherit({
_renderView: function _renderView() {
this.callBase();
this._updateScrollable();
},
_getElementClass: function _getElementClass() {
return TIMELINE_CLASS;
},
_getDateHeaderTemplate: function _getDateHeaderTemplate() {
return this.option("dateCellTemplate");
},
_getHiddenInterval: function _getHiddenInterval() {
return 0;
},
_getIndicationFirstViewDate: function _getIndicationFirstViewDate() {
return dateUtils.trimTime(new Date(this._firstViewDate));
},
getCellDuration: function getCellDuration() {
return toMs("day");
},
getEndViewDate: function getEndViewDate() {
var dateOfLastViewCell = this.getDateOfLastViewCell();
return new Date(dateOfLastViewCell.getTime() + this._calculateDayDuration() * toMs("hour") - toMs("minute"));
},
_getCellCount: function _getCellCount() {
var currentDate = this.option("currentDate"),
cellCount = 0;
if (this._isWorkSpaceWithCount()) {
var intervalCount = this.option("intervalCount");
for (var i = 1; i <= intervalCount; i++) {
cellCount += new Date(currentDate.getFullYear(), currentDate.getMonth() + i, 0).getDate();
}
} else {
cellCount = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0).getDate();
}
return cellCount;
},
_setFirstViewDate: function _setFirstViewDate() {
this._firstViewDate = dateUtils.getFirstMonthDate(this.option("currentDate"));
this._setStartDayHour(this._firstViewDate);
},
_getFormat: function _getFormat() {
return this._formatWeekdayAndDay;
},
_getDateByIndex: function _getDateByIndex(headerIndex) {
var resultDate = new Date(this._firstViewDate);
resultDate.setDate(this._firstViewDate.getDate() + headerIndex);
return resultDate;
},
_getInterval: function _getInterval() {
return DAY_IN_MILLISECONDS;
},
_getIntervalBetween: function _getIntervalBetween(currentDate) {
var firstViewDate = this.getStartViewDate(),
timeZoneOffset = dateUtils.getTimezonesDifference(firstViewDate, currentDate);
return currentDate.getTime() - (firstViewDate.getTime() - this.option("startDayHour") * 3600000) - timeZoneOffset;
},
calculateEndDate: function calculateEndDate(startDate) {
var startDateCopy = new Date(startDate);
return new Date(startDateCopy.setHours(this.option("endDayHour")));
},
_calculateHiddenInterval: function _calculateHiddenInterval() {
return 0;
},
_getDateByCellIndexes: function _getDateByCellIndexes(rowIndex, cellIndex) {
var date = this.callBase(rowIndex, cellIndex);
this._setStartDayHour(date);
return date;
},
needUpdateScrollPosition: function needUpdateScrollPosition(hours, minutes, bounds, date) {
return this._dateWithinBounds(bounds, date);
},
getPositionShift: function getPositionShift() {
return {
top: 0,
left: 0
};
}
});
registerComponent("dxSchedulerTimelineMonth", SchedulerTimelineMonth);
module.exports = SchedulerTimelineMonth;
;