@hpcc-js/layout 3.5.7 → 3.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +43 -43
- package/README.md +83 -83
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +8 -8
- package/src/AbsoluteSurface.css +8 -8
- package/src/AbsoluteSurface.ts +93 -93
- package/src/Accordion.css +101 -101
- package/src/Accordion.ts +146 -146
- package/src/Border.css +148 -148
- package/src/Border.ts +636 -636
- package/src/Border2.css +22 -22
- package/src/Border2.ts +391 -391
- package/src/Carousel.css +7 -7
- package/src/Carousel.ts +100 -100
- package/src/Cell.css +10 -10
- package/src/Cell.ts +94 -94
- package/src/ChartPanel.css +7 -7
- package/src/ChartPanel.ts +635 -635
- package/src/FlexGrid.css +8 -8
- package/src/FlexGrid.ts +140 -140
- package/src/Grid.css +89 -89
- package/src/Grid.ts +576 -576
- package/src/HorizontalList.ts +15 -15
- package/src/Layered.css +11 -11
- package/src/Layered.ts +132 -132
- package/src/Legend.ts +516 -516
- package/src/Modal.css +50 -50
- package/src/Modal.ts +289 -289
- package/src/Popup.ts +120 -120
- package/src/Surface.css +104 -104
- package/src/Surface.ts +223 -223
- package/src/Tabbed.css +23 -23
- package/src/Tabbed.ts +165 -165
- package/src/Toolbar.css +33 -33
- package/src/Toolbar.ts +127 -127
- package/src/VerticalList.ts +15 -15
- package/src/__package__.ts +3 -3
- package/src/index.ts +20 -20
package/src/Modal.ts
CHANGED
|
@@ -1,289 +1,289 @@
|
|
|
1
|
-
import { HTMLWidget, ISize, Widget } from "@hpcc-js/common";
|
|
2
|
-
|
|
3
|
-
import "../src/Modal.css";
|
|
4
|
-
|
|
5
|
-
export class Modal extends HTMLWidget {
|
|
6
|
-
|
|
7
|
-
protected _widget: Widget;
|
|
8
|
-
|
|
9
|
-
protected _relativeTarget: HTMLElement;
|
|
10
|
-
|
|
11
|
-
protected _fade;
|
|
12
|
-
protected _modal;
|
|
13
|
-
protected _modalHeader;
|
|
14
|
-
protected _modalBody;
|
|
15
|
-
protected _modalHeaderAnnotations;
|
|
16
|
-
protected _modalHeaderCloseButton;
|
|
17
|
-
_close: () => void;
|
|
18
|
-
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
|
-
this._tag = "div";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
closeModal() {
|
|
25
|
-
this.visible(false);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
getRelativeTarget() {
|
|
29
|
-
let relativeTarget;
|
|
30
|
-
if (this.relativeTargetId()) {
|
|
31
|
-
relativeTarget = document.getElementById(this.relativeTargetId());
|
|
32
|
-
if (relativeTarget) {
|
|
33
|
-
return relativeTarget;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (!relativeTarget) {
|
|
37
|
-
relativeTarget = this.locateAncestor("layout_Grid");
|
|
38
|
-
if (relativeTarget && relativeTarget.element) {
|
|
39
|
-
return relativeTarget.element().node();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return document.body;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setModalSize(): ISize {
|
|
46
|
-
if (this.fixedHeight() !== null && this.fixedWidth() !== null) {
|
|
47
|
-
this._modal
|
|
48
|
-
.style("height", this.fixedHeight())
|
|
49
|
-
.style("width", this.fixedWidth())
|
|
50
|
-
.style("min-height", null)
|
|
51
|
-
.style("min-width", null)
|
|
52
|
-
.style("max-height", null)
|
|
53
|
-
.style("max-width", null)
|
|
54
|
-
;
|
|
55
|
-
} else if (this.minHeight() || this.minWidth()) {
|
|
56
|
-
this._modal
|
|
57
|
-
.style("min-height", this.minHeight())
|
|
58
|
-
.style("min-width", this.minWidth())
|
|
59
|
-
.style("max-height", this.maxHeight())
|
|
60
|
-
.style("max-width", this.maxWidth())
|
|
61
|
-
;
|
|
62
|
-
}
|
|
63
|
-
const modalRect = this._modal.node().getBoundingClientRect();
|
|
64
|
-
const headerRect = this._modalHeader.node().getBoundingClientRect();
|
|
65
|
-
this._modalBody
|
|
66
|
-
.style("height", (modalRect.height - headerRect.height) + "px")
|
|
67
|
-
.style("width", modalRect.width);
|
|
68
|
-
|
|
69
|
-
return modalRect;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
setFadePosition(rect) {
|
|
73
|
-
this._fade
|
|
74
|
-
.style("top", rect.top + "px")
|
|
75
|
-
.style("left", rect.left + "px")
|
|
76
|
-
.style("width", rect.width + "px")
|
|
77
|
-
.style("height", rect.height + "px")
|
|
78
|
-
;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
setModalPosition(rect) {
|
|
82
|
-
const modalRect = this.setModalSize();
|
|
83
|
-
if (this.fixedTop() !== null && this.fixedLeft() !== null) {
|
|
84
|
-
this._modal
|
|
85
|
-
.style("top", `calc(${this.fixedTop()} + ${rect.top}px)`)
|
|
86
|
-
.style("left", `calc(${this.fixedLeft()} + ${rect.left}px)`)
|
|
87
|
-
;
|
|
88
|
-
} else if (this.fixedHeight() !== null && this.fixedWidth() !== null) {
|
|
89
|
-
this._modal
|
|
90
|
-
.style("top", (rect.top + (rect.height / 2) - (modalRect.height / 2)) + "px")
|
|
91
|
-
.style("left", (rect.left + (rect.width / 2) - (modalRect.width / 2)) + "px")
|
|
92
|
-
;
|
|
93
|
-
} else if (this.minHeight() || this.minWidth()) {
|
|
94
|
-
const contentRect = this._modal.node().getBoundingClientRect();
|
|
95
|
-
this._modal
|
|
96
|
-
.style("top", (rect.top + (rect.height / 2) - (contentRect.height / 2)) + "px")
|
|
97
|
-
.style("left", (rect.left + (rect.width / 2) - (contentRect.width / 2)) + "px")
|
|
98
|
-
;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
resize(size?: any): this {
|
|
103
|
-
super.resize();
|
|
104
|
-
if (this._modal) this.setModalSize();
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
resizeBodySync(width: number, height: number): this {
|
|
109
|
-
const header = this._modalHeader.node();
|
|
110
|
-
const headerRect = header.getBoundingClientRect();
|
|
111
|
-
|
|
112
|
-
this._modal
|
|
113
|
-
.style("width", width + "px")
|
|
114
|
-
.style("height", (height + headerRect.height) + "px")
|
|
115
|
-
.style("min-width", width + "px")
|
|
116
|
-
.style("min-height", (height + headerRect.height) + "px")
|
|
117
|
-
;
|
|
118
|
-
this._modalHeader
|
|
119
|
-
.style("width", width + "px")
|
|
120
|
-
;
|
|
121
|
-
this._modalBody
|
|
122
|
-
.style("width", width + "px")
|
|
123
|
-
.style("height", height + "px")
|
|
124
|
-
;
|
|
125
|
-
return this
|
|
126
|
-
.minWidth(width + "px")
|
|
127
|
-
.minHeight((height + headerRect.height) + "px")
|
|
128
|
-
.resize({
|
|
129
|
-
height: height + headerRect.height,
|
|
130
|
-
width
|
|
131
|
-
})
|
|
132
|
-
;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
enter(domNode, element) {
|
|
136
|
-
super.enter(domNode, element);
|
|
137
|
-
this._fade = element.append("div")
|
|
138
|
-
.classed("layout_Modal-fade", true)
|
|
139
|
-
.classed("layout_Modal-fadeClickable", this.enableClickFadeToClose())
|
|
140
|
-
.classed("layout_Modal-fade-hidden", !this.showFade())
|
|
141
|
-
;
|
|
142
|
-
const header_h = this.titleFontSize() * 2;
|
|
143
|
-
this._modal = element.append("div")
|
|
144
|
-
.classed("layout_Modal-content", true)
|
|
145
|
-
;
|
|
146
|
-
this._modalHeader = this._modal.append("div")
|
|
147
|
-
.classed("layout_Modal-header", true)
|
|
148
|
-
.style("color", this.titleFontColor())
|
|
149
|
-
.style("font-size", this.titleFontSize() + "px")
|
|
150
|
-
.style("height", header_h + "px")
|
|
151
|
-
;
|
|
152
|
-
this._modalBody = this._modal.append("div")
|
|
153
|
-
.classed("layout_Modal-body", true)
|
|
154
|
-
.style("height", `calc( 100% - ${header_h}px )`)
|
|
155
|
-
.style("overflow-x", this.overflowX())
|
|
156
|
-
.style("overflow-y", this.overflowY())
|
|
157
|
-
;
|
|
158
|
-
this._modalHeader.append("div")
|
|
159
|
-
.classed("layout_Modal-title", true)
|
|
160
|
-
.style("line-height", this.titleFontSize() + "px")
|
|
161
|
-
.style("top", (this.titleFontSize() / 2) + "px")
|
|
162
|
-
.style("left", (this.titleFontSize() / 2) + "px")
|
|
163
|
-
.text(this.formattedTitle())
|
|
164
|
-
;
|
|
165
|
-
|
|
166
|
-
this._modalHeaderAnnotations = this._modalHeader.append("div")
|
|
167
|
-
.classed("layout_Modal-annotations", true)
|
|
168
|
-
;
|
|
169
|
-
this._modalHeaderCloseButton = this._modalHeaderAnnotations.append("div")
|
|
170
|
-
.classed("layout_Modal-closeButton", true)
|
|
171
|
-
.html("<i class=\"fa fa-close\"></i>")
|
|
172
|
-
;
|
|
173
|
-
|
|
174
|
-
this._modalHeaderAnnotations
|
|
175
|
-
.style("line-height", this.titleFontSize() + "px")
|
|
176
|
-
.style("right", (this.titleFontSize() / 2) + "px")
|
|
177
|
-
.style("top", (this.titleFontSize() / 2) + "px")
|
|
178
|
-
;
|
|
179
|
-
this._modalHeaderCloseButton.on("click", () => {
|
|
180
|
-
this.closeModal();
|
|
181
|
-
});
|
|
182
|
-
this._fade.on("click", n => {
|
|
183
|
-
if (this.enableClickFadeToClose()) {
|
|
184
|
-
this.closeModal();
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
update(domNode, element) {
|
|
190
|
-
super.update(domNode, element);
|
|
191
|
-
element.style("display", this.show() ? null : "none");
|
|
192
|
-
this._fade.classed("layout_Modal-fade-hidden", !this.showFade());
|
|
193
|
-
this._relativeTarget = this.getRelativeTarget();
|
|
194
|
-
|
|
195
|
-
this.setModalSize();
|
|
196
|
-
const rect = this._relativeTarget.getBoundingClientRect();
|
|
197
|
-
this.setFadePosition(rect);
|
|
198
|
-
this.setModalPosition(rect);
|
|
199
|
-
|
|
200
|
-
if (this.show()) {
|
|
201
|
-
if (!this._widget.target()) {
|
|
202
|
-
this._widget.target(this._modalBody.node());
|
|
203
|
-
}
|
|
204
|
-
this._widget.resize().render();
|
|
205
|
-
} else {
|
|
206
|
-
this._widget
|
|
207
|
-
.target(null)
|
|
208
|
-
.render()
|
|
209
|
-
;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
exit(domNode, element) {
|
|
214
|
-
if (this._widget) {
|
|
215
|
-
this._widget.target(null);
|
|
216
|
-
}
|
|
217
|
-
super.exit(domNode, element);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
formattedTitle() {
|
|
221
|
-
const title = this.title_exists() ? this.title().trim() : "";
|
|
222
|
-
if (title.length > 0 && title.slice(0, 1) === "(" && title.slice(-1) === ")") {
|
|
223
|
-
return title.slice(1, -1);
|
|
224
|
-
}
|
|
225
|
-
return this.title();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
Modal.prototype._class += " layout_Modal";
|
|
229
|
-
|
|
230
|
-
export interface Modal {
|
|
231
|
-
show(): boolean;
|
|
232
|
-
show(_: boolean): this;
|
|
233
|
-
showFade(): boolean;
|
|
234
|
-
showFade(_: boolean): this;
|
|
235
|
-
enableClickFadeToClose(): boolean;
|
|
236
|
-
enableClickFadeToClose(_: boolean): this;
|
|
237
|
-
title(): string;
|
|
238
|
-
title(_: string): this;
|
|
239
|
-
title_exists(): boolean;
|
|
240
|
-
titleFontSize(): number;
|
|
241
|
-
titleFontSize(_: number): this;
|
|
242
|
-
titleFontColor(): string;
|
|
243
|
-
titleFontColor(_: string): this;
|
|
244
|
-
minWidth(): string;
|
|
245
|
-
minWidth(_: string): this;
|
|
246
|
-
minHeight(): string;
|
|
247
|
-
minHeight(_: string): this;
|
|
248
|
-
maxWidth(): string;
|
|
249
|
-
maxWidth(_: string): this;
|
|
250
|
-
maxHeight(): string;
|
|
251
|
-
maxHeight(_: string): this;
|
|
252
|
-
fixedWidth(): string;
|
|
253
|
-
fixedWidth(_: string): this;
|
|
254
|
-
fixedHeight(): string;
|
|
255
|
-
fixedHeight(_: string): this;
|
|
256
|
-
fixedTop(): string;
|
|
257
|
-
fixedTop(_: string): this;
|
|
258
|
-
fixedLeft(): string;
|
|
259
|
-
fixedLeft(_: string): this;
|
|
260
|
-
relativeTargetId(): string;
|
|
261
|
-
relativeTargetId(_: string): this;
|
|
262
|
-
widget(): Widget;
|
|
263
|
-
widget(_: Widget): this;
|
|
264
|
-
overflowX(): "hidden" | "scroll";
|
|
265
|
-
overflowX(_: "hidden" | "scroll"): this;
|
|
266
|
-
overflowY(): "hidden" | "scroll";
|
|
267
|
-
overflowY(_: "hidden" | "scroll"): this;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
Modal.prototype.publish("title", null, "string", "title");
|
|
271
|
-
Modal.prototype.publish("widget", null, "widget", "widget");
|
|
272
|
-
Modal.prototype.publish("titleFontSize", 18, "number", "titleFontSize (in pixels)");
|
|
273
|
-
Modal.prototype.publish("titleFontColor", "#ffffff", "html-color", "titleFontColor");
|
|
274
|
-
Modal.prototype.publish("relativeTargetId", null, "string", "relativeTargetId");
|
|
275
|
-
|
|
276
|
-
Modal.prototype.publish("show", true, "boolean", "show");
|
|
277
|
-
Modal.prototype.publish("showFade", true, "boolean", "showFade");
|
|
278
|
-
Modal.prototype.publish("enableClickFadeToClose", true, "boolean", "enableClickFadeToClose");
|
|
279
|
-
|
|
280
|
-
Modal.prototype.publish("minWidth", "400px", "string", "minWidth");
|
|
281
|
-
Modal.prototype.publish("minHeight", "400px", "string", "minHeight");
|
|
282
|
-
Modal.prototype.publish("maxWidth", "800px", "string", "maxWidth");
|
|
283
|
-
Modal.prototype.publish("maxHeight", "800px", "string", "maxHeight");
|
|
284
|
-
Modal.prototype.publish("fixedWidth", null, "string", "fixedWidth");
|
|
285
|
-
Modal.prototype.publish("fixedHeight", null, "string", "fixedHeight");
|
|
286
|
-
Modal.prototype.publish("fixedTop", null, "string", "fixedTop");
|
|
287
|
-
Modal.prototype.publish("fixedLeft", null, "string", "fixedLeft");
|
|
288
|
-
Modal.prototype.publish("overflowX", "hidden", "string", "overflowX");
|
|
289
|
-
Modal.prototype.publish("overflowY", "scroll", "string", "overflowY");
|
|
1
|
+
import { HTMLWidget, ISize, Widget } from "@hpcc-js/common";
|
|
2
|
+
|
|
3
|
+
import "../src/Modal.css";
|
|
4
|
+
|
|
5
|
+
export class Modal extends HTMLWidget {
|
|
6
|
+
|
|
7
|
+
protected _widget: Widget;
|
|
8
|
+
|
|
9
|
+
protected _relativeTarget: HTMLElement;
|
|
10
|
+
|
|
11
|
+
protected _fade;
|
|
12
|
+
protected _modal;
|
|
13
|
+
protected _modalHeader;
|
|
14
|
+
protected _modalBody;
|
|
15
|
+
protected _modalHeaderAnnotations;
|
|
16
|
+
protected _modalHeaderCloseButton;
|
|
17
|
+
_close: () => void;
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this._tag = "div";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
closeModal() {
|
|
25
|
+
this.visible(false);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getRelativeTarget() {
|
|
29
|
+
let relativeTarget;
|
|
30
|
+
if (this.relativeTargetId()) {
|
|
31
|
+
relativeTarget = document.getElementById(this.relativeTargetId());
|
|
32
|
+
if (relativeTarget) {
|
|
33
|
+
return relativeTarget;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!relativeTarget) {
|
|
37
|
+
relativeTarget = this.locateAncestor("layout_Grid");
|
|
38
|
+
if (relativeTarget && relativeTarget.element) {
|
|
39
|
+
return relativeTarget.element().node();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return document.body;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setModalSize(): ISize {
|
|
46
|
+
if (this.fixedHeight() !== null && this.fixedWidth() !== null) {
|
|
47
|
+
this._modal
|
|
48
|
+
.style("height", this.fixedHeight())
|
|
49
|
+
.style("width", this.fixedWidth())
|
|
50
|
+
.style("min-height", null)
|
|
51
|
+
.style("min-width", null)
|
|
52
|
+
.style("max-height", null)
|
|
53
|
+
.style("max-width", null)
|
|
54
|
+
;
|
|
55
|
+
} else if (this.minHeight() || this.minWidth()) {
|
|
56
|
+
this._modal
|
|
57
|
+
.style("min-height", this.minHeight())
|
|
58
|
+
.style("min-width", this.minWidth())
|
|
59
|
+
.style("max-height", this.maxHeight())
|
|
60
|
+
.style("max-width", this.maxWidth())
|
|
61
|
+
;
|
|
62
|
+
}
|
|
63
|
+
const modalRect = this._modal.node().getBoundingClientRect();
|
|
64
|
+
const headerRect = this._modalHeader.node().getBoundingClientRect();
|
|
65
|
+
this._modalBody
|
|
66
|
+
.style("height", (modalRect.height - headerRect.height) + "px")
|
|
67
|
+
.style("width", modalRect.width);
|
|
68
|
+
|
|
69
|
+
return modalRect;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setFadePosition(rect) {
|
|
73
|
+
this._fade
|
|
74
|
+
.style("top", rect.top + "px")
|
|
75
|
+
.style("left", rect.left + "px")
|
|
76
|
+
.style("width", rect.width + "px")
|
|
77
|
+
.style("height", rect.height + "px")
|
|
78
|
+
;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setModalPosition(rect) {
|
|
82
|
+
const modalRect = this.setModalSize();
|
|
83
|
+
if (this.fixedTop() !== null && this.fixedLeft() !== null) {
|
|
84
|
+
this._modal
|
|
85
|
+
.style("top", `calc(${this.fixedTop()} + ${rect.top}px)`)
|
|
86
|
+
.style("left", `calc(${this.fixedLeft()} + ${rect.left}px)`)
|
|
87
|
+
;
|
|
88
|
+
} else if (this.fixedHeight() !== null && this.fixedWidth() !== null) {
|
|
89
|
+
this._modal
|
|
90
|
+
.style("top", (rect.top + (rect.height / 2) - (modalRect.height / 2)) + "px")
|
|
91
|
+
.style("left", (rect.left + (rect.width / 2) - (modalRect.width / 2)) + "px")
|
|
92
|
+
;
|
|
93
|
+
} else if (this.minHeight() || this.minWidth()) {
|
|
94
|
+
const contentRect = this._modal.node().getBoundingClientRect();
|
|
95
|
+
this._modal
|
|
96
|
+
.style("top", (rect.top + (rect.height / 2) - (contentRect.height / 2)) + "px")
|
|
97
|
+
.style("left", (rect.left + (rect.width / 2) - (contentRect.width / 2)) + "px")
|
|
98
|
+
;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
resize(size?: any): this {
|
|
103
|
+
super.resize();
|
|
104
|
+
if (this._modal) this.setModalSize();
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
resizeBodySync(width: number, height: number): this {
|
|
109
|
+
const header = this._modalHeader.node();
|
|
110
|
+
const headerRect = header.getBoundingClientRect();
|
|
111
|
+
|
|
112
|
+
this._modal
|
|
113
|
+
.style("width", width + "px")
|
|
114
|
+
.style("height", (height + headerRect.height) + "px")
|
|
115
|
+
.style("min-width", width + "px")
|
|
116
|
+
.style("min-height", (height + headerRect.height) + "px")
|
|
117
|
+
;
|
|
118
|
+
this._modalHeader
|
|
119
|
+
.style("width", width + "px")
|
|
120
|
+
;
|
|
121
|
+
this._modalBody
|
|
122
|
+
.style("width", width + "px")
|
|
123
|
+
.style("height", height + "px")
|
|
124
|
+
;
|
|
125
|
+
return this
|
|
126
|
+
.minWidth(width + "px")
|
|
127
|
+
.minHeight((height + headerRect.height) + "px")
|
|
128
|
+
.resize({
|
|
129
|
+
height: height + headerRect.height,
|
|
130
|
+
width
|
|
131
|
+
})
|
|
132
|
+
;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
enter(domNode, element) {
|
|
136
|
+
super.enter(domNode, element);
|
|
137
|
+
this._fade = element.append("div")
|
|
138
|
+
.classed("layout_Modal-fade", true)
|
|
139
|
+
.classed("layout_Modal-fadeClickable", this.enableClickFadeToClose())
|
|
140
|
+
.classed("layout_Modal-fade-hidden", !this.showFade())
|
|
141
|
+
;
|
|
142
|
+
const header_h = this.titleFontSize() * 2;
|
|
143
|
+
this._modal = element.append("div")
|
|
144
|
+
.classed("layout_Modal-content", true)
|
|
145
|
+
;
|
|
146
|
+
this._modalHeader = this._modal.append("div")
|
|
147
|
+
.classed("layout_Modal-header", true)
|
|
148
|
+
.style("color", this.titleFontColor())
|
|
149
|
+
.style("font-size", this.titleFontSize() + "px")
|
|
150
|
+
.style("height", header_h + "px")
|
|
151
|
+
;
|
|
152
|
+
this._modalBody = this._modal.append("div")
|
|
153
|
+
.classed("layout_Modal-body", true)
|
|
154
|
+
.style("height", `calc( 100% - ${header_h}px )`)
|
|
155
|
+
.style("overflow-x", this.overflowX())
|
|
156
|
+
.style("overflow-y", this.overflowY())
|
|
157
|
+
;
|
|
158
|
+
this._modalHeader.append("div")
|
|
159
|
+
.classed("layout_Modal-title", true)
|
|
160
|
+
.style("line-height", this.titleFontSize() + "px")
|
|
161
|
+
.style("top", (this.titleFontSize() / 2) + "px")
|
|
162
|
+
.style("left", (this.titleFontSize() / 2) + "px")
|
|
163
|
+
.text(this.formattedTitle())
|
|
164
|
+
;
|
|
165
|
+
|
|
166
|
+
this._modalHeaderAnnotations = this._modalHeader.append("div")
|
|
167
|
+
.classed("layout_Modal-annotations", true)
|
|
168
|
+
;
|
|
169
|
+
this._modalHeaderCloseButton = this._modalHeaderAnnotations.append("div")
|
|
170
|
+
.classed("layout_Modal-closeButton", true)
|
|
171
|
+
.html("<i class=\"fa fa-close\"></i>")
|
|
172
|
+
;
|
|
173
|
+
|
|
174
|
+
this._modalHeaderAnnotations
|
|
175
|
+
.style("line-height", this.titleFontSize() + "px")
|
|
176
|
+
.style("right", (this.titleFontSize() / 2) + "px")
|
|
177
|
+
.style("top", (this.titleFontSize() / 2) + "px")
|
|
178
|
+
;
|
|
179
|
+
this._modalHeaderCloseButton.on("click", () => {
|
|
180
|
+
this.closeModal();
|
|
181
|
+
});
|
|
182
|
+
this._fade.on("click", n => {
|
|
183
|
+
if (this.enableClickFadeToClose()) {
|
|
184
|
+
this.closeModal();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
update(domNode, element) {
|
|
190
|
+
super.update(domNode, element);
|
|
191
|
+
element.style("display", this.show() ? null : "none");
|
|
192
|
+
this._fade.classed("layout_Modal-fade-hidden", !this.showFade());
|
|
193
|
+
this._relativeTarget = this.getRelativeTarget();
|
|
194
|
+
|
|
195
|
+
this.setModalSize();
|
|
196
|
+
const rect = this._relativeTarget.getBoundingClientRect();
|
|
197
|
+
this.setFadePosition(rect);
|
|
198
|
+
this.setModalPosition(rect);
|
|
199
|
+
|
|
200
|
+
if (this.show()) {
|
|
201
|
+
if (!this._widget.target()) {
|
|
202
|
+
this._widget.target(this._modalBody.node());
|
|
203
|
+
}
|
|
204
|
+
this._widget.resize().render();
|
|
205
|
+
} else {
|
|
206
|
+
this._widget
|
|
207
|
+
.target(null)
|
|
208
|
+
.render()
|
|
209
|
+
;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
exit(domNode, element) {
|
|
214
|
+
if (this._widget) {
|
|
215
|
+
this._widget.target(null);
|
|
216
|
+
}
|
|
217
|
+
super.exit(domNode, element);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
formattedTitle() {
|
|
221
|
+
const title = this.title_exists() ? this.title().trim() : "";
|
|
222
|
+
if (title.length > 0 && title.slice(0, 1) === "(" && title.slice(-1) === ")") {
|
|
223
|
+
return title.slice(1, -1);
|
|
224
|
+
}
|
|
225
|
+
return this.title();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
Modal.prototype._class += " layout_Modal";
|
|
229
|
+
|
|
230
|
+
export interface Modal {
|
|
231
|
+
show(): boolean;
|
|
232
|
+
show(_: boolean): this;
|
|
233
|
+
showFade(): boolean;
|
|
234
|
+
showFade(_: boolean): this;
|
|
235
|
+
enableClickFadeToClose(): boolean;
|
|
236
|
+
enableClickFadeToClose(_: boolean): this;
|
|
237
|
+
title(): string;
|
|
238
|
+
title(_: string): this;
|
|
239
|
+
title_exists(): boolean;
|
|
240
|
+
titleFontSize(): number;
|
|
241
|
+
titleFontSize(_: number): this;
|
|
242
|
+
titleFontColor(): string;
|
|
243
|
+
titleFontColor(_: string): this;
|
|
244
|
+
minWidth(): string;
|
|
245
|
+
minWidth(_: string): this;
|
|
246
|
+
minHeight(): string;
|
|
247
|
+
minHeight(_: string): this;
|
|
248
|
+
maxWidth(): string;
|
|
249
|
+
maxWidth(_: string): this;
|
|
250
|
+
maxHeight(): string;
|
|
251
|
+
maxHeight(_: string): this;
|
|
252
|
+
fixedWidth(): string;
|
|
253
|
+
fixedWidth(_: string): this;
|
|
254
|
+
fixedHeight(): string;
|
|
255
|
+
fixedHeight(_: string): this;
|
|
256
|
+
fixedTop(): string;
|
|
257
|
+
fixedTop(_: string): this;
|
|
258
|
+
fixedLeft(): string;
|
|
259
|
+
fixedLeft(_: string): this;
|
|
260
|
+
relativeTargetId(): string;
|
|
261
|
+
relativeTargetId(_: string): this;
|
|
262
|
+
widget(): Widget;
|
|
263
|
+
widget(_: Widget): this;
|
|
264
|
+
overflowX(): "hidden" | "scroll";
|
|
265
|
+
overflowX(_: "hidden" | "scroll"): this;
|
|
266
|
+
overflowY(): "hidden" | "scroll";
|
|
267
|
+
overflowY(_: "hidden" | "scroll"): this;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
Modal.prototype.publish("title", null, "string", "title");
|
|
271
|
+
Modal.prototype.publish("widget", null, "widget", "widget");
|
|
272
|
+
Modal.prototype.publish("titleFontSize", 18, "number", "titleFontSize (in pixels)");
|
|
273
|
+
Modal.prototype.publish("titleFontColor", "#ffffff", "html-color", "titleFontColor");
|
|
274
|
+
Modal.prototype.publish("relativeTargetId", null, "string", "relativeTargetId");
|
|
275
|
+
|
|
276
|
+
Modal.prototype.publish("show", true, "boolean", "show");
|
|
277
|
+
Modal.prototype.publish("showFade", true, "boolean", "showFade");
|
|
278
|
+
Modal.prototype.publish("enableClickFadeToClose", true, "boolean", "enableClickFadeToClose");
|
|
279
|
+
|
|
280
|
+
Modal.prototype.publish("minWidth", "400px", "string", "minWidth");
|
|
281
|
+
Modal.prototype.publish("minHeight", "400px", "string", "minHeight");
|
|
282
|
+
Modal.prototype.publish("maxWidth", "800px", "string", "maxWidth");
|
|
283
|
+
Modal.prototype.publish("maxHeight", "800px", "string", "maxHeight");
|
|
284
|
+
Modal.prototype.publish("fixedWidth", null, "string", "fixedWidth");
|
|
285
|
+
Modal.prototype.publish("fixedHeight", null, "string", "fixedHeight");
|
|
286
|
+
Modal.prototype.publish("fixedTop", null, "string", "fixedTop");
|
|
287
|
+
Modal.prototype.publish("fixedLeft", null, "string", "fixedLeft");
|
|
288
|
+
Modal.prototype.publish("overflowX", "hidden", "string", "overflowX");
|
|
289
|
+
Modal.prototype.publish("overflowY", "scroll", "string", "overflowY");
|