@deephaven/golden-layout 0.22.3-beta.18 → 0.22.3-beta.21
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/dist/LayoutManager.js +60 -260
- package/dist/LayoutManager.js.map +1 -1
- package/dist/base.js.map +1 -1
- package/dist/config/Config.js.map +1 -1
- package/dist/config/ItemConfig.js.map +1 -1
- package/dist/container/ItemContainer.js +14 -50
- package/dist/container/ItemContainer.js.map +1 -1
- package/dist/container/index.js.map +1 -1
- package/dist/controls/BrowserPopout.js +17 -63
- package/dist/controls/BrowserPopout.js.map +1 -1
- package/dist/controls/DragProxy.js +13 -73
- package/dist/controls/DragProxy.js.map +1 -1
- package/dist/controls/DragSource.js +3 -19
- package/dist/controls/DragSource.js.map +1 -1
- package/dist/controls/DragSourceFromEvent.js +5 -24
- package/dist/controls/DragSourceFromEvent.js.map +1 -1
- package/dist/controls/DropTargetIndicator.js +0 -7
- package/dist/controls/DropTargetIndicator.js.map +1 -1
- package/dist/controls/Header.js +89 -233
- package/dist/controls/Header.js.map +1 -1
- package/dist/controls/HeaderButton.js +0 -9
- package/dist/controls/HeaderButton.js.map +1 -1
- package/dist/controls/Splitter.js +0 -14
- package/dist/controls/Splitter.js.map +1 -1
- package/dist/controls/Tab.js +21 -62
- package/dist/controls/Tab.js.map +1 -1
- package/dist/controls/TransitionIndicator.js +2 -21
- package/dist/controls/TransitionIndicator.js.map +1 -1
- package/dist/controls/index.js.map +1 -1
- package/dist/errors/ConfigurationError.js +0 -5
- package/dist/errors/ConfigurationError.js.map +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/items/AbstractContentItem.js +37 -133
- package/dist/items/AbstractContentItem.js.map +1 -1
- package/dist/items/Component.js +2 -27
- package/dist/items/Component.js.map +1 -1
- package/dist/items/Root.js +1 -26
- package/dist/items/Root.js.map +1 -1
- package/dist/items/RowOrColumn.js +32 -128
- package/dist/items/RowOrColumn.js.map +1 -1
- package/dist/items/Stack.js +27 -115
- package/dist/items/Stack.js.map +1 -1
- package/dist/items/index.js.map +1 -1
- package/dist/utils/BubblingEvent.js +0 -6
- package/dist/utils/BubblingEvent.js.map +1 -1
- package/dist/utils/ConfigMinifier.js +13 -26
- package/dist/utils/ConfigMinifier.js.map +1 -1
- package/dist/utils/DragListener.js +8 -47
- package/dist/utils/DragListener.js.map +1 -1
- package/dist/utils/EventEmitter.js +5 -25
- package/dist/utils/EventEmitter.js.map +1 -1
- package/dist/utils/EventHub.js +8 -27
- package/dist/utils/EventHub.js.map +1 -1
- package/dist/utils/ReactComponentHandler.js +6 -35
- package/dist/utils/ReactComponentHandler.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils.js +5 -11
- package/dist/utils/utils.js.map +1 -1
- package/package.json +2 -2
package/dist/LayoutManager.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
import $ from 'jquery';
|
|
8
5
|
import lm from "./base.js";
|
|
9
6
|
import { defaultConfig } from "./config/index.js";
|
|
@@ -11,7 +8,6 @@ import { BrowserPopout, DragSource, DragSourceFromEvent, DropTargetIndicator, Tr
|
|
|
11
8
|
import { ConfigurationError } from "./errors/index.js";
|
|
12
9
|
import { AbstractContentItem, isStack, Component, Root, RowOrColumn, Stack } from "./items/index.js";
|
|
13
10
|
import { minifyConfig, unminifyConfig, EventEmitter, EventHub, ReactComponentHandler, getQueryStringParam, getUniqueId, stripTags } from "./utils/index.js";
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* The main class that will be exposed as GoldenLayout.
|
|
17
13
|
*
|
|
@@ -34,6 +30,7 @@ export default class LayoutManager extends EventEmitter {
|
|
|
34
30
|
static minifyConfig(config) {
|
|
35
31
|
return minifyConfig(config);
|
|
36
32
|
}
|
|
33
|
+
|
|
37
34
|
/**
|
|
38
35
|
* Takes a configuration Object that was previously minified
|
|
39
36
|
* using minifyConfig and returns its original version
|
|
@@ -41,71 +38,40 @@ export default class LayoutManager extends EventEmitter {
|
|
|
41
38
|
* @param minifiedConfig
|
|
42
39
|
* @returns the original configuration
|
|
43
40
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
41
|
static unminifyConfig(config) {
|
|
47
42
|
return unminifyConfig(config);
|
|
48
43
|
}
|
|
49
|
-
|
|
50
44
|
constructor(config, container) {
|
|
51
45
|
super();
|
|
52
|
-
|
|
53
46
|
_defineProperty(this, "isInitialised", false);
|
|
54
|
-
|
|
55
47
|
_defineProperty(this, "_isFullPage", false);
|
|
56
|
-
|
|
57
48
|
_defineProperty(this, "_resizeTimeoutId", void 0);
|
|
58
|
-
|
|
59
49
|
_defineProperty(this, "_components", {
|
|
60
50
|
'lm-react-component': ReactComponentHandler
|
|
61
51
|
});
|
|
62
|
-
|
|
63
52
|
_defineProperty(this, "_fallbackComponent", void 0);
|
|
64
|
-
|
|
65
53
|
_defineProperty(this, "_itemAreas", []);
|
|
66
|
-
|
|
67
54
|
_defineProperty(this, "_maximisedItem", null);
|
|
68
|
-
|
|
69
55
|
_defineProperty(this, "_maximisePlaceholder", $('<div class="lm_maximise_place"></div>'));
|
|
70
|
-
|
|
71
56
|
_defineProperty(this, "_creationTimeoutPassed", false);
|
|
72
|
-
|
|
73
57
|
_defineProperty(this, "_subWindowsCreated", false);
|
|
74
|
-
|
|
75
58
|
_defineProperty(this, "_dragSources", []);
|
|
76
|
-
|
|
77
59
|
_defineProperty(this, "_updatingColumnsResponsive", false);
|
|
78
|
-
|
|
79
60
|
_defineProperty(this, "_firstLoad", true);
|
|
80
|
-
|
|
81
61
|
_defineProperty(this, "width", null);
|
|
82
|
-
|
|
83
62
|
_defineProperty(this, "height", null);
|
|
84
|
-
|
|
85
63
|
_defineProperty(this, "root", void 0);
|
|
86
|
-
|
|
87
64
|
_defineProperty(this, "openPopouts", []);
|
|
88
|
-
|
|
89
65
|
_defineProperty(this, "selectedItem", null);
|
|
90
|
-
|
|
91
66
|
_defineProperty(this, "isSubWindow", false);
|
|
92
|
-
|
|
93
67
|
_defineProperty(this, "eventHub", new EventHub(this));
|
|
94
|
-
|
|
95
68
|
_defineProperty(this, "config", void 0);
|
|
96
|
-
|
|
97
69
|
_defineProperty(this, "container", void 0);
|
|
98
|
-
|
|
99
70
|
_defineProperty(this, "_originalContainer", void 0);
|
|
100
|
-
|
|
101
71
|
_defineProperty(this, "dropTargetIndicator", null);
|
|
102
|
-
|
|
103
72
|
_defineProperty(this, "transitionIndicator", null);
|
|
104
|
-
|
|
105
73
|
_defineProperty(this, "tabDropPlaceholder", $('<div class="lm_drop_tab_placeholder"></div>'));
|
|
106
|
-
|
|
107
74
|
_defineProperty(this, "_typeToItem", void 0);
|
|
108
|
-
|
|
109
75
|
this._onResize = this._onResize.bind(this);
|
|
110
76
|
this._onUnload = this._onUnload.bind(this);
|
|
111
77
|
this._windowBlur = this._windowBlur.bind(this);
|
|
@@ -113,11 +79,9 @@ export default class LayoutManager extends EventEmitter {
|
|
|
113
79
|
this.config = this._createConfig(config);
|
|
114
80
|
this._originalContainer = container;
|
|
115
81
|
this.container = this._getContainer();
|
|
116
|
-
|
|
117
82
|
if (this.isSubWindow) {
|
|
118
83
|
$('body').css('visibility', 'hidden');
|
|
119
84
|
}
|
|
120
|
-
|
|
121
85
|
this._typeToItem = {
|
|
122
86
|
column: RowOrColumn.bind(this, true),
|
|
123
87
|
row: RowOrColumn.bind(this, false),
|
|
@@ -125,6 +89,7 @@ export default class LayoutManager extends EventEmitter {
|
|
|
125
89
|
component: Component
|
|
126
90
|
};
|
|
127
91
|
}
|
|
92
|
+
|
|
128
93
|
/**
|
|
129
94
|
* Register a component with the layout manager. If a configuration node
|
|
130
95
|
* of type component is reached it will look up componentName and create the
|
|
@@ -140,90 +105,75 @@ export default class LayoutManager extends EventEmitter {
|
|
|
140
105
|
* @param constructor
|
|
141
106
|
* @returns cleanup function to deregister component
|
|
142
107
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
108
|
registerComponent(name, constructor) {
|
|
146
109
|
if (typeof constructor !== 'function' && (constructor == null || constructor.render == null || typeof constructor.render !== 'function')) {
|
|
147
110
|
throw new Error('Please register a constructor function');
|
|
148
111
|
}
|
|
149
|
-
|
|
150
112
|
if (this._components[name] !== undefined) {
|
|
151
113
|
throw new Error('Component ' + name + ' is already registered');
|
|
152
114
|
}
|
|
153
|
-
|
|
154
115
|
this._components[name] = constructor;
|
|
155
|
-
|
|
156
116
|
var cleanup = () => {
|
|
157
117
|
if (this._components[name] === undefined) {
|
|
158
118
|
throw new Error('Component ' + name + ' is not registered');
|
|
159
119
|
}
|
|
160
|
-
|
|
161
120
|
delete this._components[name];
|
|
162
121
|
};
|
|
163
|
-
|
|
164
122
|
return cleanup;
|
|
165
123
|
}
|
|
124
|
+
|
|
166
125
|
/**
|
|
167
126
|
* Set a fallback component to be rendered in place of unregistered components
|
|
168
127
|
* @param constructor
|
|
169
128
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
129
|
setFallbackComponent(constructor) {
|
|
173
130
|
this._fallbackComponent = constructor;
|
|
174
131
|
}
|
|
132
|
+
|
|
175
133
|
/**
|
|
176
134
|
* Creates a layout configuration object based on the the current state
|
|
177
135
|
* @param root
|
|
178
136
|
* @returns GoldenLayout configuration
|
|
179
137
|
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
138
|
toConfig(root) {
|
|
183
139
|
if (this.isInitialised === false) {
|
|
184
140
|
throw new Error("Can't create config, layout not yet initialised");
|
|
185
141
|
}
|
|
186
|
-
|
|
187
142
|
if (root && !(root instanceof AbstractContentItem)) {
|
|
188
143
|
throw new Error('Root must be a ContentItem');
|
|
189
144
|
}
|
|
145
|
+
|
|
190
146
|
/*
|
|
191
147
|
* settings & labels
|
|
192
148
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
149
|
var config = {
|
|
196
150
|
settings: _objectSpread({}, this.config.settings),
|
|
197
151
|
dimensions: _objectSpread({}, this.config.dimensions),
|
|
198
152
|
labels: _objectSpread({}, this.config.labels),
|
|
199
153
|
content: []
|
|
200
154
|
};
|
|
155
|
+
|
|
201
156
|
/*
|
|
202
157
|
* Content
|
|
203
158
|
*/
|
|
204
|
-
|
|
205
159
|
var next = function next(configNode, item) {
|
|
206
160
|
for (var _key in item.config) {
|
|
207
161
|
if (_key !== 'content') {
|
|
208
162
|
configNode[_key] = item.config[_key];
|
|
209
163
|
}
|
|
210
164
|
}
|
|
211
|
-
|
|
212
165
|
if (configNode.componentName === 'lm-react-component') {
|
|
213
166
|
// We change the type in `createContentItem`, so change it back here
|
|
214
167
|
configNode.type = 'react-component';
|
|
215
168
|
}
|
|
216
|
-
|
|
217
169
|
if (item.contentItems.length) {
|
|
218
170
|
configNode.content = [];
|
|
219
|
-
|
|
220
171
|
for (var i = 0; i < item.contentItems.length; i++) {
|
|
221
172
|
configNode.content[i] = {};
|
|
222
173
|
next(configNode.content[i], item.contentItems[i]);
|
|
223
174
|
}
|
|
224
175
|
}
|
|
225
176
|
};
|
|
226
|
-
|
|
227
177
|
if (root) {
|
|
228
178
|
next(config, {
|
|
229
179
|
contentItems: [root]
|
|
@@ -231,35 +181,31 @@ export default class LayoutManager extends EventEmitter {
|
|
|
231
181
|
} else {
|
|
232
182
|
next(config, this.root);
|
|
233
183
|
}
|
|
184
|
+
|
|
234
185
|
/*
|
|
235
186
|
* Retrieve config for subwindows
|
|
236
187
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
188
|
this._$reconcilePopoutWindows();
|
|
240
|
-
|
|
241
189
|
config.openPopouts = [];
|
|
242
|
-
|
|
243
190
|
for (var i = 0; i < this.openPopouts.length; i++) {
|
|
244
191
|
config.openPopouts.push(this.openPopouts[i].toConfig());
|
|
245
192
|
}
|
|
193
|
+
|
|
246
194
|
/*
|
|
247
195
|
* Add maximised item
|
|
248
196
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
197
|
config.maximisedItemId = this._maximisedItem ? '__glMaximised' : undefined;
|
|
252
198
|
return config;
|
|
253
199
|
}
|
|
200
|
+
|
|
254
201
|
/**
|
|
255
202
|
* Returns a previously registered component
|
|
256
203
|
* @param name The name used
|
|
257
204
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
205
|
getComponent(name) {
|
|
261
206
|
return this._components[name];
|
|
262
207
|
}
|
|
208
|
+
|
|
263
209
|
/**
|
|
264
210
|
* Returns a fallback component to render in place of unregistered components
|
|
265
211
|
*
|
|
@@ -267,11 +213,10 @@ export default class LayoutManager extends EventEmitter {
|
|
|
267
213
|
*
|
|
268
214
|
* @returns {Function}
|
|
269
215
|
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
216
|
getFallbackComponent() {
|
|
273
217
|
return this._fallbackComponent;
|
|
274
218
|
}
|
|
219
|
+
|
|
275
220
|
/**
|
|
276
221
|
* Creates the actual layout. Must be called after all initial components
|
|
277
222
|
* are registered. Recurses through the configuration and sets up
|
|
@@ -280,8 +225,6 @@ export default class LayoutManager extends EventEmitter {
|
|
|
280
225
|
* If called before the document is ready it adds itself as a listener
|
|
281
226
|
* to the document.ready event
|
|
282
227
|
*/
|
|
283
|
-
|
|
284
|
-
|
|
285
228
|
init() {
|
|
286
229
|
/**
|
|
287
230
|
* Create the popout windows straight away. If popouts are blocked
|
|
@@ -290,95 +233,72 @@ export default class LayoutManager extends EventEmitter {
|
|
|
290
233
|
*/
|
|
291
234
|
if (this._subWindowsCreated === false) {
|
|
292
235
|
this._createSubWindows();
|
|
293
|
-
|
|
294
236
|
this._subWindowsCreated = true;
|
|
295
237
|
}
|
|
238
|
+
|
|
296
239
|
/**
|
|
297
240
|
* If the document isn't ready yet, wait for it.
|
|
298
241
|
*/
|
|
299
|
-
|
|
300
|
-
|
|
301
242
|
if (document.readyState === 'loading' || document.body === null) {
|
|
302
243
|
$(document).ready(this.init.bind(this));
|
|
303
244
|
return;
|
|
304
245
|
}
|
|
246
|
+
|
|
305
247
|
/**
|
|
306
248
|
* If this is a subwindow, wait a few milliseconds for the original
|
|
307
249
|
* page's js calls to be executed, then replace the bodies content
|
|
308
250
|
* with GoldenLayout
|
|
309
251
|
*/
|
|
310
|
-
|
|
311
|
-
|
|
312
252
|
if (this.isSubWindow === true && this._creationTimeoutPassed === false) {
|
|
313
253
|
setTimeout(this.init.bind(this), 7);
|
|
314
254
|
this._creationTimeoutPassed = true;
|
|
315
255
|
return;
|
|
316
256
|
}
|
|
317
|
-
|
|
318
257
|
if (this.isSubWindow === true) {
|
|
319
258
|
this._adjustToWindowMode();
|
|
320
259
|
}
|
|
321
|
-
|
|
322
260
|
this._setContainer();
|
|
323
|
-
|
|
324
261
|
this.dropTargetIndicator = new DropTargetIndicator();
|
|
325
262
|
this.transitionIndicator = new TransitionIndicator();
|
|
326
263
|
this.updateSize();
|
|
327
|
-
|
|
328
264
|
this._create(this.config);
|
|
329
|
-
|
|
330
265
|
this._bindEvents();
|
|
331
|
-
|
|
332
266
|
this.isInitialised = true;
|
|
333
|
-
|
|
334
267
|
this._adjustColumnsResponsive();
|
|
335
|
-
|
|
336
268
|
this.emit('initialised');
|
|
337
269
|
}
|
|
270
|
+
|
|
338
271
|
/**
|
|
339
272
|
* Updates the layout managers size
|
|
340
273
|
* @param width width in pixels
|
|
341
274
|
* @param height height in pixels
|
|
342
275
|
*/
|
|
343
|
-
|
|
344
|
-
|
|
345
276
|
updateSize(width, height) {
|
|
346
277
|
var _ref, _ref2;
|
|
347
|
-
|
|
348
278
|
this.width = (_ref = width !== null && width !== void 0 ? width : this.container.width()) !== null && _ref !== void 0 ? _ref : 0;
|
|
349
279
|
this.height = (_ref2 = height !== null && height !== void 0 ? height : this.container.height()) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
|
350
|
-
|
|
351
280
|
if (this.isInitialised === true) {
|
|
352
281
|
this.root.callDownwards('setSize', [this.width, this.height]);
|
|
353
|
-
|
|
354
282
|
if (this._maximisedItem) {
|
|
355
283
|
var _this$container$width, _this$container$heigh;
|
|
356
|
-
|
|
357
284
|
this._maximisedItem.element.width((_this$container$width = this.container.width()) !== null && _this$container$width !== void 0 ? _this$container$width : 0);
|
|
358
|
-
|
|
359
285
|
this._maximisedItem.element.height((_this$container$heigh = this.container.height()) !== null && _this$container$heigh !== void 0 ? _this$container$heigh : 0);
|
|
360
|
-
|
|
361
286
|
this._maximisedItem.callDownwards('setSize');
|
|
362
287
|
}
|
|
363
|
-
|
|
364
288
|
this._adjustColumnsResponsive();
|
|
365
289
|
}
|
|
366
290
|
}
|
|
291
|
+
|
|
367
292
|
/**
|
|
368
293
|
* Destroys the LayoutManager instance itself as well as every ContentItem
|
|
369
294
|
* within it. After this is called nothing should be left of the LayoutManager.
|
|
370
295
|
*/
|
|
371
|
-
|
|
372
|
-
|
|
373
296
|
destroy() {
|
|
374
297
|
var _this$dropTargetIndic, _this$transitionIndic;
|
|
375
|
-
|
|
376
298
|
if (this.isInitialised === false || !this.root) {
|
|
377
299
|
return;
|
|
378
300
|
}
|
|
379
|
-
|
|
380
301
|
this._onUnload();
|
|
381
|
-
|
|
382
302
|
$(window).off('resize', this._onResize);
|
|
383
303
|
$(window).off('unload beforeunload', this._onUnload);
|
|
384
304
|
$(window).off('blur.lm').off('focus.lm');
|
|
@@ -388,13 +308,12 @@ export default class LayoutManager extends EventEmitter {
|
|
|
388
308
|
(_this$dropTargetIndic = this.dropTargetIndicator) === null || _this$dropTargetIndic === void 0 ? void 0 : _this$dropTargetIndic.destroy();
|
|
389
309
|
(_this$transitionIndic = this.transitionIndicator) === null || _this$transitionIndic === void 0 ? void 0 : _this$transitionIndic.destroy();
|
|
390
310
|
this.eventHub.destroy();
|
|
391
|
-
|
|
392
311
|
this._dragSources.forEach(function (dragSource) {
|
|
393
312
|
dragSource._dragListener.destroy();
|
|
394
313
|
});
|
|
395
|
-
|
|
396
314
|
this._dragSources = [];
|
|
397
315
|
}
|
|
316
|
+
|
|
398
317
|
/**
|
|
399
318
|
* Recursively creates new item tree structures based on a provided
|
|
400
319
|
* ItemConfiguration object
|
|
@@ -405,33 +324,31 @@ export default class LayoutManager extends EventEmitter {
|
|
|
405
324
|
*
|
|
406
325
|
* @returns Created item
|
|
407
326
|
*/
|
|
408
|
-
|
|
409
|
-
|
|
410
327
|
createContentItem(config, parent) {
|
|
411
328
|
var typeErrorMsg, contentItem;
|
|
412
|
-
|
|
413
329
|
if (typeof config.type !== 'string') {
|
|
414
330
|
throw new ConfigurationError("Missing parameter 'type'", config);
|
|
415
331
|
}
|
|
416
|
-
|
|
417
332
|
if (config.type === 'react-component') {
|
|
418
333
|
config.type = 'component';
|
|
419
334
|
config.componentName = 'lm-react-component';
|
|
420
335
|
}
|
|
421
|
-
|
|
422
336
|
if (!this._typeToItem[config.type]) {
|
|
423
337
|
typeErrorMsg = "Unknown type '" + config.type + "'. " + 'Valid types are ' + Object.keys(this._typeToItem).join(',');
|
|
424
338
|
throw new ConfigurationError(typeErrorMsg);
|
|
425
339
|
}
|
|
340
|
+
|
|
426
341
|
/**
|
|
427
342
|
* We add an additional stack around every component that's not within a stack anyways.
|
|
428
343
|
*/
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
!(parent instanceof Stack) &&
|
|
434
|
-
|
|
344
|
+
if (
|
|
345
|
+
// If this is a component
|
|
346
|
+
config.type === 'component' &&
|
|
347
|
+
// and it's not already within a stack
|
|
348
|
+
!(parent instanceof Stack) &&
|
|
349
|
+
// and we have a parent
|
|
350
|
+
!!parent &&
|
|
351
|
+
// and it's not the topmost item in a new window
|
|
435
352
|
!(this.isSubWindow === true && parent instanceof Root)) {
|
|
436
353
|
config = {
|
|
437
354
|
type: 'stack',
|
|
@@ -440,10 +357,10 @@ export default class LayoutManager extends EventEmitter {
|
|
|
440
357
|
content: [config]
|
|
441
358
|
};
|
|
442
359
|
}
|
|
443
|
-
|
|
444
360
|
contentItem = new this._typeToItem[config.type](this, config, parent);
|
|
445
361
|
return contentItem;
|
|
446
362
|
}
|
|
363
|
+
|
|
447
364
|
/**
|
|
448
365
|
* Creates a popout window with the specified content and dimensions
|
|
449
366
|
*
|
|
@@ -454,19 +371,16 @@ export default class LayoutManager extends EventEmitter {
|
|
|
454
371
|
* @param indexInParent The position of this item within its parent element
|
|
455
372
|
* @returns Created popout
|
|
456
373
|
*/
|
|
457
|
-
|
|
458
|
-
|
|
459
374
|
createPopout(configOrContentItem, dimensions, parentId, indexInParent) {
|
|
460
375
|
var config = configOrContentItem;
|
|
461
376
|
var configArray = [];
|
|
462
377
|
var isItem = configOrContentItem instanceof AbstractContentItem;
|
|
463
378
|
var self = this;
|
|
464
|
-
|
|
465
379
|
if (isItem) {
|
|
466
380
|
var _parent2;
|
|
467
|
-
|
|
468
381
|
configArray = this.toConfig(configOrContentItem).content;
|
|
469
382
|
parentId = getUniqueId();
|
|
383
|
+
|
|
470
384
|
/**
|
|
471
385
|
* If the item is the only component within a stack or for some
|
|
472
386
|
* other reason the only child of its parent the parent will be destroyed
|
|
@@ -475,22 +389,16 @@ export default class LayoutManager extends EventEmitter {
|
|
|
475
389
|
* In order to support this we move up the tree until we find something
|
|
476
390
|
* that will remain after the item is being popped out
|
|
477
391
|
*/
|
|
478
|
-
|
|
479
392
|
var parent = configOrContentItem.parent;
|
|
480
393
|
var child = configOrContentItem;
|
|
481
|
-
|
|
482
394
|
while (((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.contentItems.length) === 1 && !parent.isRoot) {
|
|
483
395
|
var _parent;
|
|
484
|
-
|
|
485
396
|
child = parent;
|
|
486
397
|
parent = parent.parent;
|
|
487
398
|
}
|
|
488
|
-
|
|
489
399
|
(_parent2 = parent) === null || _parent2 === void 0 ? void 0 : _parent2.addId(parentId);
|
|
490
|
-
|
|
491
400
|
if (indexInParent == undefined || Number.isNaN(indexInParent)) {
|
|
492
401
|
var _parent3;
|
|
493
|
-
|
|
494
402
|
indexInParent = (_parent3 = parent) === null || _parent3 === void 0 ? void 0 : _parent3.contentItems.indexOf(child);
|
|
495
403
|
}
|
|
496
404
|
} else {
|
|
@@ -500,10 +408,8 @@ export default class LayoutManager extends EventEmitter {
|
|
|
500
408
|
configArray = configOrContentItem;
|
|
501
409
|
}
|
|
502
410
|
}
|
|
503
|
-
|
|
504
411
|
if (!dimensions && isItem) {
|
|
505
412
|
var _configOrContentItem$, _configOrContentItem$2, _configOrContentItem$3;
|
|
506
|
-
|
|
507
413
|
var windowLeft = window.screenX || window.screenLeft;
|
|
508
414
|
var windowTop = window.screenY || window.screenTop;
|
|
509
415
|
var offset = (_configOrContentItem$ = configOrContentItem.element.offset()) !== null && _configOrContentItem$ !== void 0 ? _configOrContentItem$ : {
|
|
@@ -517,7 +423,6 @@ export default class LayoutManager extends EventEmitter {
|
|
|
517
423
|
height: (_configOrContentItem$3 = configOrContentItem.element.height()) !== null && _configOrContentItem$3 !== void 0 ? _configOrContentItem$3 : 0
|
|
518
424
|
};
|
|
519
425
|
}
|
|
520
|
-
|
|
521
426
|
if (!dimensions && !isItem) {
|
|
522
427
|
dimensions = {
|
|
523
428
|
left: window.screenX || window.screenLeft + 20,
|
|
@@ -526,15 +431,12 @@ export default class LayoutManager extends EventEmitter {
|
|
|
526
431
|
height: 309
|
|
527
432
|
};
|
|
528
433
|
}
|
|
529
|
-
|
|
530
434
|
if (isItem) {
|
|
531
435
|
configOrContentItem.remove();
|
|
532
436
|
}
|
|
533
|
-
|
|
534
437
|
if (!dimensions || !parentId || indexInParent === undefined) {
|
|
535
438
|
return;
|
|
536
439
|
}
|
|
537
|
-
|
|
538
440
|
var browserPopout = new BrowserPopout(configArray, dimensions, parentId, indexInParent, this);
|
|
539
441
|
browserPopout.on('initialised', function () {
|
|
540
442
|
self.emit('windowOpened', browserPopout);
|
|
@@ -545,6 +447,7 @@ export default class LayoutManager extends EventEmitter {
|
|
|
545
447
|
this.openPopouts.push(browserPopout);
|
|
546
448
|
return browserPopout;
|
|
547
449
|
}
|
|
450
|
+
|
|
548
451
|
/**
|
|
549
452
|
* Attaches DragListener to any given DOM element
|
|
550
453
|
* and turns it into a way of creating new ContentItems
|
|
@@ -553,28 +456,24 @@ export default class LayoutManager extends EventEmitter {
|
|
|
553
456
|
* @param element
|
|
554
457
|
* @param itemConfig for the new item to be created, or a function which will provide it
|
|
555
458
|
*/
|
|
556
|
-
|
|
557
|
-
|
|
558
459
|
createDragSource(element, itemConfig) {
|
|
559
460
|
this.config.settings.constrainDragToContainer = false;
|
|
560
461
|
var dragSource = new DragSource(element, itemConfig, this);
|
|
561
|
-
|
|
562
462
|
this._dragSources.push(dragSource);
|
|
563
|
-
|
|
564
463
|
return dragSource;
|
|
565
464
|
}
|
|
465
|
+
|
|
566
466
|
/**
|
|
567
467
|
* Create a new item in a dragging state, given a starting mouse event to act as the initial position
|
|
568
468
|
*
|
|
569
469
|
* @param itemConfig for the new item to be created, or a function which will provide it
|
|
570
470
|
* @param event used as the starting position for the dragProxy
|
|
571
471
|
*/
|
|
572
|
-
|
|
573
|
-
|
|
574
472
|
createDragSourceFromEvent(itemConfig, event) {
|
|
575
473
|
this.config.settings.constrainDragToContainer = false;
|
|
576
474
|
return new DragSourceFromEvent(itemConfig, this, event);
|
|
577
475
|
}
|
|
476
|
+
|
|
578
477
|
/**
|
|
579
478
|
* Programmatically selects an item. This deselects
|
|
580
479
|
* the currently selected item, selects the specified item
|
|
@@ -583,71 +482,54 @@ export default class LayoutManager extends EventEmitter {
|
|
|
583
482
|
* @param item
|
|
584
483
|
* @param _$silent Wheather to notify the item of its selection
|
|
585
484
|
*/
|
|
586
|
-
|
|
587
|
-
|
|
588
485
|
selectItem(item, _$silent) {
|
|
589
486
|
if (this.config.settings.selectionEnabled !== true) {
|
|
590
487
|
throw new Error('Please set selectionEnabled to true to use this feature');
|
|
591
488
|
}
|
|
592
|
-
|
|
593
489
|
if (item === this.selectedItem) {
|
|
594
490
|
return;
|
|
595
491
|
}
|
|
596
|
-
|
|
597
492
|
if (this.selectedItem !== null) {
|
|
598
493
|
this.selectedItem.deselect();
|
|
599
494
|
}
|
|
600
|
-
|
|
601
495
|
if (item && _$silent !== true) {
|
|
602
496
|
item.select();
|
|
603
497
|
}
|
|
604
|
-
|
|
605
498
|
this.selectedItem = item;
|
|
606
499
|
this.emit('selectionChanged', item);
|
|
607
500
|
}
|
|
501
|
+
|
|
608
502
|
/*************************
|
|
609
503
|
* PACKAGE PRIVATE
|
|
610
504
|
*************************/
|
|
611
|
-
|
|
612
|
-
|
|
613
505
|
_$maximiseItem(contentItem) {
|
|
614
506
|
var _this$container$width2, _this$container$heigh2;
|
|
615
|
-
|
|
616
507
|
if (this._maximisedItem !== null) {
|
|
617
508
|
this._$minimiseItem(this._maximisedItem);
|
|
618
509
|
}
|
|
619
|
-
|
|
620
510
|
this._maximisedItem = contentItem;
|
|
621
|
-
|
|
622
511
|
this._maximisedItem.addId('__glMaximised');
|
|
623
|
-
|
|
624
512
|
contentItem.element.addClass('lm_maximised');
|
|
625
513
|
contentItem.element.after(this._maximisePlaceholder);
|
|
626
514
|
this.root.element.prepend(contentItem.element);
|
|
627
515
|
contentItem.element.width((_this$container$width2 = this.container.width()) !== null && _this$container$width2 !== void 0 ? _this$container$width2 : 0);
|
|
628
516
|
contentItem.element.height((_this$container$heigh2 = this.container.height()) !== null && _this$container$heigh2 !== void 0 ? _this$container$heigh2 : 0);
|
|
629
517
|
contentItem.callDownwards('setSize');
|
|
630
|
-
|
|
631
518
|
this._maximisedItem.emit('maximised');
|
|
632
|
-
|
|
633
519
|
this.emit('stateChanged');
|
|
634
520
|
}
|
|
635
|
-
|
|
636
521
|
_$minimiseItem(contentItem) {
|
|
637
522
|
var _contentItem$parent;
|
|
638
|
-
|
|
639
523
|
contentItem.element.removeClass('lm_maximised');
|
|
640
524
|
contentItem.removeId('__glMaximised');
|
|
641
|
-
|
|
642
525
|
this._maximisePlaceholder.after(contentItem.element);
|
|
643
|
-
|
|
644
526
|
this._maximisePlaceholder.remove();
|
|
645
|
-
|
|
646
527
|
(_contentItem$parent = contentItem.parent) === null || _contentItem$parent === void 0 ? void 0 : _contentItem$parent.callDownwards('setSize');
|
|
647
528
|
this._maximisedItem = null;
|
|
648
529
|
contentItem.emit('minimised');
|
|
649
530
|
this.emit('stateChanged');
|
|
650
531
|
}
|
|
532
|
+
|
|
651
533
|
/**
|
|
652
534
|
* This method is used to get around sandboxed iframe restrictions.
|
|
653
535
|
* If 'allow-top-navigation' is not specified in the iframe's 'sandbox' attribute
|
|
@@ -658,39 +540,30 @@ export default class LayoutManager extends EventEmitter {
|
|
|
658
540
|
* _$closeWindow on the child window's gl instance which (after a timeout to disconnect
|
|
659
541
|
* the invoking method from the close call) closes itself.
|
|
660
542
|
*/
|
|
661
|
-
|
|
662
|
-
|
|
663
543
|
_$closeWindow() {
|
|
664
544
|
window.setTimeout(function () {
|
|
665
545
|
window.close();
|
|
666
546
|
}, 1);
|
|
667
547
|
}
|
|
668
|
-
|
|
669
548
|
_$getArea(x, y) {
|
|
670
549
|
var smallestSurface = Infinity;
|
|
671
550
|
var mathingArea = null;
|
|
672
|
-
|
|
673
551
|
for (var i = 0; i < this._itemAreas.length; i++) {
|
|
674
552
|
var area = this._itemAreas[i];
|
|
675
|
-
|
|
676
553
|
if (x > area.x1 && x < area.x2 && y > area.y1 && y < area.y2 && smallestSurface > area.surface) {
|
|
677
554
|
smallestSurface = area.surface;
|
|
678
555
|
mathingArea = area;
|
|
679
556
|
}
|
|
680
557
|
}
|
|
681
|
-
|
|
682
558
|
return mathingArea;
|
|
683
559
|
}
|
|
560
|
+
|
|
684
561
|
/**
|
|
685
562
|
* Creates the drop zones at the edges of the screen
|
|
686
563
|
*/
|
|
687
|
-
|
|
688
|
-
|
|
689
564
|
_$createRootItemAreas() {
|
|
690
565
|
var areaSize = 50;
|
|
691
|
-
|
|
692
566
|
var rootArea = _objectSpread({}, this.root._$getArea());
|
|
693
|
-
|
|
694
567
|
var areas = [_objectSpread(_objectSpread({}, rootArea), {}, {
|
|
695
568
|
side: 'left',
|
|
696
569
|
x2: rootArea.x1 + areaSize
|
|
@@ -707,14 +580,12 @@ export default class LayoutManager extends EventEmitter {
|
|
|
707
580
|
areas.forEach(area => {
|
|
708
581
|
area.surface = (area.x2 - area.x1) * (area.y2 - area.y1);
|
|
709
582
|
});
|
|
710
|
-
|
|
711
583
|
this._itemAreas.push(...areas);
|
|
712
584
|
}
|
|
713
|
-
|
|
714
585
|
_$calculateItemAreas() {
|
|
715
586
|
var allContentItems = this._getAllContentItems();
|
|
716
|
-
|
|
717
587
|
this._itemAreas = [];
|
|
588
|
+
|
|
718
589
|
/**
|
|
719
590
|
* If the last item is dragged out, highlight the entire container size to
|
|
720
591
|
* allow to re-drop it. allContentItems[ 0 ] === this.root at this point
|
|
@@ -722,41 +593,31 @@ export default class LayoutManager extends EventEmitter {
|
|
|
722
593
|
* Don't include root into the possible drop areas though otherwise since it
|
|
723
594
|
* will used for every gap in the layout, e.g. splitters
|
|
724
595
|
*/
|
|
725
|
-
|
|
726
596
|
if (allContentItems.length === 1) {
|
|
727
597
|
this._itemAreas.push(this.root._$getArea());
|
|
728
|
-
|
|
729
598
|
return;
|
|
730
599
|
}
|
|
731
|
-
|
|
732
600
|
this._$createRootItemAreas();
|
|
733
|
-
|
|
734
601
|
for (var i = 0; i < allContentItems.length; i++) {
|
|
735
602
|
var item = allContentItems[i];
|
|
736
|
-
|
|
737
603
|
if (!isStack(item)) {
|
|
738
604
|
continue;
|
|
739
605
|
}
|
|
740
|
-
|
|
741
606
|
var area = item._$getArea();
|
|
742
|
-
|
|
743
607
|
if (area === null) {
|
|
744
608
|
continue;
|
|
745
609
|
} else if (area instanceof Array) {
|
|
746
610
|
this._itemAreas = this._itemAreas.concat(area);
|
|
747
611
|
} else {
|
|
748
612
|
var _area$contentItem$_co;
|
|
749
|
-
|
|
750
613
|
this._itemAreas.push(area);
|
|
751
|
-
|
|
752
614
|
var header = _objectSpread(_objectSpread({}, area), (_area$contentItem$_co = area.contentItem._contentAreaDimensions) === null || _area$contentItem$_co === void 0 ? void 0 : _area$contentItem$_co.header.highlightArea);
|
|
753
|
-
|
|
754
615
|
header.surface = (header.x2 - header.x1) * (header.y2 - header.y1);
|
|
755
|
-
|
|
756
616
|
this._itemAreas.push(header);
|
|
757
617
|
}
|
|
758
618
|
}
|
|
759
619
|
}
|
|
620
|
+
|
|
760
621
|
/**
|
|
761
622
|
* Takes a contentItem or a configuration and optionally a parent
|
|
762
623
|
* item and returns an initialised instance of the contentItem.
|
|
@@ -765,21 +626,16 @@ export default class LayoutManager extends EventEmitter {
|
|
|
765
626
|
* @param contentItemOrConfig
|
|
766
627
|
* @param parent Only necessary when passing in config
|
|
767
628
|
*/
|
|
768
|
-
|
|
769
|
-
|
|
770
629
|
_$normalizeContentItem(contentItemOrConfig, parent) {
|
|
771
630
|
if (!contentItemOrConfig) {
|
|
772
631
|
throw new Error('No content item defined');
|
|
773
632
|
}
|
|
774
|
-
|
|
775
633
|
if (typeof contentItemOrConfig === 'function') {
|
|
776
634
|
contentItemOrConfig = contentItemOrConfig();
|
|
777
635
|
}
|
|
778
|
-
|
|
779
636
|
if (contentItemOrConfig instanceof AbstractContentItem) {
|
|
780
637
|
return contentItemOrConfig;
|
|
781
638
|
}
|
|
782
|
-
|
|
783
639
|
if ($.isPlainObject(contentItemOrConfig) && contentItemOrConfig.type) {
|
|
784
640
|
var newContentItem = this.createContentItem(contentItemOrConfig, parent);
|
|
785
641
|
newContentItem.callDownwards('_$init');
|
|
@@ -788,91 +644,78 @@ export default class LayoutManager extends EventEmitter {
|
|
|
788
644
|
throw new Error('Invalid contentItem');
|
|
789
645
|
}
|
|
790
646
|
}
|
|
647
|
+
|
|
791
648
|
/**
|
|
792
649
|
* Iterates through the array of open popout windows and removes the ones
|
|
793
650
|
* that are effectively closed. This is necessary due to the lack of reliably
|
|
794
651
|
* listening for window.close / unload events in a cross browser compatible fashion.
|
|
795
652
|
*/
|
|
796
|
-
|
|
797
|
-
|
|
798
653
|
_$reconcilePopoutWindows() {
|
|
799
654
|
var openPopouts = [];
|
|
800
|
-
|
|
801
655
|
for (var i = 0; i < this.openPopouts.length; i++) {
|
|
802
656
|
var _this$openPopouts$i$g;
|
|
803
|
-
|
|
804
657
|
if (((_this$openPopouts$i$g = this.openPopouts[i].getWindow()) === null || _this$openPopouts$i$g === void 0 ? void 0 : _this$openPopouts$i$g.closed) === false) {
|
|
805
658
|
openPopouts.push(this.openPopouts[i]);
|
|
806
659
|
} else {
|
|
807
660
|
this.emit('windowClosed', this.openPopouts[i]);
|
|
808
661
|
}
|
|
809
662
|
}
|
|
810
|
-
|
|
811
663
|
if (this.openPopouts.length !== openPopouts.length) {
|
|
812
664
|
this.emit('stateChanged');
|
|
813
665
|
this.openPopouts = openPopouts;
|
|
814
666
|
}
|
|
815
667
|
}
|
|
668
|
+
|
|
816
669
|
/***************************
|
|
817
670
|
* PRIVATE
|
|
818
671
|
***************************/
|
|
819
|
-
|
|
820
672
|
/**
|
|
821
673
|
* Returns a flattened array of all content items,
|
|
822
674
|
* regardles of level or type
|
|
823
675
|
* @return Flattened array of content items
|
|
824
676
|
*/
|
|
825
|
-
|
|
826
|
-
|
|
827
677
|
_getAllContentItems() {
|
|
828
678
|
var allContentItems = [];
|
|
829
|
-
|
|
830
679
|
var addChildren = contentItem => {
|
|
831
680
|
allContentItems.push(contentItem);
|
|
832
|
-
|
|
833
681
|
if (contentItem.contentItems instanceof Array) {
|
|
834
682
|
for (var i = 0; i < contentItem.contentItems.length; i++) {
|
|
835
683
|
addChildren(contentItem.contentItems[i]);
|
|
836
684
|
}
|
|
837
685
|
}
|
|
838
686
|
};
|
|
839
|
-
|
|
840
687
|
addChildren(this.root);
|
|
841
688
|
return allContentItems;
|
|
842
689
|
}
|
|
690
|
+
|
|
843
691
|
/**
|
|
844
692
|
* Binds to DOM/BOM events on init
|
|
845
693
|
*/
|
|
846
|
-
|
|
847
|
-
|
|
848
694
|
_bindEvents() {
|
|
849
695
|
if (this._isFullPage) {
|
|
850
696
|
$(window).resize(this._onResize);
|
|
851
697
|
}
|
|
852
|
-
|
|
853
698
|
$(window).on('unload beforeunload', this._onUnload).on('blur.lm', this._windowBlur).on('focus.lm', this._windowFocus);
|
|
854
699
|
}
|
|
700
|
+
|
|
855
701
|
/**
|
|
856
702
|
* Handles setting a class based on window focus, useful for focus indicators
|
|
857
703
|
*/
|
|
858
|
-
|
|
859
|
-
|
|
860
704
|
_windowBlur() {
|
|
861
705
|
this.root.element.addClass('lm_window_blur');
|
|
862
706
|
}
|
|
863
|
-
|
|
864
707
|
_windowFocus() {
|
|
865
708
|
this.root.element.removeClass('lm_window_blur');
|
|
866
709
|
}
|
|
710
|
+
|
|
867
711
|
/**
|
|
868
712
|
* Debounces resize events
|
|
869
713
|
*/
|
|
870
|
-
|
|
871
|
-
|
|
872
714
|
_onResize() {
|
|
873
715
|
clearTimeout(this._resizeTimeoutId);
|
|
874
716
|
this._resizeTimeoutId = window.setTimeout(this.updateSize.bind(this), 100);
|
|
875
717
|
}
|
|
718
|
+
|
|
876
719
|
/**
|
|
877
720
|
* Extends the default config with the user specific settings and applies
|
|
878
721
|
* derivations. Please note that there's a seperate method (AbstractContentItem._extendItemNode)
|
|
@@ -881,26 +724,19 @@ export default class LayoutManager extends EventEmitter {
|
|
|
881
724
|
* @param config
|
|
882
725
|
* @returns config
|
|
883
726
|
*/
|
|
884
|
-
|
|
885
|
-
|
|
886
727
|
_createConfig(config) {
|
|
887
728
|
var _config$settings;
|
|
888
|
-
|
|
889
729
|
var windowConfigKey = getQueryStringParam('gl-window');
|
|
890
|
-
|
|
891
730
|
if (windowConfigKey) {
|
|
892
731
|
this.isSubWindow = true;
|
|
893
732
|
config = JSON.parse(localStorage.getItem(windowConfigKey) || '{}');
|
|
894
733
|
config = unminifyConfig(config);
|
|
895
734
|
localStorage.removeItem(windowConfigKey);
|
|
896
735
|
}
|
|
897
|
-
|
|
898
736
|
config = $.extend(true, {}, defaultConfig, config);
|
|
899
|
-
|
|
900
737
|
var nextNode = function nextNode(node) {
|
|
901
738
|
for (var key in node) {
|
|
902
739
|
var value = node[key];
|
|
903
|
-
|
|
904
740
|
if (key !== 'props' && typeof value === 'object' && value != null) {
|
|
905
741
|
nextNode(value);
|
|
906
742
|
} else if (key === 'type' && value === 'react-component') {
|
|
@@ -909,24 +745,19 @@ export default class LayoutManager extends EventEmitter {
|
|
|
909
745
|
}
|
|
910
746
|
}
|
|
911
747
|
};
|
|
912
|
-
|
|
913
748
|
nextNode(config);
|
|
914
|
-
|
|
915
749
|
if (((_config$settings = config.settings) === null || _config$settings === void 0 ? void 0 : _config$settings.hasHeaders) === false) {
|
|
916
750
|
config.dimensions.headerHeight = 0;
|
|
917
751
|
}
|
|
918
|
-
|
|
919
752
|
return config;
|
|
920
753
|
}
|
|
754
|
+
|
|
921
755
|
/**
|
|
922
756
|
* This is executed when GoldenLayout detects that it is run
|
|
923
757
|
* within a previously opened popout window.
|
|
924
758
|
*/
|
|
925
|
-
|
|
926
|
-
|
|
927
759
|
_adjustToWindowMode() {
|
|
928
760
|
var _this$config$content$;
|
|
929
|
-
|
|
930
761
|
var popInButton = $('<div class="lm_popin" title="' + this.config.labels.popin + '">' + '<div class="lm_icon"></div>' + '<div class="lm_bg"></div>' + '</div>');
|
|
931
762
|
popInButton.click(() => {
|
|
932
763
|
this.emit('popIn');
|
|
@@ -934,11 +765,11 @@ export default class LayoutManager extends EventEmitter {
|
|
|
934
765
|
document.title = stripTags((_this$config$content$ = this.config.content[0].title) !== null && _this$config$content$ !== void 0 ? _this$config$content$ : '');
|
|
935
766
|
$('head').append($('body link, body style, template, .gl_keep'));
|
|
936
767
|
this.container = $('body').html('').css('visibility', 'visible').append(popInButton);
|
|
768
|
+
|
|
937
769
|
/*
|
|
938
770
|
* This seems a bit pointless, but actually causes a reflow/re-evaluation getting around
|
|
939
771
|
* slickgrid's "Cannot find stylesheet." bug in chrome
|
|
940
772
|
*/
|
|
941
|
-
|
|
942
773
|
var x = document.body.offsetHeight; // jshint ignore:line
|
|
943
774
|
|
|
944
775
|
/*
|
|
@@ -946,47 +777,38 @@ export default class LayoutManager extends EventEmitter {
|
|
|
946
777
|
* to allow the opening window to interact with
|
|
947
778
|
* it
|
|
948
779
|
*/
|
|
949
|
-
|
|
950
780
|
window.__glInstance = this;
|
|
951
781
|
}
|
|
782
|
+
|
|
952
783
|
/**
|
|
953
784
|
* Creates Subwindows (if there are any). Throws an error
|
|
954
785
|
* if popouts are blocked.
|
|
955
786
|
*/
|
|
956
|
-
|
|
957
|
-
|
|
958
787
|
_createSubWindows() {
|
|
959
788
|
if (!this.config.openPopouts) {
|
|
960
789
|
return;
|
|
961
790
|
}
|
|
962
|
-
|
|
963
791
|
for (var i = 0; i < this.config.openPopouts.length; i++) {
|
|
964
792
|
var popout = this.config.openPopouts[i];
|
|
965
793
|
this.createPopout(popout.content, popout.dimensions, popout.parentId, popout.indexInParent);
|
|
966
794
|
}
|
|
967
795
|
}
|
|
968
|
-
|
|
969
796
|
_getContainer() {
|
|
970
797
|
var container = this._originalContainer ? $(this._originalContainer) : $('body');
|
|
971
|
-
|
|
972
798
|
if (container.length === 0) {
|
|
973
799
|
throw new Error('GoldenLayout container not found');
|
|
974
800
|
}
|
|
975
|
-
|
|
976
801
|
if (container.length > 1) {
|
|
977
802
|
throw new Error('GoldenLayout more than one container element specified');
|
|
978
803
|
}
|
|
979
|
-
|
|
980
804
|
return container;
|
|
981
805
|
}
|
|
806
|
+
|
|
982
807
|
/**
|
|
983
808
|
* Determines what element the layout will be created in
|
|
984
809
|
*/
|
|
985
|
-
|
|
986
|
-
|
|
987
810
|
_setContainer() {
|
|
988
811
|
var container = this._getContainer();
|
|
989
|
-
|
|
990
812
|
if (container[0] === document.body) {
|
|
991
813
|
this._isFullPage = true;
|
|
992
814
|
$('html, body').css({
|
|
@@ -996,49 +818,41 @@ export default class LayoutManager extends EventEmitter {
|
|
|
996
818
|
overflow: 'hidden'
|
|
997
819
|
});
|
|
998
820
|
}
|
|
999
|
-
|
|
1000
821
|
this.container = container;
|
|
1001
822
|
}
|
|
823
|
+
|
|
1002
824
|
/**
|
|
1003
825
|
* Kicks of the initial, recursive creation chain
|
|
1004
826
|
*
|
|
1005
827
|
* @param config GoldenLayout Config
|
|
1006
828
|
*/
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
829
|
_create(config) {
|
|
1010
830
|
var errorMsg;
|
|
1011
|
-
|
|
1012
831
|
if (!(config.content instanceof Array)) {
|
|
1013
832
|
if (config.content === undefined) {
|
|
1014
833
|
errorMsg = "Missing setting 'content' on top level of configuration";
|
|
1015
834
|
} else {
|
|
1016
835
|
errorMsg = "Configuration parameter 'content' must be an array";
|
|
1017
836
|
}
|
|
1018
|
-
|
|
1019
837
|
throw new ConfigurationError(errorMsg, config);
|
|
1020
838
|
}
|
|
1021
|
-
|
|
1022
839
|
if (config.content.length > 1) {
|
|
1023
840
|
errorMsg = "Top level content can't contain more then one element.";
|
|
1024
841
|
throw new ConfigurationError(errorMsg, config);
|
|
1025
842
|
}
|
|
1026
|
-
|
|
1027
843
|
this.root = new Root(this, {
|
|
1028
844
|
content: config.content
|
|
1029
845
|
}, this.container);
|
|
1030
846
|
this.root.callDownwards('_$init');
|
|
1031
|
-
|
|
1032
847
|
if (config.maximisedItemId === '__glMaximised') {
|
|
1033
848
|
this.root.getItemsById(config.maximisedItemId)[0].toggleMaximise();
|
|
1034
849
|
}
|
|
1035
850
|
}
|
|
851
|
+
|
|
1036
852
|
/**
|
|
1037
853
|
* Called when the window is closed or the user navigates away
|
|
1038
854
|
* from the page
|
|
1039
855
|
*/
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
856
|
_onUnload() {
|
|
1043
857
|
if (this.config.settings.closePopoutsOnUnload === true) {
|
|
1044
858
|
for (var i = 0; i < this.openPopouts.length; i++) {
|
|
@@ -1046,69 +860,61 @@ export default class LayoutManager extends EventEmitter {
|
|
|
1046
860
|
}
|
|
1047
861
|
}
|
|
1048
862
|
}
|
|
863
|
+
|
|
1049
864
|
/**
|
|
1050
865
|
* Adjusts the number of columns to be lower to fit the screen and still maintain minItemWidth.
|
|
1051
866
|
*/
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
867
|
_adjustColumnsResponsive() {
|
|
1055
868
|
// If there is no min width set, or not content items, do nothing.
|
|
1056
869
|
if (!this._useResponsiveLayout() || this._updatingColumnsResponsive || !this.config.dimensions || !this.config.dimensions.minItemWidth || this.root.contentItems.length === 0 || !this.root.contentItems[0].isRow) {
|
|
1057
870
|
this._firstLoad = false;
|
|
1058
871
|
return;
|
|
1059
872
|
}
|
|
873
|
+
this._firstLoad = false;
|
|
1060
874
|
|
|
1061
|
-
|
|
1062
|
-
|
|
875
|
+
// If there is only one column, do nothing.
|
|
1063
876
|
var columnCount = this.root.contentItems[0].contentItems.length;
|
|
1064
|
-
|
|
1065
877
|
if (columnCount <= 1) {
|
|
1066
878
|
return;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
879
|
+
}
|
|
1069
880
|
|
|
881
|
+
// If they all still fit, do nothing.
|
|
1070
882
|
var minItemWidth = this.config.dimensions.minItemWidth;
|
|
1071
883
|
var totalMinWidth = columnCount * minItemWidth;
|
|
1072
|
-
|
|
1073
884
|
if (this.width == null || totalMinWidth <= this.width) {
|
|
1074
885
|
return;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
886
|
+
}
|
|
1077
887
|
|
|
1078
|
-
|
|
888
|
+
// Prevent updates while it is already happening.
|
|
889
|
+
this._updatingColumnsResponsive = true;
|
|
1079
890
|
|
|
891
|
+
// Figure out how many columns to stack, and put them all in the first stack container.
|
|
1080
892
|
var finalColumnCount = Math.max(Math.floor(this.width / minItemWidth), 1);
|
|
1081
893
|
var stackColumnCount = columnCount - finalColumnCount;
|
|
1082
894
|
var rootContentItem = this.root.contentItems[0];
|
|
1083
|
-
|
|
1084
895
|
var firstStackContainer = this._findAllStackContainers()[0];
|
|
1085
|
-
|
|
1086
896
|
for (var i = 0; i < stackColumnCount; i++) {
|
|
1087
897
|
// Stack from right.
|
|
1088
898
|
var column = rootContentItem.contentItems[rootContentItem.contentItems.length - 1];
|
|
1089
|
-
|
|
1090
899
|
this._addChildContentItemsToContainer(firstStackContainer, column);
|
|
1091
900
|
}
|
|
1092
|
-
|
|
1093
901
|
this._updatingColumnsResponsive = false;
|
|
1094
902
|
}
|
|
903
|
+
|
|
1095
904
|
/**
|
|
1096
905
|
* Determines if responsive layout should be used.
|
|
1097
906
|
*
|
|
1098
907
|
* @returns True if responsive layout should be used; otherwise false.
|
|
1099
908
|
*/
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
909
|
_useResponsiveLayout() {
|
|
1103
910
|
return this.config.settings && (this.config.settings.responsiveMode == 'always' || this.config.settings.responsiveMode == 'onload' && this._firstLoad);
|
|
1104
911
|
}
|
|
912
|
+
|
|
1105
913
|
/**
|
|
1106
914
|
* Adds all children of a node to another container recursively.
|
|
1107
915
|
* @param container - Container to add child content items to.
|
|
1108
916
|
* @param node - Node to search for content items.
|
|
1109
917
|
*/
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
918
|
_addChildContentItemsToContainer(container, node) {
|
|
1113
919
|
if (node.type === 'stack') {
|
|
1114
920
|
node.contentItems.forEach(function (item) {
|
|
@@ -1121,27 +927,23 @@ export default class LayoutManager extends EventEmitter {
|
|
|
1121
927
|
});
|
|
1122
928
|
}
|
|
1123
929
|
}
|
|
930
|
+
|
|
1124
931
|
/**
|
|
1125
932
|
* Finds all the stack containers.
|
|
1126
933
|
* @returns The found stack containers.
|
|
1127
934
|
*/
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
935
|
_findAllStackContainers() {
|
|
1131
936
|
var stackContainers = [];
|
|
1132
|
-
|
|
1133
937
|
this._findAllStackContainersRecursive(stackContainers, this.root);
|
|
1134
|
-
|
|
1135
938
|
return stackContainers;
|
|
1136
939
|
}
|
|
940
|
+
|
|
1137
941
|
/**
|
|
1138
942
|
* Finds all the stack containers.
|
|
1139
943
|
*
|
|
1140
944
|
* @param stackContainers Set of containers to populate.
|
|
1141
945
|
* @param node Current node to process.
|
|
1142
946
|
*/
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
947
|
_findAllStackContainersRecursive(stackContainers, node) {
|
|
1146
948
|
node.contentItems.forEach(item => {
|
|
1147
949
|
if (isStack(item)) {
|
|
@@ -1151,8 +953,6 @@ export default class LayoutManager extends EventEmitter {
|
|
|
1151
953
|
}
|
|
1152
954
|
});
|
|
1153
955
|
}
|
|
1154
|
-
|
|
1155
956
|
}
|
|
1156
|
-
|
|
1157
957
|
_defineProperty(LayoutManager, "__lm", lm);
|
|
1158
958
|
//# sourceMappingURL=LayoutManager.js.map
|