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