UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

158 lines (119 loc) 5.64 kB
"use strict"; var GroupedStrategy = require("./ui.scheduler.work_space.grouped.strategy"); var HORIZONTAL_GROUPED_ATTR = "dx-group-row-count"; var HorizontalGroupedStrategy = GroupedStrategy.inherit({ prepareCellIndexes: function prepareCellIndexes(cellCoordinates, groupIndex) { return { rowIndex: cellCoordinates.rowIndex, cellIndex: cellCoordinates.cellIndex + groupIndex * this._workSpace._getCellCount() }; }, calculateCellIndex: function calculateCellIndex(rowIndex, cellIndex) { cellIndex = cellIndex % this._workSpace._getCellCount(); return this._workSpace._getRowCount() * cellIndex + rowIndex; }, getGroupIndex: function getGroupIndex(rowIndex, cellIndex) { return Math.floor(cellIndex / this._workSpace._getCellCount()); }, calculateHeaderCellRepeatCount: function calculateHeaderCellRepeatCount() { return this._workSpace._getGroupCount() || 1; }, insertAllDayRowsIntoDateTable: function insertAllDayRowsIntoDateTable() { return false; }, getTotalCellCount: function getTotalCellCount(groupCount) { groupCount = groupCount || 1; return this._workSpace._getCellCount() * groupCount; }, getTotalRowCount: function getTotalRowCount() { return this._workSpace._getRowCount(); }, addAdditionalGroupCellClasses: function addAdditionalGroupCellClasses(cellClass, index) { cellClass = this._addLastGroupCellClass(cellClass, index); return this._addFirstGroupCellClass(cellClass, index); }, _addLastGroupCellClass: function _addLastGroupCellClass(cellClass, index) { if (index % this._workSpace._getCellCount() === 0) { return cellClass + " " + this.getLastGroupCellClass(); } return cellClass; }, _addFirstGroupCellClass: function _addFirstGroupCellClass(cellClass, index) { if ((index - 1) % this._workSpace._getCellCount() === 0) { return cellClass + " " + this.getFirstGroupCellClass(); } return cellClass; }, getHorizontalMax: function getHorizontalMax(groupIndex) { return this._workSpace.getMaxAllowedPosition()[groupIndex]; }, getVerticalMax: function getVerticalMax(groupIndex) { return this._workSpace.getMaxAllowedVerticalPosition()[0]; }, calculateTimeCellRepeatCount: function calculateTimeCellRepeatCount() { return 1; }, getWorkSpaceMinWidth: function getWorkSpaceMinWidth() { var minWidth = this._workSpace._getWorkSpaceWidth(), workspaceContainerWidth = this._workSpace.$element().get(0).getBoundingClientRect().width - this._workSpace.getTimePanelWidth(); if (minWidth < workspaceContainerWidth) { minWidth = workspaceContainerWidth; } return minWidth; }, getAllDayOffset: function getAllDayOffset() { return this._workSpace.getAllDayHeight(); }, getAllDayTableHeight: function getAllDayTableHeight() { return this._workSpace._$allDayTable.get(0).getBoundingClientRect().height || 0; }, getGroupCountAttr: function getGroupCountAttr(groupRowCount, groupRows) { return { attr: HORIZONTAL_GROUPED_ATTR, count: groupRows && groupRows.elements.length }; }, getLeftOffset: function getLeftOffset() { return this._workSpace.getTimePanelWidth(); }, getGroupBoundsOffset: function getGroupBoundsOffset(cellCount, $cells, cellWidth, coordinates) { var cellIndex = this._workSpace.getCellIndexByCoordinates(coordinates), groupIndex = coordinates.groupIndex || Math.floor(cellIndex / cellCount), startCellIndex = groupIndex * cellCount, startOffset = $cells.eq(startCellIndex).offset().left - cellWidth / 2, endOffset = $cells.eq(startCellIndex + cellCount - 1).offset().left + cellWidth + cellWidth / 2; return { left: startOffset, right: endOffset, top: 0, bottom: 0 }; }, shiftIndicator: function shiftIndicator($indicator, height, rtlOffset, i) { var offset = this._workSpace._getCellCount() * this._workSpace.getRoundedCellWidth(i - 1, 0) * i + this._workSpace.getIndicatorOffset(i) + i, horizontalOffset = rtlOffset ? rtlOffset - offset : offset; $indicator.css("left", horizontalOffset); $indicator.css("top", height); }, getShaderOffset: function getShaderOffset(i, width) { var offset = this._workSpace._getCellCount() * this._workSpace.getRoundedCellWidth(i - 1) * i; return this._workSpace.option("rtlEnabled") ? this._workSpace._dateTableScrollable.$content().get(0).getBoundingClientRect().width - offset - this._workSpace.getTimePanelWidth() - width : offset; }, getShaderTopOffset: function getShaderTopOffset(i) { return -this.getShaderMaxHeight() * (i > 0 ? 1 : 0); }, getShaderHeight: function getShaderHeight() { var height = this._workSpace.getIndicationHeight(); return height; }, getShaderMaxHeight: function getShaderMaxHeight() { return this._workSpace._dateTableScrollable.$content().get(0).getBoundingClientRect().height; }, getShaderWidth: function getShaderWidth(i) { return this._workSpace.getIndicationWidth(i); }, getScrollableScrollTop: function getScrollableScrollTop(allDay) { return !allDay ? this._workSpace.getScrollable().scrollTop() : 0; } }); module.exports = HorizontalGroupedStrategy;