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 utils_1 = require("../utils");
|
19 | var context_1 = require("../context/context");
|
20 | var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | var RowContainerComponent = (function () {
|
27 | function RowContainerComponent(params) {
|
28 | this.childCount = 0;
|
29 | this.rowTemplatesToAdd = [];
|
30 | this.afterGuiAttachedCallbacks = [];
|
31 | this.eContainer = params.eContainer;
|
32 | this.eViewport = params.eViewport;
|
33 | this.hideWhenNoChildren = params.hideWhenNoChildren;
|
34 | }
|
35 | RowContainerComponent.prototype.setVerticalScrollPosition = function (verticalScrollPosition) {
|
36 | this.scrollTop = verticalScrollPosition;
|
37 | };
|
38 | RowContainerComponent.prototype.postConstruct = function () {
|
39 | this.domOrder = this.gridOptionsWrapper.isEnsureDomOrder();
|
40 | this.checkVisibility();
|
41 | };
|
42 | RowContainerComponent.prototype.getRowElement = function (compId) {
|
43 | return this.eContainer.querySelector("[comp-id=\"" + compId + "\"]");
|
44 | };
|
45 | RowContainerComponent.prototype.setHeight = function (height) {
|
46 | this.eContainer.style.height = height + "px";
|
47 | };
|
48 | RowContainerComponent.prototype.flushRowTemplates = function () {
|
49 |
|
50 |
|
51 | if (this.rowTemplatesToAdd.length !== 0) {
|
52 | var htmlToAdd = this.rowTemplatesToAdd.join('');
|
53 | utils_1.Utils.appendHtml(this.eContainer, htmlToAdd);
|
54 | this.rowTemplatesToAdd.length = 0;
|
55 | }
|
56 |
|
57 |
|
58 | this.afterGuiAttachedCallbacks.forEach(function (func) { return func(); });
|
59 | this.afterGuiAttachedCallbacks.length = 0;
|
60 | this.lastPlacedElement = null;
|
61 | };
|
62 | RowContainerComponent.prototype.appendRowTemplate = function (rowTemplate, callback) {
|
63 | if (this.domOrder) {
|
64 | this.lastPlacedElement = utils_1.Utils.insertTemplateWithDomOrder(this.eContainer, rowTemplate, this.lastPlacedElement);
|
65 | }
|
66 | else {
|
67 | this.rowTemplatesToAdd.push(rowTemplate);
|
68 | }
|
69 | this.afterGuiAttachedCallbacks.push(callback);
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | this.childCount++;
|
76 | this.checkVisibility();
|
77 | };
|
78 | RowContainerComponent.prototype.ensureDomOrder = function (eRow) {
|
79 | if (this.domOrder) {
|
80 | utils_1.Utils.ensureDomOrder(this.eContainer, eRow, this.lastPlacedElement);
|
81 | this.lastPlacedElement = eRow;
|
82 | }
|
83 | };
|
84 | RowContainerComponent.prototype.removeRowElement = function (eRow) {
|
85 | this.eContainer.removeChild(eRow);
|
86 | this.childCount--;
|
87 | this.checkVisibility();
|
88 | };
|
89 | RowContainerComponent.prototype.checkVisibility = function () {
|
90 | if (!this.hideWhenNoChildren) {
|
91 | return;
|
92 | }
|
93 | var eGui = this.eViewport ? this.eViewport : this.eContainer;
|
94 | var visible = this.childCount > 0;
|
95 | if (this.visible !== visible) {
|
96 | this.visible = visible;
|
97 | utils_1.Utils.setVisible(eGui, visible);
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | if (visible && this.eViewport) {
|
106 | this.eViewport.scrollTop = this.scrollTop;
|
107 | }
|
108 | }
|
109 | };
|
110 | __decorate([
|
111 | context_1.Autowired('gridOptionsWrapper'),
|
112 | __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
113 | ], RowContainerComponent.prototype, "gridOptionsWrapper", void 0);
|
114 | __decorate([
|
115 | context_1.PostConstruct,
|
116 | __metadata("design:type", Function),
|
117 | __metadata("design:paramtypes", []),
|
118 | __metadata("design:returntype", void 0)
|
119 | ], RowContainerComponent.prototype, "postConstruct", null);
|
120 | return RowContainerComponent;
|
121 | }());
|
122 | exports.RowContainerComponent = RowContainerComponent;
|