UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

109 lines (108 loc) 5.45 kB
/** * DevExtreme (cjs/__internal/ui/gantt/ui.gantt.size_helper.js) * Version: 26.1.4 * Build date: Fri Jul 24 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GanttSizeHelper = void 0; var _size = require("../../../core/utils/size"); var _window = require("../../../core/utils/window"); class GanttSizeHelper { constructor(gantt) { this._gantt = gantt } _setTreeListDimension(dimension, value) { var _this$_gantt$_ganttTr; const setter = "width" === dimension ? _size.setWidth : _size.setHeight; const getter = "width" === dimension ? _size.getWidth : _size.getHeight; setter(this._gantt._$treeListWrapper, value); null === (_this$_gantt$_ganttTr = this._gantt._ganttTreeList) || void 0 === _this$_gantt$_ganttTr || _this$_gantt$_ganttTr.setOption(dimension, getter(this._gantt._$treeListWrapper)) } _setGanttViewDimension(dimension, value) { const setter = "width" === dimension ? _size.setWidth : _size.setHeight; const getter = "width" === dimension ? _size.getWidth : _size.getHeight; setter(this._gantt._$ganttView, value); this._gantt._setGanttViewOption(dimension, getter(this._gantt._$ganttView)) } _getPanelsWidthByOption() { var _leftPanelWidth$index, _leftPanelWidth$index2; const ganttWidth = (0, _size.getWidth)(this._gantt.$element()); const { taskListWidth: leftPanelWidth } = this._gantt.option(); let rightPanelWidth; if (!isNaN(leftPanelWidth)) { rightPanelWidth = ganttWidth - parseInt(leftPanelWidth, 10) } else if ((null === (_leftPanelWidth$index = leftPanelWidth.indexOf) || void 0 === _leftPanelWidth$index ? void 0 : _leftPanelWidth$index.call(leftPanelWidth, "px")) > 0) { rightPanelWidth = ganttWidth - parseInt(leftPanelWidth.replace("px", ""), 10) + "px" } else if ((null === (_leftPanelWidth$index2 = leftPanelWidth.indexOf) || void 0 === _leftPanelWidth$index2 ? void 0 : _leftPanelWidth$index2.call(leftPanelWidth, "%")) > 0) { rightPanelWidth = 100 - parseInt(leftPanelWidth.replace("%", ""), 10) + "%" } return { leftPanelWidth: leftPanelWidth, rightPanelWidth: rightPanelWidth } } onAdjustControl() { const elementHeight = (0, _size.getHeight)(this._gantt.$element()); this.updateGanttWidth(); this.setGanttHeight(elementHeight) } onApplyPanelSize(e) { this.setInnerElementsWidth(e); this.updateGanttRowHeights() } updateGanttRowHeights() { var _this$_gantt$_ganttTr2; const rowHeight = null === (_this$_gantt$_ganttTr2 = this._gantt._ganttTreeList) || void 0 === _this$_gantt$_ganttTr2 ? void 0 : _this$_gantt$_ganttTr2.getRowHeight(); if (this._gantt._getGanttViewOption("rowHeight") !== rowHeight) { var _this$_gantt$_ganttVi; this._gantt._setGanttViewOption("rowHeight", rowHeight); null === (_this$_gantt$_ganttVi = this._gantt._ganttView) || void 0 === _this$_gantt$_ganttVi || _this$_gantt$_ganttVi._ganttViewCore.updateRowHeights(rowHeight) } } adjustHeight() { if (!this._gantt._hasHeight) { var _this$_gantt$_ganttTr3; this._gantt._setGanttViewOption("height", 0); this._gantt._setGanttViewOption("height", null === (_this$_gantt$_ganttTr3 = this._gantt._ganttTreeList) || void 0 === _this$_gantt$_ganttTr3 ? void 0 : _this$_gantt$_ganttTr3.getOffsetHeight()) } } setInnerElementsWidth(widths) { var _widths, _widths2; if (!(0, _window.hasWindow)()) { return } const takeWithFromOption = !widths; if (takeWithFromOption) { widths = this._getPanelsWidthByOption(); this._setTreeListDimension("width", 0); this._setGanttViewDimension("width", 0) } this._setTreeListDimension("width", null === (_widths = widths) || void 0 === _widths ? void 0 : _widths.leftPanelWidth); this._setGanttViewDimension("width", null === (_widths2 = widths) || void 0 === _widths2 ? void 0 : _widths2.rightPanelWidth); if (takeWithFromOption) { var _this$_gantt$_splitte; null === (_this$_gantt$_splitte = this._gantt._splitter) || void 0 === _this$_gantt$_splitte || _this$_gantt$_splitte._setSplitterPositionLeft() } } updateGanttWidth() { var _this$_gantt$_splitte2; null === (_this$_gantt$_splitte2 = this._gantt._splitter) || void 0 === _this$_gantt$_splitte2 || _this$_gantt$_splitte2._dimensionChanged() } setGanttHeight(height) { var _this$_gantt$_ganttVi2; const toolbarHeightOffset = this._gantt._$toolbarWrapper.get(0).offsetHeight; const mainWrapperHeight = height - toolbarHeightOffset; this._setTreeListDimension("height", mainWrapperHeight); this._setGanttViewDimension("height", mainWrapperHeight); null === (_this$_gantt$_ganttVi2 = this._gantt._ganttView) || void 0 === _this$_gantt$_ganttVi2 || _this$_gantt$_ganttVi2._ganttViewCore.resetAndUpdate() } } exports.GanttSizeHelper = GanttSizeHelper;