1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
9 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
10 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
11 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
12 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
13 | };
|
14 | var __metadata = (this && this.__metadata) || function (k, v) {
|
15 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
16 | };
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | var context_1 = require("../context/context");
|
19 | var beans_1 = require("./beans");
|
20 | var cellComp_1 = require("./cellComp");
|
21 | var columnController_1 = require("../columnController/columnController");
|
22 | var utils_1 = require("../utils");
|
23 | var AutoHeightCalculator = (function () {
|
24 | function AutoHeightCalculator() {
|
25 | }
|
26 | AutoHeightCalculator.prototype.registerGridComp = function (gridPanel) {
|
27 | this.gridPanel = gridPanel;
|
28 | };
|
29 | AutoHeightCalculator.prototype.getPreferredHeightForRow = function (rowNode) {
|
30 | var _this = this;
|
31 | if (!this.eDummyContainer) {
|
32 | this.eDummyContainer = document.createElement('div');
|
33 |
|
34 |
|
35 | utils_1._.addCssClass(this.eDummyContainer, 'ag-row ag-row-no-focus');
|
36 | }
|
37 |
|
38 |
|
39 | var eBodyContainer = this.gridPanel.getBodyContainer();
|
40 | eBodyContainer.appendChild(this.eDummyContainer);
|
41 | var cellComps = [];
|
42 | var cols = this.columnController.getAllAutoRowHeightCols();
|
43 | console.log();
|
44 | cols.forEach(function (col) {
|
45 | var cellComp = new cellComp_1.CellComp(_this.$scope, _this.beans, col, rowNode, null, true);
|
46 | cellComp.setParentRow(_this.eDummyContainer);
|
47 | cellComps.push(cellComp);
|
48 | });
|
49 | var template = cellComps.map(function (cellComp) { return cellComp.getCreateTemplate(); }).join(' ');
|
50 | this.eDummyContainer.innerHTML = template;
|
51 |
|
52 | cellComps.forEach(function (cellComp) { return cellComp.afterAttached(); });
|
53 |
|
54 |
|
55 |
|
56 | var maxCellHeight = 0;
|
57 | for (var i = 0; i < this.eDummyContainer.children.length; i++) {
|
58 | var child = this.eDummyContainer.children[i];
|
59 | if (child.offsetHeight > maxCellHeight) {
|
60 | maxCellHeight = child.offsetHeight;
|
61 | }
|
62 | }
|
63 |
|
64 | eBodyContainer.removeChild(this.eDummyContainer);
|
65 | cellComps.forEach(function (cellComp) {
|
66 |
|
67 | cellComp.detach();
|
68 | cellComp.destroy();
|
69 | });
|
70 |
|
71 | utils_1._.removeAllChildren(this.eDummyContainer);
|
72 | return maxCellHeight;
|
73 | };
|
74 | __decorate([
|
75 | context_1.Autowired('beans'),
|
76 | __metadata("design:type", beans_1.Beans)
|
77 | ], AutoHeightCalculator.prototype, "beans", void 0);
|
78 | __decorate([
|
79 | context_1.Autowired("$scope"),
|
80 | __metadata("design:type", Object)
|
81 | ], AutoHeightCalculator.prototype, "$scope", void 0);
|
82 | __decorate([
|
83 | context_1.Autowired("columnController"),
|
84 | __metadata("design:type", columnController_1.ColumnController)
|
85 | ], AutoHeightCalculator.prototype, "columnController", void 0);
|
86 | AutoHeightCalculator = __decorate([
|
87 | context_1.Bean('autoHeightCalculator')
|
88 | ], AutoHeightCalculator);
|
89 | return AutoHeightCalculator;
|
90 | }());
|
91 | exports.AutoHeightCalculator = AutoHeightCalculator;
|