dock-spawn-ts 2.513.0 → 2.514.0
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/lib/css/dock-manager.css +9 -1
- package/lib/es5/dock-spawn-ts.js +1 -1
- package/lib/js/ContainerType.d.ts +6 -6
- package/lib/js/ContainerType.js +7 -7
- package/lib/js/Dialog.d.ts +43 -43
- package/lib/js/Dialog.js +136 -136
- package/lib/js/DockConfig.d.ts +7 -7
- package/lib/js/DockConfig.js +8 -8
- package/lib/js/DockGraphDeserializer.d.ts +18 -18
- package/lib/js/DockGraphDeserializer.js +116 -116
- package/lib/js/DockGraphSerializer.d.ts +13 -13
- package/lib/js/DockGraphSerializer.js +40 -40
- package/lib/js/DockLayoutEngine.d.ts +35 -35
- package/lib/js/DockLayoutEngine.js +319 -319
- package/lib/js/DockManager.d.ts +153 -153
- package/lib/js/DockManager.js +728 -728
- package/lib/js/DockManagerContext.d.ts +9 -9
- package/lib/js/DockManagerContext.js +9 -9
- package/lib/js/DockModel.d.ts +8 -8
- package/lib/js/DockModel.js +5 -5
- package/lib/js/DockNode.d.ts +15 -15
- package/lib/js/DockNode.js +61 -61
- package/lib/js/DockWheel.d.ts +40 -40
- package/lib/js/DockWheel.js +200 -200
- package/lib/js/DockWheelItem.d.ts +15 -15
- package/lib/js/DockWheelItem.js +27 -27
- package/lib/js/DocumentManagerContainer.d.ts +16 -16
- package/lib/js/DocumentManagerContainer.js +28 -28
- package/lib/js/DocumentTabPage.d.ts +14 -14
- package/lib/js/DocumentTabPage.js +26 -26
- package/lib/js/DraggableContainer.d.ts +52 -52
- package/lib/js/DraggableContainer.js +183 -183
- package/lib/js/EventHandler.d.ts +7 -7
- package/lib/js/EventHandler.js +11 -11
- package/lib/js/Exports.d.ts +30 -30
- package/lib/js/Exports.js +30 -30
- package/lib/js/FillDockContainer.d.ts +33 -33
- package/lib/js/FillDockContainer.js +69 -69
- package/lib/js/HorizontalDockContainer.d.ts +6 -6
- package/lib/js/HorizontalDockContainer.js +9 -9
- package/lib/js/PanelContainer.d.ts +101 -101
- package/lib/js/PanelContainer.js +384 -384
- package/lib/js/PanelContainer.js.map +1 -1
- package/lib/js/Point.d.ts +5 -5
- package/lib/js/Point.js +6 -6
- package/lib/js/ResizableContainer.d.ts +55 -55
- package/lib/js/ResizableContainer.js +241 -241
- package/lib/js/ResizeHandle.d.ts +15 -15
- package/lib/js/ResizeHandle.js +48 -48
- package/lib/js/SplitterBar.d.ts +35 -35
- package/lib/js/SplitterBar.js +149 -149
- package/lib/js/SplitterDockContainer.d.ts +35 -35
- package/lib/js/SplitterDockContainer.js +65 -65
- package/lib/js/SplitterPanel.d.ts +26 -26
- package/lib/js/SplitterPanel.js +191 -191
- package/lib/js/TabHandle.d.ts +55 -55
- package/lib/js/TabHandle.js +261 -260
- package/lib/js/TabHandle.js.map +1 -1
- package/lib/js/TabHost.d.ts +46 -46
- package/lib/js/TabHost.js +223 -223
- package/lib/js/TabHost.js.map +1 -1
- package/lib/js/TabPage.d.ts +19 -19
- package/lib/js/TabPage.js +74 -73
- package/lib/js/TabPage.js.map +1 -1
- package/lib/js/UndockInitiator.d.ts +31 -31
- package/lib/js/UndockInitiator.js +140 -140
- package/lib/js/Utils.d.ts +14 -14
- package/lib/js/Utils.js +70 -69
- package/lib/js/Utils.js.map +1 -1
- package/lib/js/VerticalDockContainer.d.ts +6 -6
- package/lib/js/VerticalDockContainer.js +9 -9
- package/lib/js/enums/PanelType.d.ts +4 -4
- package/lib/js/enums/PanelType.js +5 -5
- package/lib/js/enums/TabHostDirection.d.ts +6 -6
- package/lib/js/enums/TabHostDirection.js +7 -7
- package/lib/js/enums/WheelTypes.d.ts +11 -11
- package/lib/js/enums/WheelTypes.js +14 -14
- package/lib/js/interfaces/IDockContainer.d.ts +25 -25
- package/lib/js/interfaces/IDockContainer.js +1 -1
- package/lib/js/interfaces/IDockContainerWithSize.d.ts +5 -5
- package/lib/js/interfaces/IDockContainerWithSize.js +1 -1
- package/lib/js/interfaces/ILayoutEventListener.d.ts +26 -26
- package/lib/js/interfaces/ILayoutEventListener.js +1 -1
- package/lib/js/interfaces/IMouseOrTouchEvent.d.ts +6 -6
- package/lib/js/interfaces/IMouseOrTouchEvent.js +1 -1
- package/lib/js/interfaces/INodeInfo.d.ts +7 -7
- package/lib/js/interfaces/INodeInfo.js +1 -1
- package/lib/js/interfaces/IPanelInfo.d.ts +9 -9
- package/lib/js/interfaces/IPanelInfo.js +1 -1
- package/lib/js/interfaces/IRectangle.d.ts +6 -6
- package/lib/js/interfaces/IRectangle.js +1 -1
- package/lib/js/interfaces/ISize.d.ts +4 -4
- package/lib/js/interfaces/ISize.js +1 -1
- package/lib/js/interfaces/IState.d.ts +10 -10
- package/lib/js/interfaces/IState.js +1 -1
- package/lib/js/interfaces/IThickness.d.ts +6 -6
- package/lib/js/interfaces/IThickness.js +1 -1
- package/lib/js/webcomponent/DockSpawnTsWebcomponent.d.ts +30 -30
- package/lib/js/webcomponent/DockSpawnTsWebcomponent.js +153 -152
- package/lib/js/webcomponent/DockSpawnTsWebcomponent.js.map +1 -1
- package/package.json +6 -6
- package/src/PanelContainer.ts +1 -1
- package/src/TabHost.ts +5 -5
- package/src/TabPage.ts +4 -3
|
@@ -1,242 +1,242 @@
|
|
|
1
|
-
import { ResizeHandle } from "./ResizeHandle.js";
|
|
2
|
-
import { EventHandler } from "./EventHandler.js";
|
|
3
|
-
import { Point } from "./Point.js";
|
|
4
|
-
import { Utils } from "./Utils.js";
|
|
5
|
-
/**
|
|
6
|
-
* Decorates a dock container with resizer handles around its base element
|
|
7
|
-
* This enables the container to be resized from all directions
|
|
8
|
-
*/
|
|
9
|
-
export class ResizableContainer {
|
|
10
|
-
constructor(dialog, delegate, topLevelElement, disableResize = false) {
|
|
11
|
-
this.dialog = dialog;
|
|
12
|
-
this.disableResize = disableResize;
|
|
13
|
-
this.delegate = delegate;
|
|
14
|
-
this.containerElement = delegate.containerElement;
|
|
15
|
-
this.dockManager = delegate.dockManager;
|
|
16
|
-
this.topLevelElement = topLevelElement;
|
|
17
|
-
this.containerType = delegate.containerType;
|
|
18
|
-
this.topLevelElement.style.left = this.topLevelElement.offsetLeft + 'px';
|
|
19
|
-
this.topLevelElement.style.top = this.topLevelElement.offsetTop + 'px';
|
|
20
|
-
this.minimumAllowedChildNodes = delegate.minimumAllowedChildNodes;
|
|
21
|
-
this._buildResizeHandles();
|
|
22
|
-
this.readyToProcessNextResize = true;
|
|
23
|
-
this.dockSpawnResizedEvent = new CustomEvent("DockSpawnResizedEvent", { composed: true, bubbles: true });
|
|
24
|
-
this.iframeEventHandlers = [];
|
|
25
|
-
}
|
|
26
|
-
setActiveChild( /*child*/) {
|
|
27
|
-
}
|
|
28
|
-
_buildResizeHandles() {
|
|
29
|
-
this.resizeHandles = [];
|
|
30
|
-
// this._buildResizeHandle(true, false, true, false); // Dont need the corner resizer near the close button
|
|
31
|
-
if (!this.disableResize) {
|
|
32
|
-
this._buildResizeHandle(false, true, true, false);
|
|
33
|
-
this._buildResizeHandle(true, false, false, true);
|
|
34
|
-
this._buildResizeHandle(false, true, false, true);
|
|
35
|
-
this._buildResizeHandle(true, false, false, false);
|
|
36
|
-
this._buildResizeHandle(false, true, false, false);
|
|
37
|
-
this._buildResizeHandle(false, false, true, false);
|
|
38
|
-
this._buildResizeHandle(false, false, false, true);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
_buildResizeHandle(east, west, north, south) {
|
|
42
|
-
let handle = new ResizeHandle();
|
|
43
|
-
handle.east = east;
|
|
44
|
-
handle.west = west;
|
|
45
|
-
handle.north = north;
|
|
46
|
-
handle.south = south;
|
|
47
|
-
// Create an invisible div for the handle
|
|
48
|
-
handle.element = document.createElement('div');
|
|
49
|
-
this.topLevelElement.appendChild(handle.element);
|
|
50
|
-
// Build the class name for the handle
|
|
51
|
-
let verticalClass = '';
|
|
52
|
-
let horizontalClass = '';
|
|
53
|
-
if (north)
|
|
54
|
-
verticalClass = 'n';
|
|
55
|
-
if (south)
|
|
56
|
-
verticalClass = 's';
|
|
57
|
-
if (east)
|
|
58
|
-
horizontalClass = 'e';
|
|
59
|
-
if (west)
|
|
60
|
-
horizontalClass = 'w';
|
|
61
|
-
let cssClass = 'resize-handle-' + verticalClass + horizontalClass;
|
|
62
|
-
if (verticalClass.length > 0 && horizontalClass.length > 0)
|
|
63
|
-
handle.corner = true;
|
|
64
|
-
handle.element.classList.add(handle.corner ? 'resize-handle-corner' : 'resize-handle');
|
|
65
|
-
handle.element.classList.add(cssClass);
|
|
66
|
-
this.resizeHandles.push(handle);
|
|
67
|
-
handle.mouseDownHandler = new EventHandler(handle.element, 'mousedown', (e) => { this.onMouseDown(handle, e); });
|
|
68
|
-
handle.touchDownHandler = new EventHandler(handle.element, 'touchstart', (e) => { this.onMouseDown(handle, e); });
|
|
69
|
-
}
|
|
70
|
-
saveState(state) {
|
|
71
|
-
this.delegate.saveState(state);
|
|
72
|
-
}
|
|
73
|
-
loadState(state) {
|
|
74
|
-
this.delegate.loadState(state);
|
|
75
|
-
}
|
|
76
|
-
get width() {
|
|
77
|
-
return this.delegate.width;
|
|
78
|
-
}
|
|
79
|
-
get height() {
|
|
80
|
-
return this.delegate.height;
|
|
81
|
-
}
|
|
82
|
-
get name() {
|
|
83
|
-
return this.delegate.name;
|
|
84
|
-
}
|
|
85
|
-
set name(value) {
|
|
86
|
-
if (value)
|
|
87
|
-
this.delegate.name = value;
|
|
88
|
-
}
|
|
89
|
-
resize(width, height) {
|
|
90
|
-
this.delegate.resize(width, height);
|
|
91
|
-
this._adjustResizeHandles(width, height);
|
|
92
|
-
document.dispatchEvent(this.dockSpawnResizedEvent);
|
|
93
|
-
}
|
|
94
|
-
_adjustResizeHandles(width, height) {
|
|
95
|
-
this.resizeHandles.forEach((handle) => {
|
|
96
|
-
handle.adjustSize(width, height);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
performLayout(children) {
|
|
100
|
-
this.delegate.performLayout(children, false);
|
|
101
|
-
}
|
|
102
|
-
destroy() {
|
|
103
|
-
this.removeDecorator();
|
|
104
|
-
this.delegate.destroy();
|
|
105
|
-
}
|
|
106
|
-
removeDecorator() {
|
|
107
|
-
}
|
|
108
|
-
onMouseMovedIframe(handle, e, iframe) {
|
|
109
|
-
let posIf = iframe.getBoundingClientRect();
|
|
110
|
-
this.onMouseMoved(handle, e, { x: posIf.x, y: posIf.y });
|
|
111
|
-
}
|
|
112
|
-
onMouseMoved(handle, event, iframeOffset) {
|
|
113
|
-
let touchOrMouseData = null;
|
|
114
|
-
if (event.changedTouches) {
|
|
115
|
-
if (event.changedTouches.length > 1)
|
|
116
|
-
return;
|
|
117
|
-
touchOrMouseData = event.changedTouches[0];
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
touchOrMouseData = event;
|
|
121
|
-
}
|
|
122
|
-
if (!this.readyToProcessNextResize)
|
|
123
|
-
return;
|
|
124
|
-
this.readyToProcessNextResize = false;
|
|
125
|
-
if (this.dialog.panel)
|
|
126
|
-
this.dockManager.suspendLayout(this.dialog.panel);
|
|
127
|
-
let currentMousePosition = new Point(touchOrMouseData.clientX, touchOrMouseData.clientY);
|
|
128
|
-
if (iframeOffset)
|
|
129
|
-
currentMousePosition = new Point(touchOrMouseData.clientX + iframeOffset.x, touchOrMouseData.clientY + iframeOffset.y);
|
|
130
|
-
let dx = this.dockManager.checkXBounds(this.topLevelElement, currentMousePosition, this.previousMousePosition, handle.west, handle.east);
|
|
131
|
-
let dy = this.dockManager.checkYBounds(this.topLevelElement, currentMousePosition, this.previousMousePosition, handle.north, handle.south);
|
|
132
|
-
this._performDrag(handle, dx, dy);
|
|
133
|
-
this.previousMousePosition = currentMousePosition;
|
|
134
|
-
this.readyToProcessNextResize = true;
|
|
135
|
-
if (this.dialog.panel)
|
|
136
|
-
this.dockManager.resumeLayout(this.dialog.panel);
|
|
137
|
-
this.dockManager.notifyOnContainerResized(this);
|
|
138
|
-
}
|
|
139
|
-
onMouseDown(handle, event) {
|
|
140
|
-
let touchOrMouseData = null;
|
|
141
|
-
if (event.touches) {
|
|
142
|
-
if (event.touches.length > 1)
|
|
143
|
-
return;
|
|
144
|
-
touchOrMouseData = event.touches[0];
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
touchOrMouseData = event;
|
|
148
|
-
}
|
|
149
|
-
this.previousMousePosition = new Point(touchOrMouseData.clientX, touchOrMouseData.clientY);
|
|
150
|
-
if (handle.mouseMoveHandler) {
|
|
151
|
-
handle.mouseMoveHandler.cancel();
|
|
152
|
-
delete handle.mouseMoveHandler;
|
|
153
|
-
}
|
|
154
|
-
if (handle.touchMoveHandler) {
|
|
155
|
-
handle.touchMoveHandler.cancel();
|
|
156
|
-
delete handle.touchMoveHandler;
|
|
157
|
-
}
|
|
158
|
-
if (handle.mouseUpHandler) {
|
|
159
|
-
handle.mouseUpHandler.cancel();
|
|
160
|
-
delete handle.mouseUpHandler;
|
|
161
|
-
}
|
|
162
|
-
if (handle.touchUpHandler) {
|
|
163
|
-
handle.touchUpHandler.cancel();
|
|
164
|
-
delete handle.touchUpHandler;
|
|
165
|
-
}
|
|
166
|
-
for (let e of this.iframeEventHandlers) {
|
|
167
|
-
e.cancel();
|
|
168
|
-
}
|
|
169
|
-
this.iframeEventHandlers = [];
|
|
170
|
-
// Create the mouse event handlers
|
|
171
|
-
handle.mouseMoveHandler = new EventHandler(window, 'mousemove', (e) => { this.onMouseMoved(handle, e); });
|
|
172
|
-
handle.touchMoveHandler = new EventHandler(window, 'touchmove', (e) => { this.onMouseMoved(handle, e); });
|
|
173
|
-
handle.mouseUpHandler = new EventHandler(window, 'mouseup', (e) => { this.onMouseUp(handle); });
|
|
174
|
-
handle.touchUpHandler = new EventHandler(window, 'touchend', (e) => { this.onMouseUp(handle); });
|
|
175
|
-
if (this.dockManager.iframes) {
|
|
176
|
-
for (let f of this.dockManager.iframes) {
|
|
177
|
-
let mmi = this.onMouseMovedIframe.bind(this);
|
|
178
|
-
this.iframeEventHandlers.push(new EventHandler(f.contentWindow, 'mousemove', (e) => mmi(handle, e, f)));
|
|
179
|
-
this.iframeEventHandlers.push(new EventHandler(f.contentWindow, 'mouseup', (e) => this.onMouseUp(handle)));
|
|
180
|
-
this.iframeEventHandlers.push(new EventHandler(f.contentWindow, 'touchmove', (e) => mmi(handle, e, f)));
|
|
181
|
-
this.iframeEventHandlers.push(new EventHandler(f.contentWindow, 'touchend', (e) => this.onMouseUp(handle)));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
Utils.disableGlobalTextSelection(this.dockManager.config.dialogRootElement);
|
|
185
|
-
}
|
|
186
|
-
onMouseUp(handle) {
|
|
187
|
-
handle.mouseMoveHandler.cancel();
|
|
188
|
-
handle.touchMoveHandler.cancel();
|
|
189
|
-
handle.mouseUpHandler.cancel();
|
|
190
|
-
handle.touchUpHandler.cancel();
|
|
191
|
-
delete handle.mouseMoveHandler;
|
|
192
|
-
delete handle.touchMoveHandler;
|
|
193
|
-
delete handle.mouseUpHandler;
|
|
194
|
-
delete handle.touchUpHandler;
|
|
195
|
-
for (let e of this.iframeEventHandlers) {
|
|
196
|
-
e.cancel();
|
|
197
|
-
}
|
|
198
|
-
this.iframeEventHandlers = [];
|
|
199
|
-
Utils.enableGlobalTextSelection(this.dockManager.config.dialogRootElement);
|
|
200
|
-
}
|
|
201
|
-
_performDrag(handle, dx, dy) {
|
|
202
|
-
let bounds = {};
|
|
203
|
-
bounds.left = Utils.getPixels(this.topLevelElement.style.left);
|
|
204
|
-
bounds.top = Utils.getPixels(this.topLevelElement.style.top);
|
|
205
|
-
bounds.width = this.topLevelElement.clientWidth;
|
|
206
|
-
bounds.height = this.topLevelElement.clientHeight;
|
|
207
|
-
if (handle.east)
|
|
208
|
-
this._resizeEast(dx, bounds);
|
|
209
|
-
if (handle.west)
|
|
210
|
-
this._resizeWest(dx, bounds);
|
|
211
|
-
if (handle.north)
|
|
212
|
-
this._resizeNorth(dy, bounds);
|
|
213
|
-
if (handle.south)
|
|
214
|
-
this._resizeSouth(dy, bounds);
|
|
215
|
-
}
|
|
216
|
-
_resizeWest(dx, bounds) {
|
|
217
|
-
this._resizeContainer(dx, 0, -dx, 0, bounds);
|
|
218
|
-
}
|
|
219
|
-
_resizeEast(dx, bounds) {
|
|
220
|
-
this._resizeContainer(0, 0, dx, 0, bounds);
|
|
221
|
-
}
|
|
222
|
-
_resizeNorth(dy, bounds) {
|
|
223
|
-
this._resizeContainer(0, dy, 0, -dy, bounds);
|
|
224
|
-
}
|
|
225
|
-
_resizeSouth(dy, bounds) {
|
|
226
|
-
this._resizeContainer(0, 0, 0, dy, bounds);
|
|
227
|
-
}
|
|
228
|
-
_resizeContainer(leftDelta, topDelta, widthDelta, heightDelta, bounds) {
|
|
229
|
-
bounds.left += leftDelta;
|
|
230
|
-
bounds.top += topDelta;
|
|
231
|
-
bounds.width += widthDelta;
|
|
232
|
-
bounds.height += heightDelta;
|
|
233
|
-
let minWidth = 50; // TODO: Move to external configuration
|
|
234
|
-
let minHeight = 50; // TODO: Move to external configuration
|
|
235
|
-
bounds.width = Math.max(bounds.width, minWidth);
|
|
236
|
-
bounds.height = Math.max(bounds.height, minHeight);
|
|
237
|
-
this.topLevelElement.style.left = bounds.left + 'px';
|
|
238
|
-
this.topLevelElement.style.top = bounds.top + 'px';
|
|
239
|
-
this.resize(bounds.width, bounds.height);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
1
|
+
import { ResizeHandle } from "./ResizeHandle.js";
|
|
2
|
+
import { EventHandler } from "./EventHandler.js";
|
|
3
|
+
import { Point } from "./Point.js";
|
|
4
|
+
import { Utils } from "./Utils.js";
|
|
5
|
+
/**
|
|
6
|
+
* Decorates a dock container with resizer handles around its base element
|
|
7
|
+
* This enables the container to be resized from all directions
|
|
8
|
+
*/
|
|
9
|
+
export class ResizableContainer {
|
|
10
|
+
constructor(dialog, delegate, topLevelElement, disableResize = false) {
|
|
11
|
+
this.dialog = dialog;
|
|
12
|
+
this.disableResize = disableResize;
|
|
13
|
+
this.delegate = delegate;
|
|
14
|
+
this.containerElement = delegate.containerElement;
|
|
15
|
+
this.dockManager = delegate.dockManager;
|
|
16
|
+
this.topLevelElement = topLevelElement;
|
|
17
|
+
this.containerType = delegate.containerType;
|
|
18
|
+
this.topLevelElement.style.left = this.topLevelElement.offsetLeft + 'px';
|
|
19
|
+
this.topLevelElement.style.top = this.topLevelElement.offsetTop + 'px';
|
|
20
|
+
this.minimumAllowedChildNodes = delegate.minimumAllowedChildNodes;
|
|
21
|
+
this._buildResizeHandles();
|
|
22
|
+
this.readyToProcessNextResize = true;
|
|
23
|
+
this.dockSpawnResizedEvent = new CustomEvent("DockSpawnResizedEvent", { composed: true, bubbles: true });
|
|
24
|
+
this.iframeEventHandlers = [];
|
|
25
|
+
}
|
|
26
|
+
setActiveChild( /*child*/) {
|
|
27
|
+
}
|
|
28
|
+
_buildResizeHandles() {
|
|
29
|
+
this.resizeHandles = [];
|
|
30
|
+
// this._buildResizeHandle(true, false, true, false); // Dont need the corner resizer near the close button
|
|
31
|
+
if (!this.disableResize) {
|
|
32
|
+
this._buildResizeHandle(false, true, true, false);
|
|
33
|
+
this._buildResizeHandle(true, false, false, true);
|
|
34
|
+
this._buildResizeHandle(false, true, false, true);
|
|
35
|
+
this._buildResizeHandle(true, false, false, false);
|
|
36
|
+
this._buildResizeHandle(false, true, false, false);
|
|
37
|
+
this._buildResizeHandle(false, false, true, false);
|
|
38
|
+
this._buildResizeHandle(false, false, false, true);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
_buildResizeHandle(east, west, north, south) {
|
|
42
|
+
let handle = new ResizeHandle();
|
|
43
|
+
handle.east = east;
|
|
44
|
+
handle.west = west;
|
|
45
|
+
handle.north = north;
|
|
46
|
+
handle.south = south;
|
|
47
|
+
// Create an invisible div for the handle
|
|
48
|
+
handle.element = document.createElement('div');
|
|
49
|
+
this.topLevelElement.appendChild(handle.element);
|
|
50
|
+
// Build the class name for the handle
|
|
51
|
+
let verticalClass = '';
|
|
52
|
+
let horizontalClass = '';
|
|
53
|
+
if (north)
|
|
54
|
+
verticalClass = 'n';
|
|
55
|
+
if (south)
|
|
56
|
+
verticalClass = 's';
|
|
57
|
+
if (east)
|
|
58
|
+
horizontalClass = 'e';
|
|
59
|
+
if (west)
|
|
60
|
+
horizontalClass = 'w';
|
|
61
|
+
let cssClass = 'resize-handle-' + verticalClass + horizontalClass;
|
|
62
|
+
if (verticalClass.length > 0 && horizontalClass.length > 0)
|
|
63
|
+
handle.corner = true;
|
|
64
|
+
handle.element.classList.add(handle.corner ? 'resize-handle-corner' : 'resize-handle');
|
|
65
|
+
handle.element.classList.add(cssClass);
|
|
66
|
+
this.resizeHandles.push(handle);
|
|
67
|
+
handle.mouseDownHandler = new EventHandler(handle.element, 'mousedown', (e) => { this.onMouseDown(handle, e); });
|
|
68
|
+
handle.touchDownHandler = new EventHandler(handle.element, 'touchstart', (e) => { this.onMouseDown(handle, e); });
|
|
69
|
+
}
|
|
70
|
+
saveState(state) {
|
|
71
|
+
this.delegate.saveState(state);
|
|
72
|
+
}
|
|
73
|
+
loadState(state) {
|
|
74
|
+
this.delegate.loadState(state);
|
|
75
|
+
}
|
|
76
|
+
get width() {
|
|
77
|
+
return this.delegate.width;
|
|
78
|
+
}
|
|
79
|
+
get height() {
|
|
80
|
+
return this.delegate.height;
|
|
81
|
+
}
|
|
82
|
+
get name() {
|
|
83
|
+
return this.delegate.name;
|
|
84
|
+
}
|
|
85
|
+
set name(value) {
|
|
86
|
+
if (value)
|
|
87
|
+
this.delegate.name = value;
|
|
88
|
+
}
|
|
89
|
+
resize(width, height) {
|
|
90
|
+
this.delegate.resize(width, height);
|
|
91
|
+
this._adjustResizeHandles(width, height);
|
|
92
|
+
document.dispatchEvent(this.dockSpawnResizedEvent);
|
|
93
|
+
}
|
|
94
|
+
_adjustResizeHandles(width, height) {
|
|
95
|
+
this.resizeHandles.forEach((handle) => {
|
|
96
|
+
handle.adjustSize(width, height);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
performLayout(children) {
|
|
100
|
+
this.delegate.performLayout(children, false);
|
|
101
|
+
}
|
|
102
|
+
destroy() {
|
|
103
|
+
this.removeDecorator();
|
|
104
|
+
this.delegate.destroy();
|
|
105
|
+
}
|
|
106
|
+
removeDecorator() {
|
|
107
|
+
}
|
|
108
|
+
onMouseMovedIframe(handle, e, iframe) {
|
|
109
|
+
let posIf = iframe.getBoundingClientRect();
|
|
110
|
+
this.onMouseMoved(handle, e, { x: posIf.x, y: posIf.y });
|
|
111
|
+
}
|
|
112
|
+
onMouseMoved(handle, event, iframeOffset) {
|
|
113
|
+
let touchOrMouseData = null;
|
|
114
|
+
if (event.changedTouches) {
|
|
115
|
+
if (event.changedTouches.length > 1)
|
|
116
|
+
return;
|
|
117
|
+
touchOrMouseData = event.changedTouches[0];
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
touchOrMouseData = event;
|
|
121
|
+
}
|
|
122
|
+
if (!this.readyToProcessNextResize)
|
|
123
|
+
return;
|
|
124
|
+
this.readyToProcessNextResize = false;
|
|
125
|
+
if (this.dialog.panel)
|
|
126
|
+
this.dockManager.suspendLayout(this.dialog.panel);
|
|
127
|
+
let currentMousePosition = new Point(touchOrMouseData.clientX, touchOrMouseData.clientY);
|
|
128
|
+
if (iframeOffset)
|
|
129
|
+
currentMousePosition = new Point(touchOrMouseData.clientX + iframeOffset.x, touchOrMouseData.clientY + iframeOffset.y);
|
|
130
|
+
let dx = this.dockManager.checkXBounds(this.topLevelElement, currentMousePosition, this.previousMousePosition, handle.west, handle.east);
|
|
131
|
+
let dy = this.dockManager.checkYBounds(this.topLevelElement, currentMousePosition, this.previousMousePosition, handle.north, handle.south);
|
|
132
|
+
this._performDrag(handle, dx, dy);
|
|
133
|
+
this.previousMousePosition = currentMousePosition;
|
|
134
|
+
this.readyToProcessNextResize = true;
|
|
135
|
+
if (this.dialog.panel)
|
|
136
|
+
this.dockManager.resumeLayout(this.dialog.panel);
|
|
137
|
+
this.dockManager.notifyOnContainerResized(this);
|
|
138
|
+
}
|
|
139
|
+
onMouseDown(handle, event) {
|
|
140
|
+
let touchOrMouseData = null;
|
|
141
|
+
if (event.touches) {
|
|
142
|
+
if (event.touches.length > 1)
|
|
143
|
+
return;
|
|
144
|
+
touchOrMouseData = event.touches[0];
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
touchOrMouseData = event;
|
|
148
|
+
}
|
|
149
|
+
this.previousMousePosition = new Point(touchOrMouseData.clientX, touchOrMouseData.clientY);
|
|
150
|
+
if (handle.mouseMoveHandler) {
|
|
151
|
+
handle.mouseMoveHandler.cancel();
|
|
152
|
+
delete handle.mouseMoveHandler;
|
|
153
|
+
}
|
|
154
|
+
if (handle.touchMoveHandler) {
|
|
155
|
+
handle.touchMoveHandler.cancel();
|
|
156
|
+
delete handle.touchMoveHandler;
|
|
157
|
+
}
|
|
158
|
+
if (handle.mouseUpHandler) {
|
|
159
|
+
handle.mouseUpHandler.cancel();
|
|
160
|
+
delete handle.mouseUpHandler;
|
|
161
|
+
}
|
|
162
|
+
if (handle.touchUpHandler) {
|
|
163
|
+
handle.touchUpHandler.cancel();
|
|
164
|
+
delete handle.touchUpHandler;
|
|
165
|
+
}
|
|
166
|
+
for (let e of this.iframeEventHandlers) {
|
|
167
|
+
e.cancel();
|
|
168
|
+
}
|
|
169
|
+
this.iframeEventHandlers = [];
|
|
170
|
+
// Create the mouse event handlers
|
|
171
|
+
handle.mouseMoveHandler = new EventHandler(window, 'mousemove', (e) => { this.onMouseMoved(handle, e); });
|
|
172
|
+
handle.touchMoveHandler = new EventHandler(window, 'touchmove', (e) => { this.onMouseMoved(handle, e); });
|
|
173
|
+
handle.mouseUpHandler = new EventHandler(window, 'mouseup', (e) => { this.onMouseUp(handle); });
|
|
174
|
+
handle.touchUpHandler = new EventHandler(window, 'touchend', (e) => { this.onMouseUp(handle); });
|
|
175
|
+
if (this.dockManager.iframes) {
|
|
176
|
+
for (let f of this.dockManager.iframes) {
|
|
177
|
+
let mmi = this.onMouseMovedIframe.bind(this);
|
|
178
|
+
this.iframeEventHandlers.push(new EventHandler(f.contentWindow, 'mousemove', (e) => mmi(handle, e, f)));
|
|
179
|
+
this.iframeEventHandlers.push(new EventHandler(f.contentWindow, 'mouseup', (e) => this.onMouseUp(handle)));
|
|
180
|
+
this.iframeEventHandlers.push(new EventHandler(f.contentWindow, 'touchmove', (e) => mmi(handle, e, f)));
|
|
181
|
+
this.iframeEventHandlers.push(new EventHandler(f.contentWindow, 'touchend', (e) => this.onMouseUp(handle)));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
Utils.disableGlobalTextSelection(this.dockManager.config.dialogRootElement);
|
|
185
|
+
}
|
|
186
|
+
onMouseUp(handle) {
|
|
187
|
+
handle.mouseMoveHandler.cancel();
|
|
188
|
+
handle.touchMoveHandler.cancel();
|
|
189
|
+
handle.mouseUpHandler.cancel();
|
|
190
|
+
handle.touchUpHandler.cancel();
|
|
191
|
+
delete handle.mouseMoveHandler;
|
|
192
|
+
delete handle.touchMoveHandler;
|
|
193
|
+
delete handle.mouseUpHandler;
|
|
194
|
+
delete handle.touchUpHandler;
|
|
195
|
+
for (let e of this.iframeEventHandlers) {
|
|
196
|
+
e.cancel();
|
|
197
|
+
}
|
|
198
|
+
this.iframeEventHandlers = [];
|
|
199
|
+
Utils.enableGlobalTextSelection(this.dockManager.config.dialogRootElement);
|
|
200
|
+
}
|
|
201
|
+
_performDrag(handle, dx, dy) {
|
|
202
|
+
let bounds = {};
|
|
203
|
+
bounds.left = Utils.getPixels(this.topLevelElement.style.left);
|
|
204
|
+
bounds.top = Utils.getPixels(this.topLevelElement.style.top);
|
|
205
|
+
bounds.width = this.topLevelElement.clientWidth;
|
|
206
|
+
bounds.height = this.topLevelElement.clientHeight;
|
|
207
|
+
if (handle.east)
|
|
208
|
+
this._resizeEast(dx, bounds);
|
|
209
|
+
if (handle.west)
|
|
210
|
+
this._resizeWest(dx, bounds);
|
|
211
|
+
if (handle.north)
|
|
212
|
+
this._resizeNorth(dy, bounds);
|
|
213
|
+
if (handle.south)
|
|
214
|
+
this._resizeSouth(dy, bounds);
|
|
215
|
+
}
|
|
216
|
+
_resizeWest(dx, bounds) {
|
|
217
|
+
this._resizeContainer(dx, 0, -dx, 0, bounds);
|
|
218
|
+
}
|
|
219
|
+
_resizeEast(dx, bounds) {
|
|
220
|
+
this._resizeContainer(0, 0, dx, 0, bounds);
|
|
221
|
+
}
|
|
222
|
+
_resizeNorth(dy, bounds) {
|
|
223
|
+
this._resizeContainer(0, dy, 0, -dy, bounds);
|
|
224
|
+
}
|
|
225
|
+
_resizeSouth(dy, bounds) {
|
|
226
|
+
this._resizeContainer(0, 0, 0, dy, bounds);
|
|
227
|
+
}
|
|
228
|
+
_resizeContainer(leftDelta, topDelta, widthDelta, heightDelta, bounds) {
|
|
229
|
+
bounds.left += leftDelta;
|
|
230
|
+
bounds.top += topDelta;
|
|
231
|
+
bounds.width += widthDelta;
|
|
232
|
+
bounds.height += heightDelta;
|
|
233
|
+
let minWidth = 50; // TODO: Move to external configuration
|
|
234
|
+
let minHeight = 50; // TODO: Move to external configuration
|
|
235
|
+
bounds.width = Math.max(bounds.width, minWidth);
|
|
236
|
+
bounds.height = Math.max(bounds.height, minHeight);
|
|
237
|
+
this.topLevelElement.style.left = bounds.left + 'px';
|
|
238
|
+
this.topLevelElement.style.top = bounds.top + 'px';
|
|
239
|
+
this.resize(bounds.width, bounds.height);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
242
|
//# sourceMappingURL=ResizableContainer.js.map
|
package/lib/js/ResizeHandle.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { EventHandler } from "./EventHandler.js";
|
|
2
|
-
export declare class ResizeHandle {
|
|
3
|
-
element: HTMLElement;
|
|
4
|
-
handleSize: number;
|
|
5
|
-
cornerSize: number;
|
|
6
|
-
east: boolean;
|
|
7
|
-
west: boolean;
|
|
8
|
-
north: boolean;
|
|
9
|
-
south: boolean;
|
|
10
|
-
corner: boolean;
|
|
11
|
-
mouseDownHandler: EventHandler;
|
|
12
|
-
touchDownHandler: EventHandler;
|
|
13
|
-
constructor();
|
|
14
|
-
adjustSize(clientWidth: number, clientHeight: number): void;
|
|
15
|
-
}
|
|
1
|
+
import { EventHandler } from "./EventHandler.js";
|
|
2
|
+
export declare class ResizeHandle {
|
|
3
|
+
element: HTMLElement;
|
|
4
|
+
handleSize: number;
|
|
5
|
+
cornerSize: number;
|
|
6
|
+
east: boolean;
|
|
7
|
+
west: boolean;
|
|
8
|
+
north: boolean;
|
|
9
|
+
south: boolean;
|
|
10
|
+
corner: boolean;
|
|
11
|
+
mouseDownHandler: EventHandler;
|
|
12
|
+
touchDownHandler: EventHandler;
|
|
13
|
+
constructor();
|
|
14
|
+
adjustSize(clientWidth: number, clientHeight: number): void;
|
|
15
|
+
}
|
package/lib/js/ResizeHandle.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
export class ResizeHandle {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.element = undefined;
|
|
4
|
-
this.handleSize = 6; // TODO: Get this from DOM
|
|
5
|
-
this.cornerSize = 12; // TODO: Get this from DOM
|
|
6
|
-
this.east = false;
|
|
7
|
-
this.west = false;
|
|
8
|
-
this.north = false;
|
|
9
|
-
this.south = false;
|
|
10
|
-
this.corner = false;
|
|
11
|
-
}
|
|
12
|
-
adjustSize(clientWidth, clientHeight) {
|
|
13
|
-
if (this.corner) {
|
|
14
|
-
if (this.west)
|
|
15
|
-
this.element.style.left = '0px';
|
|
16
|
-
if (this.east)
|
|
17
|
-
this.element.style.left = (clientWidth - this.cornerSize) + 'px';
|
|
18
|
-
if (this.north)
|
|
19
|
-
this.element.style.top = '0px';
|
|
20
|
-
if (this.south)
|
|
21
|
-
this.element.style.top = (clientHeight - this.cornerSize) + 'px';
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
if (this.west) {
|
|
25
|
-
this.element.style.left = '0px';
|
|
26
|
-
this.element.style.top = this.cornerSize + 'px';
|
|
27
|
-
}
|
|
28
|
-
if (this.east) {
|
|
29
|
-
this.element.style.left = (clientWidth - this.handleSize) + 'px';
|
|
30
|
-
this.element.style.top = this.cornerSize + 'px';
|
|
31
|
-
}
|
|
32
|
-
if (this.north) {
|
|
33
|
-
this.element.style.left = this.cornerSize + 'px';
|
|
34
|
-
this.element.style.top = '0px';
|
|
35
|
-
}
|
|
36
|
-
if (this.south) {
|
|
37
|
-
this.element.style.left = this.cornerSize + 'px';
|
|
38
|
-
this.element.style.top = (clientHeight - this.handleSize) + 'px';
|
|
39
|
-
}
|
|
40
|
-
if (this.west || this.east) {
|
|
41
|
-
this.element.style.height = (clientHeight - this.cornerSize * 2) + 'px';
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.element.style.width = (clientWidth - this.cornerSize * 2) + 'px';
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
export class ResizeHandle {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.element = undefined;
|
|
4
|
+
this.handleSize = 6; // TODO: Get this from DOM
|
|
5
|
+
this.cornerSize = 12; // TODO: Get this from DOM
|
|
6
|
+
this.east = false;
|
|
7
|
+
this.west = false;
|
|
8
|
+
this.north = false;
|
|
9
|
+
this.south = false;
|
|
10
|
+
this.corner = false;
|
|
11
|
+
}
|
|
12
|
+
adjustSize(clientWidth, clientHeight) {
|
|
13
|
+
if (this.corner) {
|
|
14
|
+
if (this.west)
|
|
15
|
+
this.element.style.left = '0px';
|
|
16
|
+
if (this.east)
|
|
17
|
+
this.element.style.left = (clientWidth - this.cornerSize) + 'px';
|
|
18
|
+
if (this.north)
|
|
19
|
+
this.element.style.top = '0px';
|
|
20
|
+
if (this.south)
|
|
21
|
+
this.element.style.top = (clientHeight - this.cornerSize) + 'px';
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (this.west) {
|
|
25
|
+
this.element.style.left = '0px';
|
|
26
|
+
this.element.style.top = this.cornerSize + 'px';
|
|
27
|
+
}
|
|
28
|
+
if (this.east) {
|
|
29
|
+
this.element.style.left = (clientWidth - this.handleSize) + 'px';
|
|
30
|
+
this.element.style.top = this.cornerSize + 'px';
|
|
31
|
+
}
|
|
32
|
+
if (this.north) {
|
|
33
|
+
this.element.style.left = this.cornerSize + 'px';
|
|
34
|
+
this.element.style.top = '0px';
|
|
35
|
+
}
|
|
36
|
+
if (this.south) {
|
|
37
|
+
this.element.style.left = this.cornerSize + 'px';
|
|
38
|
+
this.element.style.top = (clientHeight - this.handleSize) + 'px';
|
|
39
|
+
}
|
|
40
|
+
if (this.west || this.east) {
|
|
41
|
+
this.element.style.height = (clientHeight - this.cornerSize * 2) + 'px';
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.element.style.width = (clientWidth - this.cornerSize * 2) + 'px';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
49
|
//# sourceMappingURL=ResizeHandle.js.map
|