@syncfusion/ej2-layouts 20.2.46 → 20.3.48
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/CHANGELOG.md +8 -0
- package/dist/ej2-layouts.min.js +10 -0
- package/dist/ej2-layouts.umd.min.js +2 -2
- package/dist/ej2-layouts.umd.min.js.map +1 -1
- package/dist/es6/ej2-layouts.es2015.js +1 -1
- package/dist/es6/ej2-layouts.es2015.js.map +1 -1
- package/dist/es6/ej2-layouts.es5.js +3 -2
- package/dist/es6/ej2-layouts.es5.js.map +1 -1
- package/dist/global/ej2-layouts.min.js +2 -2
- package/dist/global/ej2-layouts.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/dashboard-layout/dashboard-layout.ts +3329 -0
- package/dist/ts/splitter/splitter.ts +2711 -0
- package/package.json +7 -7
- package/src/dashboard-layout/dashboard-layout.js +0 -1
- package/src/splitter/splitter.d.ts +1 -0
- package/src/splitter/splitter.js +3 -1
- package/styles/avatar/_bootstrap-dark-definition.scss +0 -1
- package/styles/avatar/_fabric-dark-definition.scss +0 -1
- package/styles/avatar/_highcontrast-light-definition.scss +0 -1
- package/styles/avatar/_material-dark-definition.scss +0 -1
- package/styles/avatar/_theme.scss +1 -0
- package/styles/bootstrap-dark.css +11 -9
- package/styles/bootstrap.css +11 -9
- package/styles/bootstrap4.css +11 -9
- package/styles/bootstrap5-dark.css +11 -9
- package/styles/bootstrap5.css +11 -9
- package/styles/card/_all.scss +1 -1
- package/styles/card/_bootstrap-dark-definition.scss +6 -9
- package/styles/card/_bootstrap-definition.scss +2 -4
- package/styles/card/_bootstrap4-definition.scss +2 -4
- package/styles/card/_bootstrap5-definition.scss +8 -2
- package/styles/card/_fabric-dark-definition.scss +6 -9
- package/styles/card/_fabric-definition.scss +2 -4
- package/styles/card/_fluent-definition.scss +8 -2
- package/styles/card/_fusionnew-definition.scss +8 -2
- package/styles/card/_highcontrast-definition.scss +2 -4
- package/styles/card/_highcontrast-light-definition.scss +6 -9
- package/styles/card/_layout.scss +7 -8
- package/styles/card/_material-dark-definition.scss +7 -8
- package/styles/card/_material-definition.scss +4 -5
- package/styles/card/_material3-definition.scss +8 -2
- package/styles/card/_tailwind-definition.scss +7 -2
- package/styles/card/_theme.scss +3 -3
- package/styles/card/bootstrap-dark.css +5 -4
- package/styles/card/bootstrap.css +5 -4
- package/styles/card/bootstrap4.css +5 -4
- package/styles/card/bootstrap5-dark.css +5 -4
- package/styles/card/bootstrap5.css +5 -4
- package/styles/card/fabric-dark.css +5 -4
- package/styles/card/fabric.css +5 -4
- package/styles/card/fluent-dark.css +5 -4
- package/styles/card/fluent.css +5 -4
- package/styles/card/highcontrast-light.css +5 -4
- package/styles/card/highcontrast.css +5 -4
- package/styles/card/material-dark.css +5 -4
- package/styles/card/material.css +5 -4
- package/styles/card/tailwind-dark.css +3 -6
- package/styles/card/tailwind.css +3 -6
- package/styles/dashboard-layout/_bootstrap-dark-definition.scss +1 -3
- package/styles/dashboard-layout/_bootstrap-definition.scss +1 -3
- package/styles/dashboard-layout/_bootstrap4-definition.scss +2 -3
- package/styles/dashboard-layout/_bootstrap5-definition.scss +1 -2
- package/styles/dashboard-layout/_fabric-dark-definition.scss +1 -3
- package/styles/dashboard-layout/_fabric-definition.scss +1 -3
- package/styles/dashboard-layout/_fluent-definition.scss +1 -2
- package/styles/dashboard-layout/_fusionnew-definition.scss +1 -2
- package/styles/dashboard-layout/_highcontrast-definition.scss +1 -3
- package/styles/dashboard-layout/_highcontrast-light-definition.scss +1 -3
- package/styles/dashboard-layout/_layout.scss +0 -5
- package/styles/dashboard-layout/_material-dark-definition.scss +1 -3
- package/styles/dashboard-layout/_material-definition.scss +1 -3
- package/styles/dashboard-layout/_material3-definition.scss +1 -2
- package/styles/dashboard-layout/_tailwind-definition.scss +1 -2
- package/styles/dashboard-layout/bootstrap-dark.css +1 -0
- package/styles/dashboard-layout/bootstrap.css +1 -0
- package/styles/dashboard-layout/bootstrap4.css +1 -0
- package/styles/dashboard-layout/bootstrap5-dark.css +1 -0
- package/styles/dashboard-layout/bootstrap5.css +1 -0
- package/styles/dashboard-layout/fabric-dark.css +1 -0
- package/styles/dashboard-layout/fabric.css +1 -0
- package/styles/dashboard-layout/fluent-dark.css +1 -0
- package/styles/dashboard-layout/fluent.css +1 -0
- package/styles/dashboard-layout/highcontrast-light.css +1 -0
- package/styles/dashboard-layout/highcontrast.css +1 -0
- package/styles/dashboard-layout/icons/_bootstrap-dark.scss +0 -1
- package/styles/dashboard-layout/icons/_bootstrap.scss +0 -1
- package/styles/dashboard-layout/icons/_bootstrap4.scss +0 -1
- package/styles/dashboard-layout/icons/_bootstrap5.scss +0 -1
- package/styles/dashboard-layout/icons/_fabric-dark.scss +0 -2
- package/styles/dashboard-layout/icons/_fabric.scss +0 -2
- package/styles/dashboard-layout/icons/_fluent.scss +0 -1
- package/styles/dashboard-layout/icons/_fusionnew.scss +0 -1
- package/styles/dashboard-layout/icons/_highcontrast.scss +0 -1
- package/styles/dashboard-layout/icons/_material-dark.scss +0 -1
- package/styles/dashboard-layout/icons/_material.scss +0 -1
- package/styles/dashboard-layout/icons/_material3.scss +0 -1
- package/styles/dashboard-layout/icons/_tailwind-dark.scss +0 -1
- package/styles/dashboard-layout/icons/_tailwind.scss +0 -1
- package/styles/dashboard-layout/material-dark.css +1 -0
- package/styles/dashboard-layout/material.css +1 -0
- package/styles/dashboard-layout/tailwind-dark.css +1 -0
- package/styles/dashboard-layout/tailwind.css +1 -0
- package/styles/fabric-dark.css +11 -9
- package/styles/fabric.css +11 -9
- package/styles/fluent-dark.css +11 -9
- package/styles/fluent.css +11 -9
- package/styles/highcontrast-light.css +11 -9
- package/styles/highcontrast.css +11 -9
- package/styles/material-dark.css +11 -9
- package/styles/material.css +11 -9
- package/styles/splitter/_all.scss +1 -1
- package/styles/splitter/_bootstrap-dark-definition.scss +1 -0
- package/styles/splitter/_bootstrap-definition.scss +1 -0
- package/styles/splitter/_bootstrap4-definition.scss +1 -0
- package/styles/splitter/_bootstrap5-definition.scss +4 -1
- package/styles/splitter/_definition.scss +1 -0
- package/styles/splitter/_fabric-dark-definition.scss +1 -0
- package/styles/splitter/_fabric-definition.scss +1 -0
- package/styles/splitter/_fluent-definition.scss +2 -0
- package/styles/splitter/_fusionnew-definition.scss +4 -1
- package/styles/splitter/_highcontrast-definition.scss +1 -0
- package/styles/splitter/_highcontrast-light-definition.scss +1 -0
- package/styles/splitter/_layout.scss +8 -9
- package/styles/splitter/_material-dark-definition.scss +1 -0
- package/styles/splitter/_material-definition.scss +1 -0
- package/styles/splitter/_material3-definition.scss +4 -1
- package/styles/splitter/_responsive.scss +1 -0
- package/styles/splitter/_tailwind-definition.scss +4 -1
- package/styles/splitter/_theme.scss +2 -2
- package/styles/splitter/bootstrap-dark.css +7 -5
- package/styles/splitter/bootstrap.css +7 -5
- package/styles/splitter/bootstrap4.css +7 -5
- package/styles/splitter/bootstrap5-dark.css +7 -5
- package/styles/splitter/bootstrap5.css +7 -5
- package/styles/splitter/fabric-dark.css +7 -5
- package/styles/splitter/fabric.css +7 -5
- package/styles/splitter/fluent-dark.css +7 -5
- package/styles/splitter/fluent.css +7 -5
- package/styles/splitter/highcontrast-light.css +7 -5
- package/styles/splitter/highcontrast.css +7 -5
- package/styles/splitter/material-dark.css +7 -5
- package/styles/splitter/material.css +7 -5
- package/styles/splitter/tailwind-dark.css +7 -5
- package/styles/splitter/tailwind.css +7 -5
- package/styles/tailwind-dark.css +9 -11
- package/styles/tailwind.css +9 -11
@@ -0,0 +1,3329 @@
|
|
1
|
+
import { Component, Property, NotifyPropertyChanges, INotifyPropertyChanged, isUndefined } from '@syncfusion/ej2-base';
|
2
|
+
import { Collection, Draggable, isNullOrUndefined, DragEventArgs, append, setValue } from '@syncfusion/ej2-base';
|
3
|
+
import { EmitType, Event, formatUnit, ChildProperty, compile, closest, SanitizeHtmlHelper, getValue } from '@syncfusion/ej2-base';
|
4
|
+
import { setStyleAttribute as setStyle, addClass, detach, removeClass, EventHandler, Browser, extend } from '@syncfusion/ej2-base';
|
5
|
+
import { DashboardLayoutModel, PanelModel } from './dashboard-layout-model';
|
6
|
+
|
7
|
+
|
8
|
+
// constant class definitions
|
9
|
+
const preventSelect: string = 'e-prevent';
|
10
|
+
const dragging: string = 'e-dragging';
|
11
|
+
const draggable: string = 'e-draggable';
|
12
|
+
const dragRestrict: string = 'e-drag-restrict';
|
13
|
+
const drag: string = 'e-drag';
|
14
|
+
const resize: string = 'e-resize';
|
15
|
+
const resizeicon: string = 'e-dl-icon';
|
16
|
+
const responsive: string = 'e-responsive';
|
17
|
+
const east: string = 'e-east';
|
18
|
+
const west: string = 'e-west';
|
19
|
+
const north: string = 'e-north';
|
20
|
+
const south: string = 'e-south';
|
21
|
+
const single: string = 'e-single';
|
22
|
+
const double: string = 'e-double';
|
23
|
+
const northEast: string = 'e-north-east';
|
24
|
+
const southEast: string = 'e-south-east';
|
25
|
+
const northWest: string = 'e-north-west';
|
26
|
+
const southWest: string = 'e-south-west';
|
27
|
+
const panel: string = 'e-panel';
|
28
|
+
const panelContent: string = 'e-panel-content';
|
29
|
+
const panelContainer: string = 'e-panel-container';
|
30
|
+
const disable: string = 'e-disabled';
|
31
|
+
const header: string = 'e-panel-header';
|
32
|
+
const panelTransition: string = 'e-panel-transition';
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Defines the panel of the DashboardLayout component.
|
36
|
+
*/
|
37
|
+
export class Panel extends ChildProperty<Panel> {
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Defines the id of the panel.
|
41
|
+
*
|
42
|
+
* @default ''
|
43
|
+
*/
|
44
|
+
@Property('')
|
45
|
+
public id: string;
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Defines the CSS class name that can be appended with each panel element.
|
49
|
+
*
|
50
|
+
* @default ''
|
51
|
+
*/
|
52
|
+
@Property('')
|
53
|
+
public cssClass: string;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Defines the template value that should be displayed as the panel's header.
|
57
|
+
*
|
58
|
+
*/
|
59
|
+
@Property('')
|
60
|
+
public header: string | HTMLElement;
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Defines the template value that should be displayed as the panel's content.
|
64
|
+
*
|
65
|
+
*/
|
66
|
+
|
67
|
+
@Property('')
|
68
|
+
public content: string | HTMLElement;
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Defines whether to the panel should be enabled or not.
|
72
|
+
*
|
73
|
+
* @default true
|
74
|
+
*/
|
75
|
+
@Property(true)
|
76
|
+
public enabled: boolean;
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Defines a row value where the panel should be placed.
|
80
|
+
*
|
81
|
+
* @default 0
|
82
|
+
* @aspType int
|
83
|
+
*/
|
84
|
+
@Property(0)
|
85
|
+
public row: number;
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Defines the column value where the panel to be placed.
|
89
|
+
*
|
90
|
+
* @default 0
|
91
|
+
* @aspType int
|
92
|
+
*/
|
93
|
+
@Property(0)
|
94
|
+
public col: number;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Specifies the width of the panel in the layout in cells count.
|
98
|
+
*
|
99
|
+
* @default 1
|
100
|
+
*/
|
101
|
+
@Property(1)
|
102
|
+
public sizeX: number;
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Specifies the height of the panel in the layout in cells count.
|
106
|
+
*
|
107
|
+
* @default 1
|
108
|
+
*/
|
109
|
+
@Property(1)
|
110
|
+
public sizeY: number;
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Specifies the minimum height of the panel in cells count.
|
114
|
+
*
|
115
|
+
* @default 1
|
116
|
+
*/
|
117
|
+
@Property(1)
|
118
|
+
public minSizeY: number;
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Specifies the minimum width of the panel in cells count.
|
122
|
+
*
|
123
|
+
* @default 1
|
124
|
+
*/
|
125
|
+
@Property(1)
|
126
|
+
public minSizeX: number;
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Specifies the maximum height of the panel in cells count.
|
130
|
+
*
|
131
|
+
* @default null
|
132
|
+
* @aspType int
|
133
|
+
*
|
134
|
+
*/
|
135
|
+
@Property(null)
|
136
|
+
public maxSizeY: number;
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Specifies the maximum width of the panel in cells count.
|
140
|
+
*
|
141
|
+
* @default null
|
142
|
+
* @aspType int
|
143
|
+
*/
|
144
|
+
@Property(null)
|
145
|
+
public maxSizeX: number;
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Specifies the z-index of the panel
|
149
|
+
*
|
150
|
+
* @default 1000
|
151
|
+
* @aspType double
|
152
|
+
*/
|
153
|
+
@Property(1000)
|
154
|
+
public zIndex: number;
|
155
|
+
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* The DashboardLayout is a grid structured layout control, that helps to create a dashboard with panels.
|
161
|
+
* Panels hold the UI components or data to be visualized with flexible options like resize, reorder, drag-n-drop, remove and add,
|
162
|
+
* that allows users to easily place the panels at a desired position within the grid layout.
|
163
|
+
* ```html
|
164
|
+
* <div id="default-layout">
|
165
|
+
* ```
|
166
|
+
* ```typescript
|
167
|
+
* <script>
|
168
|
+
* let dashBoardObject : DashboardLayout = new DashboardLayout();
|
169
|
+
* dashBoardObject.appendTo('#default-layout');
|
170
|
+
* </script>
|
171
|
+
* ```
|
172
|
+
*/
|
173
|
+
|
174
|
+
|
175
|
+
@NotifyPropertyChanges
|
176
|
+
export class DashboardLayout extends Component<HTMLElement> implements INotifyPropertyChanged {
|
177
|
+
|
178
|
+
protected panelCollection: HTMLElement[];
|
179
|
+
protected checkCollision: HTMLElement[];
|
180
|
+
protected mainElement: HTMLElement;
|
181
|
+
protected rows: number = 1;
|
182
|
+
protected dragobj: Draggable;
|
183
|
+
protected dragStartArgs: DragStartArgs;
|
184
|
+
protected dragStopEventArgs: DragStopArgs;
|
185
|
+
protected draggedEventArgs: DraggedEventArgs;
|
186
|
+
protected updatedRows: number;
|
187
|
+
protected tempObject: DashboardLayout;
|
188
|
+
protected sortedArray: HTMLElement[][];
|
189
|
+
protected cloneArray: HTMLElement[][];
|
190
|
+
protected panelID: number = 0;
|
191
|
+
protected movePanelCalled: boolean = false;
|
192
|
+
protected resizeCalled: boolean = false;
|
193
|
+
protected gridPanelCollection: PanelModel[];
|
194
|
+
protected overlapElement: HTMLElement[];
|
195
|
+
protected shouldRestrict: boolean;
|
196
|
+
protected shouldSubRestrict: boolean;
|
197
|
+
protected overlapElementClone: HTMLElement[];
|
198
|
+
protected overlapSubElementClone: HTMLElement[];
|
199
|
+
protected dragCollection: Draggable[];
|
200
|
+
protected iterationValue: number;
|
201
|
+
protected shadowEle: HTMLElement;
|
202
|
+
protected elementRef: {
|
203
|
+
top: string;
|
204
|
+
left: string;
|
205
|
+
height: string;
|
206
|
+
width: string;
|
207
|
+
};
|
208
|
+
protected allItems: HTMLElement[];
|
209
|
+
protected dimensions: (string | number)[];
|
210
|
+
protected oldRowCol: {
|
211
|
+
[key: string]: {
|
212
|
+
row: number,
|
213
|
+
col: number
|
214
|
+
};
|
215
|
+
};
|
216
|
+
protected collisionChecker: {
|
217
|
+
[key: string]: {
|
218
|
+
ele: HTMLElement,
|
219
|
+
row: number,
|
220
|
+
srcEle: HTMLElement
|
221
|
+
};
|
222
|
+
};
|
223
|
+
protected availableClasses: string[];
|
224
|
+
protected addPanelCalled: boolean;
|
225
|
+
protected isSubValue: boolean;
|
226
|
+
protected direction: number;
|
227
|
+
protected directionRow: number;
|
228
|
+
protected lastMouseX: number;
|
229
|
+
protected lastMouseY: number;
|
230
|
+
protected elementX: number;
|
231
|
+
protected elementY: number;
|
232
|
+
protected elementWidth: number;
|
233
|
+
protected elementHeight: number;
|
234
|
+
protected previousRow: number;
|
235
|
+
protected originalWidth: number;
|
236
|
+
protected originalHeight: number;
|
237
|
+
protected handleClass: string;
|
238
|
+
protected mOffX: number = 0;
|
239
|
+
protected mOffY: number = 0;
|
240
|
+
protected maxTop: number = 9999;
|
241
|
+
protected maxRows: number = 100;
|
242
|
+
protected maxLeft: number;
|
243
|
+
protected mouseX: number = 0;
|
244
|
+
protected mouseY: number = 0;
|
245
|
+
protected minTop: number = 0;
|
246
|
+
protected minLeft: number = 0;
|
247
|
+
protected moveTarget: HTMLElement;
|
248
|
+
protected upTarget: HTMLElement;
|
249
|
+
protected downTarget: HTMLElement;
|
250
|
+
protected leftAdjustable: boolean;
|
251
|
+
protected rightAdjustable: boolean;
|
252
|
+
protected topAdjustable: boolean;
|
253
|
+
protected restrictDynamicUpdate: boolean;
|
254
|
+
protected spacedColumnValue: number;
|
255
|
+
protected checkingElement: HTMLElement;
|
256
|
+
protected panelContent: HTMLElement;
|
257
|
+
protected panelHeaderElement: HTMLElement;
|
258
|
+
protected panelBody: HTMLElement;
|
259
|
+
protected startRow: number;
|
260
|
+
protected startCol: number;
|
261
|
+
protected maxColumnValue: number;
|
262
|
+
protected checkColumnValue: number;
|
263
|
+
protected spacedRowValue: number;
|
264
|
+
protected cellSize: number[];
|
265
|
+
protected table: HTMLElement;
|
266
|
+
protected cloneObject: {
|
267
|
+
[key: string]: {
|
268
|
+
row: number,
|
269
|
+
col: number
|
270
|
+
};
|
271
|
+
};
|
272
|
+
private panelsInitialModel: PanelModel[];
|
273
|
+
protected isRenderComplete: boolean;
|
274
|
+
protected isMouseUpBound: boolean;
|
275
|
+
protected isMouseMoveBound: boolean;
|
276
|
+
protected contentTemplateChild: HTMLElement[];
|
277
|
+
private isInlineRendering: boolean = false;
|
278
|
+
private removeAllCalled: boolean = false;
|
279
|
+
// to check whether removePanel is executed in mobile device
|
280
|
+
private isPanelRemoved: boolean = false;
|
281
|
+
// to maintain sizeY in mobile device
|
282
|
+
private panelsSizeY: number = 0;
|
283
|
+
private resizeHeight: boolean = false;
|
284
|
+
private refreshListener: Function;
|
285
|
+
|
286
|
+
/**
|
287
|
+
* If allowDragging is set to true, then the DashboardLayout allows you to drag and reorder the panels.
|
288
|
+
*
|
289
|
+
* @default true
|
290
|
+
*/
|
291
|
+
@Property(true)
|
292
|
+
public allowDragging: boolean;
|
293
|
+
|
294
|
+
/**
|
295
|
+
* If allowResizing is set to true, then the DashboardLayout allows you to resize the panels.
|
296
|
+
*
|
297
|
+
* @default false
|
298
|
+
*/
|
299
|
+
@Property(false)
|
300
|
+
public allowResizing: boolean;
|
301
|
+
|
302
|
+
/**
|
303
|
+
* If pushing is set to true, then the DashboardLayout allow to push the panels when panels collide
|
304
|
+
* while dragging or resizing the panels.
|
305
|
+
*
|
306
|
+
* @default true
|
307
|
+
* @private
|
308
|
+
*/
|
309
|
+
@Property(true)
|
310
|
+
private allowPushing: boolean;
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Defines whether to allow the cross-scripting site or not.
|
314
|
+
*
|
315
|
+
* @default true
|
316
|
+
*/
|
317
|
+
@Property(true)
|
318
|
+
public enableHtmlSanitizer: boolean;
|
319
|
+
|
320
|
+
|
321
|
+
/**
|
322
|
+
* If allowFloating is set to true, then the DashboardLayout automatically move the panels upwards to fill the empty available
|
323
|
+
* cells while dragging or resizing the panels.
|
324
|
+
*
|
325
|
+
* @default true
|
326
|
+
*/
|
327
|
+
@Property(true)
|
328
|
+
public allowFloating: boolean;
|
329
|
+
|
330
|
+
/**
|
331
|
+
* Defines the cell aspect ratio of the panel.
|
332
|
+
*
|
333
|
+
* @default 1
|
334
|
+
*/
|
335
|
+
@Property(1)
|
336
|
+
public cellAspectRatio: number;
|
337
|
+
|
338
|
+
/**
|
339
|
+
* Defines the spacing between the panels.
|
340
|
+
*
|
341
|
+
* @default [5,5]
|
342
|
+
*/
|
343
|
+
@Property([5, 5])
|
344
|
+
public cellSpacing: number[];
|
345
|
+
|
346
|
+
/**
|
347
|
+
* Defines the number of columns to be created in the DashboardLayout.
|
348
|
+
*
|
349
|
+
* @default 1
|
350
|
+
*/
|
351
|
+
@Property(1)
|
352
|
+
public columns: number;
|
353
|
+
/**
|
354
|
+
* Enables or disables the grid lines for the Dashboard Layout panels.
|
355
|
+
*
|
356
|
+
* @default false
|
357
|
+
*/
|
358
|
+
@Property(false)
|
359
|
+
public showGridLines: boolean;
|
360
|
+
|
361
|
+
/**
|
362
|
+
* Defines the draggable handle selector which will act as dragging handler for the panels.
|
363
|
+
*
|
364
|
+
* @default null
|
365
|
+
*/
|
366
|
+
@Property(null)
|
367
|
+
public draggableHandle: string;
|
368
|
+
|
369
|
+
/**
|
370
|
+
* Locale property.
|
371
|
+
* This is not a dashboard layout property.
|
372
|
+
*
|
373
|
+
* @default 'en-US'
|
374
|
+
* @private
|
375
|
+
*/
|
376
|
+
@Property('en-US')
|
377
|
+
public locale: string;
|
378
|
+
|
379
|
+
/**
|
380
|
+
* Defines the media query value where the dashboardlayout becomes stacked layout when the resolution meets.
|
381
|
+
*
|
382
|
+
* @default 'max-width:600px'
|
383
|
+
*/
|
384
|
+
@Property('max-width: 600px')
|
385
|
+
public mediaQuery: string;
|
386
|
+
|
387
|
+
/**
|
388
|
+
*
|
389
|
+
* Defines the panels property of the DashboardLayout component.
|
390
|
+
*
|
391
|
+
* @default null
|
392
|
+
*/
|
393
|
+
@Collection<PanelModel>([], Panel)
|
394
|
+
public panels: PanelModel[];
|
395
|
+
|
396
|
+
/**
|
397
|
+
* Defines the resizing handles directions used for resizing the panels.
|
398
|
+
*
|
399
|
+
* @default 'e-south-east'
|
400
|
+
*
|
401
|
+
*/
|
402
|
+
@Property(['e-south-east'])
|
403
|
+
public resizableHandles: string[];
|
404
|
+
|
405
|
+
/**
|
406
|
+
* Triggers whenever the panels positions are changed.
|
407
|
+
*
|
408
|
+
* @event 'object'
|
409
|
+
*/
|
410
|
+
@Event()
|
411
|
+
public change: EmitType<ChangeEventArgs>;
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
/**
|
416
|
+
* Triggers when a panel is about to drag.
|
417
|
+
*
|
418
|
+
* @event 'object'
|
419
|
+
*/
|
420
|
+
@Event()
|
421
|
+
public dragStart: EmitType<DragStartArgs>;
|
422
|
+
|
423
|
+
/**
|
424
|
+
* Triggers while a panel is dragged continuously.
|
425
|
+
*
|
426
|
+
* @event 'object'
|
427
|
+
*/
|
428
|
+
@Event()
|
429
|
+
public drag: EmitType<DraggedEventArgs>;
|
430
|
+
|
431
|
+
/**
|
432
|
+
* Triggers when a dragged panel is dropped.
|
433
|
+
*
|
434
|
+
* @event 'object'
|
435
|
+
*/
|
436
|
+
@Event()
|
437
|
+
public dragStop: EmitType<DragStopArgs>;
|
438
|
+
|
439
|
+
/**
|
440
|
+
* Triggers when a panel is about to resize.
|
441
|
+
*
|
442
|
+
* @event 'object'
|
443
|
+
*/
|
444
|
+
@Event()
|
445
|
+
public resizeStart: EmitType<ResizeArgs>;
|
446
|
+
|
447
|
+
/**
|
448
|
+
* Triggers when a panel is being resized continuously.
|
449
|
+
*
|
450
|
+
* @event 'object'
|
451
|
+
*/
|
452
|
+
@Event()
|
453
|
+
public resize: EmitType<ResizeArgs>;
|
454
|
+
|
455
|
+
/**
|
456
|
+
* Triggers when a panel resize ends.
|
457
|
+
*
|
458
|
+
* @event 'object'
|
459
|
+
*/
|
460
|
+
@Event()
|
461
|
+
public resizeStop: EmitType<ResizeArgs>;
|
462
|
+
|
463
|
+
/**
|
464
|
+
* Triggers when Dashboard Layout is created.
|
465
|
+
*
|
466
|
+
* @event 'object'
|
467
|
+
*/
|
468
|
+
|
469
|
+
@Event()
|
470
|
+
public created: EmitType<Object>;
|
471
|
+
/**
|
472
|
+
* Triggers when Dashboard Layout is destroyed.
|
473
|
+
*
|
474
|
+
* @event 'object'
|
475
|
+
*/
|
476
|
+
|
477
|
+
@Event()
|
478
|
+
public destroyed: EmitType<Object>;
|
479
|
+
|
480
|
+
|
481
|
+
/**
|
482
|
+
* Initialize the event handler
|
483
|
+
*
|
484
|
+
* @private
|
485
|
+
*/
|
486
|
+
|
487
|
+
protected preRender(): void {
|
488
|
+
this.panelCollection = [];
|
489
|
+
this.sortedArray = [];
|
490
|
+
this.gridPanelCollection = [];
|
491
|
+
this.overlapElement = [];
|
492
|
+
this.overlapElementClone = [];
|
493
|
+
this.overlapSubElementClone = [];
|
494
|
+
this.collisionChecker = {};
|
495
|
+
this.dragCollection = [];
|
496
|
+
this.elementRef = { top: '', left: '', height: '', width: '' };
|
497
|
+
this.dimensions = [];
|
498
|
+
this.allItems = [];
|
499
|
+
this.oldRowCol = {};
|
500
|
+
this.availableClasses = [];
|
501
|
+
this.setOldRowCol();
|
502
|
+
this.calculateCellSize();
|
503
|
+
this.contentTemplateChild = [].slice.call(this.element.children);
|
504
|
+
}
|
505
|
+
|
506
|
+
protected setOldRowCol(): void {
|
507
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
508
|
+
if (!this.panels[i].id) {
|
509
|
+
this.panelPropertyChange(this.panels[i], { id: 'layout_' + this.panelID.toString() });
|
510
|
+
this.panelID = this.panelID + 1;
|
511
|
+
}
|
512
|
+
this.oldRowCol[this.panels[i].id] = { row: this.panels[i].row, col: this.panels[i].col };
|
513
|
+
}
|
514
|
+
}
|
515
|
+
|
516
|
+
protected createPanelElement(cssClass: string[], idValue: string): HTMLElement {
|
517
|
+
const ele: HTMLElement = <HTMLElement>this.createElement('div');
|
518
|
+
if (cssClass && cssClass.length > 0) { addClass([ele], cssClass); }
|
519
|
+
if (idValue) { ele.setAttribute('id', idValue); }
|
520
|
+
return ele;
|
521
|
+
}
|
522
|
+
|
523
|
+
/**
|
524
|
+
* To Initialize the control rendering.
|
525
|
+
*
|
526
|
+
* @returns void
|
527
|
+
* @private
|
528
|
+
*/
|
529
|
+
|
530
|
+
protected render(): void {
|
531
|
+
this.initialize();
|
532
|
+
this.isRenderComplete = true;
|
533
|
+
if (this.showGridLines && !this.checkMediaQuery()) {
|
534
|
+
this.initGridLines();
|
535
|
+
}
|
536
|
+
this.updateDragArea();
|
537
|
+
this.renderComplete();
|
538
|
+
this.renderReactTemplates();
|
539
|
+
}
|
540
|
+
|
541
|
+
private initGridLines(): void {
|
542
|
+
this.table = document.createElement('table');
|
543
|
+
const tbody: HTMLElement = document.createElement('tbody');
|
544
|
+
this.table.classList.add('e-dashboard-gridline-table');
|
545
|
+
for (let i: number = 0; i < this.maxRow(); i++) {
|
546
|
+
const tr: HTMLElement = document.createElement('tr');
|
547
|
+
for (let j: number = 0; j < this.columns; j++) {
|
548
|
+
const td: HTMLElement = document.createElement('td');
|
549
|
+
td.classList.add('e-dashboard-gridline');
|
550
|
+
this.setAttributes({ value: { row: i.toString(), col: j.toString(), sizeX: '1', sizeY: '1' } }, td);
|
551
|
+
td.setAttribute('id', '' + j);
|
552
|
+
this.setPanelPosition(td, i, j);
|
553
|
+
this.setHeightAndWidth(td, { row: i, col: j, sizeX: 1, sizeY: 1 });
|
554
|
+
tr.appendChild(td);
|
555
|
+
}
|
556
|
+
tbody.appendChild(tr);
|
557
|
+
}
|
558
|
+
this.table.appendChild(tbody);
|
559
|
+
this.element.appendChild(this.table);
|
560
|
+
this.renderReactTemplates();
|
561
|
+
}
|
562
|
+
|
563
|
+
private initialize(): void {
|
564
|
+
this.updateRowHeight();
|
565
|
+
if (this.element.childElementCount > 0 && this.element.querySelectorAll('.e-panel').length > 0) {
|
566
|
+
const panelElements: HTMLElement[] = [];
|
567
|
+
this.setProperties({ panels: [] }, true);
|
568
|
+
this.isInlineRendering = true;
|
569
|
+
for (let i: number = 0; i < this.element.querySelectorAll('.e-panel').length; i++) {
|
570
|
+
panelElements.push(<HTMLElement>(this.element.querySelectorAll('.e-panel')[i]));
|
571
|
+
}
|
572
|
+
for (let i: number = 0; i < panelElements.length; i++) {
|
573
|
+
const panelElement: HTMLElement = <HTMLElement>panelElements[i];
|
574
|
+
if (this.enableRtl) {
|
575
|
+
addClass([panelElement], 'e-rtl');
|
576
|
+
}
|
577
|
+
this.getInlinePanels(panelElement);
|
578
|
+
this.maxCol();
|
579
|
+
this.maxRow();
|
580
|
+
}
|
581
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
582
|
+
const panelElement: HTMLElement = this.element.querySelector('#' + this.panels[i].id);
|
583
|
+
this.setMinMaxValues(this.panels[i]);
|
584
|
+
if (this.maxColumnValue < this.panels[i].col || this.maxColumnValue < (this.panels[i].col + this.panels[i].sizeX)) {
|
585
|
+
const colValue: number = this.maxColumnValue - this.panels[i].sizeX;
|
586
|
+
this.panelPropertyChange(this.panels[i], { col: colValue < 0 ? 0 : colValue });
|
587
|
+
}
|
588
|
+
this.setXYAttributes(panelElement, this.panels[i]);
|
589
|
+
const panel: HTMLElement = this.renderPanels(panelElement, this.panels[i], this.panels[i].id, false);
|
590
|
+
this.panelCollection.push(panel);
|
591
|
+
this.setHeightAndWidth(panelElement, this.panels[i]);
|
592
|
+
this.tempObject = this;
|
593
|
+
if (this.mediaQuery && !window.matchMedia('(' + this.mediaQuery + ')').matches) {
|
594
|
+
this.setPanelPosition(panelElement, this.panels[i].row, this.panels[i].col);
|
595
|
+
this.mainElement = panelElement;
|
596
|
+
this.updatePanelLayout(panelElement, this.panels[i]);
|
597
|
+
this.mainElement = null;
|
598
|
+
}
|
599
|
+
this.setClasses([panelElement]);
|
600
|
+
}
|
601
|
+
this.updateOldRowColumn();
|
602
|
+
if (this.checkMediaQuery()) {
|
603
|
+
this.checkMediaQuerySizing();
|
604
|
+
}
|
605
|
+
} else {
|
606
|
+
this.renderDashBoardCells(this.panels);
|
607
|
+
}
|
608
|
+
if (this.allowDragging && (this.mediaQuery ? !window.matchMedia('(' + this.mediaQuery + ')').matches : true)) {
|
609
|
+
this.enableDraggingContent(this.panelCollection);
|
610
|
+
}
|
611
|
+
this.sortedPanel();
|
612
|
+
this.bindEvents();
|
613
|
+
this.updatePanels();
|
614
|
+
this.updateCloneArrayObject();
|
615
|
+
this.checkColumnValue = this.maxColumnValue;
|
616
|
+
if (!(this.checkMediaQuery())) {
|
617
|
+
this.panelResponsiveUpdate();
|
618
|
+
}
|
619
|
+
this.setEnableRtl();
|
620
|
+
}
|
621
|
+
protected checkMediaQuery(): boolean {
|
622
|
+
return (this.mediaQuery && window.matchMedia('(' + this.mediaQuery + ')').matches);
|
623
|
+
}
|
624
|
+
protected calculateCellSize(): void {
|
625
|
+
this.cellSize = [];
|
626
|
+
if ((this.checkMediaQuery())) {
|
627
|
+
this.cellSize[1] = this.element.parentElement
|
628
|
+
&& ((this.element.parentElement.offsetWidth)) / this.cellAspectRatio;
|
629
|
+
} else {
|
630
|
+
|
631
|
+
this.cellSize[0] = this.element.parentElement &&
|
632
|
+
((this.element.parentElement.offsetWidth));
|
633
|
+
this.cellSize[0] = this.element.parentElement
|
634
|
+
&& ((this.element.parentElement.offsetWidth - ((this.maxCol() - 1) * this.cellSpacing[0]))
|
635
|
+
/ (this.maxCol()));
|
636
|
+
this.cellSize[1] = <number>this.cellSize[0] / this.cellAspectRatio;
|
637
|
+
}
|
638
|
+
}
|
639
|
+
protected maxRow(recheck?: boolean): number {
|
640
|
+
let maxRow: number = 1;
|
641
|
+
if (this.rows > 1 && isNullOrUndefined(recheck)) {
|
642
|
+
maxRow = this.rows;
|
643
|
+
return maxRow;
|
644
|
+
}
|
645
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
646
|
+
if (this.panels[i].sizeY + this.panels[i].row > maxRow) {
|
647
|
+
maxRow = this.panels[i].sizeY + this.panels[i].row;
|
648
|
+
}
|
649
|
+
}
|
650
|
+
if (this.panels.length === 0) {
|
651
|
+
maxRow = this.columns;
|
652
|
+
}
|
653
|
+
return maxRow;
|
654
|
+
}
|
655
|
+
|
656
|
+
protected maxCol(): number {
|
657
|
+
let maxCol: number = 1;
|
658
|
+
maxCol = this.columns;
|
659
|
+
this.maxColumnValue = maxCol;
|
660
|
+
return maxCol;
|
661
|
+
}
|
662
|
+
|
663
|
+
protected updateOldRowColumn(): void {
|
664
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
665
|
+
const id: string = this.panels[i].id;
|
666
|
+
if (document.getElementById(id)) {
|
667
|
+
const row: number = parseInt(document.getElementById(id).getAttribute('data-row'), 10);
|
668
|
+
const col: number = parseInt(document.getElementById(id).getAttribute('data-col'), 10);
|
669
|
+
this.oldRowCol[this.panels[i].id] = { row: row, col: col };
|
670
|
+
} else {
|
671
|
+
continue;
|
672
|
+
}
|
673
|
+
}
|
674
|
+
}
|
675
|
+
|
676
|
+
protected createSubElement(cssClass: string[], idValue: string, className: string): HTMLElement {
|
677
|
+
const element: HTMLElement = <HTMLElement>this.createElement('div');
|
678
|
+
if (className) { addClass([element], [className]); }
|
679
|
+
if (cssClass && cssClass.length > 0) { addClass([element], cssClass); }
|
680
|
+
if (idValue) { element.setAttribute('id', idValue); }
|
681
|
+
return element;
|
682
|
+
}
|
683
|
+
// eslint-disable-next-line
|
684
|
+
private templateParser(template: string): Function {
|
685
|
+
if (template) {
|
686
|
+
try {
|
687
|
+
if (document.querySelectorAll(template).length) {
|
688
|
+
return compile(document.querySelector(template).innerHTML.trim());
|
689
|
+
}
|
690
|
+
} catch (error) {
|
691
|
+
const sanitizedValue: string = SanitizeHtmlHelper.sanitize(template);
|
692
|
+
return compile((this.enableHtmlSanitizer && typeof (template) === 'string') ? sanitizedValue : template);
|
693
|
+
}
|
694
|
+
}
|
695
|
+
return undefined;
|
696
|
+
}
|
697
|
+
|
698
|
+
protected renderTemplate(content: string, appendElement: HTMLElement, type: string, isStringTemplate: boolean, prop: string): void {
|
699
|
+
// eslint-disable-next-line
|
700
|
+
const templateFn: Function = this.templateParser(content);
|
701
|
+
const templateElements: HTMLElement[] = [];
|
702
|
+
if (((<string>content)[0] === '.' || (<string>content)[0] === '#') &&
|
703
|
+
document.querySelector(<string>content).tagName !== 'SCRIPT') {
|
704
|
+
const eleVal: HTMLElement = <HTMLElement>document.querySelector(<string>content);
|
705
|
+
if (!isNullOrUndefined(eleVal)) {
|
706
|
+
if (eleVal.style.display === 'none') {
|
707
|
+
eleVal.style.removeProperty('display');
|
708
|
+
}
|
709
|
+
if (eleVal.getAttribute('style') === '') {
|
710
|
+
eleVal.removeAttribute('style');
|
711
|
+
}
|
712
|
+
appendElement.appendChild(eleVal);
|
713
|
+
return;
|
714
|
+
} else {
|
715
|
+
content = (content as string).trim();
|
716
|
+
}
|
717
|
+
} else {
|
718
|
+
// eslint-disable-next-line
|
719
|
+
const compilerFn: any = templateFn({}, this, prop, type, isStringTemplate, null, appendElement);
|
720
|
+
if (compilerFn) {
|
721
|
+
for (const item of compilerFn) {
|
722
|
+
templateElements.push(item);
|
723
|
+
}
|
724
|
+
append([].slice.call(templateElements), appendElement);
|
725
|
+
}
|
726
|
+
|
727
|
+
}
|
728
|
+
}
|
729
|
+
|
730
|
+
protected renderPanels(cellElement: HTMLElement, panelModel: PanelModel, panelId: string, isStringTemplate: boolean): HTMLElement {
|
731
|
+
addClass([cellElement], [panel, panelTransition]);
|
732
|
+
const cssClass: string[] = panelModel.cssClass ? panelModel.cssClass.split(' ') : null;
|
733
|
+
this.panelContent = cellElement.querySelector('.e-panel-container') ?
|
734
|
+
cellElement.querySelector('.e-panel-container') :
|
735
|
+
this.createSubElement(cssClass, cellElement.id + '_content', panelContainer);
|
736
|
+
cellElement.appendChild(this.panelContent);
|
737
|
+
if (!panelModel.enabled) { this.disablePanel(cellElement); }
|
738
|
+
if (panelModel.header) {
|
739
|
+
const headerTemplateElement: HTMLElement = cellElement.querySelector('.e-panel-header') ?
|
740
|
+
cellElement.querySelector('.e-panel-header') : this.createSubElement([], cellElement.id + 'template', '');
|
741
|
+
addClass([headerTemplateElement], [header]);
|
742
|
+
if (!cellElement.querySelector('.e-panel-header')) {
|
743
|
+
const id: string = this.element.id + 'HeaderTemplate' + panelId;
|
744
|
+
this.renderTemplate(<string>panelModel.header, headerTemplateElement, id, isStringTemplate, 'header');
|
745
|
+
this.panelContent.appendChild(headerTemplateElement);
|
746
|
+
this.renderReactTemplates();
|
747
|
+
}
|
748
|
+
}
|
749
|
+
if (panelModel.content) {
|
750
|
+
const cssClass: string[] = panelModel.cssClass ? panelModel.cssClass.split(' ') : null;
|
751
|
+
this.panelBody = cellElement.querySelector('.e-panel-content') ? cellElement.querySelector('.e-panel-content') :
|
752
|
+
this.createSubElement(cssClass, cellElement.id + '_body', panelContent);
|
753
|
+
const headerHeight: string = this.panelContent.querySelector('.e-panel-header') ?
|
754
|
+
window.getComputedStyle(this.panelContent.querySelector('.e-panel-header')).height : '0px';
|
755
|
+
const contentHeightValue: string = 'calc( 100% - ' + headerHeight + ')';
|
756
|
+
setStyle(this.panelBody, { height: contentHeightValue });
|
757
|
+
if (!cellElement.querySelector('.e-panel-content')) {
|
758
|
+
const id: string = this.element.id + 'ContentTemplate' + panelId;
|
759
|
+
this.renderTemplate(<string>panelModel.content, this.panelBody, id, isStringTemplate, 'content');
|
760
|
+
this.panelContent.appendChild(this.panelBody);
|
761
|
+
this.renderReactTemplates();
|
762
|
+
}
|
763
|
+
|
764
|
+
}
|
765
|
+
return cellElement;
|
766
|
+
}
|
767
|
+
|
768
|
+
protected disablePanel(panelElement: HTMLElement): void {
|
769
|
+
addClass([panelElement], [disable]);
|
770
|
+
}
|
771
|
+
|
772
|
+
protected getInlinePanels(panelElement: HTMLElement): void {
|
773
|
+
const model: PanelModel = {
|
774
|
+
sizeX: panelElement.hasAttribute('data-sizex') ? parseInt(panelElement.getAttribute('data-sizex'), 10) : 1,
|
775
|
+
sizeY: panelElement.hasAttribute('data-sizey') ? parseInt(panelElement.getAttribute('data-sizey'), 10) : 1,
|
776
|
+
minSizeX: panelElement.hasAttribute('data-minsizex') ? parseInt(panelElement.getAttribute('data-minsizex'), 10) : 1,
|
777
|
+
minSizeY: panelElement.hasAttribute('data-minsizey') ? parseInt(panelElement.getAttribute('data-minsizey'), 10) : 1,
|
778
|
+
maxSizeX: panelElement.hasAttribute('data-maxsizex') ? parseInt(panelElement.getAttribute('data-maxsizex'), 10) : null,
|
779
|
+
maxSizeY: panelElement.hasAttribute('data-maxsizey') ? parseInt(panelElement.getAttribute('data-maxsizey'), 10) : null,
|
780
|
+
row: panelElement.hasAttribute('data-row') ? parseInt(panelElement.getAttribute('data-row'), 10) : 0,
|
781
|
+
col: panelElement.hasAttribute('data-col') ? parseInt(panelElement.getAttribute('data-col'), 10) : 0,
|
782
|
+
id: panelElement.getAttribute('id'),
|
783
|
+
zIndex: panelElement.hasAttribute('data-zindex') ? parseInt(panelElement.getAttribute('data-zIndex'), 10) : 1000,
|
784
|
+
header: panelElement.querySelector('.e-panel-header') && '.e-panel-header',
|
785
|
+
content: panelElement.querySelector('.e-panel-content') && '.e-panel-content'
|
786
|
+
};
|
787
|
+
if (!model.id) {
|
788
|
+
model.id = 'layout_' + this.panelID.toString();
|
789
|
+
panelElement.setAttribute('id', model.id);
|
790
|
+
this.panelID = this.panelID + 1;
|
791
|
+
}
|
792
|
+
if (isUndefined(model.enabled)) {
|
793
|
+
model.enabled = true;
|
794
|
+
}
|
795
|
+
panelElement.style.zIndex = '' + model.zIndex;
|
796
|
+
// eslint-disable-next-line
|
797
|
+
const panelProp: Panel = new Panel((<any>this), 'panels', model, true);
|
798
|
+
this.panels.push(panelProp);
|
799
|
+
}
|
800
|
+
private resizeEvents(): void {
|
801
|
+
if (this.allowResizing) {
|
802
|
+
const panelElements: NodeList = this.element.querySelectorAll('.e-panel .e-panel-container .e-resize');
|
803
|
+
for (let i: number = 0; i < panelElements.length; i++) {
|
804
|
+
const eventName: string = (Browser.info.name === 'msie') ? 'mousedown pointerdown' : 'mousedown';
|
805
|
+
EventHandler.add((<HTMLElement>panelElements[i]), eventName, this.downResizeHandler, this);
|
806
|
+
if (Browser.info.name !== 'msie') {
|
807
|
+
EventHandler.add((<HTMLElement>panelElements[i]), 'touchstart', this.touchDownResizeHandler, this);
|
808
|
+
}
|
809
|
+
}
|
810
|
+
}
|
811
|
+
}
|
812
|
+
|
813
|
+
protected bindEvents(): void {
|
814
|
+
this.refreshListener = this.refresh.bind(this);
|
815
|
+
// eslint-disable-next-line
|
816
|
+
EventHandler.add(window as any, 'resize', this.refreshListener);
|
817
|
+
this.resizeEvents();
|
818
|
+
}
|
819
|
+
protected downResizeHandler(e: MouseEvent): void {
|
820
|
+
this.downHandler(e);
|
821
|
+
this.lastMouseX = e.pageX;
|
822
|
+
this.lastMouseY = e.pageY;
|
823
|
+
const moveEventName: string = (Browser.info.name === 'msie') ? 'mousemove pointermove' : 'mousemove';
|
824
|
+
const upEventName: string = (Browser.info.name === 'msie') ? 'mouseup pointerup' : 'mouseup';
|
825
|
+
if (!this.isMouseMoveBound) {
|
826
|
+
EventHandler.add(document, moveEventName, this.moveResizeHandler, this);
|
827
|
+
this.isMouseMoveBound = true;
|
828
|
+
}
|
829
|
+
if (!this.isMouseUpBound) {
|
830
|
+
EventHandler.add(document, upEventName, this.upResizeHandler, this);
|
831
|
+
this.isMouseUpBound = true;
|
832
|
+
}
|
833
|
+
}
|
834
|
+
|
835
|
+
protected downHandler(e: MouseEvent | TouchEvent): void {
|
836
|
+
this.resizeCalled = false;
|
837
|
+
this.panelsInitialModel = this.cloneModels(this.panels);
|
838
|
+
const el: HTMLElement = (<HTMLElement>closest(<HTMLElement>(<HTMLElement>(e.currentTarget)), '.e-panel'));
|
839
|
+
const args: ResizeArgs = { event: e, element: el, isInteracted: true };
|
840
|
+
this.trigger('resizeStart', args);
|
841
|
+
this.downTarget = (<HTMLElement>e.currentTarget);
|
842
|
+
this.shadowEle = document.createElement('div');
|
843
|
+
this.shadowEle.classList.add('e-holder');
|
844
|
+
addClass([this.element], [preventSelect]);
|
845
|
+
this.element.appendChild(this.shadowEle);
|
846
|
+
this.renderReactTemplates();
|
847
|
+
this.elementX = parseFloat(el.style.left);
|
848
|
+
this.elementY = parseFloat(el.style.top);
|
849
|
+
this.elementWidth = el.offsetWidth;
|
850
|
+
this.elementHeight = el.offsetHeight;
|
851
|
+
this.originalWidth = this.getCellInstance(el.id).sizeX;
|
852
|
+
this.originalHeight = this.getCellInstance(el.id).sizeY;
|
853
|
+
this.previousRow = this.getCellInstance(el.id).row;
|
854
|
+
}
|
855
|
+
|
856
|
+
protected touchDownResizeHandler(e: TouchEvent): void {
|
857
|
+
this.downHandler(e);
|
858
|
+
this.lastMouseX = e.changedTouches[0].pageX;
|
859
|
+
this.lastMouseY = e.changedTouches[0].pageY;
|
860
|
+
if (!this.isMouseMoveBound) {
|
861
|
+
EventHandler.add(document, 'touchmove', this.touchMoveResizeHandler, this);
|
862
|
+
this.isMouseMoveBound = true;
|
863
|
+
}
|
864
|
+
if (!this.isMouseUpBound) {
|
865
|
+
EventHandler.add(document, 'touchend', this.upResizeHandler, this);
|
866
|
+
this.isMouseUpBound = true;
|
867
|
+
}
|
868
|
+
}
|
869
|
+
|
870
|
+
private getCellSize(): number[] {
|
871
|
+
return [this.cellSize[0], this.cellSize[1]];
|
872
|
+
}
|
873
|
+
|
874
|
+
protected updateMaxTopLeft(e: MouseEvent | TouchEvent): void {
|
875
|
+
this.moveTarget = this.downTarget;
|
876
|
+
const el: HTMLElement = (<HTMLElement>closest(<HTMLElement>(this.moveTarget), '.e-panel'));
|
877
|
+
const args: ResizeArgs = { event: e, element: el, isInteracted: true };
|
878
|
+
this.trigger('resize', args);
|
879
|
+
}
|
880
|
+
|
881
|
+
protected updateResizeElement(el: HTMLElement): void {
|
882
|
+
this.maxLeft = this.element.offsetWidth - 1;
|
883
|
+
this.maxTop = <number>this.cellSize[1] * this.maxRows - 1;
|
884
|
+
removeClass([el], 'e-panel-transition');
|
885
|
+
addClass([el], [dragging]);
|
886
|
+
const handleArray: string[] = [east, west, north, south, southEast, northEast, northWest, southWest];
|
887
|
+
for (let i: number = 0; i < (<HTMLElement>this.moveTarget).classList.length; i++) {
|
888
|
+
if (handleArray.indexOf((<HTMLElement>this.moveTarget).classList[i]) !== -1) {
|
889
|
+
this.handleClass = ((<HTMLElement>this.moveTarget).classList[i]);
|
890
|
+
}
|
891
|
+
}
|
892
|
+
}
|
893
|
+
|
894
|
+
protected moveResizeHandler(e: MouseEvent): void {
|
895
|
+
this.updateMaxTopLeft(e);
|
896
|
+
const el: HTMLElement = (<HTMLElement>closest(<HTMLElement>(this.moveTarget), '.e-panel'));
|
897
|
+
if (this.lastMouseX === e.pageX || this.lastMouseY === e.pageY) {
|
898
|
+
return;
|
899
|
+
}
|
900
|
+
this.updateResizeElement(el);
|
901
|
+
const panelModel: PanelModel = this.getCellInstance(el.getAttribute('id'));
|
902
|
+
this.mouseX = e.pageX;
|
903
|
+
this.mouseY = e.pageY;
|
904
|
+
const diffY: number = this.mouseY - this.lastMouseY + this.mOffY;
|
905
|
+
const diffX: number = this.mouseX - this.lastMouseX + this.mOffX;
|
906
|
+
this.mOffX = this.mOffY = 0;
|
907
|
+
this.lastMouseY = this.mouseY;
|
908
|
+
this.lastMouseX = this.mouseX;
|
909
|
+
this.resizingPanel(el, panelModel, diffX, diffY);
|
910
|
+
}
|
911
|
+
|
912
|
+
protected touchMoveResizeHandler(e: TouchEvent): void {
|
913
|
+
this.updateMaxTopLeft(e);
|
914
|
+
const el: HTMLElement = (<HTMLElement>closest(<HTMLElement>(this.moveTarget), '.e-panel'));
|
915
|
+
if (this.lastMouseX === e.changedTouches[0].pageX || this.lastMouseY === e.changedTouches[0].pageY) {
|
916
|
+
return;
|
917
|
+
}
|
918
|
+
this.updateResizeElement(el);
|
919
|
+
const panelModel: PanelModel = this.getCellInstance(el.getAttribute('id'));
|
920
|
+
this.mouseX = e.changedTouches[0].pageX;
|
921
|
+
this.mouseY = e.changedTouches[0].pageY;
|
922
|
+
const diffX: number = this.mouseX - this.lastMouseX + this.mOffX;
|
923
|
+
const diffY: number = this.mouseY - this.lastMouseY + this.mOffY;
|
924
|
+
this.mOffX = this.mOffY = 0;
|
925
|
+
this.lastMouseX = this.mouseX;
|
926
|
+
this.lastMouseY = this.mouseY;
|
927
|
+
this.resizingPanel(el, panelModel, diffX, diffY);
|
928
|
+
}
|
929
|
+
/* istanbul ignore next */
|
930
|
+
protected resizingPanel(el: HTMLElement, panelModel: PanelModel, currentX: number, currentY: number): void {
|
931
|
+
let oldSizeX: number = this.getCellInstance(el.id).sizeX;
|
932
|
+
let oldSizeY: number = this.getCellInstance(el.id).sizeY;
|
933
|
+
const dY: number = currentY;
|
934
|
+
const dX: number = currentX;
|
935
|
+
if (this.handleClass.indexOf('north') >= 0) {
|
936
|
+
if (this.elementHeight - dY < this.getMinHeight(panelModel)) {
|
937
|
+
currentY = this.elementHeight - this.getMinHeight(panelModel);
|
938
|
+
this.mOffY = dY - currentY;
|
939
|
+
} else if (panelModel.maxSizeY && this.elementHeight - dY > this.getMaxHeight(panelModel)) {
|
940
|
+
currentY = this.elementHeight - this.getMaxHeight(panelModel);
|
941
|
+
this.mOffY = dY - currentY;
|
942
|
+
} else if (this.elementY + dY < this.minTop) {
|
943
|
+
currentY = this.minTop - this.elementY;
|
944
|
+
this.mOffY = dY - currentY;
|
945
|
+
}
|
946
|
+
this.elementY += currentY;
|
947
|
+
this.elementHeight -= currentY;
|
948
|
+
}
|
949
|
+
if (this.handleClass.indexOf('south') >= 0) {
|
950
|
+
if (this.elementHeight + dY < this.getMinHeight(panelModel)) {
|
951
|
+
currentY = this.getMinHeight(panelModel) - this.elementHeight;
|
952
|
+
this.mOffY = dY - currentY;
|
953
|
+
} else if (panelModel.maxSizeY && this.elementHeight + dY > this.getMaxHeight(panelModel)) {
|
954
|
+
currentY = this.getMaxHeight(panelModel) - this.elementHeight;
|
955
|
+
this.mOffY = dY - currentY;
|
956
|
+
}
|
957
|
+
this.elementHeight += currentY;
|
958
|
+
}
|
959
|
+
if (this.handleClass.indexOf('west') >= 0) {
|
960
|
+
if (this.elementWidth - dX < this.getMinWidth(panelModel)) {
|
961
|
+
currentX = this.elementWidth - this.getMinWidth(panelModel);
|
962
|
+
this.mOffX = dX - currentX;
|
963
|
+
} else if (panelModel.maxSizeX && this.elementWidth - dX > this.getMaxWidth(panelModel)) {
|
964
|
+
currentX = this.elementWidth - this.getMaxWidth(panelModel);
|
965
|
+
this.mOffX = dX - currentX;
|
966
|
+
} else if (this.elementX + dX < this.minLeft) {
|
967
|
+
currentX = this.minLeft - this.elementX;
|
968
|
+
this.mOffX = dX - currentX;
|
969
|
+
}
|
970
|
+
this.elementX += currentX;
|
971
|
+
this.elementWidth -= currentX;
|
972
|
+
}
|
973
|
+
if (this.handleClass.indexOf('east') >= 0) {
|
974
|
+
if (this.elementWidth + dX < this.getMinWidth(panelModel)) {
|
975
|
+
currentX = this.getMinWidth(panelModel) - this.elementWidth;
|
976
|
+
this.mOffX = dX - currentX;
|
977
|
+
} else if (panelModel.maxSizeX && this.elementWidth + dX > this.getMaxWidth(panelModel)) {
|
978
|
+
currentX = this.getMaxWidth(panelModel) - this.elementWidth;
|
979
|
+
this.mOffX = dX - currentX;
|
980
|
+
}
|
981
|
+
this.elementWidth += currentX;
|
982
|
+
}
|
983
|
+
el.style.top = this.elementY + 'px';
|
984
|
+
el.style.left = this.elementX + 'px';
|
985
|
+
el.style.width = this.elementWidth + 'px';
|
986
|
+
el.style.height = this.elementHeight + 'px';
|
987
|
+
const item: PanelModel = this.getResizeRowColumn(panelModel);
|
988
|
+
if (item.col + item.sizeX > this.columns) {
|
989
|
+
this.panelPropertyChange(item, { sizeX: item.sizeX - 1 });
|
990
|
+
}
|
991
|
+
this.shadowEle.style.top = ((item.row * this.getCellSize()[1] + (item.row * this.cellSpacing[1]))) + 'px';
|
992
|
+
this.shadowEle.style.left = ((item.col * this.getCellSize()[0]) + ((item.col) * this.cellSpacing[0])) + 'px';
|
993
|
+
this.shadowEle.style.height = ((item.sizeY * (this.getCellSize()[1] + (this.cellSpacing[1])))) + 'px';
|
994
|
+
this.shadowEle.style.width = ((item.sizeX * (this.getCellSize()[0] + (this.cellSpacing[0])))) + 'px';
|
995
|
+
if (oldSizeX !== item.sizeX || oldSizeY !== item.sizeY) {
|
996
|
+
oldSizeX = item.sizeX;
|
997
|
+
oldSizeY = item.sizeY;
|
998
|
+
const model: PanelModel = this.getCellInstance(el.id);
|
999
|
+
const value: IAttributes = {
|
1000
|
+
attributes: {
|
1001
|
+
row: model.row.toString(),
|
1002
|
+
col: model.col.toString(),
|
1003
|
+
sizeX: model.sizeX.toString(),
|
1004
|
+
sizeY: model.sizeY.toString()
|
1005
|
+
}
|
1006
|
+
};
|
1007
|
+
this.setAttributes(value, el);
|
1008
|
+
this.mainElement = el;
|
1009
|
+
this.updatePanelLayout(el, this.getCellInstance(el.id));
|
1010
|
+
this.updateOldRowColumn();
|
1011
|
+
this.sortedPanel();
|
1012
|
+
}
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
protected upResizeHandler(e: MouseEvent | TouchEvent): void {
|
1016
|
+
if (isNullOrUndefined(this.downTarget)) {
|
1017
|
+
return;
|
1018
|
+
}
|
1019
|
+
this.upTarget = (<HTMLElement>this.downTarget);
|
1020
|
+
const el: HTMLElement = (<HTMLElement>closest(<HTMLElement>(this.upTarget), '.e-panel'));
|
1021
|
+
const args: ResizeArgs = { event: e, element: el, isInteracted: true };
|
1022
|
+
if (el) {
|
1023
|
+
addClass([el], 'e-panel-transition');
|
1024
|
+
const moveEventName: string = (Browser.info.name === 'msie') ? 'mousemove pointermove' : 'mousemove';
|
1025
|
+
const upEventName: string = (Browser.info.name === 'msie') ? 'mouseup pointerup' : 'mouseup';
|
1026
|
+
EventHandler.remove(document, moveEventName, this.moveResizeHandler);
|
1027
|
+
EventHandler.remove(document, upEventName, this.upResizeHandler);
|
1028
|
+
if (Browser.info.name !== 'msie') {
|
1029
|
+
EventHandler.remove(document, 'touchmove', this.touchMoveResizeHandler);
|
1030
|
+
EventHandler.remove(document, 'touchend', this.upResizeHandler);
|
1031
|
+
}
|
1032
|
+
this.isMouseUpBound = false;
|
1033
|
+
this.isMouseMoveBound = false;
|
1034
|
+
if (this.shadowEle) {
|
1035
|
+
detach(this.shadowEle);
|
1036
|
+
}
|
1037
|
+
this.shadowEle = null;
|
1038
|
+
const panelModel: PanelModel = this.getCellInstance(el.getAttribute('id'));
|
1039
|
+
this.setPanelPosition(el, panelModel.row, panelModel.col);
|
1040
|
+
this.setHeightAndWidth(el, panelModel);
|
1041
|
+
}
|
1042
|
+
removeClass([el], [dragging]);
|
1043
|
+
this.trigger('resizeStop', args);
|
1044
|
+
this.resizeCalled = false;
|
1045
|
+
this.lastMouseX = this.lastMouseY = undefined;
|
1046
|
+
this.mOffX = this.mOffY = 0;
|
1047
|
+
this.mainElement = null;
|
1048
|
+
if (this.allowFloating) {
|
1049
|
+
this.moveItemsUpwards();
|
1050
|
+
}
|
1051
|
+
this.updatePanels();
|
1052
|
+
this.updateCloneArrayObject();
|
1053
|
+
this.checkForChanges(true);
|
1054
|
+
}
|
1055
|
+
protected getResizeRowColumn(item: PanelModel): PanelModel {
|
1056
|
+
let isChanged: boolean = false;
|
1057
|
+
let col: number = item.col;
|
1058
|
+
if (['e-west', 'e-south-west'].indexOf(this.handleClass) !== -1) {
|
1059
|
+
col = this.pixelsToColumns(this.elementX, false);
|
1060
|
+
}
|
1061
|
+
let row: number = item.row;
|
1062
|
+
if (['e-north'].indexOf(this.handleClass) !== -1) {
|
1063
|
+
row = this.pixelsToRows(this.elementY, false);
|
1064
|
+
if (this.previousRow !== row) {
|
1065
|
+
this.previousRow = row;
|
1066
|
+
isChanged = true;
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
let sizeX: number = item.sizeX;
|
1070
|
+
if (['e-north', 'e-south'].indexOf(this.handleClass) === -1) {
|
1071
|
+
sizeX = this.pixelsToColumns(this.elementWidth - (sizeX) * this.cellSpacing[1], true);
|
1072
|
+
}
|
1073
|
+
let sizeY: number = item.sizeY;
|
1074
|
+
if (['e-east', 'e-west'].indexOf(this.handleClass) === -1) {
|
1075
|
+
if (this.handleClass === 'e-north' ? isChanged : true) {
|
1076
|
+
sizeY = this.pixelsToRows(this.elementHeight - (sizeY) * this.cellSpacing[0], true);
|
1077
|
+
}
|
1078
|
+
}
|
1079
|
+
if (item.col + item.sizeX > this.columns) {
|
1080
|
+
item.sizeX = item.sizeX - 1;
|
1081
|
+
}
|
1082
|
+
const canOccupy: boolean = row > -1 && col > -1 && sizeX + col <= this.maxCol() && sizeY + row <= this.maxRow();
|
1083
|
+
if (canOccupy && (this.collisions(row, col, sizeX, sizeY, this.getPanelBase(item.id)).length === 0)
|
1084
|
+
|| this.allowPushing !== false) {
|
1085
|
+
this.panelPropertyChange(item, { row: row, col: col, sizeX: sizeX, sizeY: sizeY });
|
1086
|
+
}
|
1087
|
+
return item;
|
1088
|
+
|
1089
|
+
}
|
1090
|
+
protected pixelsToColumns(pixels: number, isCeil: boolean): number {
|
1091
|
+
const curColWidth: number = <number>this.cellSize[0];
|
1092
|
+
if (isCeil) {
|
1093
|
+
return Math.ceil(pixels / curColWidth);
|
1094
|
+
} else {
|
1095
|
+
return Math.floor(pixels / curColWidth);
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
protected pixelsToRows(pixels: number, isCeil: boolean): number {
|
1099
|
+
if (isCeil) {
|
1100
|
+
return Math.round(pixels / <number>this.cellSize[1]);
|
1101
|
+
} else {
|
1102
|
+
return Math.round(pixels / (<number>this.cellSize[1] + this.cellSpacing[0]));
|
1103
|
+
}
|
1104
|
+
}
|
1105
|
+
protected getMinWidth(item: PanelModel): number {
|
1106
|
+
return (((item.minSizeX) * this.getCellSize()[0]) + (item.minSizeX - 1) * this.cellSpacing[0]);
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
protected getMaxWidth(item: PanelModel): number {
|
1110
|
+
return (item.maxSizeX) * this.getCellSize()[0];
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
protected getMinHeight(item: PanelModel): number {
|
1114
|
+
return (((item.minSizeY) * this.getCellSize()[1]) + (item.minSizeY - 1) * this.cellSpacing[1]);
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
protected getMaxHeight(item: PanelModel): number {
|
1118
|
+
return (item.maxSizeY) * this.getCellSize()[1];
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
protected sortedPanel(): void {
|
1122
|
+
this.sortedArray = [];
|
1123
|
+
for (let i: number = 0, l: number = this.panelCollection.length; i < l; ++i) {
|
1124
|
+
this.sortItem(this.panelCollection[i]);
|
1125
|
+
}
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
protected moveItemsUpwards(): void {
|
1129
|
+
if (this.allowFloating === false) {
|
1130
|
+
return;
|
1131
|
+
}
|
1132
|
+
for (let rowIndex: number = 0, l: number = this.sortedArray.length; rowIndex < l; ++rowIndex) {
|
1133
|
+
const columns: HTMLElement[] = this.sortedArray[rowIndex];
|
1134
|
+
if (!columns) {
|
1135
|
+
continue;
|
1136
|
+
}
|
1137
|
+
for (let colIndex: number = 0, len: number = columns.length; colIndex < len; ++colIndex) {
|
1138
|
+
const item: HTMLElement = columns[colIndex];
|
1139
|
+
if (item) {
|
1140
|
+
this.moveItemUpwards(item);
|
1141
|
+
}
|
1142
|
+
}
|
1143
|
+
}
|
1144
|
+
this.updateGridLines();
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
protected moveItemUpwards(item: HTMLElement): void {
|
1148
|
+
if (this.allowFloating === false || item === this.mainElement) {
|
1149
|
+
return;
|
1150
|
+
}
|
1151
|
+
const colIndex: number = this.getCellInstance(item.id).col;
|
1152
|
+
const sizeY: number = parseInt(item.getAttribute('data-sizeY'), 10);
|
1153
|
+
const sizeX: number = parseInt(item.getAttribute('data-sizeX'), 10);
|
1154
|
+
let availableRow: number = null;
|
1155
|
+
let availableColumn: number = null;
|
1156
|
+
let rowIndex: number = parseInt(item.getAttribute('data-row'), 10) - 1;
|
1157
|
+
while (rowIndex > -1) {
|
1158
|
+
const items: HTMLElement[] = this.collisions(rowIndex, colIndex, sizeX, sizeY, item);
|
1159
|
+
if (items.length !== 0) {
|
1160
|
+
break;
|
1161
|
+
}
|
1162
|
+
availableRow = rowIndex;
|
1163
|
+
availableColumn = colIndex;
|
1164
|
+
--rowIndex;
|
1165
|
+
}
|
1166
|
+
if (availableRow !== null) {
|
1167
|
+
this.sortItem(item, availableRow, availableColumn);
|
1168
|
+
}
|
1169
|
+
}
|
1170
|
+
|
1171
|
+
private sortItem(item: HTMLElement, rowValue?: number, columnValue?: number): void {
|
1172
|
+
this.overlapElement = [];
|
1173
|
+
const column: number = parseInt((<HTMLElement>item).getAttribute('data-col'), 10);
|
1174
|
+
const row: number = parseInt((<HTMLElement>item).getAttribute('data-row'), 10);
|
1175
|
+
if (!this.sortedArray[row]) {
|
1176
|
+
this.sortedArray[row] = [];
|
1177
|
+
}
|
1178
|
+
this.sortedArray[row][column] = item;
|
1179
|
+
if (item !== undefined && rowValue !== undefined && columnValue !== undefined) {
|
1180
|
+
if (this.oldRowCol[item.id] !== undefined && this.oldRowCol[item.id].row !== null &&
|
1181
|
+
typeof this.oldRowCol[item.id].col !== 'undefined') {
|
1182
|
+
{
|
1183
|
+
const oldRow: HTMLElement[] = this.sortedArray[this.oldRowCol[item.id].row];
|
1184
|
+
if (this.oldRowCol[item.id] && oldRow[this.oldRowCol[item.id].col] === item) {
|
1185
|
+
delete oldRow[this.oldRowCol[item.id].col];
|
1186
|
+
this.updateOldRowColumn();
|
1187
|
+
this.sortedPanel();
|
1188
|
+
}
|
1189
|
+
}
|
1190
|
+
}
|
1191
|
+
this.oldRowCol[item.id].row = rowValue;
|
1192
|
+
this.oldRowCol[item.id].row = columnValue;
|
1193
|
+
if (!this.sortedArray[row]) {
|
1194
|
+
this.sortedArray[row] = [];
|
1195
|
+
}
|
1196
|
+
this.sortedArray[row][column] = item;
|
1197
|
+
if (this.allItems.indexOf(item) === -1) {
|
1198
|
+
this.allItems.push(item);
|
1199
|
+
}
|
1200
|
+
this.panelPropertyChange(this.getCellInstance(item.id), { row: rowValue, col: columnValue });
|
1201
|
+
const panelModel: PanelModel = this.getCellInstance(item.id);
|
1202
|
+
this.setAttributes({ value: { col: panelModel.col.toString(), row: panelModel.row.toString() } }, item);
|
1203
|
+
this.updateLayout(item, this.getCellInstance(item.id));
|
1204
|
+
}
|
1205
|
+
}
|
1206
|
+
|
1207
|
+
protected updateLayout(element: HTMLElement, panelModel: PanelModel): void {
|
1208
|
+
this.setPanelPosition(element, panelModel.row, panelModel.col);
|
1209
|
+
this.setHeightAndWidth(element, panelModel);
|
1210
|
+
this.updateRowHeight();
|
1211
|
+
this.sortedPanel();
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
public refresh(): void {
|
1215
|
+
this.panelsSizeY = 0;
|
1216
|
+
this.updateDragArea();
|
1217
|
+
if (this.checkMediaQuery()) {
|
1218
|
+
this.checkMediaQuerySizing();
|
1219
|
+
} else {
|
1220
|
+
if (this.element.classList.contains(responsive)) {
|
1221
|
+
removeClass([this.element], [responsive]);
|
1222
|
+
const internalPanels : any = this.element.querySelectorAll(((this.element.id) ? '#' + this.element.id + ' > ' : '') + '.e-panel');
|
1223
|
+
for (let i: number = 0; i < internalPanels.length; i++) {
|
1224
|
+
const ele: HTMLElement = internalPanels[i];
|
1225
|
+
const cellInstance: PanelModel = this.getCellInstance(ele.id);
|
1226
|
+
const row: number = parseInt(ele.getAttribute('data-row'), 10);
|
1227
|
+
const col: number = parseInt(ele.getAttribute('data-col'), 10);
|
1228
|
+
this.panelPropertyChange(cellInstance, { row: row, col: col });
|
1229
|
+
this.setHeightAndWidth(ele, this.getCellInstance(ele.id));
|
1230
|
+
this.setPanelPosition(ele, row, col);
|
1231
|
+
this.updateRowHeight();
|
1232
|
+
}
|
1233
|
+
}
|
1234
|
+
this.panelResponsiveUpdate();
|
1235
|
+
this.updateGridLines();
|
1236
|
+
}
|
1237
|
+
this.removeResizeClasses(this.panelCollection);
|
1238
|
+
this.setClasses(this.panelCollection);
|
1239
|
+
this.resizeEvents();
|
1240
|
+
this.checkDragging(this.dragCollection);
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
protected updateGridLines(): void {
|
1244
|
+
if (this.element.querySelector('.e-dashboard-gridline-table')) {
|
1245
|
+
if (this.table) {
|
1246
|
+
detach(this.table);
|
1247
|
+
}
|
1248
|
+
this.initGridLines();
|
1249
|
+
}
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
protected checkDragging(dragCollection: Draggable[]): void {
|
1253
|
+
if (this.checkMediaQuery() || !this.allowDragging) {
|
1254
|
+
for (let i: number = 0; i < dragCollection.length; i++) {
|
1255
|
+
dragCollection[i].destroy();
|
1256
|
+
}
|
1257
|
+
} else {
|
1258
|
+
for (let i: number = 0; i < dragCollection.length; i++) {
|
1259
|
+
dragCollection[i].destroy();
|
1260
|
+
}
|
1261
|
+
this.enableDraggingContent(this.panelCollection);
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
protected sortPanels(): PanelModel[] {
|
1267
|
+
const model: PanelModel[] = [];
|
1268
|
+
for (let row: number = 0; row <= this.rows; row++) {
|
1269
|
+
for (let col: number = 0; col < this.columns; col++) {
|
1270
|
+
this.panels.filter((panel: PanelModel) => {
|
1271
|
+
if (panel.row === row && panel.col === col) {
|
1272
|
+
model.push(panel);
|
1273
|
+
}
|
1274
|
+
});
|
1275
|
+
}
|
1276
|
+
}
|
1277
|
+
return model;
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
protected checkMediaQuerySizing(): void {
|
1281
|
+
addClass([this.element], [responsive]);
|
1282
|
+
let updatedPanel: PanelModel[];
|
1283
|
+
if (this.isPanelRemoved && this.panels) {
|
1284
|
+
updatedPanel = this.panels;
|
1285
|
+
} else {
|
1286
|
+
updatedPanel = this.sortPanels();
|
1287
|
+
}
|
1288
|
+
this.updatedRows = updatedPanel.length;
|
1289
|
+
for (let i: number = 0; i < updatedPanel.length; i++) {
|
1290
|
+
const panelElement: HTMLElement = document.getElementById(updatedPanel[i].id);
|
1291
|
+
// eslint-disable-next-line
|
1292
|
+
let updatedHeight: any;
|
1293
|
+
if (panelElement) {
|
1294
|
+
setStyle(<HTMLElement>panelElement, { 'width': '100%' });
|
1295
|
+
(<HTMLElement>panelElement).style.height = ' ' + ((this.element.parentElement
|
1296
|
+
&& this.element.parentElement.offsetWidth / this.cellAspectRatio) * updatedPanel[i].sizeY) + 'px';
|
1297
|
+
if (updatedPanel[i].sizeY > 1) {
|
1298
|
+
updatedHeight = ((this.element.parentElement
|
1299
|
+
&& this.element.parentElement.offsetWidth / this.cellAspectRatio) * updatedPanel[i].sizeY) +
|
1300
|
+
// eslint-disable-next-line radix
|
1301
|
+
parseInt((Math.round(updatedPanel[i].sizeY / 2) * this.cellSpacing[1]).toString(), 0);
|
1302
|
+
(<HTMLElement>panelElement).style.height = '' + updatedHeight + 'px';
|
1303
|
+
}
|
1304
|
+
this.resizeHeight = true;
|
1305
|
+
this.panelPropertyChange(updatedPanel[i], { row: i, col: 0 });
|
1306
|
+
this.setPanelPosition(<HTMLElement>panelElement, updatedPanel[i].row, updatedPanel[i].col);
|
1307
|
+
this.panelsSizeY = this.panelsSizeY + updatedPanel[i].sizeY;
|
1308
|
+
this.setClasses(this.panelCollection);
|
1309
|
+
this.checkDragging(this.dragCollection);
|
1310
|
+
this.removeResizeClasses(this.panelCollection);
|
1311
|
+
}
|
1312
|
+
}
|
1313
|
+
this.updateRowHeight();
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
protected panelResponsiveUpdate(): void {
|
1317
|
+
this.element.classList.add('e-responsive');
|
1318
|
+
this.calculateCellSize();
|
1319
|
+
for (let i: number = 0; i < this.element.querySelectorAll('.e-panel').length; i++) {
|
1320
|
+
const ele: Element = this.element.querySelectorAll('.e-panel')[i];
|
1321
|
+
const panelModel: PanelModel = this.getCellInstance(ele.id);
|
1322
|
+
this.setHeightAndWidth(<HTMLElement>ele, panelModel);
|
1323
|
+
}
|
1324
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
1325
|
+
this.setPanelPosition(document.getElementById(this.panels[i].id), this.panels[i].row, this.panels[i].col);
|
1326
|
+
}
|
1327
|
+
this.updateRowHeight();
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
protected updateRowHeight(): void {
|
1331
|
+
this.getRowColumn();
|
1332
|
+
this.setHeightWidth();
|
1333
|
+
}
|
1334
|
+
|
1335
|
+
protected setHeightWidth(): void {
|
1336
|
+
let heightValue: string;
|
1337
|
+
let widthValue: string;
|
1338
|
+
if (this.checkMediaQuery()) {
|
1339
|
+
let entirePanelsY: number = 0;
|
1340
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
1341
|
+
if (this.panels[i].sizeY) {
|
1342
|
+
entirePanelsY += this.panels[i].sizeY;
|
1343
|
+
}
|
1344
|
+
}
|
1345
|
+
heightValue = ((entirePanelsY) *
|
1346
|
+
(this.element.parentElement && ((this.element.parentElement.offsetWidth)) / this.cellAspectRatio) +
|
1347
|
+
(entirePanelsY - 1) * this.cellSpacing[1]) + 'px';
|
1348
|
+
} else {
|
1349
|
+
heightValue = ((this.maxRow()) *
|
1350
|
+
(<number>this.cellSize[0] / this.cellAspectRatio) + (this.maxRow() - 1) * this.cellSpacing[1]) + 'px';
|
1351
|
+
}
|
1352
|
+
setStyle(this.element, { 'height': heightValue });
|
1353
|
+
// eslint-disable-next-line prefer-const
|
1354
|
+
widthValue = window.getComputedStyle(this.element).width;
|
1355
|
+
setStyle(this.element, { 'width': widthValue });
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
protected setHeightAndWidth(panelElement: HTMLElement, panelModel: PanelModel): void {
|
1359
|
+
setStyle(panelElement, { 'height': formatUnit(this.setXYDimensions(panelModel)[0]) });
|
1360
|
+
setStyle(panelElement, { 'width': formatUnit(this.setXYDimensions(panelModel)[1]) });
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
protected renderCell(panel: PanelModel, isStringTemplate: boolean, index: number): HTMLElement {
|
1364
|
+
let cellElement: HTMLElement;
|
1365
|
+
this.dimensions = this.setXYDimensions(panel);
|
1366
|
+
if (isUndefined(panel.enabled)) {
|
1367
|
+
panel.enabled = true;
|
1368
|
+
}
|
1369
|
+
if (this.contentTemplateChild.length > 0 && !isNullOrUndefined(index)) {
|
1370
|
+
cellElement = this.contentTemplateChild[index];
|
1371
|
+
if (panel.cssClass) { addClass([cellElement], [panel.cssClass]); }
|
1372
|
+
if (panel.id) { cellElement.setAttribute('id', panel.id); }
|
1373
|
+
} else {
|
1374
|
+
cellElement = this.createPanelElement(panel.cssClass ? panel.cssClass.split(' ') : null, panel.id);
|
1375
|
+
}
|
1376
|
+
cellElement.style.zIndex = '' + panel.zIndex;
|
1377
|
+
this.element.appendChild(cellElement);
|
1378
|
+
this.renderReactTemplates();
|
1379
|
+
const dashBoardCell: HTMLElement = this.renderPanels(cellElement, panel, panel.id, isStringTemplate);
|
1380
|
+
this.panelCollection.push(dashBoardCell);
|
1381
|
+
this.setXYAttributes(cellElement, panel);
|
1382
|
+
this.setHeightAndWidth(cellElement, panel);
|
1383
|
+
return cellElement;
|
1384
|
+
}
|
1385
|
+
|
1386
|
+
protected setPanelPosition(cellElement: HTMLElement, row: number, col: number): void {
|
1387
|
+
if (!cellElement) {
|
1388
|
+
return;
|
1389
|
+
}
|
1390
|
+
if (this.checkMediaQuery()) {
|
1391
|
+
this.calculateCellSize();
|
1392
|
+
}
|
1393
|
+
const heightValue: number | string = this.getCellSize()[1];
|
1394
|
+
const widthValue: number | string = this.getCellSize()[0];
|
1395
|
+
const left: number = col === 0 ? 0 : (((col) * ((widthValue) + this.cellSpacing[0])));
|
1396
|
+
let top: number = row === 0 ? 0 : (((row) * ((heightValue) + this.cellSpacing[1])));
|
1397
|
+
if (this.checkMediaQuery()) {
|
1398
|
+
top = row === 0 ? 0 : ((this.panelsSizeY) * ((heightValue) + this.cellSpacing[1]));
|
1399
|
+
}
|
1400
|
+
setStyle(cellElement, { 'left': left + 'px', 'top': top + 'px' });
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
protected getRowColumn(): void {
|
1404
|
+
this.rows = null;
|
1405
|
+
if (this.element.querySelectorAll('.e-panel').length > 0 && !this.updatedRows) {
|
1406
|
+
const panelElements: NodeList = this.element.querySelectorAll('.e-panel');
|
1407
|
+
for (let i: number = 0; i < panelElements.length; i++) {
|
1408
|
+
const panelElement: HTMLElement = <HTMLElement>panelElements[i];
|
1409
|
+
const rowValue: number = parseInt(panelElement.getAttribute('data-row'), 10);
|
1410
|
+
const xValue: number = parseInt(panelElement.getAttribute('data-sizeY'), 10);
|
1411
|
+
this.rows = Math.max(this.rows, (rowValue + xValue));
|
1412
|
+
}
|
1413
|
+
} else {
|
1414
|
+
if (this.updatedRows) {
|
1415
|
+
this.rows = this.updatedRows;
|
1416
|
+
this.updatedRows = null;
|
1417
|
+
}
|
1418
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
1419
|
+
this.rows = Math.max(this.rows, this.panels[i].row);
|
1420
|
+
}
|
1421
|
+
}
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
protected setMinMaxValues(panel: PanelModel): void {
|
1425
|
+
if (!panel.sizeX || panel.sizeX < panel.minSizeX) {
|
1426
|
+
this.panelPropertyChange(panel, { sizeX: panel.minSizeX });
|
1427
|
+
} else if ((panel.maxSizeX && panel.sizeX > panel.maxSizeX)) {
|
1428
|
+
this.panelPropertyChange(panel, { sizeX: panel.maxSizeX });
|
1429
|
+
} else if (panel.sizeX > this.columns) {
|
1430
|
+
this.panelPropertyChange(panel, { sizeX: this.columns });
|
1431
|
+
} else {
|
1432
|
+
this.panelPropertyChange(panel, { sizeX: panel.sizeX });
|
1433
|
+
}
|
1434
|
+
if (!panel.sizeY || panel.sizeY < panel.minSizeY) {
|
1435
|
+
this.panelPropertyChange(panel, { sizeY: panel.minSizeY });
|
1436
|
+
} else if (panel.maxSizeY && panel.sizeY > panel.maxSizeY) {
|
1437
|
+
this.panelPropertyChange(panel, { sizeY: panel.maxSizeY });
|
1438
|
+
} else {
|
1439
|
+
this.panelPropertyChange(panel, { sizeY: panel.sizeY });
|
1440
|
+
}
|
1441
|
+
}
|
1442
|
+
|
1443
|
+
protected checkMinMaxValues(panel: PanelModel): void {
|
1444
|
+
if (panel.col + panel.sizeX > this.columns) {
|
1445
|
+
this.panelPropertyChange(panel, { sizeX: panel.sizeX + (this.columns - (panel.col + panel.sizeX)) });
|
1446
|
+
}
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
protected panelPropertyChange(panel: PanelModel, value: IChangePanel): void {
|
1450
|
+
// eslint-disable-next-line
|
1451
|
+
(panel as any).setProperties(value, true);
|
1452
|
+
}
|
1453
|
+
|
1454
|
+
protected renderDashBoardCells(cells: PanelModel[]): void {
|
1455
|
+
if (this.element.querySelectorAll('.e-panel').length > 0 || this.panels.length > 0) {
|
1456
|
+
for (let j: number = 0; j < cells.length; j++) {
|
1457
|
+
this.gridPanelCollection.push(<HTMLElement>cells[j]);
|
1458
|
+
this.setMinMaxValues(cells[j]);
|
1459
|
+
if (this.maxColumnValue < cells[j].col || this.maxColumnValue < (cells[j].col + cells[j].sizeX)) {
|
1460
|
+
this.panelPropertyChange(cells[j], { col: this.maxColumnValue - cells[j].sizeX });
|
1461
|
+
}
|
1462
|
+
const cell: HTMLElement = this.renderCell(cells[j], false, j);
|
1463
|
+
if (this.enableRtl) {
|
1464
|
+
addClass([cell], 'e-rtl');
|
1465
|
+
}
|
1466
|
+
this.element.appendChild(cell);
|
1467
|
+
this.renderReactTemplates();
|
1468
|
+
if (this.checkMediaQuery() && j === cells.length - 1) {
|
1469
|
+
this.checkMediaQuerySizing();
|
1470
|
+
} else {
|
1471
|
+
this.setPanelPosition(cell, cells[j].row, cells[j].col);
|
1472
|
+
this.mainElement = cell;
|
1473
|
+
this.updatePanelLayout(cell, cells[j]);
|
1474
|
+
this.mainElement = null;
|
1475
|
+
}
|
1476
|
+
}
|
1477
|
+
}
|
1478
|
+
this.setClasses(this.panelCollection);
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
protected collisions(row: number, col: number, sizeX: number, sizeY: number, ignore: HTMLElement[] | HTMLElement): HTMLElement[] {
|
1482
|
+
const items: HTMLElement[] = [];
|
1483
|
+
if (!sizeX || !sizeY) {
|
1484
|
+
sizeX = sizeY = 1;
|
1485
|
+
}
|
1486
|
+
if (ignore && !(ignore instanceof Array)) {
|
1487
|
+
ignore = [ignore];
|
1488
|
+
}
|
1489
|
+
let item: PanelModel;
|
1490
|
+
for (let h: number = 0; h < sizeY; ++h) {
|
1491
|
+
for (let w: number = 0; w < sizeX; ++w) {
|
1492
|
+
item = this.getPanel(row + h, col + w, ignore);
|
1493
|
+
if (item && (!ignore || (<HTMLElement[]>ignore).indexOf(document.getElementById(item.id)) === -1) &&
|
1494
|
+
(<HTMLElement[]>items).indexOf(document.getElementById(item.id)) === -1) {
|
1495
|
+
items.push(document.getElementById(item.id));
|
1496
|
+
}
|
1497
|
+
}
|
1498
|
+
}
|
1499
|
+
return items;
|
1500
|
+
}
|
1501
|
+
|
1502
|
+
protected rightWardsSpaceChecking(rowElements: HTMLElement[], col: number, ele: HTMLElement): number[] {
|
1503
|
+
const columns: number[] = [];
|
1504
|
+
let spacedColumns: number[] = [];
|
1505
|
+
rowElements.forEach((element: HTMLElement) => {
|
1506
|
+
const columnValue: number = parseInt(element.getAttribute('data-col'), 10);
|
1507
|
+
const sizeXValue: number = parseInt(element.getAttribute('data-sizeX'), 10);
|
1508
|
+
if (col < this.columns && columnValue >= col) {
|
1509
|
+
if (sizeXValue > 1) {
|
1510
|
+
for (let i: number = columnValue; i < columnValue + sizeXValue; i++) {
|
1511
|
+
columns.push(i);
|
1512
|
+
}
|
1513
|
+
} else {
|
1514
|
+
columns.push(columnValue);
|
1515
|
+
}
|
1516
|
+
}
|
1517
|
+
});
|
1518
|
+
if (columns.length > 0) {
|
1519
|
+
for (let i: number = col + 1; i <= this.columns - 1; i++) {
|
1520
|
+
if (columns.indexOf(i) === -1 && i !== col) {
|
1521
|
+
if (spacedColumns.indexOf(i) === -1) {
|
1522
|
+
spacedColumns.push(i);
|
1523
|
+
}
|
1524
|
+
}
|
1525
|
+
}
|
1526
|
+
}
|
1527
|
+
const occupiedValues: number[] = this.getOccupiedColumns(ele);
|
1528
|
+
occupiedValues.forEach((colValue: number) => {
|
1529
|
+
if (colValue > col && spacedColumns.indexOf(colValue) !== -1) {
|
1530
|
+
spacedColumns.splice(spacedColumns.indexOf(colValue), 1);
|
1531
|
+
}
|
1532
|
+
});
|
1533
|
+
const eleOccupiedValues: number[] = this.getOccupiedColumns(this.checkingElement);
|
1534
|
+
eleOccupiedValues.forEach((col: number) => {
|
1535
|
+
if (col > parseInt(ele.getAttribute('data-col'), 10) && occupiedValues.indexOf(col) === -1 &&
|
1536
|
+
spacedColumns.indexOf(col) === -1) {
|
1537
|
+
spacedColumns.push(col);
|
1538
|
+
}
|
1539
|
+
});
|
1540
|
+
spacedColumns = spacedColumns.sort((next: number, previous: number) => { return next - previous; });
|
1541
|
+
return spacedColumns;
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
protected getOccupiedColumns(element: HTMLElement): number[] {
|
1545
|
+
const occupiedItems: number[] = [];
|
1546
|
+
const sizeX: number = parseInt(element.getAttribute('data-sizeX'), 10);
|
1547
|
+
const col: number = parseInt(element.getAttribute('data-col'), 10);
|
1548
|
+
for (let i: number = col; (i < col + sizeX && i <= this.columns); i++) {
|
1549
|
+
occupiedItems.push(i);
|
1550
|
+
}
|
1551
|
+
return occupiedItems;
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
protected leftWardsSpaceChecking(rowElements: HTMLElement[], col: number, ele: HTMLElement): number[] {
|
1555
|
+
let spacedColumns: number[] = [];
|
1556
|
+
const columns: number[] = [];
|
1557
|
+
rowElements.forEach((element: HTMLElement) => {
|
1558
|
+
const colValue: number = parseInt(element.getAttribute('data-col'), 10);
|
1559
|
+
const xValue: number = parseInt(element.getAttribute('data-sizeX'), 10);
|
1560
|
+
if (col <= this.columns && colValue <= col) {
|
1561
|
+
if (xValue > 1) {
|
1562
|
+
for (let i: number = colValue; i < colValue + xValue; i++) {
|
1563
|
+
columns.push(i);
|
1564
|
+
}
|
1565
|
+
} else {
|
1566
|
+
columns.push(colValue);
|
1567
|
+
}
|
1568
|
+
}
|
1569
|
+
});
|
1570
|
+
if (columns.length > 0) {
|
1571
|
+
for (let j: number = 0; j <= col; j++) {
|
1572
|
+
if (columns.indexOf(j) === -1 && j !== col) {
|
1573
|
+
if (spacedColumns.indexOf(j) === -1) {
|
1574
|
+
spacedColumns.push(j);
|
1575
|
+
}
|
1576
|
+
}
|
1577
|
+
}
|
1578
|
+
}
|
1579
|
+
const occupiedValues: number[] = this.getOccupiedColumns(ele);
|
1580
|
+
occupiedValues.forEach((colValue: number) => {
|
1581
|
+
if (colValue < col && spacedColumns.indexOf(colValue) !== -1) {
|
1582
|
+
spacedColumns.splice(spacedColumns.indexOf(colValue), 1);
|
1583
|
+
}
|
1584
|
+
});
|
1585
|
+
const eleOccupiedValues: number[] = this.getOccupiedColumns(this.checkingElement);
|
1586
|
+
eleOccupiedValues.forEach((col: number) => {
|
1587
|
+
if (col < parseInt(ele.getAttribute('data-col'), 10) && occupiedValues.indexOf(col) === -1 &&
|
1588
|
+
spacedColumns.indexOf(col) === -1) {
|
1589
|
+
spacedColumns.push(col);
|
1590
|
+
}
|
1591
|
+
});
|
1592
|
+
spacedColumns = spacedColumns.sort((next: number, prev: number) => { return next - prev; });
|
1593
|
+
spacedColumns = spacedColumns.reverse();
|
1594
|
+
return spacedColumns;
|
1595
|
+
}
|
1596
|
+
|
1597
|
+
protected adjustmentAvailable(row: number, col: number, sizeY: number, sizeX: number, ele: HTMLElement): boolean {
|
1598
|
+
this.leftAdjustable = undefined;
|
1599
|
+
this.rightAdjustable = undefined;
|
1600
|
+
let isAdjustable: boolean = false;
|
1601
|
+
let rightSpacing: number[];
|
1602
|
+
let rowElement: HTMLElement[] = [];
|
1603
|
+
this.topAdjustable = undefined;
|
1604
|
+
const eleSizeX: number = parseInt(ele.getAttribute('data-sizeX'), 10);
|
1605
|
+
const eleCol: number = parseInt(ele.getAttribute('data-col'), 10);
|
1606
|
+
rowElement = this.getRowElements(this.collisions(row, 0, this.columns, sizeY, []));
|
1607
|
+
if (rowElement.indexOf(ele) === -1) {
|
1608
|
+
rowElement.push(ele);
|
1609
|
+
}
|
1610
|
+
const leftSpacing: number[] = this.leftWardsSpaceChecking(rowElement, col, ele);
|
1611
|
+
if (leftSpacing.length > 0) {
|
1612
|
+
this.leftAdjustable = this.isLeftAdjustable(leftSpacing, ele, row, col, sizeX, sizeY);
|
1613
|
+
if (this.spacedColumnValue !== eleCol - this.getCellInstance(this.checkingElement.id).sizeX) {
|
1614
|
+
this.leftAdjustable = false;
|
1615
|
+
}
|
1616
|
+
if (this.leftAdjustable) {
|
1617
|
+
this.rightAdjustable = false;
|
1618
|
+
} else {
|
1619
|
+
this.leftAdjustable = false;
|
1620
|
+
rightSpacing = this.rightWardsSpaceChecking(rowElement, col, ele);
|
1621
|
+
this.rightAdjustable = rightSpacing.length > 0 ? this.isRightAdjustable(rightSpacing, ele, row, col, sizeX, sizeY) : false;
|
1622
|
+
if (this.spacedColumnValue !== eleSizeX + eleCol) {
|
1623
|
+
this.rightAdjustable = false;
|
1624
|
+
}
|
1625
|
+
if (!this.rightAdjustable) {
|
1626
|
+
this.rightAdjustable = false;
|
1627
|
+
}
|
1628
|
+
}
|
1629
|
+
} else {
|
1630
|
+
rightSpacing = this.rightWardsSpaceChecking(rowElement, col, ele);
|
1631
|
+
this.rightAdjustable = rightSpacing.length > 0 ? this.isRightAdjustable(rightSpacing, ele, row, col, sizeX, sizeY) : false;
|
1632
|
+
if (this.spacedColumnValue !== eleSizeX + eleCol) {
|
1633
|
+
this.rightAdjustable = false;
|
1634
|
+
}
|
1635
|
+
if (this.rightAdjustable) {
|
1636
|
+
this.leftAdjustable = false;
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
if (!this.rightAdjustable && !this.leftAdjustable && row > 0) {
|
1640
|
+
const endRow: number = this.getCellInstance(ele.id).row;
|
1641
|
+
let topCheck: boolean = false;
|
1642
|
+
if (this.startRow !== endRow) {
|
1643
|
+
topCheck = true;
|
1644
|
+
}
|
1645
|
+
for (let rowValue: number = row; rowValue >= 0; rowValue--) {
|
1646
|
+
const element: HTMLElement = (this.getCellInstance(ele.id).sizeY > 1 && topCheck) ? this.checkingElement : ele;
|
1647
|
+
if ((rowValue !== endRow) && (rowValue === endRow - sizeY) &&
|
1648
|
+
this.collisions(rowValue, col, sizeX, sizeY, element).length === 0) {
|
1649
|
+
topCheck = false;
|
1650
|
+
this.topAdjustable = true;
|
1651
|
+
this.spacedRowValue = isNullOrUndefined(this.spacedRowValue) ? rowValue : this.spacedRowValue;
|
1652
|
+
this.spacedColumnValue = col;
|
1653
|
+
}
|
1654
|
+
}
|
1655
|
+
}
|
1656
|
+
if (this.rightAdjustable || this.leftAdjustable || this.topAdjustable) {
|
1657
|
+
isAdjustable = true;
|
1658
|
+
if (isNullOrUndefined(this.spacedRowValue)) {
|
1659
|
+
this.spacedRowValue = row;
|
1660
|
+
}
|
1661
|
+
}
|
1662
|
+
return isAdjustable;
|
1663
|
+
}
|
1664
|
+
|
1665
|
+
protected isXSpacingAvailable(spacing: number[], sizeX?: number): boolean {
|
1666
|
+
let isSpaceAvailable: boolean = false;
|
1667
|
+
let subSpacingColumns: number[] = [];
|
1668
|
+
for (let i: number = 0; i < spacing.length; i++) {
|
1669
|
+
if (spacing[i + 1] - spacing[i] === 1 || spacing[i + 1] - spacing[i] === -1) {
|
1670
|
+
subSpacingColumns.push(spacing[i]);
|
1671
|
+
if (sizeX === 2) {
|
1672
|
+
subSpacingColumns.push(spacing[i + 1]);
|
1673
|
+
}
|
1674
|
+
if (i === spacing.length - 2) {
|
1675
|
+
subSpacingColumns.push(spacing[i + 1]);
|
1676
|
+
if (subSpacingColumns.length > sizeX) {
|
1677
|
+
subSpacingColumns.splice(-1);
|
1678
|
+
}
|
1679
|
+
}
|
1680
|
+
if (subSpacingColumns.length === sizeX) {
|
1681
|
+
isSpaceAvailable = true;
|
1682
|
+
this.spacedColumnValue = subSpacingColumns.sort((next: number, previous: number) => { return next - previous; })[0];
|
1683
|
+
if (this.spacedColumnValue < 0) {
|
1684
|
+
this.spacedColumnValue = 1;
|
1685
|
+
}
|
1686
|
+
return isSpaceAvailable;
|
1687
|
+
}
|
1688
|
+
} else {
|
1689
|
+
subSpacingColumns = [];
|
1690
|
+
continue;
|
1691
|
+
}
|
1692
|
+
}
|
1693
|
+
return isSpaceAvailable;
|
1694
|
+
}
|
1695
|
+
|
1696
|
+
protected getRowElements(base: HTMLElement[]): HTMLElement[] {
|
1697
|
+
const rowElements: HTMLElement[] = [];
|
1698
|
+
for (let i: number = 0; i < base.length; i++) {
|
1699
|
+
rowElements.push(base[i]);
|
1700
|
+
}
|
1701
|
+
return rowElements;
|
1702
|
+
}
|
1703
|
+
protected isLeftAdjustable(spaces: number[], ele: HTMLElement, row: number, col: number, sizeX: number, sizeY: number): boolean {
|
1704
|
+
let isLeftAdjudtable: boolean;
|
1705
|
+
if (sizeX === 1 && sizeY === 1 && spaces.length > 0) {
|
1706
|
+
this.spacedColumnValue = spaces[0];
|
1707
|
+
isLeftAdjudtable = true;
|
1708
|
+
} else if (sizeX > 1 && sizeY === 1) {
|
1709
|
+
isLeftAdjudtable = this.isXSpacingAvailable(spaces, sizeX);
|
1710
|
+
} else if (sizeY > 1) {
|
1711
|
+
if (sizeX === 1) {
|
1712
|
+
let xAdjust: boolean;
|
1713
|
+
if (spaces.length >= 1) {
|
1714
|
+
xAdjust = true;
|
1715
|
+
}
|
1716
|
+
if (xAdjust) {
|
1717
|
+
for (let i: number = 0; i < spaces.length; i++) {
|
1718
|
+
const collisionValue: HTMLElement[] = this.collisions(row, spaces[i], sizeX, sizeY, this.checkingElement);
|
1719
|
+
if (collisionValue.length === 0) {
|
1720
|
+
this.spacedColumnValue = spaces[i];
|
1721
|
+
isLeftAdjudtable = true;
|
1722
|
+
return isLeftAdjudtable;
|
1723
|
+
} else {
|
1724
|
+
isLeftAdjudtable = false;
|
1725
|
+
}
|
1726
|
+
}
|
1727
|
+
}
|
1728
|
+
} else {
|
1729
|
+
isLeftAdjudtable = this.replacable(spaces, sizeX, row, sizeY, ele);
|
1730
|
+
}
|
1731
|
+
}
|
1732
|
+
return isLeftAdjudtable;
|
1733
|
+
}
|
1734
|
+
|
1735
|
+
protected isRightAdjustable(spacing: number[], ele: HTMLElement, row: number, col: number, sizeX: number, sizeY: number): boolean {
|
1736
|
+
let isRightAdjudtable: boolean;
|
1737
|
+
if (sizeX === 1 && sizeY === 1 && spacing.length > 0) {
|
1738
|
+
this.spacedColumnValue = spacing[0];
|
1739
|
+
isRightAdjudtable = true;
|
1740
|
+
} else if (sizeX > 1 && sizeY === 1) {
|
1741
|
+
isRightAdjudtable = this.isXSpacingAvailable(spacing, sizeX);
|
1742
|
+
} else if (sizeY > 1) {
|
1743
|
+
if (sizeX === 1) {
|
1744
|
+
let xAdjust: boolean;
|
1745
|
+
if (spacing.length >= 1) {
|
1746
|
+
xAdjust = true;
|
1747
|
+
}
|
1748
|
+
if (xAdjust) {
|
1749
|
+
for (let i: number = 0; i < spacing.length; i++) {
|
1750
|
+
const collisionValue: HTMLElement[] = this.collisions(row, spacing[i], sizeX, sizeY, this.checkingElement);
|
1751
|
+
for (let collision: number = 0; collision < collisionValue.length; collision++) {
|
1752
|
+
if (parseInt(ele.getAttribute('data-col'), 10) !== spacing[i]) {
|
1753
|
+
collisionValue.splice(collisionValue.indexOf(collisionValue[collision]), 1);
|
1754
|
+
}
|
1755
|
+
}
|
1756
|
+
if (collisionValue.length === 0) {
|
1757
|
+
isRightAdjudtable = true;
|
1758
|
+
this.spacedColumnValue = spacing[i];
|
1759
|
+
return isRightAdjudtable;
|
1760
|
+
} else {
|
1761
|
+
isRightAdjudtable = false;
|
1762
|
+
}
|
1763
|
+
}
|
1764
|
+
}
|
1765
|
+
} else {
|
1766
|
+
isRightAdjudtable = this.replacable(spacing, sizeX, row, sizeY, ele);
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
return isRightAdjudtable;
|
1770
|
+
}
|
1771
|
+
protected replacable(spacing: number[], sizeX: number, row: number, sizeY: number, ele: HTMLElement): boolean {
|
1772
|
+
let isRightAdjudtable: boolean;
|
1773
|
+
const updatedCollision: HTMLElement[] = [];
|
1774
|
+
for (let j: number = 0; j < spacing.length; j++) {
|
1775
|
+
const xAdjust: boolean = this.isXSpacingAvailable(spacing, sizeX);
|
1776
|
+
if (xAdjust) {
|
1777
|
+
const exclusions: HTMLElement[] = [];
|
1778
|
+
exclusions.push(this.checkingElement);
|
1779
|
+
exclusions.push(ele);
|
1780
|
+
if (updatedCollision.length === 0) {
|
1781
|
+
isRightAdjudtable = true;
|
1782
|
+
// eslint-disable-next-line no-self-assign
|
1783
|
+
this.spacedColumnValue = this.spacedColumnValue;
|
1784
|
+
return isRightAdjudtable;
|
1785
|
+
} else {
|
1786
|
+
isRightAdjudtable = false;
|
1787
|
+
}
|
1788
|
+
}
|
1789
|
+
}
|
1790
|
+
return isRightAdjudtable;
|
1791
|
+
}
|
1792
|
+
|
1793
|
+
protected sortCollisionItems(collisionItems: HTMLElement[]): HTMLElement[] {
|
1794
|
+
const updatedCollision: HTMLElement[] = [];
|
1795
|
+
let rowElements: HTMLElement[];
|
1796
|
+
for (let row: number = this.rows - 1; row >= 0; row--) {
|
1797
|
+
rowElements = [];
|
1798
|
+
collisionItems.forEach((element: HTMLElement) => {
|
1799
|
+
if (element && element.getAttribute('data-row') === row.toString()) {
|
1800
|
+
rowElements.push(element);
|
1801
|
+
}
|
1802
|
+
});
|
1803
|
+
for (let column: number = this.columns - 1; column >= 0; column--) {
|
1804
|
+
rowElements.forEach((item: HTMLElement) => {
|
1805
|
+
if (item && item.getAttribute('data-col') === column.toString()) {
|
1806
|
+
updatedCollision.push(item);
|
1807
|
+
}
|
1808
|
+
});
|
1809
|
+
}
|
1810
|
+
}
|
1811
|
+
return updatedCollision;
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
protected updatedModels(collisionItems: HTMLElement[], panelModel: PanelModel, ele: HTMLElement): HTMLElement[] {
|
1815
|
+
const removeableElement: HTMLElement[] = [];
|
1816
|
+
if (!this.mainElement) {
|
1817
|
+
this.sortedPanel();
|
1818
|
+
}
|
1819
|
+
collisionItems.forEach((element: HTMLElement) => {
|
1820
|
+
this.checkingElement = element;
|
1821
|
+
const model: PanelModel = this.getCellInstance(element.id);
|
1822
|
+
const adjust: boolean = !this.adjustmentAvailable(model.row, model.col, model.sizeY, model.sizeX, ele);
|
1823
|
+
if (model.sizeX > 1 && adjust) {
|
1824
|
+
for (let rowValue: number = model.row; rowValue < panelModel.row + panelModel.sizeY; rowValue++) {
|
1825
|
+
const collisions: HTMLElement[] = this.collisions(rowValue, model.col, model.sizeX, model.sizeY, element);
|
1826
|
+
collisions.forEach((item: HTMLElement) => {
|
1827
|
+
if (collisionItems.indexOf(item) >= 0 && removeableElement.indexOf(item) === -1) {
|
1828
|
+
removeableElement.push(item);
|
1829
|
+
}
|
1830
|
+
});
|
1831
|
+
}
|
1832
|
+
}
|
1833
|
+
});
|
1834
|
+
removeableElement.forEach((item: HTMLElement) => {
|
1835
|
+
if (removeableElement.indexOf(item) >= 0) {
|
1836
|
+
collisionItems.splice(collisionItems.indexOf(item), 1);
|
1837
|
+
}
|
1838
|
+
});
|
1839
|
+
return collisionItems;
|
1840
|
+
}
|
1841
|
+
|
1842
|
+
protected resetLayout(model: PanelModel): HTMLElement[] {
|
1843
|
+
let collisions: HTMLElement[] = this.collisions(model.row, model.col, model.sizeX, model.sizeY, this.mainElement);
|
1844
|
+
if (!this.mainElement || this.addPanelCalled || this.resizeCalled || this.movePanelCalled) {
|
1845
|
+
return collisions;
|
1846
|
+
}
|
1847
|
+
if (this.mainElement && this.oldRowCol !== this.cloneObject) {
|
1848
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
1849
|
+
const element: HTMLElement = document.getElementById(this.panels[i].id);
|
1850
|
+
if (element === this.mainElement) {
|
1851
|
+
continue;
|
1852
|
+
}
|
1853
|
+
const rowValue: number = this.cloneObject[element.id].row;
|
1854
|
+
const colValue: number = this.cloneObject[element.id].col;
|
1855
|
+
this.setPanelPosition(element, rowValue, colValue);
|
1856
|
+
this.panelPropertyChange(this.getCellInstance(element.id), { row: rowValue, col: colValue });
|
1857
|
+
this.setAttributes({ value: { col: colValue.toString(), row: rowValue.toString() } }, element);
|
1858
|
+
this.updateOldRowColumn();
|
1859
|
+
}
|
1860
|
+
}
|
1861
|
+
this.sortedArray = this.cloneArray;
|
1862
|
+
collisions = this.collisions(model.row, model.col, model.sizeX, model.sizeY, this.mainElement);
|
1863
|
+
this.sortedPanel();
|
1864
|
+
this.updateOldRowColumn();
|
1865
|
+
if (this.checkCollision && this.checkCollision.length > 0 && collisions.indexOf(this.checkCollision[0]) === -1 &&
|
1866
|
+
this.cloneObject[this.checkCollision[0].id].row === model.row) {
|
1867
|
+
collisions.push(this.checkCollision[0]);
|
1868
|
+
}
|
1869
|
+
return collisions;
|
1870
|
+
}
|
1871
|
+
|
1872
|
+
protected swapAvailability(collisions: HTMLElement[], element: HTMLElement): boolean {
|
1873
|
+
let available: boolean = true;
|
1874
|
+
const eleModel: PanelModel = this.getCellInstance(element.id);
|
1875
|
+
for (let count: number = 0; count < collisions.length; count++) {
|
1876
|
+
const collideModel: PanelModel = this.getCellInstance(collisions[count].id);
|
1877
|
+
for (let i: number = 1; i < eleModel.sizeY; i++) {
|
1878
|
+
const excludeEle: HTMLElement[] = [];
|
1879
|
+
excludeEle.push(element);
|
1880
|
+
excludeEle.push(collisions[count]);
|
1881
|
+
const collision: HTMLElement[] =
|
1882
|
+
this.collisions(eleModel.row + i, collideModel.col, collideModel.sizeX, collideModel.sizeY, excludeEle);
|
1883
|
+
if (collision.length > 0) {
|
1884
|
+
available = false;
|
1885
|
+
return false;
|
1886
|
+
} else {
|
1887
|
+
continue;
|
1888
|
+
}
|
1889
|
+
}
|
1890
|
+
}
|
1891
|
+
return available;
|
1892
|
+
}
|
1893
|
+
|
1894
|
+
protected checkForSwapping(collisions: HTMLElement[], element: HTMLElement): boolean {
|
1895
|
+
if (!this.mainElement || collisions.length === 0) {
|
1896
|
+
return false;
|
1897
|
+
}
|
1898
|
+
let direction: number;
|
1899
|
+
const eleSwapRow: number = parseInt(collisions[0].getAttribute('data-row'), 10);
|
1900
|
+
if (this.startRow < eleSwapRow) {
|
1901
|
+
direction = 1;
|
1902
|
+
} else if (this.startRow > eleSwapRow) {
|
1903
|
+
direction = 0;
|
1904
|
+
}
|
1905
|
+
if (!this.swapAvailability(collisions, element)) {
|
1906
|
+
return false;
|
1907
|
+
}
|
1908
|
+
let isSwappable: boolean = false;
|
1909
|
+
for (let count1: number = 0; count1 < collisions.length; count1++) {
|
1910
|
+
if (collisions.length >= 1 && this.cloneObject[this.mainElement.id] && this.cloneObject[this.mainElement.id].row === this.oldRowCol[this.mainElement.id].row) {
|
1911
|
+
return false;
|
1912
|
+
}
|
1913
|
+
}
|
1914
|
+
const updatedRow: number = direction === 0 ?
|
1915
|
+
this.getCellInstance(this.mainElement.id).row + this.getCellInstance(this.mainElement.id).sizeY
|
1916
|
+
: this.startRow;
|
1917
|
+
for (let count: number = 0; count < collisions.length; count++) {
|
1918
|
+
const collideInstance: PanelModel = this.getCellInstance(collisions[count].id);
|
1919
|
+
const elementinstance: PanelModel = this.getCellInstance(element.id);
|
1920
|
+
const ignore: HTMLElement[] = [];
|
1921
|
+
if (collideInstance.sizeY === 1 && ignore.indexOf(collisions[count]) === -1) {
|
1922
|
+
ignore.push(collisions[count]);
|
1923
|
+
} else if (collideInstance.sizeY > 1 && ignore.indexOf(collisions[count]) === -1) {
|
1924
|
+
if (direction === 1 && elementinstance.row === (this.cloneObject[collideInstance.id].row + collideInstance.sizeY - 1)) {
|
1925
|
+
ignore.push(collisions[count]);
|
1926
|
+
} else if (direction === 0 && elementinstance.row === (this.cloneObject[collideInstance.id].row)) {
|
1927
|
+
ignore.push(collisions[count]);
|
1928
|
+
} else {
|
1929
|
+
return false;
|
1930
|
+
}
|
1931
|
+
}
|
1932
|
+
if (collideInstance.sizeY <= elementinstance.sizeY && ignore.indexOf(collisions[count]) === -1) {
|
1933
|
+
ignore.push(collisions[count]);
|
1934
|
+
}
|
1935
|
+
ignore.push(this.mainElement);
|
1936
|
+
const swapCollision: HTMLElement[]
|
1937
|
+
= this.collisions(updatedRow, collideInstance.col, collideInstance.sizeX, collideInstance.sizeY, ignore);
|
1938
|
+
if (swapCollision.length > 0) {
|
1939
|
+
isSwappable = false;
|
1940
|
+
return isSwappable;
|
1941
|
+
} else {
|
1942
|
+
if (count === collisions.length - 1) {
|
1943
|
+
isSwappable = true;
|
1944
|
+
}
|
1945
|
+
continue;
|
1946
|
+
}
|
1947
|
+
}
|
1948
|
+
return isSwappable;
|
1949
|
+
}
|
1950
|
+
|
1951
|
+
protected swapItems(collisions: HTMLElement[], element: HTMLElement, panelModel: PanelModel): void {
|
1952
|
+
let direction: number;
|
1953
|
+
const swappedElements: HTMLElement[] = [];
|
1954
|
+
swappedElements.push(element);
|
1955
|
+
const eleSwapRow: number = parseInt(collisions[0].getAttribute('data-row'), 10);
|
1956
|
+
if (this.startRow < eleSwapRow) {
|
1957
|
+
direction = 1;
|
1958
|
+
} else if (this.startRow > eleSwapRow) {
|
1959
|
+
direction = 0;
|
1960
|
+
}
|
1961
|
+
const collisionItemsRow: number = direction === 0 ? eleSwapRow + panelModel.sizeY : this.startRow;
|
1962
|
+
if (!this.movePanelCalled) {
|
1963
|
+
const collisionInstance: PanelModel = this.getCellInstance(collisions[0].id);
|
1964
|
+
this.panelPropertyChange(panelModel, { row: direction === 0 ? eleSwapRow : collisionItemsRow + collisionInstance.sizeY });
|
1965
|
+
}
|
1966
|
+
for (let count: number = 0; count < collisions.length; count++) {
|
1967
|
+
swappedElements.push(collisions[count]);
|
1968
|
+
this.setPanelPosition(collisions[count], collisionItemsRow, (this.getCellInstance(collisions[count].id)).col);
|
1969
|
+
this.panelPropertyChange(this.getCellInstance(collisions[count].id), { row: collisionItemsRow });
|
1970
|
+
collisions[count].setAttribute('data-row', collisionItemsRow.toString());
|
1971
|
+
}
|
1972
|
+
element.setAttribute('data-row', panelModel.row.toString());
|
1973
|
+
this.setPanelPosition(this.shadowEle, panelModel.row, panelModel.col);
|
1974
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
1975
|
+
this.oldRowCol[this.panels[i].id] = { row: this.panels[i].row, col: this.panels[i].col };
|
1976
|
+
}
|
1977
|
+
this.startRow = panelModel.row;
|
1978
|
+
this.updateOldRowColumn();
|
1979
|
+
swappedElements.forEach((item: HTMLElement) => {
|
1980
|
+
this.cloneObject[item.id] = this.oldRowCol[item.id];
|
1981
|
+
const itemModel: PanelModel = this.getCellInstance(item.id);
|
1982
|
+
for (let i: number = 0; i < this.sortedArray.length; i++) {
|
1983
|
+
if (!this.sortedArray[i]) {
|
1984
|
+
continue;
|
1985
|
+
}
|
1986
|
+
for (let j: number = 0; j < this.sortedArray[i].length; j++) {
|
1987
|
+
if (this.sortedArray[i][j] === item) {
|
1988
|
+
this.sortedArray[i][j] = undefined;
|
1989
|
+
}
|
1990
|
+
}
|
1991
|
+
}
|
1992
|
+
if (!this.sortedArray[itemModel.row]) {
|
1993
|
+
this.sortedArray[itemModel.row] = [];
|
1994
|
+
}
|
1995
|
+
this.sortedArray[itemModel.row][itemModel.col] = item;
|
1996
|
+
this.cloneArray = this.sortedArray;
|
1997
|
+
});
|
1998
|
+
}
|
1999
|
+
|
2000
|
+
protected updatePanelLayout(element: HTMLElement, panelModel: PanelModel): void {
|
2001
|
+
this.collisionChecker = {};
|
2002
|
+
let initialModel: HTMLElement[] = [];
|
2003
|
+
let checkForAdjustment: boolean;
|
2004
|
+
const collisionModels: HTMLElement[] = [];
|
2005
|
+
let swappingAvailable: boolean;
|
2006
|
+
if (this.mainElement && this.isRenderComplete) {
|
2007
|
+
initialModel = this.resetLayout(panelModel);
|
2008
|
+
} else {
|
2009
|
+
initialModel = this.collisions(panelModel.row, panelModel.col, panelModel.sizeX, panelModel.sizeY, element);
|
2010
|
+
}
|
2011
|
+
if (initialModel.length > 0) {
|
2012
|
+
initialModel = this.sortCollisionItems(initialModel);
|
2013
|
+
initialModel = this.updatedModels(initialModel, panelModel, element);
|
2014
|
+
swappingAvailable = !isNullOrUndefined(this.startRow) ? this.checkForSwapping(initialModel, element) : false;
|
2015
|
+
if (swappingAvailable) {
|
2016
|
+
this.swapItems(initialModel, element, panelModel);
|
2017
|
+
} else {
|
2018
|
+
for (let i: number = 0; i < initialModel.length; i++) {
|
2019
|
+
const model: PanelModel = this.getCellInstance(initialModel[i].id);
|
2020
|
+
this.checkingElement = initialModel[i];
|
2021
|
+
this.spacedRowValue = null;
|
2022
|
+
this.spacedColumnValue = null;
|
2023
|
+
checkForAdjustment = this.adjustmentAvailable(model.row, model.col, model.sizeY, model.sizeX, element);
|
2024
|
+
if (checkForAdjustment && !isNullOrUndefined(this.spacedColumnValue)) {
|
2025
|
+
this.setPanelPosition(initialModel[i], this.spacedRowValue, this.spacedColumnValue);
|
2026
|
+
this.oldRowCol[(initialModel[i].id)] = { row: this.spacedRowValue, col: this.spacedColumnValue };
|
2027
|
+
const value: IAttributes = {
|
2028
|
+
attributes: {
|
2029
|
+
row: this.spacedRowValue.toString(),
|
2030
|
+
col: this.spacedColumnValue.toString()
|
2031
|
+
}
|
2032
|
+
};
|
2033
|
+
this.setAttributes(value, initialModel[i]);
|
2034
|
+
this.panelPropertyChange(model, { col: this.spacedColumnValue, row: this.spacedRowValue });
|
2035
|
+
// updated the panel model array as inTopAdjustable case with floating enabled instead of dragging and extra row
|
2036
|
+
if (this.topAdjustable && this.allowFloating) {
|
2037
|
+
this.updatePanels();
|
2038
|
+
this.updateCloneArrayObject();
|
2039
|
+
}
|
2040
|
+
this.spacedRowValue = null;
|
2041
|
+
if (i < initialModel.length) {
|
2042
|
+
continue;
|
2043
|
+
}
|
2044
|
+
} else {
|
2045
|
+
collisionModels.push(initialModel[i]);
|
2046
|
+
}
|
2047
|
+
}
|
2048
|
+
}
|
2049
|
+
}
|
2050
|
+
if (collisionModels.length > 0) {
|
2051
|
+
// eslint-disable-next-line
|
2052
|
+
const proxy: DashboardLayout = this;
|
2053
|
+
collisionModels.forEach((item1: HTMLElement) => {
|
2054
|
+
if (proxy.overlapElement.indexOf(item1) === -1) {
|
2055
|
+
proxy.overlapElement.push(item1);
|
2056
|
+
}
|
2057
|
+
});
|
2058
|
+
if (this.overlapElement && this.overlapElement.indexOf(element) !== -1) {
|
2059
|
+
this.overlapElement.splice(this.overlapElement.indexOf(element), 1);
|
2060
|
+
}
|
2061
|
+
if (collisionModels.length > 0) {
|
2062
|
+
this.updateRowColumn(panelModel.row, this.overlapElement, element);
|
2063
|
+
this.checkForCompletePushing();
|
2064
|
+
}
|
2065
|
+
}
|
2066
|
+
if (!this.isSubValue) {
|
2067
|
+
this.sortedPanel();
|
2068
|
+
}
|
2069
|
+
this.updateRowHeight();
|
2070
|
+
this.updateGridLines();
|
2071
|
+
}
|
2072
|
+
|
2073
|
+
protected checkForCompletePushing(): void {
|
2074
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
2075
|
+
if (this.collisionChecker[this.panels[i].id] && this.collisionChecker[this.panels[i].id] !== null) {
|
2076
|
+
this.overlapElement = [this.collisionChecker[this.panels[i].id].ele];
|
2077
|
+
const key: string = this.panels[i].id;
|
2078
|
+
this.updateRowColumn(this.collisionChecker[key].row, this.overlapElement, this.collisionChecker[key].srcEle);
|
2079
|
+
}
|
2080
|
+
}
|
2081
|
+
}
|
2082
|
+
|
2083
|
+
protected updateCollisionChecked(item: HTMLElement): void {
|
2084
|
+
for (let count: number = 0; count < Object.keys(this.collisionChecker).length; count++) {
|
2085
|
+
this.collisionChecker[item.id] = null;
|
2086
|
+
}
|
2087
|
+
}
|
2088
|
+
protected updateRowColumn(row: number, ele: HTMLElement[], srcEle: HTMLElement): void {
|
2089
|
+
if (!srcEle) {
|
2090
|
+
return;
|
2091
|
+
}
|
2092
|
+
const eleSizeY: number = parseInt(srcEle.getAttribute('data-sizeY'), 10);
|
2093
|
+
const eleRow: number = parseInt(srcEle.getAttribute('data-row'), 10);
|
2094
|
+
this.overlapElementClone = this.overlapElement && !this.shouldRestrict ? this.overlapElement : this.overlapElement;
|
2095
|
+
for (let i: number = 0; i < this.overlapElementClone.length; i++) {
|
2096
|
+
if (this.overlapElementClone.length === 0) {
|
2097
|
+
return;
|
2098
|
+
}
|
2099
|
+
for (let i: number = 0; i < this.overlapElementClone.length; i++) {
|
2100
|
+
this.collisionChecker[this.overlapElementClone[i].id] = {
|
2101
|
+
ele: this.overlapElementClone[i],
|
2102
|
+
row: row,
|
2103
|
+
srcEle: srcEle
|
2104
|
+
};
|
2105
|
+
}
|
2106
|
+
const updatedRow: number = eleRow + eleSizeY;
|
2107
|
+
const collisionY: number = parseInt(this.overlapElementClone[i].getAttribute('data-sizeY'), 10);
|
2108
|
+
const collisionCol: number = parseInt(this.overlapElementClone[i].getAttribute('data-col'), 10);
|
2109
|
+
const collisionX: number = parseInt(this.overlapElementClone[i].getAttribute('data-sizeX'), 10);
|
2110
|
+
let colValue: number;
|
2111
|
+
let collisionModels: HTMLElement[];
|
2112
|
+
if (this.overlapSubElementClone.indexOf(srcEle) === - 1) {
|
2113
|
+
this.overlapSubElementClone.push(srcEle);
|
2114
|
+
}
|
2115
|
+
if (this.overlapSubElementClone.indexOf(this.overlapElementClone[i]) === - 1) {
|
2116
|
+
this.overlapSubElementClone.push(this.overlapElementClone[i]);
|
2117
|
+
}
|
2118
|
+
if (collisionY > 1 || collisionX > 1) {
|
2119
|
+
const overlapElementModel: PanelModel = this.getCellInstance(this.overlapElementClone[i].id);
|
2120
|
+
colValue = overlapElementModel.col;
|
2121
|
+
const ele: HTMLElement = document.getElementById(overlapElementModel.id);
|
2122
|
+
for (let k: number = overlapElementModel.row; k < eleRow + eleSizeY; k++) {
|
2123
|
+
this.isSubValue = true;
|
2124
|
+
this.panelPropertyChange(overlapElementModel, { row: overlapElementModel.row + 1 });
|
2125
|
+
ele.setAttribute('data-row', overlapElementModel.row.toString());
|
2126
|
+
this.setPanelPosition(ele, overlapElementModel.row, colValue);
|
2127
|
+
this.updateCollisionChecked(ele);
|
2128
|
+
this.oldRowCol[(ele.id)] = { row: overlapElementModel.row, col: colValue };
|
2129
|
+
const panelModel: PanelModel = this.getCellInstance(ele.id);
|
2130
|
+
this.panelPropertyChange(panelModel, { col: colValue, row: overlapElementModel.row });
|
2131
|
+
const eleRow: number = parseInt(ele.getAttribute('data-row'), 10);
|
2132
|
+
const eleCol: number = parseInt(ele.getAttribute('data-col'), 10);
|
2133
|
+
const sizeX: number = parseInt(ele.getAttribute('data-sizeX'), 10);
|
2134
|
+
const sizeY: number = parseInt(ele.getAttribute('data-sizeY'), 10);
|
2135
|
+
const excludeElements: HTMLElement[] = [];
|
2136
|
+
excludeElements.push(ele);
|
2137
|
+
excludeElements.push(srcEle);
|
2138
|
+
collisionModels = this.collisions(eleRow, eleCol, sizeX, sizeY, excludeElements);
|
2139
|
+
if (this.mainElement && collisionModels.indexOf(this.mainElement) !== -1) {
|
2140
|
+
collisionModels.splice(collisionModels.indexOf(this.mainElement), 1);
|
2141
|
+
}
|
2142
|
+
this.collisionPanel(collisionModels, eleCol, eleRow, ele);
|
2143
|
+
}
|
2144
|
+
this.isSubValue = false;
|
2145
|
+
} else {
|
2146
|
+
if (this.addPanelCalled) {
|
2147
|
+
this.addPanelCalled = false;
|
2148
|
+
}
|
2149
|
+
this.overlapElementClone[i].setAttribute('data-row', updatedRow.toString());
|
2150
|
+
const excludeEle: HTMLElement[] = [];
|
2151
|
+
excludeEle.push(this.overlapElementClone[i]);
|
2152
|
+
excludeEle.push(srcEle);
|
2153
|
+
collisionModels = this.collisions(updatedRow, collisionCol, collisionX, collisionY, excludeEle);
|
2154
|
+
if (this.mainElement && collisionModels.indexOf(this.mainElement) !== -1) {
|
2155
|
+
collisionModels.splice(collisionModels.indexOf(this.mainElement), 1);
|
2156
|
+
}
|
2157
|
+
colValue = parseInt(this.overlapElementClone[i].getAttribute('data-col'), 10);
|
2158
|
+
this.setPanelPosition(this.overlapElementClone[i], updatedRow, colValue);
|
2159
|
+
this.updateCollisionChecked(this.overlapElementClone[i]);
|
2160
|
+
this.oldRowCol[(this.overlapElementClone[i].id)] = { row: updatedRow, col: colValue };
|
2161
|
+
const panelModel: PanelModel = this.getCellInstance(this.overlapElementClone[i].id);
|
2162
|
+
this.panelPropertyChange(panelModel, { col: colValue, row: updatedRow });
|
2163
|
+
this.collisionPanel(collisionModels, colValue, updatedRow, this.overlapElementClone[i]);
|
2164
|
+
}
|
2165
|
+
}
|
2166
|
+
}
|
2167
|
+
|
2168
|
+
protected collisionPanel(collisionModels: HTMLElement[], colValue: number, updatedRow: number, clone: HTMLElement): void {
|
2169
|
+
const panelModel: PanelModel = this.getCellInstance(clone.id);
|
2170
|
+
this.panelPropertyChange(panelModel, { row: updatedRow, col: colValue });
|
2171
|
+
if (collisionModels.length > 0) {
|
2172
|
+
// eslint-disable-next-line
|
2173
|
+
const proxy: DashboardLayout = this;
|
2174
|
+
this.overlapElement = [];
|
2175
|
+
this.shouldRestrict = true;
|
2176
|
+
collisionModels.forEach((item1: HTMLElement) => {
|
2177
|
+
proxy.overlapElement.push(item1);
|
2178
|
+
});
|
2179
|
+
const overlapElementRow1: number = parseInt(clone.getAttribute('data-row'), 10);
|
2180
|
+
for (let m: number = 0; m < this.overlapElement.length; m++) {
|
2181
|
+
this.updateRowColumn(overlapElementRow1, this.overlapElement, clone);
|
2182
|
+
}
|
2183
|
+
this.shouldRestrict = false;
|
2184
|
+
} else {
|
2185
|
+
if (!this.addPanelCalled) {
|
2186
|
+
this.sortedPanel();
|
2187
|
+
}
|
2188
|
+
if (this.overlapSubElementClone.length > 0) {
|
2189
|
+
for (let p: number = 0; p < this.overlapSubElementClone.length; p++) {
|
2190
|
+
const rowVal: number = parseInt(this.overlapSubElementClone[p].getAttribute('data-row'), 10);
|
2191
|
+
const colValue: number = parseInt(this.overlapSubElementClone[p].getAttribute('data-col'), 10);
|
2192
|
+
const sizeX: number = parseInt(this.overlapSubElementClone[p].getAttribute('data-sizeX'), 10);
|
2193
|
+
const sizeY: number = parseInt(this.overlapSubElementClone[p].getAttribute('data-sizeY'), 10);
|
2194
|
+
const collisionModels1: HTMLElement[] = this.collisions(rowVal, colValue, sizeX, sizeY, this.overlapSubElementClone);
|
2195
|
+
if (this.mainElement && collisionModels1.indexOf(this.mainElement) !== -1) {
|
2196
|
+
collisionModels1.splice(collisionModels1.indexOf(this.mainElement), 1);
|
2197
|
+
}
|
2198
|
+
// eslint-disable-next-line
|
2199
|
+
const proxy: DashboardLayout = this;
|
2200
|
+
collisionModels1.forEach((item1: HTMLElement) => {
|
2201
|
+
proxy.overlapElement.push(item1);
|
2202
|
+
});
|
2203
|
+
if (collisionModels1.length > 0) {
|
2204
|
+
this.updateRowColumn(rowVal, this.overlapElement, this.overlapSubElementClone[p]);
|
2205
|
+
}
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
this.overlapSubElementClone = [];
|
2209
|
+
}
|
2210
|
+
}
|
2211
|
+
|
2212
|
+
protected removeResizeClasses(panelElements: HTMLElement[]): void {
|
2213
|
+
for (let i: number = 0; i < panelElements.length; i++) {
|
2214
|
+
const element: HTMLElement = panelElements[i];
|
2215
|
+
const resizerElements: NodeList = element.querySelectorAll('.e-resize');
|
2216
|
+
for (let i: number = 0; i < resizerElements.length; i++) {
|
2217
|
+
detach(resizerElements[i]);
|
2218
|
+
}
|
2219
|
+
}
|
2220
|
+
}
|
2221
|
+
|
2222
|
+
protected ensureDrag(): void {
|
2223
|
+
this.checkDragging(this.dragCollection);
|
2224
|
+
const dragPanels: NodeListOf<Element> = this.element.querySelectorAll('.' + drag);
|
2225
|
+
removeClass(dragPanels, [drag]);
|
2226
|
+
this.setClasses(this.panelCollection);
|
2227
|
+
}
|
2228
|
+
|
2229
|
+
protected setClasses(panelCollection: HTMLElement[]): void {
|
2230
|
+
for (let i: number = 0; i < panelCollection.length; i++) {
|
2231
|
+
const element: HTMLElement = panelCollection[i];
|
2232
|
+
const containerEle: HTMLElement = panelCollection[i].querySelector('.e-panel-container');
|
2233
|
+
if (this.allowDragging) {
|
2234
|
+
if (this.draggableHandle && element.querySelectorAll(this.draggableHandle)[0]) {
|
2235
|
+
addClass([element.querySelectorAll(this.draggableHandle)[0]], [drag]);
|
2236
|
+
} else {
|
2237
|
+
addClass([element], [drag]);
|
2238
|
+
}
|
2239
|
+
}
|
2240
|
+
if (this.allowResizing &&
|
2241
|
+
this.mediaQuery ? !(this.checkMediaQuery()) : false) {
|
2242
|
+
this.setResizingClass(element, containerEle);
|
2243
|
+
}
|
2244
|
+
}
|
2245
|
+
|
2246
|
+
}
|
2247
|
+
protected setResizingClass(ele?: HTMLElement, container?: HTMLElement): void {
|
2248
|
+
this.availableClasses = this.resizableHandles;
|
2249
|
+
if (!ele.querySelector(".e-resize")) {
|
2250
|
+
for (let j: number = 0; j < this.availableClasses.length; j++) {
|
2251
|
+
const spanEle: HTMLElement = this.createElement('span');
|
2252
|
+
let addClassValue: string;
|
2253
|
+
container.appendChild(spanEle);
|
2254
|
+
if (this.availableClasses[j] === 'e-east' || this.availableClasses[j] === 'e-west' ||
|
2255
|
+
this.availableClasses[j] === 'e-north' || this.availableClasses[j] === 'e-south') {
|
2256
|
+
addClassValue = single;
|
2257
|
+
} else {
|
2258
|
+
addClassValue = double;
|
2259
|
+
}
|
2260
|
+
addClass([spanEle], [addClassValue, this.availableClasses[j], resize, resizeicon]);
|
2261
|
+
}
|
2262
|
+
}
|
2263
|
+
}
|
2264
|
+
protected setXYAttributes(element: HTMLElement, panelModel: PanelModel): void {
|
2265
|
+
const value: IAttributes = {
|
2266
|
+
value: {
|
2267
|
+
sizeX: panelModel.sizeX.toString(),
|
2268
|
+
sizeY: panelModel.sizeY.toString(),
|
2269
|
+
minSizeX: panelModel.minSizeX.toString(),
|
2270
|
+
minSizeY: panelModel.minSizeY.toString(),
|
2271
|
+
maxSizeX: !isNullOrUndefined(panelModel.maxSizeX) ? panelModel.maxSizeX.toString() : undefined,
|
2272
|
+
maxSizeY: !isNullOrUndefined(panelModel.maxSizeY) ? panelModel.maxSizeY.toString() : undefined,
|
2273
|
+
row: panelModel.row.toString(),
|
2274
|
+
col: panelModel.col.toString()
|
2275
|
+
}
|
2276
|
+
};
|
2277
|
+
this.setAttributes(value, element);
|
2278
|
+
}
|
2279
|
+
|
2280
|
+
protected setXYDimensions(panelModel: PanelModel): (string | number)[] {
|
2281
|
+
const cellHeight: number | string = this.getCellSize()[1];
|
2282
|
+
const cellWidth: number | string = this.getCellSize()[0];
|
2283
|
+
let widthValue: number | string; let heigthValue: number | string;
|
2284
|
+
if (panelModel && typeof (cellWidth) === 'number' && typeof (panelModel.sizeX) === 'number' && panelModel.sizeX > 1) {
|
2285
|
+
widthValue = (panelModel.sizeX * cellWidth) + (panelModel.sizeX - 1) * this.cellSpacing[0];
|
2286
|
+
} else {
|
2287
|
+
widthValue = cellWidth;
|
2288
|
+
}
|
2289
|
+
if (panelModel && typeof (cellHeight) === 'number' && panelModel.sizeY > 1 && typeof (panelModel.sizeY) === 'number') {
|
2290
|
+
heigthValue = (panelModel.sizeY * cellHeight) + (panelModel.sizeY - 1) * this.cellSpacing[1];
|
2291
|
+
} else {
|
2292
|
+
heigthValue = formatUnit(cellHeight);
|
2293
|
+
}
|
2294
|
+
return [heigthValue, widthValue];
|
2295
|
+
}
|
2296
|
+
|
2297
|
+
protected getRowColumnDragValues(args: DragEventArgs): number[] {
|
2298
|
+
let value: number[] = [];
|
2299
|
+
const elementTop: number = parseFloat(args.element.style.top);
|
2300
|
+
const elementLeft: number = parseFloat(args.element.style.left);
|
2301
|
+
const row: number = Math.round(elementTop / (this.getCellSize()[1] + this.cellSpacing[1]));
|
2302
|
+
const col: number = Math.round(elementLeft / (this.getCellSize()[0] + + this.cellSpacing[0]));
|
2303
|
+
value = [row, col];
|
2304
|
+
return value;
|
2305
|
+
}
|
2306
|
+
protected checkForChanges(isInteracted: boolean, added?: PanelModel[], removed?: PanelModel[]): void {
|
2307
|
+
let changedPanels: PanelModel[] = [];
|
2308
|
+
if (this.removeAllCalled) {
|
2309
|
+
changedPanels = [];
|
2310
|
+
} else {
|
2311
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
2312
|
+
if (((!isNullOrUndefined(added) ? (this.panels[i].id !== added[0].id) : true) &&
|
2313
|
+
(!isNullOrUndefined(removed) ? (this.panels[i].id !== removed[0].id) : true)) &&
|
2314
|
+
(this.panels[i].row !== this.panelsInitialModel[i].row || this.panels[i].col !== this.panelsInitialModel[i].col)) {
|
2315
|
+
changedPanels.push(this.panels[i]);
|
2316
|
+
}
|
2317
|
+
}
|
2318
|
+
}
|
2319
|
+
if (changedPanels.length > 0 || this.removeAllCalled) {
|
2320
|
+
const changedArgs: ChangeEventArgs = {
|
2321
|
+
changedPanels: changedPanels, isInteracted: isInteracted,
|
2322
|
+
addedPanels: !isNullOrUndefined(added) ? added : [], removedPanels: !isNullOrUndefined(removed) ? removed : []
|
2323
|
+
};
|
2324
|
+
this.trigger('change', changedArgs);
|
2325
|
+
}
|
2326
|
+
}
|
2327
|
+
protected enableDraggingContent(collections: HTMLElement[]): void {
|
2328
|
+
for (let i: number = 0; i < collections.length; i++) {
|
2329
|
+
const abortArray: string[] = ['.e-resize', '.' + dragRestrict];
|
2330
|
+
const cellElement: HTMLElement = collections[i];
|
2331
|
+
{
|
2332
|
+
this.dragobj = new Draggable(cellElement, {
|
2333
|
+
preventDefault: false,
|
2334
|
+
clone: false,
|
2335
|
+
dragArea: this.element,
|
2336
|
+
isDragScroll: true,
|
2337
|
+
handle: this.draggableHandle ? this.draggableHandle : '.e-panel',
|
2338
|
+
abort: abortArray,
|
2339
|
+
dragStart: this.onDraggingStart.bind(this),
|
2340
|
+
dragStop: (args: DragEventArgs) => {
|
2341
|
+
const model: PanelModel = this.getCellInstance(this.mainElement.id);
|
2342
|
+
if (this.allowPushing &&
|
2343
|
+
this.collisions(model.row, model.col, model.sizeX, model.sizeY, this.mainElement).length > 0) {
|
2344
|
+
this.setHolderPosition(args);
|
2345
|
+
this.setPanelPosition(this.mainElement, model.row, model.col);
|
2346
|
+
this.updatePanelLayout(this.mainElement, model);
|
2347
|
+
} else {
|
2348
|
+
this.setPanelPosition(this.mainElement, model.row, model.col);
|
2349
|
+
}
|
2350
|
+
this.mainElement = null;
|
2351
|
+
const item: PanelModel = this.getPanelBase(args);
|
2352
|
+
if (this.shadowEle) {
|
2353
|
+
detach(this.shadowEle);
|
2354
|
+
}
|
2355
|
+
removeClass([this.element], [preventSelect]);
|
2356
|
+
removeClass([args.element], [dragging]);
|
2357
|
+
this.shadowEle = null;
|
2358
|
+
args.element.classList.remove('e-dragging');
|
2359
|
+
const row: number = this.getRowColumnDragValues(args)[0];
|
2360
|
+
const col: number = this.getRowColumnDragValues(args)[1];
|
2361
|
+
const panelModel: PanelModel = this.getCellInstance(args.element.id);
|
2362
|
+
if (this.allowPushing &&
|
2363
|
+
this.collisions(row, col, panelModel.sizeX, panelModel.sizeY, document.getElementById(item.id)).length === 0) {
|
2364
|
+
this.panelPropertyChange(this.getCellInstance(args.element.id), { row: row, col: col });
|
2365
|
+
this.oldRowCol[args.element.id].row = row;
|
2366
|
+
this.oldRowCol[args.element.id].col = col;
|
2367
|
+
this.setAttributes({ value: { col: col.toString(), row: row.toString() } }, args.element);
|
2368
|
+
this.sortedPanel();
|
2369
|
+
} else {
|
2370
|
+
this.panelPropertyChange(this.getCellInstance(args.element.id), {
|
2371
|
+
row: this.oldRowCol[args.element.id].row,
|
2372
|
+
col: this.oldRowCol[args.element.id].col
|
2373
|
+
});
|
2374
|
+
args.element.setAttribute('data-col', this.getCellInstance(args.element.id).col.toString());
|
2375
|
+
args.element.setAttribute('data-row', this.getCellInstance(args.element.id).row.toString());
|
2376
|
+
this.sortedPanel();
|
2377
|
+
}
|
2378
|
+
const panelInstance: PanelModel = this.getCellInstance(args.element.id);
|
2379
|
+
this.setPanelPosition(args.element, panelInstance.row, panelInstance.col);
|
2380
|
+
this.updatePanels();
|
2381
|
+
this.updateCloneArrayObject();
|
2382
|
+
this.checkForChanges(true);
|
2383
|
+
this.dragStopEventArgs = { event: args.event, element: args.element };
|
2384
|
+
this.trigger('dragStop', args);
|
2385
|
+
this.resizeEvents();
|
2386
|
+
this.rows = this.maxRow(true);
|
2387
|
+
this.setHeightWidth();
|
2388
|
+
this.updateDragArea();
|
2389
|
+
},
|
2390
|
+
drag: (args: DragEventArgs) => {
|
2391
|
+
this.draggedEventArgs = {
|
2392
|
+
event: args.event,
|
2393
|
+
element: args.element,
|
2394
|
+
target: <HTMLElement>closest((args.target), '.e-panel')
|
2395
|
+
};
|
2396
|
+
this.trigger('drag', this.draggedEventArgs);
|
2397
|
+
this.onDragStart(args);
|
2398
|
+
}
|
2399
|
+
});
|
2400
|
+
if (this.dragCollection.indexOf(this.dragobj) === -1) {
|
2401
|
+
this.dragCollection.push(this.dragobj);
|
2402
|
+
}
|
2403
|
+
}
|
2404
|
+
}
|
2405
|
+
}
|
2406
|
+
|
2407
|
+
protected updatePanels(): void {
|
2408
|
+
this.moveItemsUpwards();
|
2409
|
+
this.updateOldRowColumn();
|
2410
|
+
this.sortedPanel();
|
2411
|
+
}
|
2412
|
+
|
2413
|
+
protected updateDragArea(): void {
|
2414
|
+
this.dragCollection.forEach((dragobj: Draggable) => {
|
2415
|
+
// eslint-disable-next-line
|
2416
|
+
(<any>dragobj).setDragArea();
|
2417
|
+
});
|
2418
|
+
}
|
2419
|
+
|
2420
|
+
protected updateRowsHeight(row: number, sizeY: number, addRows: number): void {
|
2421
|
+
if (row + sizeY >= this.rows) {
|
2422
|
+
this.rows = this.rows + addRows;
|
2423
|
+
this.setHeightWidth();
|
2424
|
+
}
|
2425
|
+
}
|
2426
|
+
|
2427
|
+
private onDraggingStart(args: DragEventArgs): void {
|
2428
|
+
const dragArgs: DragEventArgs = args;
|
2429
|
+
this.trigger('dragStart', dragArgs, (dragArgs: DragEventArgs) => {
|
2430
|
+
});
|
2431
|
+
this.panelsInitialModel = this.cloneModels(this.panels);
|
2432
|
+
this.mainElement = args.element;
|
2433
|
+
this.cloneObject = JSON.parse(JSON.stringify(this.cloneObject));
|
2434
|
+
const eleRowValue: number = this.startRow = parseInt(args.element.getAttribute('data-row'), 10);
|
2435
|
+
this.startCol = parseInt(args.element.getAttribute('data-col'), 10);
|
2436
|
+
const eleSizeY: number = parseInt(args.element.getAttribute('data-sizeY'), 10);
|
2437
|
+
this.updateRowsHeight(eleRowValue, eleSizeY, eleSizeY);
|
2438
|
+
this.updateDragArea();
|
2439
|
+
this.shadowEle = document.createElement('div');
|
2440
|
+
this.shadowEle.classList.add('e-holder');
|
2441
|
+
this.shadowEle.classList.add('e-holder-transition');
|
2442
|
+
setStyle(this.shadowEle, { 'position': 'absolute' });
|
2443
|
+
addClass([this.element], [preventSelect]);
|
2444
|
+
addClass([args.element], [dragging]);
|
2445
|
+
this.element.appendChild(this.shadowEle);
|
2446
|
+
this.renderReactTemplates();
|
2447
|
+
this.shadowEle = document.querySelector('.e-holder');
|
2448
|
+
this.shadowEle.style.height = (this.getCellInstance(args.element.id).sizeY * <number>this.cellSize[1]) + 'px';
|
2449
|
+
this.shadowEle.style.width = (this.getCellInstance(args.element.id).sizeX * <number>this.cellSize[0]) + 'px';
|
2450
|
+
const panelInstance: PanelModel = this.getCellInstance(args.element.id);
|
2451
|
+
this.setPanelPosition(this.shadowEle, panelInstance.row, panelInstance.col);
|
2452
|
+
}
|
2453
|
+
// eslint-disable-next-line
|
2454
|
+
private cloneModels(source?: any, target?: any): PanelModel[] {
|
2455
|
+
if (target === undefined) {
|
2456
|
+
target = [];
|
2457
|
+
}
|
2458
|
+
for (let i: number = 0; i < source.length; i++) {
|
2459
|
+
// tslint:disable-next-line
|
2460
|
+
if (!target[i]) {
|
2461
|
+
target[i] = {};
|
2462
|
+
}
|
2463
|
+
// eslint-disable-next-line guard-for-in
|
2464
|
+
for (const k in source[i]) {
|
2465
|
+
target[i][k] = source[i][k];
|
2466
|
+
}
|
2467
|
+
}
|
2468
|
+
return target;
|
2469
|
+
}
|
2470
|
+
|
2471
|
+
private onDragStart(args: DragEventArgs): void {
|
2472
|
+
let endCol: number;
|
2473
|
+
let endRow: number;
|
2474
|
+
let dragCol: number;
|
2475
|
+
const col: number = dragCol = this.getRowColumnDragValues(args)[1];
|
2476
|
+
const row: number = this.getRowColumnDragValues(args)[0];
|
2477
|
+
if (col < 0 || row < 0) {
|
2478
|
+
return;
|
2479
|
+
}
|
2480
|
+
this.panelPropertyChange(this.getCellInstance(args.element.id), { row: row, col: col });
|
2481
|
+
const panelModel: PanelModel = this.getCellInstance(args.element.id);
|
2482
|
+
this.updateRowsHeight(panelModel.row, panelModel.sizeY, 1);
|
2483
|
+
this.updateDragArea();
|
2484
|
+
if (this.allowPushing) {
|
2485
|
+
this.setAttributes({ value: { col: col.toString(), row: row.toString() } }, args.element);
|
2486
|
+
this.panelPropertyChange(this.getCellInstance(args.element.id), { row: row, col: col });
|
2487
|
+
endCol = this.oldRowCol[(args.element.id)].col;
|
2488
|
+
endRow = this.oldRowCol[(args.element.id)].row;
|
2489
|
+
this.oldRowCol[(args.element.id)] = { row: row, col: col };
|
2490
|
+
this.updateOldRowColumn();
|
2491
|
+
if (this.startCol !== endCol || this.startRow !== endRow) {
|
2492
|
+
this.setHolderPosition(args);
|
2493
|
+
if (this.startCol !== endCol) {
|
2494
|
+
this.startRow = endRow;
|
2495
|
+
}
|
2496
|
+
if (this.startRow !== endRow) {
|
2497
|
+
this.startCol = endCol;
|
2498
|
+
}
|
2499
|
+
if (this.allowPushing) {
|
2500
|
+
this.mainElement = args.element;
|
2501
|
+
const model: PanelModel = panelModel;
|
2502
|
+
this.checkCollision = this.collisions(model.row, model.col, model.sizeX, model.sizeY, args.element);
|
2503
|
+
if (panelModel.col >= this.checkColumnValue) {
|
2504
|
+
this.checkCollision = [];
|
2505
|
+
}
|
2506
|
+
this.updatePanelLayout(args.element, panelModel);
|
2507
|
+
this.moveItemsUpwards();
|
2508
|
+
}
|
2509
|
+
}
|
2510
|
+
}
|
2511
|
+
if (this.allowPushing !== false) {
|
2512
|
+
this.panelPropertyChange(this.getCellInstance(args.element.id), { row: row, col: col });
|
2513
|
+
}
|
2514
|
+
if (this.oldRowCol[args.element.id].row !== row || this.oldRowCol[args.element.id].col !== col) {
|
2515
|
+
this.panelPropertyChange(this.getCellInstance(args.element.id), { row: row, col: col });
|
2516
|
+
this.setAttributes({ value: { col: col.toString(), row: row.toString() } }, args.element);
|
2517
|
+
}
|
2518
|
+
if (this.startCol !== dragCol) {
|
2519
|
+
this.startCol = endCol;
|
2520
|
+
this.moveItemsUpwards();
|
2521
|
+
}
|
2522
|
+
if (!this.allowPushing) {
|
2523
|
+
this.setHolderPosition(args);
|
2524
|
+
}
|
2525
|
+
this.removeResizeClasses(this.panelCollection);
|
2526
|
+
this.setClasses(this.panelCollection);
|
2527
|
+
if (this.allowPushing === false) {
|
2528
|
+
return;
|
2529
|
+
}
|
2530
|
+
}
|
2531
|
+
|
2532
|
+
protected getPanelBase(args: HTMLElement | DragEventArgs | string): HTMLElement {
|
2533
|
+
let item: HTMLElement;
|
2534
|
+
for (let i: number = 0; i < this.panelCollection.length; i++) {
|
2535
|
+
if (this.panelCollection[i].id === (((<DragEventArgs>args).element
|
2536
|
+
&& (<DragEventArgs>args).element.id) || <string>args)) {
|
2537
|
+
item = this.panelCollection[i];
|
2538
|
+
}
|
2539
|
+
}
|
2540
|
+
return item;
|
2541
|
+
}
|
2542
|
+
|
2543
|
+
protected getPanel(row: number, column: number, excludeItems: HTMLElement[] | HTMLElement): PanelModel {
|
2544
|
+
if (excludeItems && !(excludeItems instanceof Array)) {
|
2545
|
+
excludeItems = [excludeItems];
|
2546
|
+
}
|
2547
|
+
let sizeY: number = 1;
|
2548
|
+
while (row > -1) {
|
2549
|
+
let sizeX: number = 1;
|
2550
|
+
let col: number = column;
|
2551
|
+
while (col > -1) {
|
2552
|
+
const items: HTMLElement[] = this.sortedArray[row];
|
2553
|
+
if (items) {
|
2554
|
+
const item: HTMLElement = items[col];
|
2555
|
+
if (item && (!excludeItems ||
|
2556
|
+
(<HTMLElement[]>excludeItems).indexOf(item) === -1) && parseInt(item.getAttribute('data-sizeX'), 10) >= sizeX
|
2557
|
+
&& parseInt(item.getAttribute('data-sizeY'), 10) >= sizeY) {
|
2558
|
+
return item;
|
2559
|
+
}
|
2560
|
+
}
|
2561
|
+
++sizeX;
|
2562
|
+
--col;
|
2563
|
+
}
|
2564
|
+
--row;
|
2565
|
+
++sizeY;
|
2566
|
+
}
|
2567
|
+
return null;
|
2568
|
+
}
|
2569
|
+
|
2570
|
+
protected setHolderPosition(args: DragEventArgs): void {
|
2571
|
+
const sizeY: number = parseInt(args.element.getAttribute('data-sizeY'), 10);
|
2572
|
+
const col: number = parseInt(args.element.getAttribute('data-col'), 10);
|
2573
|
+
const row: number = parseInt(args.element.getAttribute('data-row'), 10);
|
2574
|
+
const sizeX: number = parseInt(args.element.getAttribute('data-sizeX'), 10);
|
2575
|
+
const widthValue: number = this.getCellSize()[0];
|
2576
|
+
const heightValue: number = this.getCellSize()[1];
|
2577
|
+
const top: number = row === 0 ? 0 : (((row) * (heightValue + this.cellSpacing[1])));
|
2578
|
+
const left: number = col === 0 ? 0 : (((col) * (widthValue + this.cellSpacing[0])));
|
2579
|
+
const cellSizeOne: number = this.getCellSize()[1];
|
2580
|
+
const cellSizeZero: number = this.getCellSize()[0];
|
2581
|
+
this.elementRef.top = this.shadowEle.style.top = top + 'px';
|
2582
|
+
this.elementRef.left = this.shadowEle.style.left = left + 'px';
|
2583
|
+
this.elementRef.height = this.shadowEle.style.height = ((sizeY * cellSizeOne) + ((sizeY - 1) * this.cellSpacing[1])) + 'px';
|
2584
|
+
this.elementRef.width = this.shadowEle.style.width = ((sizeX * cellSizeZero) + ((sizeX - 1) * this.cellSpacing[0])) + 'px';
|
2585
|
+
}
|
2586
|
+
|
2587
|
+
protected getCellInstance(idValue: string): PanelModel {
|
2588
|
+
let currentCellInstance: PanelModel;
|
2589
|
+
for (let i: number = 0; i < this.panels.length; i++) {
|
2590
|
+
if (this.panels[i].id === idValue) {
|
2591
|
+
currentCellInstance = this.panels[i];
|
2592
|
+
}
|
2593
|
+
}
|
2594
|
+
return currentCellInstance;
|
2595
|
+
}
|
2596
|
+
|
2597
|
+
/**
|
2598
|
+
* Allows to add a panel to the Dashboardlayout.
|
2599
|
+
*
|
2600
|
+
* @param {panel} panel - Defines the panel element.
|
2601
|
+
*
|
2602
|
+
* @returns void
|
2603
|
+
* @deprecated
|
2604
|
+
*/
|
2605
|
+
|
2606
|
+
public addPanel(panel: PanelModel): void {
|
2607
|
+
this.panelsSizeY = 0;
|
2608
|
+
this.maxCol();
|
2609
|
+
if (!panel.minSizeX) {
|
2610
|
+
panel.minSizeX = 1;
|
2611
|
+
}
|
2612
|
+
if (!panel.minSizeY) {
|
2613
|
+
panel.minSizeY = 1;
|
2614
|
+
}
|
2615
|
+
if (!panel.id) {
|
2616
|
+
panel.id = 'layout_' + this.panelID.toString();
|
2617
|
+
this.panelID = this.panelID + 1;
|
2618
|
+
}
|
2619
|
+
// eslint-disable-next-line
|
2620
|
+
const panelProp: Panel = new Panel((<any>this), 'panels', panel, true);
|
2621
|
+
this.panels.push(panelProp);
|
2622
|
+
this.panelsInitialModel = this.cloneModels(this.panels);
|
2623
|
+
this.setMinMaxValues(panelProp);
|
2624
|
+
if (this.maxColumnValue < panelProp.col || this.maxColumnValue < (panelProp.col + panelProp.sizeX)) {
|
2625
|
+
this.panelPropertyChange(panelProp, { col: this.maxColumnValue - panelProp.sizeX });
|
2626
|
+
}
|
2627
|
+
const cell: HTMLElement = this.renderCell(panelProp, true, null);
|
2628
|
+
this.oldRowCol[panelProp.id] = { row: panelProp.row, col: panelProp.col };
|
2629
|
+
this.cloneObject[panelProp.id] = { row: panelProp.row, col: panelProp.col };
|
2630
|
+
this.updateOldRowColumn();
|
2631
|
+
this.element.insertAdjacentElement('afterbegin', cell);
|
2632
|
+
this.addPanelCalled = true;
|
2633
|
+
if (this.checkMediaQuery()) {
|
2634
|
+
this.checkMediaQuerySizing();
|
2635
|
+
this.removeResizeClasses(this.panelCollection);
|
2636
|
+
} else {
|
2637
|
+
this.mainElement = cell;
|
2638
|
+
if (!this.checkCollision) {
|
2639
|
+
this.checkCollision = [];
|
2640
|
+
}
|
2641
|
+
this.setPanelPosition(cell, panelProp.row, panelProp.col);
|
2642
|
+
this.updatePanelLayout(cell, panelProp);
|
2643
|
+
}
|
2644
|
+
this.addPanelCalled = false;
|
2645
|
+
if (this.allowDragging &&
|
2646
|
+
this.mediaQuery ? !(this.checkMediaQuery()) : false) {
|
2647
|
+
this.enableDraggingContent([document.getElementById(panelProp.id)]);
|
2648
|
+
}
|
2649
|
+
this.setClasses([cell]);
|
2650
|
+
if (this.allowFloating) {
|
2651
|
+
this.mainElement = null;
|
2652
|
+
this.moveItemsUpwards();
|
2653
|
+
}
|
2654
|
+
this.updateOldRowColumn();
|
2655
|
+
this.sortedPanel();
|
2656
|
+
this.updateCloneArrayObject();
|
2657
|
+
if (this.allowResizing) {
|
2658
|
+
for (let i: number = 0; i < cell.querySelectorAll('.e-resize').length; i++) {
|
2659
|
+
const eventName: string = (Browser.info.name === 'msie') ? 'mousedown pointerdown' : 'mousedown';
|
2660
|
+
EventHandler.add(cell.querySelectorAll('.e-resize')[i], eventName, this.downResizeHandler, this);
|
2661
|
+
if (Browser.info.name !== 'msie') {
|
2662
|
+
EventHandler.add(cell.querySelectorAll('.e-resize')[i], 'touchstart', this.touchDownResizeHandler, this);
|
2663
|
+
}
|
2664
|
+
}
|
2665
|
+
}
|
2666
|
+
this.checkForChanges(false, [panelProp]);
|
2667
|
+
}
|
2668
|
+
|
2669
|
+
/**
|
2670
|
+
* Allows to update a panel in the DashboardLayout.
|
2671
|
+
*
|
2672
|
+
* @param {panel} panel - Defines the panel element.
|
2673
|
+
*
|
2674
|
+
* @returns void
|
2675
|
+
* @deprecated
|
2676
|
+
*/
|
2677
|
+
|
2678
|
+
public updatePanel(panel: PanelModel): void {
|
2679
|
+
this.panelsSizeY = 0;
|
2680
|
+
if (!panel.id) {
|
2681
|
+
return;
|
2682
|
+
}
|
2683
|
+
const panelInstance: PanelModel = this.getCellInstance(panel.id);
|
2684
|
+
if (!panelInstance) {
|
2685
|
+
return;
|
2686
|
+
}
|
2687
|
+
this.maxCol();
|
2688
|
+
panel.col = (panel.col < 1) ? 0 : ((panel.col > this.columns)) ? this.columns - 1 : panel.col;
|
2689
|
+
if (isNullOrUndefined(panel.col)) {
|
2690
|
+
panel.col = panelInstance.col;
|
2691
|
+
}
|
2692
|
+
this.panelPropertyChange(panelInstance, panel);
|
2693
|
+
this.setMinMaxValues(panelInstance);
|
2694
|
+
const cell: HTMLElement = document.getElementById(panel.id);
|
2695
|
+
this.mainElement = cell;
|
2696
|
+
const cssClass: string[] = panelInstance.cssClass ? panelInstance.cssClass.split(' ') : null;
|
2697
|
+
this.panelContent = cell.querySelector('.e-panel-container') ?
|
2698
|
+
cell.querySelector('.e-panel-container') :
|
2699
|
+
this.createSubElement(cssClass, cell.id + '_content', panelContainer);
|
2700
|
+
cell.appendChild(this.panelContent);
|
2701
|
+
if (panelInstance.header) {
|
2702
|
+
const headerTemplateElement: HTMLElement = cell.querySelector('.e-panel-header') ?
|
2703
|
+
cell.querySelector('.e-panel-header') : this.createSubElement([], cell.id + 'template', '');
|
2704
|
+
addClass([headerTemplateElement], [header]);
|
2705
|
+
headerTemplateElement.innerHTML = '';
|
2706
|
+
const id: string = this.element.id + 'HeaderTemplate' + panelInstance.id;
|
2707
|
+
this.renderTemplate(<string>panelInstance.header, headerTemplateElement, id, true, 'header');
|
2708
|
+
this.panelContent.appendChild(headerTemplateElement);
|
2709
|
+
this.renderReactTemplates();
|
2710
|
+
} else {
|
2711
|
+
if (cell.querySelector('.e-panel-header')) {
|
2712
|
+
detach(cell.querySelector('.e-panel-header'));
|
2713
|
+
}
|
2714
|
+
}
|
2715
|
+
if (panelInstance.content) {
|
2716
|
+
const cssClass: string[] = panelInstance.cssClass ? panelInstance.cssClass.split(' ') : null;
|
2717
|
+
this.panelBody = cell.querySelector('.e-panel-content') ? cell.querySelector('.e-panel-content') :
|
2718
|
+
this.createSubElement(cssClass, cell.id + '_body', panelContent);
|
2719
|
+
this.panelBody.innerHTML = '';
|
2720
|
+
const headerHeight: string = this.panelContent.querySelector('.e-panel-header') ?
|
2721
|
+
window.getComputedStyle(this.panelContent.querySelector('.e-panel-header')).height : '0px';
|
2722
|
+
const contentHeightValue: string = 'calc( 100% - ' + headerHeight + ')';
|
2723
|
+
setStyle(this.panelBody, { height: contentHeightValue });
|
2724
|
+
const id: string = this.element.id + 'ContentTemplate' + panelInstance.id;
|
2725
|
+
this.renderTemplate(<string>panelInstance.content, this.panelBody, id, true, 'content');
|
2726
|
+
this.panelContent.appendChild(this.panelBody);
|
2727
|
+
this.renderReactTemplates();
|
2728
|
+
} else {
|
2729
|
+
if (cell.querySelector('.e-panel-content')) {
|
2730
|
+
detach(cell.querySelector('.e-panel-content'));
|
2731
|
+
}
|
2732
|
+
}
|
2733
|
+
this.setXYAttributes(cell, panelInstance);
|
2734
|
+
this.setHeightAndWidth(cell, panelInstance);
|
2735
|
+
this.setPanelPosition(cell, panelInstance.row, panelInstance.col);
|
2736
|
+
this.updatePanelLayout(cell, panelInstance);
|
2737
|
+
if (this.checkMediaQuery()) { this.checkMediaQuerySizing(); }
|
2738
|
+
this.mainElement = null;
|
2739
|
+
this.updatePanels();
|
2740
|
+
this.updateCloneArrayObject();
|
2741
|
+
}
|
2742
|
+
|
2743
|
+
protected updateCloneArrayObject(): void {
|
2744
|
+
this.cloneArray = this.sortedArray;
|
2745
|
+
this.cloneObject = JSON.parse(JSON.stringify(this.oldRowCol));
|
2746
|
+
}
|
2747
|
+
|
2748
|
+
/**
|
2749
|
+
* Returns the panels object of the DashboardLayout.
|
2750
|
+
*
|
2751
|
+
* @returns [`PanelModel[]`](./panelModel)
|
2752
|
+
*/
|
2753
|
+
|
2754
|
+
public serialize(): PanelModel[] {
|
2755
|
+
const cloneModel: PanelModel[] = this.cloneModels(this.panels);
|
2756
|
+
const customObject: {
|
2757
|
+
id: string, row: number, col: number, sizeX: number,
|
2758
|
+
sizeY: number, minSizeX: number, minSizeY: number, maxSizeX: number,
|
2759
|
+
maxSizeY: number
|
2760
|
+
}[] = [];
|
2761
|
+
for (let i: number = 0; i < cloneModel.length; i++) {
|
2762
|
+
customObject.push({
|
2763
|
+
id: cloneModel[i].id, row: cloneModel[i].row, col: cloneModel[i].col, sizeX: cloneModel[i].sizeX,
|
2764
|
+
sizeY: cloneModel[i].sizeY, minSizeX: cloneModel[i].minSizeX, minSizeY: cloneModel[i].minSizeY,
|
2765
|
+
maxSizeX: cloneModel[i].maxSizeX, maxSizeY: cloneModel[i].maxSizeY
|
2766
|
+
});
|
2767
|
+
}
|
2768
|
+
return (customObject);
|
2769
|
+
}
|
2770
|
+
|
2771
|
+
/**
|
2772
|
+
* Removes all the panels from the DashboardLayout.
|
2773
|
+
*/
|
2774
|
+
|
2775
|
+
public removeAll(): void {
|
2776
|
+
this.removeAllCalled = true;
|
2777
|
+
for (let i: number = 0; i < this.panelCollection.length; i++) {
|
2778
|
+
detach(this.panelCollection[i]);
|
2779
|
+
this.clearTemplate();
|
2780
|
+
}
|
2781
|
+
this.removeAllPanel();
|
2782
|
+
this.rows = 0;
|
2783
|
+
this.gridPanelCollection = [];
|
2784
|
+
this.setHeightWidth();
|
2785
|
+
this.sortedPanel();
|
2786
|
+
this.sortedArray = [];
|
2787
|
+
this.overlapElementClone = [];
|
2788
|
+
this.overlapElement = [];
|
2789
|
+
this.overlapSubElementClone = [];
|
2790
|
+
this.panelCollection = [];
|
2791
|
+
this.oldRowCol = {};
|
2792
|
+
this.cloneObject = {};
|
2793
|
+
const clonedPanels: PanelModel[] = this.cloneModels(this.panels);
|
2794
|
+
this.setProperties({ panels: [] }, true);
|
2795
|
+
this.updatePanels();
|
2796
|
+
this.updateCloneArrayObject();
|
2797
|
+
this.checkForChanges(false, null, clonedPanels);
|
2798
|
+
this.removeAllCalled = false;
|
2799
|
+
}
|
2800
|
+
|
2801
|
+
/**
|
2802
|
+
* Removes the panel from the DashboardLayout.
|
2803
|
+
*
|
2804
|
+
* @param {string} id - Defines the panel ID.
|
2805
|
+
*
|
2806
|
+
* @returns void
|
2807
|
+
*/
|
2808
|
+
|
2809
|
+
public removePanel(id: string): void {
|
2810
|
+
this.panelsSizeY = 0;
|
2811
|
+
this.panelsInitialModel = this.cloneModels(this.panels);
|
2812
|
+
let removedPanel: PanelModel;
|
2813
|
+
for (let i: number = 0; i < this.panelCollection.length; i++) {
|
2814
|
+
if (this.panelCollection[i].id === id) {
|
2815
|
+
detach(this.panelCollection[i]);
|
2816
|
+
this.panelCollection.splice(i, 1);
|
2817
|
+
}
|
2818
|
+
if (this.panels[i].id === id) {
|
2819
|
+
removedPanel = this.panels[i];
|
2820
|
+
this.panels.splice(i, 1);
|
2821
|
+
this.panelsInitialModel.splice(i, 1);
|
2822
|
+
this.updateOldRowColumn();
|
2823
|
+
this.sortedPanel();
|
2824
|
+
}
|
2825
|
+
}
|
2826
|
+
this.updatePanels();
|
2827
|
+
if (this.checkMediaQuery()) {
|
2828
|
+
this.isPanelRemoved = true;
|
2829
|
+
this.checkMediaQuerySizing();
|
2830
|
+
this.isPanelRemoved = false;
|
2831
|
+
}
|
2832
|
+
this.gridPanelCollection.forEach((item: HTMLElement) => {
|
2833
|
+
if (item.id === id) {
|
2834
|
+
this.gridPanelCollection.splice(this.gridPanelCollection.indexOf(item), 1);
|
2835
|
+
}
|
2836
|
+
});
|
2837
|
+
this.updateCloneArrayObject();
|
2838
|
+
this.checkForChanges(false, null, [removedPanel]);
|
2839
|
+
}
|
2840
|
+
|
2841
|
+
constructor(options?: DashboardLayoutModel, element?: string | HTMLInputElement) {
|
2842
|
+
super(options, element);
|
2843
|
+
setValue('mergePersistData', this.mergePersistPanelData, this);
|
2844
|
+
}
|
2845
|
+
|
2846
|
+
/**
|
2847
|
+
*Moves the panel in the DashboardLayout.
|
2848
|
+
*
|
2849
|
+
* @param {string} id - Defines the panel ID.
|
2850
|
+
*
|
2851
|
+
* @param {number} row - Defines the row of dashboard layout.
|
2852
|
+
*
|
2853
|
+
* @param {number} col - Defines the column of dashboard layout.
|
2854
|
+
*
|
2855
|
+
* @returns void
|
2856
|
+
*/
|
2857
|
+
|
2858
|
+
public movePanel(id: string, row: number, col: number): void {
|
2859
|
+
this.movePanelCalled = true;
|
2860
|
+
this.panelsInitialModel = this.cloneModels(this.panels);
|
2861
|
+
const panelInstance: PanelModel = this.getCellInstance(id);
|
2862
|
+
if ((isNaN(row) || row === null) || (isNaN(col) || col === null) || !panelInstance) {
|
2863
|
+
return;
|
2864
|
+
}
|
2865
|
+
if (col < 0) {
|
2866
|
+
col = 0;
|
2867
|
+
} else if (col > this.columns) {
|
2868
|
+
col = this.columns - panelInstance.sizeX;
|
2869
|
+
}
|
2870
|
+
this.panelPropertyChange(panelInstance, { row: row, col: col });
|
2871
|
+
const ele: HTMLElement = document.getElementById(id);
|
2872
|
+
this.mainElement = ele;
|
2873
|
+
this.startRow = parseInt(ele.getAttribute('data-row'), 10);
|
2874
|
+
this.startCol = parseInt(ele.getAttribute('data-col'), 10);
|
2875
|
+
this.setAttributes({ value: { col: col.toString(), row: row.toString() } }, ele);
|
2876
|
+
this.updateOldRowColumn();
|
2877
|
+
this.setPanelPosition(ele, row, col);
|
2878
|
+
this.updatePanelLayout(ele, panelInstance);
|
2879
|
+
this.updateRowHeight();
|
2880
|
+
this.updatePanels();
|
2881
|
+
this.updateCloneArrayObject();
|
2882
|
+
this.mainElement = null;
|
2883
|
+
if (this.allowFloating) {
|
2884
|
+
this.moveItemsUpwards();
|
2885
|
+
}
|
2886
|
+
this.movePanelCalled = false;
|
2887
|
+
this.checkForChanges(false);
|
2888
|
+
}
|
2889
|
+
|
2890
|
+
protected setAttributes(value: IAttributes, ele: HTMLElement): void {
|
2891
|
+
for (let i: number = 0; i < Object.keys(value).length; i++) {
|
2892
|
+
if (Object.keys(value)) {
|
2893
|
+
if (value[Object.keys(value)[i]].col) {
|
2894
|
+
ele.setAttribute('data-col', value[Object.keys(value)[i]].col.toString());
|
2895
|
+
}
|
2896
|
+
if (value[Object.keys(value)[i]].row) {
|
2897
|
+
ele.setAttribute('data-row', value[Object.keys(value)[i]].row.toString());
|
2898
|
+
}
|
2899
|
+
if (value[Object.keys(value)[i]].sizeX) {
|
2900
|
+
ele.setAttribute('data-sizeX', value[Object.keys(value)[i]].sizeX.toString());
|
2901
|
+
}
|
2902
|
+
if (value[Object.keys(value)[i]].sizeY) {
|
2903
|
+
ele.setAttribute('data-sizeY', value[Object.keys(value)[i]].sizeY.toString());
|
2904
|
+
}
|
2905
|
+
if (value[Object.keys(value)[i]].minSizeX) {
|
2906
|
+
ele.setAttribute('data-minSizeX', value[Object.keys(value)[i]].minSizeX.toString());
|
2907
|
+
}
|
2908
|
+
if (value[Object.keys(value)[i]].minSizeY) {
|
2909
|
+
ele.setAttribute('data-minSizeY', value[Object.keys(value)[i]].minSizeY.toString());
|
2910
|
+
}
|
2911
|
+
if (value[Object.keys(value)[i]].maxSizeX) {
|
2912
|
+
ele.setAttribute('data-maxSizeY', value[Object.keys(value)[i]].maxSizeX.toString());
|
2913
|
+
}
|
2914
|
+
if (value[Object.keys(value)[i]].maxSizeY) {
|
2915
|
+
ele.setAttribute('data-maxSizeY', value[Object.keys(value)[i]].maxSizeY.toString());
|
2916
|
+
}
|
2917
|
+
}
|
2918
|
+
}
|
2919
|
+
}
|
2920
|
+
|
2921
|
+
/**
|
2922
|
+
* Resize the panel in the DashboardLayout.
|
2923
|
+
*
|
2924
|
+
* @param {string} id - Defines the panel ID.
|
2925
|
+
*
|
2926
|
+
* @param {number} sizeX - Defines the sizeX of dashboard layout.
|
2927
|
+
*
|
2928
|
+
* @param {number} sizeY - Defines the sizeY of dashboard layout.
|
2929
|
+
*/
|
2930
|
+
|
2931
|
+
public resizePanel(id: string, sizeX: number, sizeY: number): void {
|
2932
|
+
this.panelsInitialModel = this.cloneModels(this.panels);
|
2933
|
+
const panelInstance: PanelModel = this.getCellInstance(id);
|
2934
|
+
this.resizeCalled = true;
|
2935
|
+
const ele: HTMLElement = document.getElementById(id);
|
2936
|
+
const args: ResizeArgs = { event: null, element: ele, isInteracted: false };
|
2937
|
+
this.trigger('resizeStart', args);
|
2938
|
+
this.panelPropertyChange(panelInstance, { sizeX: sizeX, sizeY: sizeY });
|
2939
|
+
this.setMinMaxValues(panelInstance);
|
2940
|
+
this.checkMinMaxValues(panelInstance);
|
2941
|
+
this.mainElement = ele;
|
2942
|
+
this.setAttributes({ value: { sizeX: panelInstance.sizeX.toString(), sizeY: panelInstance.sizeY.toString() } }, ele);
|
2943
|
+
this.setHeightAndWidth(ele, panelInstance);
|
2944
|
+
this.updatePanelLayout(ele, panelInstance);
|
2945
|
+
this.updatePanels();
|
2946
|
+
this.updateRowHeight();
|
2947
|
+
this.resizeCalled = false;
|
2948
|
+
this.trigger('resizeStop', args);
|
2949
|
+
this.checkForChanges(false);
|
2950
|
+
}
|
2951
|
+
|
2952
|
+
/**
|
2953
|
+
* Destroys the DashboardLayout component
|
2954
|
+
*
|
2955
|
+
* @returns void
|
2956
|
+
*/
|
2957
|
+
|
2958
|
+
public destroy(): void {
|
2959
|
+
// eslint-disable-next-line
|
2960
|
+
EventHandler.remove(window as any, 'resize', this.refreshListener);
|
2961
|
+
removeClass([this.element], ['e-dashboardlayout', 'e-lib', 'e-responsive', 'e-control']);
|
2962
|
+
this.element.removeAttribute('style');
|
2963
|
+
for (let i: number = 0; i < this.dragCollection.length; i++) {
|
2964
|
+
this.dragCollection[i].destroy();
|
2965
|
+
}
|
2966
|
+
this.removeAllPanel();
|
2967
|
+
super.destroy();
|
2968
|
+
this.clearTemplate();
|
2969
|
+
this.renderReactTemplates();
|
2970
|
+
}
|
2971
|
+
|
2972
|
+
private removeAllPanel(): void {
|
2973
|
+
while (this.element.firstElementChild) {
|
2974
|
+
detach(this.element.firstElementChild);
|
2975
|
+
this.clearTemplate();
|
2976
|
+
}
|
2977
|
+
}
|
2978
|
+
|
2979
|
+
protected setEnableRtl(): void {
|
2980
|
+
if (this.enableRtl === true) {
|
2981
|
+
addClass([this.element], 'e-rtl');
|
2982
|
+
}
|
2983
|
+
else {
|
2984
|
+
removeClass([this.element], 'e-rtl');
|
2985
|
+
}
|
2986
|
+
}
|
2987
|
+
/**
|
2988
|
+
* Called internally if any of the property value changed.
|
2989
|
+
* returns void
|
2990
|
+
*
|
2991
|
+
* @private
|
2992
|
+
*/
|
2993
|
+
|
2994
|
+
private updateCellSizeAndSpacing(): void {
|
2995
|
+
this.panelResponsiveUpdate();
|
2996
|
+
this.setHeightWidth();
|
2997
|
+
this.getRowColumn();
|
2998
|
+
for (let i: number = 0; i < this.element.querySelectorAll('.e-panel').length; i++) {
|
2999
|
+
const ele: HTMLElement = <HTMLElement>this.element.querySelectorAll('.e-panel')[i];
|
3000
|
+
const panelModel: PanelModel = this.getCellInstance(ele.id);
|
3001
|
+
this.setHeightAndWidth(ele, panelModel);
|
3002
|
+
this.setPanelPosition(ele, panelModel.row, panelModel.col);
|
3003
|
+
}
|
3004
|
+
}
|
3005
|
+
|
3006
|
+
private updatePanelsDynamically(panels: PanelModel[]): void {
|
3007
|
+
this.removeAll();
|
3008
|
+
this.setProperties({ panels: panels }, true);
|
3009
|
+
this.setOldRowCol();
|
3010
|
+
if (this.table) { this.table.remove(); }
|
3011
|
+
this.initialize();
|
3012
|
+
if (this.checkMediaQuery()) {
|
3013
|
+
this.refresh();
|
3014
|
+
}
|
3015
|
+
if (this.showGridLines) {
|
3016
|
+
this.initGridLines();
|
3017
|
+
}
|
3018
|
+
}
|
3019
|
+
|
3020
|
+
private checkForIDValues(panels: PanelModel[]): void {
|
3021
|
+
if (!isNullOrUndefined(panels) && panels.length > 0) {
|
3022
|
+
this.panelID = 0;
|
3023
|
+
panels.forEach((panel: PanelModel) => {
|
3024
|
+
if (!panel.id) {
|
3025
|
+
this.panelPropertyChange(panel, { id: 'layout_' + this.panelID.toString() });
|
3026
|
+
this.panelID = this.panelID + 1;
|
3027
|
+
}
|
3028
|
+
});
|
3029
|
+
} else {
|
3030
|
+
this.restrictDynamicUpdate = true;
|
3031
|
+
}
|
3032
|
+
}
|
3033
|
+
|
3034
|
+
/**
|
3035
|
+
* Called internally if any of the property value changed.
|
3036
|
+
*
|
3037
|
+
* returns void
|
3038
|
+
*
|
3039
|
+
* @private
|
3040
|
+
*/
|
3041
|
+
|
3042
|
+
// eslint-disable-next-line
|
3043
|
+
public onPropertyChanged(newProp: DashboardLayoutModel, oldProp: DashboardLayoutModel): void {
|
3044
|
+
if (newProp.panels && newProp.panels.length > 0 && newProp.panels[0] instanceof Panel) { this.checkForIDValues(newProp.panels); }
|
3045
|
+
for (const prop of Object.keys(newProp)) {
|
3046
|
+
switch (prop) {
|
3047
|
+
case 'enableRtl':
|
3048
|
+
this.setProperties({ enableRtl: newProp.enableRtl }, true);
|
3049
|
+
this.setEnableRtl();
|
3050
|
+
break;
|
3051
|
+
case 'mediaQuery':
|
3052
|
+
this.setProperties({ mediaQuery: newProp.mediaQuery }, true);
|
3053
|
+
if (this.checkMediaQuery()) { this.checkMediaQuerySizing(); }
|
3054
|
+
break;
|
3055
|
+
case 'allowDragging':
|
3056
|
+
this.setProperties({ allowDragging: newProp.allowDragging }, true);
|
3057
|
+
this.ensureDrag();
|
3058
|
+
break;
|
3059
|
+
case 'allowResizing':
|
3060
|
+
this.setProperties({ allowResizing: newProp.allowResizing }, true);
|
3061
|
+
if (this.allowResizing) {
|
3062
|
+
this.setClasses(this.panelCollection);
|
3063
|
+
this.resizeEvents();
|
3064
|
+
} else {
|
3065
|
+
const panelElements: NodeList = this.element.querySelectorAll('.e-panel .e-panel-container .e-resize');
|
3066
|
+
for (let i: number = 0; i < panelElements.length; i++) {
|
3067
|
+
const eventName: string = (Browser.info.name === 'msie') ? 'mousedown pointerdown' : 'mousedown';
|
3068
|
+
const element: HTMLElement = <HTMLElement>panelElements[i];
|
3069
|
+
EventHandler.remove(element, eventName, this.downResizeHandler);
|
3070
|
+
if (Browser.info.name !== 'msie') {
|
3071
|
+
EventHandler.remove(element, 'touchstart', this.touchDownResizeHandler);
|
3072
|
+
}
|
3073
|
+
}
|
3074
|
+
this.removeResizeClasses(this.panelCollection);
|
3075
|
+
}
|
3076
|
+
break;
|
3077
|
+
case 'cellSpacing':
|
3078
|
+
this.setProperties({ cellSpacing: newProp.cellSpacing }, true);
|
3079
|
+
this.updateCellSizeAndSpacing();
|
3080
|
+
this.updateGridLines();
|
3081
|
+
break;
|
3082
|
+
case 'draggableHandle':
|
3083
|
+
this.setProperties({ draggableHandle: newProp.draggableHandle }, true);
|
3084
|
+
this.ensureDrag();
|
3085
|
+
break;
|
3086
|
+
case 'allowFloating':
|
3087
|
+
this.setProperties({ allowFloating: newProp.allowFloating }, true);
|
3088
|
+
this.moveItemsUpwards();
|
3089
|
+
break;
|
3090
|
+
case 'showGridLines':
|
3091
|
+
if (this.showGridLines) {
|
3092
|
+
this.setProperties({ showGridLines: newProp.showGridLines }, true);
|
3093
|
+
this.initGridLines();
|
3094
|
+
} else {
|
3095
|
+
if (this.table) {
|
3096
|
+
detach(this.table);
|
3097
|
+
}
|
3098
|
+
}
|
3099
|
+
break;
|
3100
|
+
case 'allowPushing':
|
3101
|
+
this.setProperties({ allowPushing: newProp.allowPushing }, true);
|
3102
|
+
break;
|
3103
|
+
case 'panels':
|
3104
|
+
if (!newProp.columns && !this.restrictDynamicUpdate && (newProp.panels[0] && newProp.panels.length > 0)) {
|
3105
|
+
this.isRenderComplete = false;
|
3106
|
+
this.updatePanelsDynamically(newProp.panels);
|
3107
|
+
this.isRenderComplete = true;
|
3108
|
+
} else if (!(newProp.panels[0] && newProp.panels.length)) {
|
3109
|
+
this.isRenderComplete = false;
|
3110
|
+
this.updatePanelsDynamically(this.panels);
|
3111
|
+
this.isRenderComplete = true;
|
3112
|
+
} else { this.restrictDynamicUpdate = false; }
|
3113
|
+
break;
|
3114
|
+
case 'columns':
|
3115
|
+
this.isRenderComplete = false;
|
3116
|
+
if (newProp.panels) {
|
3117
|
+
this.updatePanelsDynamically(newProp.panels);
|
3118
|
+
}
|
3119
|
+
this.setProperties({ columns: newProp.columns }, true);
|
3120
|
+
this.panelCollection = []; this.maxColumnValue = this.columns;
|
3121
|
+
this.calculateCellSize();
|
3122
|
+
this.panels.forEach((panel: PanelModel) => {
|
3123
|
+
this.setMinMaxValues(panel);
|
3124
|
+
if (this.maxColumnValue < panel.col || this.maxColumnValue < (panel.col + panel.sizeX)) {
|
3125
|
+
const colValue: number = this.maxColumnValue - panel.sizeX;
|
3126
|
+
this.panelPropertyChange(panel, { col: colValue < 0 ? 0 : colValue });
|
3127
|
+
this.setXYAttributes(document.getElementById(panel.id), panel);
|
3128
|
+
}
|
3129
|
+
this.setHeightAndWidth(document.getElementById(panel.id), panel);
|
3130
|
+
this.panelCollection.push(document.getElementById(panel.id));
|
3131
|
+
this.setPanelPosition(document.getElementById(panel.id), panel.row, panel.col);
|
3132
|
+
this.mainElement = document.getElementById(panel.id);
|
3133
|
+
this.updatePanelLayout(document.getElementById(panel.id), panel);
|
3134
|
+
this.mainElement = null;
|
3135
|
+
});
|
3136
|
+
this.updatePanels();
|
3137
|
+
this.updateCloneArrayObject();
|
3138
|
+
this.isRenderComplete = true;
|
3139
|
+
this.updateGridLines();
|
3140
|
+
break;
|
3141
|
+
}
|
3142
|
+
}
|
3143
|
+
}
|
3144
|
+
/**
|
3145
|
+
* Gets the properties to be maintained upon browser refresh.
|
3146
|
+
*
|
3147
|
+
* @returns string
|
3148
|
+
* @private
|
3149
|
+
*/
|
3150
|
+
|
3151
|
+
public getPersistData(): string {
|
3152
|
+
const keyEntity: string[] = ['panels'];
|
3153
|
+
return this.addOnPersist(keyEntity);
|
3154
|
+
}
|
3155
|
+
|
3156
|
+
/* istanbul ignore next */
|
3157
|
+
private mergePersistPanelData(persistedData?: Object): void {
|
3158
|
+
const data: string = window.localStorage.getItem(this.getModuleName() + this.element.id);
|
3159
|
+
if (!(isNullOrUndefined(data) || (data === '')) || !isNullOrUndefined(persistedData)) {
|
3160
|
+
const dataObj: DashboardLayout = !isNullOrUndefined(persistedData) ? persistedData : JSON.parse(data);
|
3161
|
+
const keys: string[] = Object.keys(dataObj);
|
3162
|
+
this.isProtectedOnChange = true;
|
3163
|
+
for (const key of keys) {
|
3164
|
+
if ((typeof getValue(key, this) === 'object' && !isNullOrUndefined(getValue(key, this)))) {
|
3165
|
+
if (Array.isArray(getValue(key, this)) && key === 'panels') {
|
3166
|
+
this.mergePanels(<Panel[]>dataObj[key], <Panel[]>this[key]);
|
3167
|
+
}
|
3168
|
+
}
|
3169
|
+
}
|
3170
|
+
this.isProtectedOnChange = false;
|
3171
|
+
}
|
3172
|
+
}
|
3173
|
+
|
3174
|
+
/* istanbul ignore next */
|
3175
|
+
protected mergePanels(sortedPanels: Panel[], panels: Panel[]): void {
|
3176
|
+
const storedColumns: Panel[] = (<Panel[]>sortedPanels);
|
3177
|
+
for (let i: number = 0; i < storedColumns.length; i++) {
|
3178
|
+
this.checkForIDValues(panels);
|
3179
|
+
const localPanel: Panel = panels.filter((pan: Panel) => pan.id === storedColumns[i].id)[0];
|
3180
|
+
if (!isNullOrUndefined(localPanel)) {
|
3181
|
+
storedColumns[i] = <Panel>extend(localPanel, storedColumns[i], {}, true);
|
3182
|
+
}
|
3183
|
+
}
|
3184
|
+
}
|
3185
|
+
|
3186
|
+
/**
|
3187
|
+
* Returns the current module name.
|
3188
|
+
*
|
3189
|
+
* @returns string
|
3190
|
+
*
|
3191
|
+
* @private
|
3192
|
+
*/
|
3193
|
+
|
3194
|
+
protected getModuleName(): string {
|
3195
|
+
return 'DashboardLayout';
|
3196
|
+
}
|
3197
|
+
|
3198
|
+
}
|
3199
|
+
|
3200
|
+
/**
|
3201
|
+
* Defines the dragstart event arguments
|
3202
|
+
*/
|
3203
|
+
export interface DragStartArgs {
|
3204
|
+
|
3205
|
+
/**
|
3206
|
+
* Specifies the original event.
|
3207
|
+
*/
|
3208
|
+
event: MouseEvent | TouchEvent;
|
3209
|
+
|
3210
|
+
/**
|
3211
|
+
* Illustrates whether the current action needs to be prevented or not.
|
3212
|
+
*/
|
3213
|
+
cancel: boolean;
|
3214
|
+
|
3215
|
+
/**
|
3216
|
+
* Specifies the cell element being dragged.
|
3217
|
+
*/
|
3218
|
+
element: HTMLElement;
|
3219
|
+
}
|
3220
|
+
|
3221
|
+
|
3222
|
+
/**
|
3223
|
+
* Defines the change event arguments
|
3224
|
+
*/
|
3225
|
+
export interface ChangeEventArgs {
|
3226
|
+
|
3227
|
+
/**
|
3228
|
+
* Specifies the model values of the position changed panels.
|
3229
|
+
*/
|
3230
|
+
changedPanels: PanelModel[];
|
3231
|
+
/**
|
3232
|
+
* Specifies that event has triggered by user interaction.
|
3233
|
+
*/
|
3234
|
+
isInteracted: boolean;
|
3235
|
+
/**
|
3236
|
+
* Specifies the panel added to the DashboardLayout.
|
3237
|
+
*/
|
3238
|
+
addedPanels: PanelModel[];
|
3239
|
+
/**
|
3240
|
+
* Specifies the panels removed from the DashboardLayout.
|
3241
|
+
*/
|
3242
|
+
removedPanels: PanelModel[];
|
3243
|
+
}
|
3244
|
+
|
3245
|
+
/**
|
3246
|
+
* Defines the Drag event arguments
|
3247
|
+
*/
|
3248
|
+
|
3249
|
+
export interface DraggedEventArgs {
|
3250
|
+
|
3251
|
+
/**
|
3252
|
+
* Specifies the original event.
|
3253
|
+
*/
|
3254
|
+
event: MouseEvent | TouchEvent;
|
3255
|
+
|
3256
|
+
/**
|
3257
|
+
* Specifies the cell element being dragged.
|
3258
|
+
*/
|
3259
|
+
element: HTMLElement;
|
3260
|
+
|
3261
|
+
/**
|
3262
|
+
* Specifies the element below the cell element being dragged.
|
3263
|
+
*/
|
3264
|
+
target: HTMLElement;
|
3265
|
+
}
|
3266
|
+
|
3267
|
+
/**
|
3268
|
+
* Defines the dragstop event arguments
|
3269
|
+
*/
|
3270
|
+
export interface DragStopArgs {
|
3271
|
+
|
3272
|
+
/**
|
3273
|
+
* Specifies the original event.
|
3274
|
+
*/
|
3275
|
+
event: MouseEvent | TouchEvent;
|
3276
|
+
|
3277
|
+
/**
|
3278
|
+
* Specifies the cell element being dragged.
|
3279
|
+
*/
|
3280
|
+
element: HTMLElement;
|
3281
|
+
}
|
3282
|
+
|
3283
|
+
|
3284
|
+
/**
|
3285
|
+
* Defines the resize event arguments
|
3286
|
+
*/
|
3287
|
+
export interface ResizeArgs {
|
3288
|
+
|
3289
|
+
/**
|
3290
|
+
* Specifies the original event.
|
3291
|
+
*/
|
3292
|
+
event: MouseEvent | TouchEvent;
|
3293
|
+
|
3294
|
+
/**
|
3295
|
+
* Specifies the cell element being resized.
|
3296
|
+
*/
|
3297
|
+
element: HTMLElement;
|
3298
|
+
/**
|
3299
|
+
* Specifies that event has triggered by user interaction.
|
3300
|
+
*/
|
3301
|
+
isInteracted: boolean;
|
3302
|
+
}
|
3303
|
+
|
3304
|
+
interface IAttributes {
|
3305
|
+
[key: string]: {
|
3306
|
+
sizeX?: string | number;
|
3307
|
+
sizeY?: string | number;
|
3308
|
+
minSizeX?: string | number;
|
3309
|
+
minSizeY?: string | number;
|
3310
|
+
maxSizeX?: string | number;
|
3311
|
+
maxSizeY?: string | number;
|
3312
|
+
row?: string | number;
|
3313
|
+
col?: string | number;
|
3314
|
+
};
|
3315
|
+
}
|
3316
|
+
|
3317
|
+
interface IChangePanel {
|
3318
|
+
sizeX?: number;
|
3319
|
+
sizeY?: number;
|
3320
|
+
minSizeX?: number;
|
3321
|
+
minSizeY?: number;
|
3322
|
+
maxSizeX?: number;
|
3323
|
+
maxSizeY?: number;
|
3324
|
+
row?: number;
|
3325
|
+
col?: number;
|
3326
|
+
id?: string;
|
3327
|
+
header?: string | HTMLElement;
|
3328
|
+
content?: string | HTMLElement;
|
3329
|
+
}
|