@deephaven/golden-layout 0.17.1-beta.2 → 0.17.1-beta.4
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 +1140 -0
- package/dist/LayoutManager.js.map +1 -0
- package/dist/base.js +16 -0
- package/dist/base.js.map +1 -0
- package/dist/config/ItemDefaultConfig.js +8 -0
- package/dist/config/ItemDefaultConfig.js.map +1 -0
- package/dist/config/defaultConfig.js +42 -0
- package/dist/config/defaultConfig.js.map +1 -0
- package/dist/config/index.js +7 -0
- package/dist/config/index.js.map +1 -0
- package/dist/container/ItemContainer.js +192 -0
- package/dist/container/ItemContainer.js.map +1 -0
- package/dist/container/index.js +5 -0
- package/dist/container/index.js.map +1 -0
- package/dist/controls/BrowserPopout.js +260 -0
- package/dist/controls/BrowserPopout.js.map +1 -0
- package/dist/controls/DragProxy.js +236 -0
- package/dist/controls/DragProxy.js.map +1 -0
- package/dist/controls/DragSource.js +60 -0
- package/dist/controls/DragSource.js.map +1 -0
- package/dist/controls/DragSourceFromEvent.js +75 -0
- package/dist/controls/DragSourceFromEvent.js.map +1 -0
- package/dist/controls/DropTargetIndicator.js +28 -0
- package/dist/controls/DropTargetIndicator.js.map +1 -0
- package/dist/controls/Header.js +698 -0
- package/dist/controls/Header.js.map +1 -0
- package/dist/controls/HeaderButton.js +23 -0
- package/dist/controls/HeaderButton.js.map +1 -0
- package/dist/controls/Splitter.js +45 -0
- package/dist/controls/Splitter.js.map +1 -0
- package/dist/controls/Tab.js +259 -0
- package/dist/controls/Tab.js.map +1 -0
- package/dist/controls/TransitionIndicator.js +64 -0
- package/dist/controls/TransitionIndicator.js.map +1 -0
- package/dist/controls/index.js +23 -0
- package/dist/controls/index.js.map +1 -0
- package/dist/errors/ConfigurationError.js +10 -0
- package/dist/errors/ConfigurationError.js.map +1 -0
- package/dist/errors/index.js +5 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/items/AbstractContentItem.js +617 -0
- package/dist/items/AbstractContentItem.js.map +1 -0
- package/dist/items/Component.js +84 -0
- package/dist/items/Component.js.map +1 -0
- package/dist/items/Root.js +93 -0
- package/dist/items/Root.js.map +1 -0
- package/dist/items/RowOrColumn.js +550 -0
- package/dist/items/RowOrColumn.js.map +1 -0
- package/dist/items/Stack.js +498 -0
- package/dist/items/Stack.js.map +1 -0
- package/dist/items/index.js +13 -0
- package/dist/items/index.js.map +1 -0
- package/dist/utils/BubblingEvent.js +12 -0
- package/dist/utils/BubblingEvent.js.map +1 -0
- package/dist/utils/ConfigMinifier.js +160 -0
- package/dist/utils/ConfigMinifier.js.map +1 -0
- package/dist/utils/DragListener.js +128 -0
- package/dist/utils/DragListener.js.map +1 -0
- package/dist/utils/EventEmitter.js +133 -0
- package/dist/utils/EventEmitter.js.map +1 -0
- package/dist/utils/EventHub.js +147 -0
- package/dist/utils/EventHub.js.map +1 -0
- package/dist/utils/ReactComponentHandler.js +135 -0
- package/dist/utils/ReactComponentHandler.js.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/utils.js +195 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +20 -47
- package/dist/goldenlayout.js +0 -6314
- package/dist/goldenlayout.min.js +0 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import utils from '../utils/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pops a content item out into a new browser window.
|
|
5
|
+
* This is achieved by
|
|
6
|
+
*
|
|
7
|
+
* - Creating a new configuration with the content item as root element
|
|
8
|
+
* - Serializing and minifying the configuration
|
|
9
|
+
* - Opening the current window's URL with the configuration as a GET parameter
|
|
10
|
+
* - GoldenLayout when opened in the new window will look for the GET parameter
|
|
11
|
+
* and use it instead of the provided configuration
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} config GoldenLayout item config
|
|
14
|
+
* @param {Object} dimensions A map with width, height, top and left
|
|
15
|
+
* @param {String} parentId The id of the element the item will be appended to on popIn
|
|
16
|
+
* @param {Number} indexInParent The position of this element within its parent
|
|
17
|
+
* @param {lm.LayoutManager} layoutManager
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
var BrowserPopout = function BrowserPopout(config, dimensions, parentId, indexInParent, layoutManager) {
|
|
21
|
+
utils.EventEmitter.call(this);
|
|
22
|
+
this.isInitialised = false;
|
|
23
|
+
this._config = config;
|
|
24
|
+
this._dimensions = dimensions;
|
|
25
|
+
this._parentId = parentId;
|
|
26
|
+
this._indexInParent = indexInParent;
|
|
27
|
+
this._layoutManager = layoutManager;
|
|
28
|
+
this._popoutWindow = null;
|
|
29
|
+
this._id = null;
|
|
30
|
+
|
|
31
|
+
this._createWindow();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
utils.copy(BrowserPopout.prototype, {
|
|
35
|
+
toConfig: function toConfig() {
|
|
36
|
+
if (this.isInitialised === false) {
|
|
37
|
+
throw new Error("Can't create config, layout not yet initialised");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
dimensions: {
|
|
43
|
+
width: this.getGlInstance().width,
|
|
44
|
+
height: this.getGlInstance().height,
|
|
45
|
+
left: this._popoutWindow.screenX || this._popoutWindow.screenLeft,
|
|
46
|
+
top: this._popoutWindow.screenY || this._popoutWindow.screenTop
|
|
47
|
+
},
|
|
48
|
+
content: this.getGlInstance().toConfig().content,
|
|
49
|
+
parentId: this._parentId,
|
|
50
|
+
indexInParent: this._indexInParent
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
getGlInstance: function getGlInstance() {
|
|
54
|
+
return this._popoutWindow.__glInstance;
|
|
55
|
+
},
|
|
56
|
+
getWindow: function getWindow() {
|
|
57
|
+
return this._popoutWindow;
|
|
58
|
+
},
|
|
59
|
+
close: function close() {
|
|
60
|
+
if (this.getGlInstance()) {
|
|
61
|
+
this.getGlInstance()._$closeWindow();
|
|
62
|
+
} else {
|
|
63
|
+
try {
|
|
64
|
+
this.getWindow().close();
|
|
65
|
+
} catch (e) {}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns the popped out item to its original position. If the original
|
|
71
|
+
* parent isn't available anymore it falls back to the layout's topmost element
|
|
72
|
+
*/
|
|
73
|
+
popIn: function popIn() {
|
|
74
|
+
var childConfig,
|
|
75
|
+
parentItem,
|
|
76
|
+
index = this._indexInParent;
|
|
77
|
+
|
|
78
|
+
if (this._parentId) {
|
|
79
|
+
/*
|
|
80
|
+
* The $.extend call seems a bit pointless, but it's crucial to
|
|
81
|
+
* copy the config returned by this.getGlInstance().toConfig()
|
|
82
|
+
* onto a new object. Internet Explorer keeps the references
|
|
83
|
+
* to objects on the child window, resulting in the following error
|
|
84
|
+
* once the child window is closed:
|
|
85
|
+
*
|
|
86
|
+
* The callee (server [not server application]) is not available and disappeared
|
|
87
|
+
*/
|
|
88
|
+
childConfig = $.extend(true, {}, this.getGlInstance().toConfig()).content[0];
|
|
89
|
+
parentItem = this._layoutManager.root.getItemsById(this._parentId)[0];
|
|
90
|
+
/*
|
|
91
|
+
* Fallback if parentItem is not available. Either add it to the topmost
|
|
92
|
+
* item or make it the topmost item if the layout is empty
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
if (!parentItem) {
|
|
96
|
+
if (this._layoutManager.root.contentItems.length > 0) {
|
|
97
|
+
parentItem = this._layoutManager.root.contentItems[0];
|
|
98
|
+
} else {
|
|
99
|
+
parentItem = this._layoutManager.root;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
index = 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
parentItem.addChild(childConfig, this._indexInParent);
|
|
107
|
+
this.close();
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Creates the URL and window parameter
|
|
112
|
+
* and opens a new window
|
|
113
|
+
*
|
|
114
|
+
* @private
|
|
115
|
+
*
|
|
116
|
+
* @returns {void}
|
|
117
|
+
*/
|
|
118
|
+
_createWindow: function _createWindow() {
|
|
119
|
+
var checkReadyInterval,
|
|
120
|
+
url = this._createUrl(),
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Bogus title to prevent re-usage of existing window with the
|
|
124
|
+
* same title. The actual title will be set by the new window's
|
|
125
|
+
* GoldenLayout instance if it detects that it is in subWindowMode
|
|
126
|
+
*/
|
|
127
|
+
title = Math.floor(Math.random() * 1000000).toString(36),
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The options as used in the window.open string
|
|
131
|
+
*/
|
|
132
|
+
options = this._serializeWindowOptions({
|
|
133
|
+
width: this._dimensions.width,
|
|
134
|
+
height: this._dimensions.height,
|
|
135
|
+
innerWidth: this._dimensions.width,
|
|
136
|
+
innerHeight: this._dimensions.height,
|
|
137
|
+
menubar: 'no',
|
|
138
|
+
toolbar: 'no',
|
|
139
|
+
location: 'no',
|
|
140
|
+
personalbar: 'no',
|
|
141
|
+
resizable: 'yes',
|
|
142
|
+
scrollbars: 'no',
|
|
143
|
+
status: 'no'
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
this._popoutWindow = window.open(url, title, options);
|
|
147
|
+
|
|
148
|
+
if (!this._popoutWindow) {
|
|
149
|
+
if (this._layoutManager.config.settings.blockedPopoutsThrowError === true) {
|
|
150
|
+
var error = new Error('Popout blocked');
|
|
151
|
+
error.type = 'popoutBlocked';
|
|
152
|
+
throw error;
|
|
153
|
+
} else {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
$(this._popoutWindow).on('load', utils.fnBind(this._positionWindow, this)).on('unload beforeunload', utils.fnBind(this._onClose, this));
|
|
159
|
+
/**
|
|
160
|
+
* Polling the childwindow to find out if GoldenLayout has been initialised
|
|
161
|
+
* doesn't seem optimal, but the alternatives - adding a callback to the parent
|
|
162
|
+
* window or raising an event on the window object - both would introduce knowledge
|
|
163
|
+
* about the parent to the child window which we'd rather avoid
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
checkReadyInterval = setInterval(utils.fnBind(function () {
|
|
167
|
+
if (this._popoutWindow.__glInstance && this._popoutWindow.__glInstance.isInitialised) {
|
|
168
|
+
this._onInitialised();
|
|
169
|
+
|
|
170
|
+
clearInterval(checkReadyInterval);
|
|
171
|
+
}
|
|
172
|
+
}, this), 10);
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Serialises a map of key:values to a window options string
|
|
177
|
+
*
|
|
178
|
+
* @param {Object} windowOptions
|
|
179
|
+
*
|
|
180
|
+
* @returns {String} serialised window options
|
|
181
|
+
*/
|
|
182
|
+
_serializeWindowOptions: function _serializeWindowOptions(windowOptions) {
|
|
183
|
+
var windowOptionsString = [],
|
|
184
|
+
key;
|
|
185
|
+
|
|
186
|
+
for (key in windowOptions) {
|
|
187
|
+
windowOptionsString.push(key + '=' + windowOptions[key]);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return windowOptionsString.join(',');
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Creates the URL for the new window, including the
|
|
195
|
+
* config GET parameter
|
|
196
|
+
*
|
|
197
|
+
* @returns {String} URL
|
|
198
|
+
*/
|
|
199
|
+
_createUrl: function _createUrl() {
|
|
200
|
+
var config = {
|
|
201
|
+
content: this._config
|
|
202
|
+
},
|
|
203
|
+
storageKey = 'gl-window-config-' + utils.getUniqueId(),
|
|
204
|
+
urlParts;
|
|
205
|
+
config = new utils.ConfigMinifier().minifyConfig(config);
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
localStorage.setItem(storageKey, JSON.stringify(config));
|
|
209
|
+
} catch (e) {
|
|
210
|
+
throw new Error('Error while writing to localStorage ' + e.toString());
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
urlParts = document.location.href.split('?'); // URL doesn't contain GET-parameters
|
|
214
|
+
|
|
215
|
+
if (urlParts.length === 1) {
|
|
216
|
+
return urlParts[0] + '?gl-window=' + storageKey; // URL contains GET-parameters
|
|
217
|
+
} else {
|
|
218
|
+
return document.location.href + '&gl-window=' + storageKey;
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Move the newly created window roughly to
|
|
224
|
+
* where the component used to be.
|
|
225
|
+
*
|
|
226
|
+
* @private
|
|
227
|
+
*
|
|
228
|
+
* @returns {void}
|
|
229
|
+
*/
|
|
230
|
+
_positionWindow: function _positionWindow() {
|
|
231
|
+
this._popoutWindow.moveTo(this._dimensions.left, this._dimensions.top);
|
|
232
|
+
|
|
233
|
+
this._popoutWindow.focus();
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Callback when the new window is opened and the GoldenLayout instance
|
|
238
|
+
* within it is initialised
|
|
239
|
+
*
|
|
240
|
+
* @returns {void}
|
|
241
|
+
*/
|
|
242
|
+
_onInitialised: function _onInitialised() {
|
|
243
|
+
this.isInitialised = true;
|
|
244
|
+
this.getGlInstance().on('popIn', this.popIn, this);
|
|
245
|
+
this.emit('initialised');
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Invoked 50ms after the window unload event
|
|
250
|
+
*
|
|
251
|
+
* @private
|
|
252
|
+
*
|
|
253
|
+
* @returns {void}
|
|
254
|
+
*/
|
|
255
|
+
_onClose: function _onClose() {
|
|
256
|
+
setTimeout(utils.fnBind(this.emit, this, ['closed']), 50);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
export default BrowserPopout;
|
|
260
|
+
//# sourceMappingURL=BrowserPopout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserPopout.js","names":["$","utils","BrowserPopout","config","dimensions","parentId","indexInParent","layoutManager","EventEmitter","call","isInitialised","_config","_dimensions","_parentId","_indexInParent","_layoutManager","_popoutWindow","_id","_createWindow","copy","prototype","toConfig","Error","width","getGlInstance","height","left","screenX","screenLeft","top","screenY","screenTop","content","__glInstance","getWindow","close","_$closeWindow","e","popIn","childConfig","parentItem","index","extend","root","getItemsById","contentItems","length","addChild","checkReadyInterval","url","_createUrl","title","Math","floor","random","toString","options","_serializeWindowOptions","innerWidth","innerHeight","menubar","toolbar","location","personalbar","resizable","scrollbars","status","window","open","settings","blockedPopoutsThrowError","error","type","on","fnBind","_positionWindow","_onClose","setInterval","_onInitialised","clearInterval","windowOptions","windowOptionsString","key","push","join","storageKey","getUniqueId","urlParts","ConfigMinifier","minifyConfig","localStorage","setItem","JSON","stringify","document","href","split","moveTo","focus","emit","setTimeout"],"sources":["../../src/controls/BrowserPopout.js"],"sourcesContent":["import $ from 'jquery';\nimport utils from '../utils/index.js';\n\n/**\n * Pops a content item out into a new browser window.\n * This is achieved by\n *\n * - Creating a new configuration with the content item as root element\n * - Serializing and minifying the configuration\n * - Opening the current window's URL with the configuration as a GET parameter\n * - GoldenLayout when opened in the new window will look for the GET parameter\n * and use it instead of the provided configuration\n *\n * @param {Object} config GoldenLayout item config\n * @param {Object} dimensions A map with width, height, top and left\n * @param {String} parentId The id of the element the item will be appended to on popIn\n * @param {Number} indexInParent The position of this element within its parent\n * @param {lm.LayoutManager} layoutManager\n */\nconst BrowserPopout = function (\n config,\n dimensions,\n parentId,\n indexInParent,\n layoutManager\n) {\n utils.EventEmitter.call(this);\n this.isInitialised = false;\n\n this._config = config;\n this._dimensions = dimensions;\n this._parentId = parentId;\n this._indexInParent = indexInParent;\n this._layoutManager = layoutManager;\n this._popoutWindow = null;\n this._id = null;\n this._createWindow();\n};\n\nutils.copy(BrowserPopout.prototype, {\n toConfig: function () {\n if (this.isInitialised === false) {\n throw new Error(\"Can't create config, layout not yet initialised\");\n return;\n }\n return {\n dimensions: {\n width: this.getGlInstance().width,\n height: this.getGlInstance().height,\n left: this._popoutWindow.screenX || this._popoutWindow.screenLeft,\n top: this._popoutWindow.screenY || this._popoutWindow.screenTop,\n },\n content: this.getGlInstance().toConfig().content,\n parentId: this._parentId,\n indexInParent: this._indexInParent,\n };\n },\n\n getGlInstance: function () {\n return this._popoutWindow.__glInstance;\n },\n\n getWindow: function () {\n return this._popoutWindow;\n },\n\n close: function () {\n if (this.getGlInstance()) {\n this.getGlInstance()._$closeWindow();\n } else {\n try {\n this.getWindow().close();\n } catch (e) {}\n }\n },\n\n /**\n * Returns the popped out item to its original position. If the original\n * parent isn't available anymore it falls back to the layout's topmost element\n */\n popIn: function () {\n var childConfig,\n parentItem,\n index = this._indexInParent;\n\n if (this._parentId) {\n /*\n * The $.extend call seems a bit pointless, but it's crucial to\n * copy the config returned by this.getGlInstance().toConfig()\n * onto a new object. Internet Explorer keeps the references\n * to objects on the child window, resulting in the following error\n * once the child window is closed:\n *\n * The callee (server [not server application]) is not available and disappeared\n */\n childConfig = $.extend(true, {}, this.getGlInstance().toConfig())\n .content[0];\n parentItem = this._layoutManager.root.getItemsById(this._parentId)[0];\n\n /*\n * Fallback if parentItem is not available. Either add it to the topmost\n * item or make it the topmost item if the layout is empty\n */\n if (!parentItem) {\n if (this._layoutManager.root.contentItems.length > 0) {\n parentItem = this._layoutManager.root.contentItems[0];\n } else {\n parentItem = this._layoutManager.root;\n }\n index = 0;\n }\n }\n\n parentItem.addChild(childConfig, this._indexInParent);\n this.close();\n },\n\n /**\n * Creates the URL and window parameter\n * and opens a new window\n *\n * @private\n *\n * @returns {void}\n */\n _createWindow: function () {\n var checkReadyInterval,\n url = this._createUrl(),\n /**\n * Bogus title to prevent re-usage of existing window with the\n * same title. The actual title will be set by the new window's\n * GoldenLayout instance if it detects that it is in subWindowMode\n */\n title = Math.floor(Math.random() * 1000000).toString(36),\n /**\n * The options as used in the window.open string\n */\n options = this._serializeWindowOptions({\n width: this._dimensions.width,\n height: this._dimensions.height,\n innerWidth: this._dimensions.width,\n innerHeight: this._dimensions.height,\n menubar: 'no',\n toolbar: 'no',\n location: 'no',\n personalbar: 'no',\n resizable: 'yes',\n scrollbars: 'no',\n status: 'no',\n });\n\n this._popoutWindow = window.open(url, title, options);\n\n if (!this._popoutWindow) {\n if (\n this._layoutManager.config.settings.blockedPopoutsThrowError === true\n ) {\n var error = new Error('Popout blocked');\n error.type = 'popoutBlocked';\n throw error;\n } else {\n return;\n }\n }\n\n $(this._popoutWindow)\n .on('load', utils.fnBind(this._positionWindow, this))\n .on('unload beforeunload', utils.fnBind(this._onClose, this));\n\n /**\n * Polling the childwindow to find out if GoldenLayout has been initialised\n * doesn't seem optimal, but the alternatives - adding a callback to the parent\n * window or raising an event on the window object - both would introduce knowledge\n * about the parent to the child window which we'd rather avoid\n */\n checkReadyInterval = setInterval(\n utils.fnBind(function () {\n if (\n this._popoutWindow.__glInstance &&\n this._popoutWindow.__glInstance.isInitialised\n ) {\n this._onInitialised();\n clearInterval(checkReadyInterval);\n }\n }, this),\n 10\n );\n },\n\n /**\n * Serialises a map of key:values to a window options string\n *\n * @param {Object} windowOptions\n *\n * @returns {String} serialised window options\n */\n _serializeWindowOptions: function (windowOptions) {\n var windowOptionsString = [],\n key;\n\n for (key in windowOptions) {\n windowOptionsString.push(key + '=' + windowOptions[key]);\n }\n\n return windowOptionsString.join(',');\n },\n\n /**\n * Creates the URL for the new window, including the\n * config GET parameter\n *\n * @returns {String} URL\n */\n _createUrl: function () {\n var config = { content: this._config },\n storageKey = 'gl-window-config-' + utils.getUniqueId(),\n urlParts;\n\n config = new utils.ConfigMinifier().minifyConfig(config);\n\n try {\n localStorage.setItem(storageKey, JSON.stringify(config));\n } catch (e) {\n throw new Error('Error while writing to localStorage ' + e.toString());\n }\n\n urlParts = document.location.href.split('?');\n\n // URL doesn't contain GET-parameters\n if (urlParts.length === 1) {\n return urlParts[0] + '?gl-window=' + storageKey;\n\n // URL contains GET-parameters\n } else {\n return document.location.href + '&gl-window=' + storageKey;\n }\n },\n\n /**\n * Move the newly created window roughly to\n * where the component used to be.\n *\n * @private\n *\n * @returns {void}\n */\n _positionWindow: function () {\n this._popoutWindow.moveTo(this._dimensions.left, this._dimensions.top);\n this._popoutWindow.focus();\n },\n\n /**\n * Callback when the new window is opened and the GoldenLayout instance\n * within it is initialised\n *\n * @returns {void}\n */\n _onInitialised: function () {\n this.isInitialised = true;\n this.getGlInstance().on('popIn', this.popIn, this);\n this.emit('initialised');\n },\n\n /**\n * Invoked 50ms after the window unload event\n *\n * @private\n *\n * @returns {void}\n */\n _onClose: function () {\n setTimeout(utils.fnBind(this.emit, this, ['closed']), 50);\n },\n});\n\nexport default BrowserPopout;\n"],"mappings":"AAAA,OAAOA,CAAP,MAAc,QAAd;AACA,OAAOC,KAAP,MAAkB,mBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CACpBC,MADoB,EAEpBC,UAFoB,EAGpBC,QAHoB,EAIpBC,aAJoB,EAKpBC,aALoB,EAMpB;EACAN,KAAK,CAACO,YAAN,CAAmBC,IAAnB,CAAwB,IAAxB;EACA,KAAKC,aAAL,GAAqB,KAArB;EAEA,KAAKC,OAAL,GAAeR,MAAf;EACA,KAAKS,WAAL,GAAmBR,UAAnB;EACA,KAAKS,SAAL,GAAiBR,QAAjB;EACA,KAAKS,cAAL,GAAsBR,aAAtB;EACA,KAAKS,cAAL,GAAsBR,aAAtB;EACA,KAAKS,aAAL,GAAqB,IAArB;EACA,KAAKC,GAAL,GAAW,IAAX;;EACA,KAAKC,aAAL;AACD,CAlBD;;AAoBAjB,KAAK,CAACkB,IAAN,CAAWjB,aAAa,CAACkB,SAAzB,EAAoC;EAClCC,QAAQ,EAAE,oBAAY;IACpB,IAAI,KAAKX,aAAL,KAAuB,KAA3B,EAAkC;MAChC,MAAM,IAAIY,KAAJ,CAAU,iDAAV,CAAN;MACA;IACD;;IACD,OAAO;MACLlB,UAAU,EAAE;QACVmB,KAAK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AAtC,EAA6C,IAA7C;IACA,KAAK6D,IAAL,CAAU,aAAV;EACD,CA9NiC;;EAgOlC;AACF;AACA;AACA;AACA;AACA;AACA;EACEvB,QAAQ,EAAE,oBAAY;IACpBwB,UAAU,CAACnG,KAAK,CAACyE,MAAN,CAAa,KAAKyB,IAAlB,EAAwB,IAAxB,EAA8B,CAAC,QAAD,CAA9B,CAAD,EAA4C,EAA5C,CAAV;EACD;AAzOiC,CAApC;AA4OA,eAAejG,aAAf"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import utils from '../utils/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* This class creates a temporary container
|
|
5
|
+
* for the component whilst it is being dragged
|
|
6
|
+
* and handles drag events
|
|
7
|
+
*
|
|
8
|
+
* @constructor
|
|
9
|
+
* @private
|
|
10
|
+
*
|
|
11
|
+
* @param {Number} x The initial x position
|
|
12
|
+
* @param {Number} y The initial y position
|
|
13
|
+
* @param {lm.utils.DragListener} dragListener
|
|
14
|
+
* @param {lm.LayoutManager} layoutManager
|
|
15
|
+
* @param {lm.item.AbstractContentItem} contentItem
|
|
16
|
+
* @param {lm.item.AbstractContentItem} originalParent
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
var DragProxy = function DragProxy(x, y, dragListener, layoutManager, contentItem, originalParent) {
|
|
20
|
+
utils.EventEmitter.call(this);
|
|
21
|
+
this._dragListener = dragListener;
|
|
22
|
+
this._layoutManager = layoutManager;
|
|
23
|
+
this._contentItem = contentItem;
|
|
24
|
+
this._originalParent = originalParent;
|
|
25
|
+
this._area = null;
|
|
26
|
+
this._lastValidArea = null;
|
|
27
|
+
|
|
28
|
+
this._dragListener.on('drag', this._onDrag, this);
|
|
29
|
+
|
|
30
|
+
this._dragListener.on('dragStop', this._onDrop, this); // set the inserted drag placeholder to be the size of the tab removed, before its removed
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if (this._contentItem.tab && this._contentItem.tab.element) {
|
|
34
|
+
this._layoutManager.tabDropPlaceholder.width(this._contentItem.tab.element.outerWidth(true));
|
|
35
|
+
|
|
36
|
+
this._layoutManager.tabDropPlaceholder.height(this._contentItem.tab.element.outerHeight(true));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.element = $(DragProxy._template);
|
|
40
|
+
|
|
41
|
+
if (originalParent && originalParent._side) {
|
|
42
|
+
this._sided = originalParent._sided;
|
|
43
|
+
this.element.addClass('lm_' + originalParent._side);
|
|
44
|
+
if (['right', 'bottom'].indexOf(originalParent._side) >= 0) this.element.find('.lm_content').after(this.element.find('.lm_header'));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.element.css({
|
|
48
|
+
left: x,
|
|
49
|
+
top: y
|
|
50
|
+
});
|
|
51
|
+
this._proxyTab = this.element.find('.lm_tab');
|
|
52
|
+
|
|
53
|
+
this._proxyTab.attr('title', utils.stripTags(this._contentItem.config.title));
|
|
54
|
+
|
|
55
|
+
this.element.find('.lm_title').html(this._contentItem.config.title);
|
|
56
|
+
this.childElementContainer = this.element.find('.lm_content');
|
|
57
|
+
this.childElementContainer.append(contentItem.element);
|
|
58
|
+
|
|
59
|
+
this._updateTree();
|
|
60
|
+
|
|
61
|
+
this._layoutManager._$calculateItemAreas();
|
|
62
|
+
|
|
63
|
+
this._setDimensions();
|
|
64
|
+
|
|
65
|
+
$(document.body).append(this.element); // there's no content tab to use yet, use the proxy tab size for placeholder sizing, after it's created
|
|
66
|
+
|
|
67
|
+
if (!this._contentItem.tab && this._proxyTab.length) {
|
|
68
|
+
this._layoutManager.tabDropPlaceholder.width(this._proxyTab.outerWidth(true));
|
|
69
|
+
|
|
70
|
+
this._layoutManager.tabDropPlaceholder.height(this._proxyTab.outerHeight(true));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var offset = this._layoutManager.container.offset();
|
|
74
|
+
|
|
75
|
+
this._minX = offset.left;
|
|
76
|
+
this._minY = offset.top;
|
|
77
|
+
this._maxX = this._layoutManager.container.width() + this._minX;
|
|
78
|
+
this._maxY = this._layoutManager.container.height() + this._minY;
|
|
79
|
+
this._width = this.element.width();
|
|
80
|
+
this._height = this.element.height();
|
|
81
|
+
|
|
82
|
+
this._setDropPosition(x, y);
|
|
83
|
+
|
|
84
|
+
this._layoutManager.emit('itemPickedUp', this._contentItem);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
DragProxy._template = '<div class="lm_dragProxy">' + '<div class="lm_header">' + '<ul class="lm_tabs">' + '<li class="lm_tab lm_active"><i class="lm_left"></i>' + '<span class="lm_title"></span>' + '<i class="lm_right"></i></li>' + '</ul>' + '</div>' + '<div class="lm_content"></div>' + '</div>';
|
|
88
|
+
utils.copy(DragProxy.prototype, {
|
|
89
|
+
/**
|
|
90
|
+
* Callback on every mouseMove event during a drag. Determines if the drag is
|
|
91
|
+
* still within the valid drag area and calls the layoutManager to highlight the
|
|
92
|
+
* current drop area
|
|
93
|
+
*
|
|
94
|
+
* @param {Number} offsetX The difference from the original x position in px
|
|
95
|
+
* @param {Number} offsetY The difference from the original y position in px
|
|
96
|
+
* @param {jQuery DOM event} event
|
|
97
|
+
*
|
|
98
|
+
* @private
|
|
99
|
+
*
|
|
100
|
+
* @returns {void}
|
|
101
|
+
*/
|
|
102
|
+
_onDrag: function _onDrag(offsetX, offsetY, event) {
|
|
103
|
+
event = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[0] : event;
|
|
104
|
+
var x = event.pageX,
|
|
105
|
+
y = event.pageY,
|
|
106
|
+
isWithinContainer = x > this._minX && x < this._maxX && y > this._minY && y < this._maxY;
|
|
107
|
+
|
|
108
|
+
if (!isWithinContainer && this._layoutManager.config.settings.constrainDragToContainer === true) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
this._setDropPosition(x, y);
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Sets the target position, highlighting the appropriate area
|
|
117
|
+
*
|
|
118
|
+
* @param {Number} x The x position in px
|
|
119
|
+
* @param {Number} y The y position in px
|
|
120
|
+
*
|
|
121
|
+
* @private
|
|
122
|
+
*
|
|
123
|
+
* @returns {void}
|
|
124
|
+
*/
|
|
125
|
+
_setDropPosition: function _setDropPosition(x, y) {
|
|
126
|
+
this.element.css({
|
|
127
|
+
left: x,
|
|
128
|
+
top: y
|
|
129
|
+
});
|
|
130
|
+
this._area = this._layoutManager._$getArea(x, y);
|
|
131
|
+
|
|
132
|
+
if (this._area !== null) {
|
|
133
|
+
this._lastValidArea = this._area;
|
|
134
|
+
|
|
135
|
+
this._area.contentItem._$highlightDropZone(x, y, this._area);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Callback when the drag has finished. Determines the drop area
|
|
141
|
+
* and adds the child to it
|
|
142
|
+
*
|
|
143
|
+
* @private
|
|
144
|
+
*
|
|
145
|
+
* @returns {void}
|
|
146
|
+
*/
|
|
147
|
+
_onDrop: function _onDrop() {
|
|
148
|
+
this._layoutManager.dropTargetIndicator.hide();
|
|
149
|
+
/*
|
|
150
|
+
* Valid drop area found
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
if (this._area !== null) {
|
|
155
|
+
this._area.contentItem._$onDrop(this._contentItem, this._area);
|
|
156
|
+
/**
|
|
157
|
+
* No valid drop area available at present, but one has been found before.
|
|
158
|
+
* Use it
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
} else if (this._lastValidArea !== null) {
|
|
162
|
+
this._lastValidArea.contentItem._$onDrop(this._contentItem, this._lastValidArea);
|
|
163
|
+
/**
|
|
164
|
+
* No valid drop area found during the duration of the drag. Return
|
|
165
|
+
* content item to its original position if a original parent is provided.
|
|
166
|
+
* (Which is not the case if the drag had been initiated by createDragSource)
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
} else if (this._originalParent) {
|
|
170
|
+
this._originalParent.addChild(this._contentItem);
|
|
171
|
+
/**
|
|
172
|
+
* The drag didn't ultimately end up with adding the content item to
|
|
173
|
+
* any container. In order to ensure clean up happens, destroy the
|
|
174
|
+
* content item.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
} else {
|
|
178
|
+
this._contentItem._$destroy();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this._dragListener.off('drag', this._onDrag, this);
|
|
182
|
+
|
|
183
|
+
this._dragListener.off('dragStop', this._onDrop, this);
|
|
184
|
+
|
|
185
|
+
this.element.remove();
|
|
186
|
+
|
|
187
|
+
this._layoutManager.emit('itemDropped', this._contentItem);
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Removes the item from its original position within the tree
|
|
192
|
+
*
|
|
193
|
+
* @private
|
|
194
|
+
*
|
|
195
|
+
* @returns {void}
|
|
196
|
+
*/
|
|
197
|
+
_updateTree: function _updateTree() {
|
|
198
|
+
/**
|
|
199
|
+
* parent is null if the drag had been initiated by a external drag source
|
|
200
|
+
*/
|
|
201
|
+
if (this._contentItem.parent) {
|
|
202
|
+
this._contentItem.parent.removeChild(this._contentItem, true);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this._contentItem._$setParent(this);
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Updates the Drag Proxie's dimensions
|
|
210
|
+
*
|
|
211
|
+
* @private
|
|
212
|
+
*
|
|
213
|
+
* @returns {void}
|
|
214
|
+
*/
|
|
215
|
+
_setDimensions: function _setDimensions() {
|
|
216
|
+
var dimensions = this._layoutManager.config.dimensions,
|
|
217
|
+
width = dimensions.dragProxyWidth,
|
|
218
|
+
height = dimensions.dragProxyHeight;
|
|
219
|
+
this.element.width(width);
|
|
220
|
+
this.element.height(height);
|
|
221
|
+
width -= this._sided ? dimensions.headerHeight : 0;
|
|
222
|
+
height -= !this._sided ? dimensions.headerHeight : 0;
|
|
223
|
+
this.childElementContainer.width(width);
|
|
224
|
+
this.childElementContainer.height(height);
|
|
225
|
+
|
|
226
|
+
this._contentItem.element.width(width);
|
|
227
|
+
|
|
228
|
+
this._contentItem.element.height(height);
|
|
229
|
+
|
|
230
|
+
this._contentItem.callDownwards('_$show');
|
|
231
|
+
|
|
232
|
+
this._contentItem.callDownwards('setSize');
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
export default DragProxy;
|
|
236
|
+
//# sourceMappingURL=DragProxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragProxy.js","names":["$","utils","DragProxy","x","y","dragListener","layoutManager","contentItem","originalParent","EventEmitter","call","_dragListener","_layoutManager","_contentItem","_originalParent","_area","_lastValidArea","on","_onDrag","_onDrop","tab","element","tabDropPlaceholder","width","outerWidth","height","outerHeight","_template","_side","_sided","addClass","indexOf","find","after","css","left","top","_proxyTab","attr","stripTags","config","title","html","childElementContainer","append","_updateTree","_$calculateItemAreas","_setDimensions","document","body","length","offset","container","_minX","_minY","_maxX","_maxY","_width","_height","_setDropPosition","emit","copy","prototype","offsetX","offsetY","event","originalEvent","touches","pageX","pageY","isWithinContainer","settings","constrainDragToContainer","_$getArea","_$highlightDropZone","dropTargetIndicator","hide","_$onDrop","addChild","_$destroy","off","remove","parent","removeChild","_$setParent","dimensions","dragProxyWidth","dragProxyHeight","headerHeight","callDownwards"],"sources":["../../src/controls/DragProxy.js"],"sourcesContent":["import $ from 'jquery';\nimport utils from '../utils/index.js';\n\n/**\n * This class creates a temporary container\n * for the component whilst it is being dragged\n * and handles drag events\n *\n * @constructor\n * @private\n *\n * @param {Number} x The initial x position\n * @param {Number} y The initial y position\n * @param {lm.utils.DragListener} dragListener\n * @param {lm.LayoutManager} layoutManager\n * @param {lm.item.AbstractContentItem} contentItem\n * @param {lm.item.AbstractContentItem} originalParent\n */\nconst DragProxy = function (\n x,\n y,\n dragListener,\n layoutManager,\n contentItem,\n originalParent\n) {\n utils.EventEmitter.call(this);\n\n this._dragListener = dragListener;\n this._layoutManager = layoutManager;\n this._contentItem = contentItem;\n this._originalParent = originalParent;\n\n this._area = null;\n this._lastValidArea = null;\n\n this._dragListener.on('drag', this._onDrag, this);\n this._dragListener.on('dragStop', this._onDrop, this);\n\n // set the inserted drag placeholder to be the size of the tab removed, before its removed\n if (this._contentItem.tab && this._contentItem.tab.element) {\n this._layoutManager.tabDropPlaceholder.width(\n this._contentItem.tab.element.outerWidth(true)\n );\n this._layoutManager.tabDropPlaceholder.height(\n this._contentItem.tab.element.outerHeight(true)\n );\n }\n\n this.element = $(DragProxy._template);\n if (originalParent && originalParent._side) {\n this._sided = originalParent._sided;\n this.element.addClass('lm_' + originalParent._side);\n if (['right', 'bottom'].indexOf(originalParent._side) >= 0)\n this.element.find('.lm_content').after(this.element.find('.lm_header'));\n }\n this.element.css({ left: x, top: y });\n this._proxyTab = this.element.find('.lm_tab');\n this._proxyTab.attr('title', utils.stripTags(this._contentItem.config.title));\n this.element.find('.lm_title').html(this._contentItem.config.title);\n this.childElementContainer = this.element.find('.lm_content');\n this.childElementContainer.append(contentItem.element);\n\n this._updateTree();\n this._layoutManager._$calculateItemAreas();\n this._setDimensions();\n\n $(document.body).append(this.element);\n\n // there's no content tab to use yet, use the proxy tab size for placeholder sizing, after it's created\n if (!this._contentItem.tab && this._proxyTab.length) {\n this._layoutManager.tabDropPlaceholder.width(\n this._proxyTab.outerWidth(true)\n );\n this._layoutManager.tabDropPlaceholder.height(\n this._proxyTab.outerHeight(true)\n );\n }\n\n var offset = this._layoutManager.container.offset();\n\n this._minX = offset.left;\n this._minY = offset.top;\n this._maxX = this._layoutManager.container.width() + this._minX;\n this._maxY = this._layoutManager.container.height() + this._minY;\n this._width = this.element.width();\n this._height = this.element.height();\n\n this._setDropPosition(x, y);\n\n this._layoutManager.emit('itemPickedUp', this._contentItem);\n};\n\nDragProxy._template =\n '<div class=\"lm_dragProxy\">' +\n '<div class=\"lm_header\">' +\n '<ul class=\"lm_tabs\">' +\n '<li class=\"lm_tab lm_active\"><i class=\"lm_left\"></i>' +\n '<span class=\"lm_title\"></span>' +\n '<i class=\"lm_right\"></i></li>' +\n '</ul>' +\n '</div>' +\n '<div class=\"lm_content\"></div>' +\n '</div>';\n\nutils.copy(DragProxy.prototype, {\n /**\n * Callback on every mouseMove event during a drag. Determines if the drag is\n * still within the valid drag area and calls the layoutManager to highlight the\n * current drop area\n *\n * @param {Number} offsetX The difference from the original x position in px\n * @param {Number} offsetY The difference from the original y position in px\n * @param {jQuery DOM event} event\n *\n * @private\n *\n * @returns {void}\n */\n _onDrag: function (offsetX, offsetY, event) {\n event =\n event.originalEvent && event.originalEvent.touches\n ? event.originalEvent.touches[0]\n : event;\n\n var x = event.pageX,\n y = event.pageY,\n isWithinContainer =\n x > this._minX && x < this._maxX && y > this._minY && y < this._maxY;\n\n if (\n !isWithinContainer &&\n this._layoutManager.config.settings.constrainDragToContainer === true\n ) {\n return;\n }\n\n this._setDropPosition(x, y);\n },\n\n /**\n * Sets the target position, highlighting the appropriate area\n *\n * @param {Number} x The x position in px\n * @param {Number} y The y position in px\n *\n * @private\n *\n * @returns {void}\n */\n _setDropPosition: function (x, y) {\n this.element.css({ left: x, top: y });\n this._area = this._layoutManager._$getArea(x, y);\n\n if (this._area !== null) {\n this._lastValidArea = this._area;\n this._area.contentItem._$highlightDropZone(x, y, this._area);\n }\n },\n\n /**\n * Callback when the drag has finished. Determines the drop area\n * and adds the child to it\n *\n * @private\n *\n * @returns {void}\n */\n _onDrop: function () {\n this._layoutManager.dropTargetIndicator.hide();\n\n /*\n * Valid drop area found\n */\n if (this._area !== null) {\n this._area.contentItem._$onDrop(this._contentItem, this._area);\n\n /**\n * No valid drop area available at present, but one has been found before.\n * Use it\n */\n } else if (this._lastValidArea !== null) {\n this._lastValidArea.contentItem._$onDrop(\n this._contentItem,\n this._lastValidArea\n );\n\n /**\n * No valid drop area found during the duration of the drag. Return\n * content item to its original position if a original parent is provided.\n * (Which is not the case if the drag had been initiated by createDragSource)\n */\n } else if (this._originalParent) {\n this._originalParent.addChild(this._contentItem);\n\n /**\n * The drag didn't ultimately end up with adding the content item to\n * any container. In order to ensure clean up happens, destroy the\n * content item.\n */\n } else {\n this._contentItem._$destroy();\n }\n\n this._dragListener.off('drag', this._onDrag, this);\n this._dragListener.off('dragStop', this._onDrop, this);\n\n this.element.remove();\n\n this._layoutManager.emit('itemDropped', this._contentItem);\n },\n\n /**\n * Removes the item from its original position within the tree\n *\n * @private\n *\n * @returns {void}\n */\n _updateTree: function () {\n /**\n * parent is null if the drag had been initiated by a external drag source\n */\n if (this._contentItem.parent) {\n this._contentItem.parent.removeChild(this._contentItem, true);\n }\n\n this._contentItem._$setParent(this);\n },\n\n /**\n * Updates the Drag Proxie's dimensions\n *\n * @private\n *\n * @returns {void}\n */\n _setDimensions: function () {\n var dimensions = this._layoutManager.config.dimensions,\n width = dimensions.dragProxyWidth,\n height = dimensions.dragProxyHeight;\n\n this.element.width(width);\n this.element.height(height);\n width -= this._sided ? dimensions.headerHeight : 0;\n height -= !this._sided ? dimensions.headerHeight : 0;\n this.childElementContainer.width(width);\n this.childElementContainer.height(height);\n this._contentItem.element.width(width);\n this._contentItem.element.height(height);\n this._contentItem.callDownwards('_$show');\n this._contentItem.callDownwards('setSize');\n },\n});\n\nexport default DragProxy;\n"],"mappings":"AAAA,OAAOA,CAAP,MAAc,QAAd;AACA,OAAOC,KAAP,MAAkB,mBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAChBC,CADgB,EAEhBC,CAFgB,EAGhBC,YAHgB,EAIhBC,aAJgB,EAKhBC,WALgB,EAMhBC,cANgB,EAOhB;EACAP,KAAK,CAACQ,YAAN,CAAmBC,IAAnB,CAAwB,IAAxB;EAEA,KAAKC,aAAL,GAAqBN,YAArB;EACA,KAAKO,cAAL,GAAsBN,aAAtB;EACA,KAAKO,YAAL,GAAoBN,WAApB;EACA,KAAKO,eAAL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,OAAlB,CAA0BI,MAA1B,CAAiCA,MAAjC;;IACA,KAAKZ,YAAL,CAAkB4E,aAAlB,CAAgC,QAAhC;;IACA,KAAK5E,YAAL,CAAkB4E,aAAlB,CAAgC,SAAhC;EACD;AAnJ6B,CAAhC;AAsJA,eAAevF,SAAf"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import utils from '../utils/index.js';
|
|
3
|
+
import DragProxy from './DragProxy.js';
|
|
4
|
+
/**
|
|
5
|
+
* Allows for any DOM item to create a component on drag
|
|
6
|
+
* start tobe dragged into the Layout
|
|
7
|
+
*
|
|
8
|
+
* @param {jQuery element} element
|
|
9
|
+
* @param {Object} itemConfig the configuration for the contentItem that will be created
|
|
10
|
+
* @param {LayoutManager} layoutManager
|
|
11
|
+
*
|
|
12
|
+
* @constructor
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
var DragSource = function DragSource(element, itemConfig, layoutManager) {
|
|
16
|
+
this._element = element;
|
|
17
|
+
this._itemConfig = itemConfig;
|
|
18
|
+
this._layoutManager = layoutManager;
|
|
19
|
+
this._dragListener = null;
|
|
20
|
+
|
|
21
|
+
this._createDragListener();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
utils.copy(DragSource.prototype, {
|
|
25
|
+
/**
|
|
26
|
+
* Called initially and after every drag
|
|
27
|
+
*
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
_createDragListener: function _createDragListener() {
|
|
31
|
+
this._dragListener = new utils.DragListener(this._element, true);
|
|
32
|
+
|
|
33
|
+
this._dragListener.on('dragStart', this._onDragStart, this);
|
|
34
|
+
|
|
35
|
+
this._dragListener.on('dragStop', this._createDragListener, this);
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Callback for the DragListener's dragStart event
|
|
40
|
+
*
|
|
41
|
+
* @param {int} x the x position of the mouse on dragStart
|
|
42
|
+
* @param {int} y the x position of the mouse on dragStart
|
|
43
|
+
*
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
_onDragStart: function _onDragStart(x, y) {
|
|
47
|
+
var itemConfig = this._itemConfig;
|
|
48
|
+
|
|
49
|
+
if (utils.isFunction(itemConfig)) {
|
|
50
|
+
itemConfig = itemConfig();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var contentItem = this._layoutManager._$normalizeContentItem($.extend(true, {}, itemConfig)),
|
|
54
|
+
dragProxy = new DragProxy(x, y, this._dragListener, this._layoutManager, contentItem, null);
|
|
55
|
+
|
|
56
|
+
this._layoutManager.transitionIndicator.transitionElements(this._element, dragProxy.element);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
export default DragSource;
|
|
60
|
+
//# sourceMappingURL=DragSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragSource.js","names":["$","utils","DragProxy","DragSource","element","itemConfig","layoutManager","_element","_itemConfig","_layoutManager","_dragListener","_createDragListener","copy","prototype","DragListener","on","_onDragStart","x","y","isFunction","contentItem","_$normalizeContentItem","extend","dragProxy","transitionIndicator","transitionElements"],"sources":["../../src/controls/DragSource.js"],"sourcesContent":["import $ from 'jquery';\nimport utils from '../utils/index.js';\nimport DragProxy from './DragProxy.js';\n\n/**\n * Allows for any DOM item to create a component on drag\n * start tobe dragged into the Layout\n *\n * @param {jQuery element} element\n * @param {Object} itemConfig the configuration for the contentItem that will be created\n * @param {LayoutManager} layoutManager\n *\n * @constructor\n */\nconst DragSource = function (element, itemConfig, layoutManager) {\n this._element = element;\n this._itemConfig = itemConfig;\n this._layoutManager = layoutManager;\n this._dragListener = null;\n\n this._createDragListener();\n};\n\nutils.copy(DragSource.prototype, {\n /**\n * Called initially and after every drag\n *\n * @returns {void}\n */\n _createDragListener: function () {\n this._dragListener = new utils.DragListener(this._element, true);\n this._dragListener.on('dragStart', this._onDragStart, this);\n this._dragListener.on('dragStop', this._createDragListener, this);\n },\n\n /**\n * Callback for the DragListener's dragStart event\n *\n * @param {int} x the x position of the mouse on dragStart\n * @param {int} y the x position of the mouse on dragStart\n *\n * @returns {void}\n */\n _onDragStart: function (x, y) {\n var itemConfig = this._itemConfig;\n if (utils.isFunction(itemConfig)) {\n itemConfig = itemConfig();\n }\n var contentItem = this._layoutManager._$normalizeContentItem(\n $.extend(true, {}, itemConfig)\n ),\n dragProxy = new DragProxy(\n x,\n y,\n this._dragListener,\n this._layoutManager,\n contentItem,\n null\n );\n\n this._layoutManager.transitionIndicator.transitionElements(\n this._element,\n dragProxy.element\n );\n },\n});\n\nexport default DragSource;\n"],"mappings":"AAAA,OAAOA,CAAP,MAAc,QAAd;AACA,OAAOC,KAAP,MAAkB,mBAAlB;AACA,OAAOC,SAAP,MAAsB,gBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAUC,OAAV,EAAmBC,UAAnB,EAA+BC,aAA/B,EAA8C;EAC/D,KAAKC,QAAL,GAAgBH,OAAhB;EACA,KAAKI,WAAL,GAAmBH,UAAnB;EACA,KAAKI,cAAL,GAAsBH,aAAtB;EACA,KAAKI,aAAL,GAAqB,IAArB;;EAEA,KAAKC,mBAAL;AACD,CAPD;;AASAV,KAAK,CAACW,IAAN,CAAWT,UAAU,CAACU,SAAtB,EAAiC;EAC/B;AACF;AACA;AACA;AACA;EACEF,mBAAmB,EAAE,+BAAY;IAC/B,KAAKD,aAAL,GAAqB,IAAIT,KAAK,CAACa,YAAV,CAAuB,KAAKP,QAA5B,EAAsC,IAAtC,CAArB;;IACA,KAAKG,aAAL,CAAmBK,EAAnB,CAAsB,WAAtB,EAAmC,KAAKC,YAAxC,EAAsD,IAAtD;;IACA,KAAKN,aAAL,CAAmBK,EAAnB,CAAsB,UAAtB,EAAkC,KAAKJ,mBAAvC,EAA4D,IAA5D;EACD,CAV8B;;EAY/B;AACF;AACA;AACA;AACA;AACA;AACA;A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