dock-spawn-ts 2.403.0 → 2.501.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/src/Dialog.ts CHANGED
@@ -73,6 +73,7 @@ export class Dialog {
73
73
  this.position = new Point(x - rect.left, y - rect.top);
74
74
  this.elementDialog.style.left = (x - rect.left) + 'px';
75
75
  this.elementDialog.style.top = (y - rect.top) + 'px';
76
+ this.panel.setDialogPosition(x, y);
76
77
  this.dockManager.notifyOnChangeDialogPosition(this, x, y);
77
78
  }
78
79
 
@@ -91,7 +92,7 @@ export class Dialog {
91
92
 
92
93
  destroy() {
93
94
  this.panel.lastDialogSize = { width: this.resizable.width, height: this.resizable.height };
94
-
95
+
95
96
  if (this.focusHandler) {
96
97
  this.focusHandler.cancel();
97
98
  delete this.focusHandler;
@@ -132,12 +133,14 @@ export class Dialog {
132
133
  }
133
134
 
134
135
  bringToFront() {
136
+ this.panel.elementContentContainer.style.zIndex = <any>this.dockManager.zIndexDialogCounter++;
135
137
  this.elementDialog.style.zIndex = <any>this.dockManager.zIndexDialogCounter++;
136
138
  this.dockManager.activePanel = this.panel;
137
139
  }
138
140
 
139
141
  hide() {
140
142
  this.elementDialog.style.zIndex = '0';
143
+ this.panel.elementContentContainer.style.zIndex = this.elementDialog.style.zIndex;
141
144
  this.elementDialog.style.display = 'none';
142
145
  if (!this.isHidden) {
143
146
  this.isHidden = true;
@@ -160,6 +163,7 @@ export class Dialog {
160
163
  }
161
164
 
162
165
  show() {
166
+ this.panel.elementContentContainer.style.zIndex = <any>this.dockManager.zIndexDialogCounter++;
163
167
  this.elementDialog.style.zIndex = <any>this.dockManager.zIndexDialogCounter++;
164
168
  this.elementDialog.style.display = 'block';
165
169
  if (this.isHidden) {
@@ -203,9 +203,9 @@ export class DockManager {
203
203
  this.context.model.rootNode.container.resize(width, height);
204
204
 
205
205
  let offsetX = 0, offsetY = 0;
206
- for (let dialog of this.context.model.dialogs){
207
- if(dialog.position.x > this.element.clientWidth || dialog.position.y > this.element.clientHeight){
208
- if(offsetX > this.element.clientWidth || offsetY > this.element.clientHeight)
206
+ for (let dialog of this.context.model.dialogs) {
207
+ if (dialog.position.x > this.element.clientWidth || dialog.position.y > this.element.clientHeight) {
208
+ if (offsetX > this.element.clientWidth || offsetY > this.element.clientHeight)
209
209
  offsetX = 0, offsetY = 0;
210
210
  dialog.setPosition(100 + offsetX, 100 + offsetY);
211
211
  offsetX += 100;
@@ -399,6 +399,7 @@ export class DockManager {
399
399
  let panel = dialog.panel;
400
400
  let newNode = new DockNode(panel);
401
401
  panel.prepareForDocking();
402
+ panel.elementContentContainer.style.zIndex = '';
402
403
  dialog.destroy();
403
404
  layoutDockFunction(referenceNode, newNode);
404
405
  // this.invalidate();
@@ -623,6 +624,7 @@ export class DockManager {
623
624
  this.layoutEventListeners.forEach((listener) => {
624
625
  if (listener.onDock) {
625
626
  listener.onDock(this, dockNode);
627
+ dockNode.container.resize(dockNode.container.width, dockNode.container.height);
626
628
  }
627
629
  });
628
630
  }
@@ -7,11 +7,12 @@ import { IDockContainer } from "./interfaces/IDockContainer.js";
7
7
  import { ContainerType } from "./ContainerType.js";
8
8
  import { IState } from "./interfaces/IState.js";
9
9
  import { DockWheelItem } from "./DockWheelItem.js";
10
+ import { PanelContainer } from "./PanelContainer.js";
10
11
 
11
12
  export class DraggableContainer implements IDockContainer {
12
13
 
13
14
  dialog: Dialog;
14
- delegate: IDockContainer;
15
+ delegate: PanelContainer;
15
16
  containerElement: HTMLElement;
16
17
  dockManager: DockManager;
17
18
  topLevelElement: HTMLElement;
@@ -26,7 +27,7 @@ export class DraggableContainer implements IDockContainer {
26
27
  touchUpHandler: EventHandler;
27
28
  private iframeEventHandlers: EventHandler[];
28
29
 
29
- constructor(dialog: Dialog, delegate: IDockContainer, topLevelElement: HTMLElement, dragHandle: HTMLElement) {
30
+ constructor(dialog: Dialog, delegate: PanelContainer, topLevelElement: HTMLElement, dragHandle: HTMLElement) {
30
31
  this.dialog = dialog;
31
32
  this.delegate = delegate;
32
33
  this.containerElement = delegate.containerElement;
@@ -158,6 +159,7 @@ export class DraggableContainer implements IDockContainer {
158
159
 
159
160
  _startDragging(event: { clientX: number, clientY: number }) {
160
161
  this.containerElement.classList.add("draggable-dragging-active");
162
+ this.delegate.elementContentContainer.classList.add("draggable-dragging-active");
161
163
  if (this.dialog.eventListener)
162
164
  this.dialog.eventListener._onDialogDragStarted(this.dialog, event);
163
165
  Utils.disableGlobalTextSelection(this.dockManager.config.dialogRootElement);
@@ -165,6 +167,7 @@ export class DraggableContainer implements IDockContainer {
165
167
 
166
168
  _stopDragging(event) {
167
169
  this.containerElement.classList.remove("draggable-dragging-active");
170
+ this.delegate.elementContentContainer.classList.remove("draggable-dragging-active");
168
171
  if (this.dialog.eventListener)
169
172
  this.dialog.eventListener._onDialogDragEnded(this.dialog, event);
170
173
  Utils.enableGlobalTextSelection(this.dockManager.config.dialogRootElement);
@@ -223,5 +226,7 @@ export class DraggableContainer implements IDockContainer {
223
226
  let top = dy + Utils.getPixels(this.topLevelElement.style.top);
224
227
  this.topLevelElement.style.left = left + 'px';
225
228
  this.topLevelElement.style.top = top + 'px';
229
+
230
+ this.dialog.panel.setDialogPosition(left,top);
226
231
  }
227
232
  }
@@ -27,6 +27,7 @@ export class PanelContainer implements IDockContainerWithSize {
27
27
  name: string;
28
28
  state: ISize;
29
29
  elementContent: HTMLElement & { resizeHandler?: any, _dockSpawnPanelContainer: PanelContainer };
30
+ elementContentContainer: HTMLElement;
30
31
  elementContentWrapper: HTMLElement;
31
32
  dockManager: DockManager;
32
33
  title: string;
@@ -61,7 +62,28 @@ export class PanelContainer implements IDockContainerWithSize {
61
62
  panelType = PanelType.panel;
62
63
  this.panelType = panelType;
63
64
 
64
- this.elementContent = Object.assign(elementContent, { _dockSpawnPanelContainer: this });
65
+ (<any>elementContent)._dockSpawnPanelContainer = this;
66
+ this.elementContent = <any>elementContent;
67
+ elementContent.style.position = 'absolute'
68
+ elementContent.style.width = '100%'
69
+ elementContent.style.height = '100%'
70
+ elementContent.style.top = '0'
71
+ elementContent.style.bottom = '0'
72
+ elementContent.hidden = false;
73
+ this.elementContentContainer = document.createElement('div');
74
+ this.elementContentContainer.className = 'panel-element-content-container';
75
+ this.elementContentContainer.style.position = 'absolute';
76
+ this.elementContentContainer.addEventListener('pointerdown', () => {
77
+ if (this.isDialog) {
78
+ this._floatingDialog.bringToFront();
79
+ } else {
80
+ if (this.tabPage)
81
+ this.tabPage.setSelected(true);
82
+ }
83
+ });
84
+ this.elementContentContainer.appendChild(elementContent);
85
+ dockManager.config.dialogRootElement.appendChild(this.elementContentContainer);
86
+
65
87
  this.dockManager = dockManager;
66
88
  this.title = title;
67
89
  this.containerType = ContainerType.panel;
@@ -187,9 +209,13 @@ export class PanelContainer implements IDockContainerWithSize {
187
209
  this.elementContentHost.classList.add('panel-content');
188
210
 
189
211
  // set the size of the dialog elements based on the panel's size
190
- let panelWidth = this.elementContent.clientWidth;
191
- let panelHeight = this.elementContent.clientHeight;
212
+ let panelWidth = this.elementContentContainer.clientWidth;
213
+ let panelHeight = this.elementContentContainer.clientHeight;
192
214
  let titleHeight = this.elementTitle.clientHeight;
215
+
216
+ this.elementContentWrapper = document.createElement("div");
217
+ this.elementContentWrapper.classList.add('panel-content-wrapper');
218
+
193
219
  this._setPanelDimensions(panelWidth, panelHeight + titleHeight);
194
220
 
195
221
  if (!this._hideCloseButton) {
@@ -199,10 +225,6 @@ export class PanelContainer implements IDockContainerWithSize {
199
225
  new EventHandler(this.elementButtonClose, 'touchstart', this.onCloseButtonClicked.bind(this));
200
226
  }
201
227
 
202
- this.elementContentWrapper = document.createElement("div");
203
- this.elementContentWrapper.classList.add('panel-content-wrapper');
204
- this.elementContentWrapper.appendChild(this.elementContent);
205
-
206
228
  Utils.removeNode(this.elementContentWrapper);
207
229
  this.elementContentHost.appendChild(this.elementContentWrapper);
208
230
 
@@ -319,6 +341,7 @@ export class PanelContainer implements IDockContainerWithSize {
319
341
  // // Already in the desired size
320
342
  // return;
321
343
  // }
344
+ this.setVisible(true);
322
345
  this._setPanelDimensions(width, height);
323
346
  this._cachedWidth = width;
324
347
  this._cachedHeight = height;
@@ -333,14 +356,32 @@ export class PanelContainer implements IDockContainerWithSize {
333
356
  _setPanelDimensions(width: number, height: number) {
334
357
  this.elementTitle.style.width = width + 'px';
335
358
  this.elementContentHost.style.width = width + 'px';
336
- this.elementContent.style.width = width + 'px';
359
+ this.elementContentContainer.style.width = width + 'px';
337
360
  this.elementPanel.style.width = width + 'px';
338
361
 
339
362
  let titleBarHeight = this.elementTitle.clientHeight;
340
363
  let contentHeight = height - titleBarHeight;
341
364
  this.elementContentHost.style.height = contentHeight + 'px';
342
- this.elementContent.style.height = contentHeight + 'px';
365
+ this.elementContentContainer.style.height = contentHeight + 'px';
343
366
  this.elementPanel.style.height = height + 'px';
367
+
368
+ if (this.elementContentContainer.parentElement != this.dockManager.config.dialogRootElement)
369
+ this.dockManager.config.dialogRootElement.appendChild(this.elementContentContainer);
370
+ const rect = this.elementContentWrapper.getBoundingClientRect();
371
+ this.elementContentContainer.style.left = rect.x + 'px';
372
+ this.elementContentContainer.style.top = rect.y + 'px';
373
+ this.elementContentContainer.style.width = rect.width + 'px';
374
+ this.elementContentContainer.style.height = rect.height + 'px';
375
+ }
376
+
377
+ setDialogPosition(x: number, y: number) {
378
+ this.elementContentContainer.style.left = x + 'px';
379
+ //todo, 25px if it is a dialog, is it always 25px? where do we know...
380
+ this.elementContentContainer.style.top = (y + this.elementTitle.clientHeight) + 'px';
381
+ }
382
+
383
+ setVisible(isVisible: boolean) {
384
+ this.elementContentContainer.style.display = isVisible ? 'block' : 'none';
344
385
  }
345
386
 
346
387
  setTitle(title: string) {
@@ -397,6 +438,8 @@ export class PanelContainer implements IDockContainerWithSize {
397
438
  async close() {
398
439
  let close = true;
399
440
 
441
+ this.dockManager.config.dialogRootElement.removeChild(this.elementContentContainer);
442
+
400
443
  if (this.closePanelContainerCallback)
401
444
  close = await this.closePanelContainerCallback(this);
402
445
  else if (this.dockManager.closePanelContainerCallback)
@@ -17,8 +17,8 @@ export abstract class SplitterDockContainer implements IDockContainerWithSize {
17
17
  _cachedHeight: number;
18
18
  state: ISize;
19
19
  containerType: ContainerType;
20
-
21
- constructor(name: string, dockManager: DockManager, childContainers: IDockContainer[], stackedVertical : boolean) {
20
+
21
+ constructor(name: string, dockManager: DockManager, childContainers: IDockContainer[], stackedVertical: boolean) {
22
22
  // for prototype inheritance purposes only
23
23
  if (arguments.length === 0) {
24
24
  return;
@@ -32,7 +32,7 @@ export abstract class SplitterDockContainer implements IDockContainerWithSize {
32
32
  this.minimumAllowedChildNodes = 2;
33
33
  }
34
34
 
35
- resize(width:number, height:number) {
35
+ resize(width: number, height: number) {
36
36
  // if (_cachedWidth === _cachedWidth && _cachedHeight === _height) {
37
37
  // // No need to resize
38
38
  // return;
@@ -42,7 +42,7 @@ export abstract class SplitterDockContainer implements IDockContainerWithSize {
42
42
  this._cachedHeight = height;
43
43
  }
44
44
 
45
- performLayout(childContainers: IDockContainer[], relayoutEvenIfEqual : boolean = false) {
45
+ performLayout(childContainers: IDockContainer[], relayoutEvenIfEqual: boolean = false) {
46
46
  this.splitterPanel.performLayout(childContainers, relayoutEvenIfEqual);
47
47
  }
48
48
 
@@ -62,7 +62,7 @@ export abstract class SplitterDockContainer implements IDockContainerWithSize {
62
62
  this.resize(this.width, this.height);
63
63
  }
64
64
 
65
- getRatios() : number[] {
65
+ getRatios(): number[] {
66
66
  return this.splitterPanel.getRatios();
67
67
  }
68
68
 
package/src/TabHost.ts CHANGED
@@ -88,8 +88,9 @@ export class TabHost {
88
88
  } else {
89
89
  this.separatorElement.classList.remove('dockspan-tab-handle-content-seperator-active');
90
90
  }
91
- if (this.activeTab)
91
+ if (this.activeTab) {
92
92
  this.activeTab.handle.setActive(isActive);
93
+ }
93
94
  }
94
95
 
95
96
  onMousedown() {
package/src/TabPage.ts CHANGED
@@ -78,6 +78,7 @@ export class TabPage {
78
78
  this._initContent = true;
79
79
  if (this.selected) {
80
80
  this.containerElement.style.display = 'block';
81
+ this.panel.setVisible(true);
81
82
  // force a resize again
82
83
  let width = this.host.contentElement.clientWidth;
83
84
  let height = this.host.contentElement.clientHeight;
@@ -86,6 +87,7 @@ export class TabPage {
86
87
  }
87
88
  else {
88
89
  this.containerElement.style.display = 'none';
90
+ this.panel.setVisible(false);
89
91
  }
90
92
  }
91
93