@schneideress/dashboardframework 0.0.1

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.
Files changed (110) hide show
  1. package/README.md +24 -0
  2. package/bundles/schneideress-dashboardframework.umd.js +5666 -0
  3. package/bundles/schneideress-dashboardframework.umd.js.map +1 -0
  4. package/bundles/schneideress-dashboardframework.umd.min.js +2 -0
  5. package/bundles/schneideress-dashboardframework.umd.min.js.map +1 -0
  6. package/esm2015/gridster/index.js +18 -0
  7. package/esm2015/gridster/lib/gridster.component.js +695 -0
  8. package/esm2015/gridster/lib/gridster.interface.js +84 -0
  9. package/esm2015/gridster/lib/gridster.module.js +27 -0
  10. package/esm2015/gridster/lib/gridsterCompact.service.js +223 -0
  11. package/esm2015/gridster/lib/gridsterConfig.constant.js +179 -0
  12. package/esm2015/gridster/lib/gridsterConfig.interface.js +219 -0
  13. package/esm2015/gridster/lib/gridsterConfigS.interface.js +161 -0
  14. package/esm2015/gridster/lib/gridsterDraggable.service.js +510 -0
  15. package/esm2015/gridster/lib/gridsterEmptyCell.service.js +317 -0
  16. package/esm2015/gridster/lib/gridsterItem.component.js +213 -0
  17. package/esm2015/gridster/lib/gridsterItem.interface.js +46 -0
  18. package/esm2015/gridster/lib/gridsterItemComponent.interface.js +48 -0
  19. package/esm2015/gridster/lib/gridsterPreview.component.js +66 -0
  20. package/esm2015/gridster/lib/gridsterPush.service.js +467 -0
  21. package/esm2015/gridster/lib/gridsterPushResize.service.js +358 -0
  22. package/esm2015/gridster/lib/gridsterRenderer.service.js +277 -0
  23. package/esm2015/gridster/lib/gridsterResizable.service.js +552 -0
  24. package/esm2015/gridster/lib/gridsterResizeEventType.interface.js +19 -0
  25. package/esm2015/gridster/lib/gridsterScroll.service.js +195 -0
  26. package/esm2015/gridster/lib/gridsterSwap.service.js +134 -0
  27. package/esm2015/gridster/lib/gridsterUtils.service.js +137 -0
  28. package/esm2015/lib/ra-dashboard-area/ra.dashboard.area.js +258 -0
  29. package/esm2015/lib/ra-widget-container/ra.widget.container.component.js +216 -0
  30. package/esm2015/lib/ra.base.dashboard.filter.js +35 -0
  31. package/esm2015/lib/ra.base.dashboard.template.js +63 -0
  32. package/esm2015/lib/ra.dashbard.event.bus.js +85 -0
  33. package/esm2015/lib/ra.dashboard.module.js +31 -0
  34. package/esm2015/lib/ra.dashboard.service.js +213 -0
  35. package/esm2015/lib/ra.event.enum.js +33 -0
  36. package/esm2015/lib/ra.gridster.config.js +63 -0
  37. package/esm2015/public-api.js +16 -0
  38. package/esm2015/schneideress-dashboardframework.js +13 -0
  39. package/esm5/gridster/index.js +18 -0
  40. package/esm5/gridster/lib/gridster.component.js +798 -0
  41. package/esm5/gridster/lib/gridster.interface.js +94 -0
  42. package/esm5/gridster/lib/gridster.module.js +31 -0
  43. package/esm5/gridster/lib/gridsterCompact.service.js +253 -0
  44. package/esm5/gridster/lib/gridsterConfig.constant.js +179 -0
  45. package/esm5/gridster/lib/gridsterConfig.interface.js +219 -0
  46. package/esm5/gridster/lib/gridsterConfigS.interface.js +161 -0
  47. package/esm5/gridster/lib/gridsterDraggable.service.js +549 -0
  48. package/esm5/gridster/lib/gridsterEmptyCell.service.js +358 -0
  49. package/esm5/gridster/lib/gridsterItem.component.js +238 -0
  50. package/esm5/gridster/lib/gridsterItem.interface.js +46 -0
  51. package/esm5/gridster/lib/gridsterItemComponent.interface.js +58 -0
  52. package/esm5/gridster/lib/gridsterPreview.component.js +70 -0
  53. package/esm5/gridster/lib/gridsterPush.service.js +547 -0
  54. package/esm5/gridster/lib/gridsterPushResize.service.js +423 -0
  55. package/esm5/gridster/lib/gridsterRenderer.service.js +323 -0
  56. package/esm5/gridster/lib/gridsterResizable.service.js +629 -0
  57. package/esm5/gridster/lib/gridsterResizeEventType.interface.js +19 -0
  58. package/esm5/gridster/lib/gridsterScroll.service.js +195 -0
  59. package/esm5/gridster/lib/gridsterSwap.service.js +152 -0
  60. package/esm5/gridster/lib/gridsterUtils.service.js +177 -0
  61. package/esm5/lib/ra-dashboard-area/ra.dashboard.area.js +307 -0
  62. package/esm5/lib/ra-widget-container/ra.widget.container.component.js +277 -0
  63. package/esm5/lib/ra.base.dashboard.filter.js +38 -0
  64. package/esm5/lib/ra.base.dashboard.template.js +63 -0
  65. package/esm5/lib/ra.dashbard.event.bus.js +125 -0
  66. package/esm5/lib/ra.dashboard.module.js +35 -0
  67. package/esm5/lib/ra.dashboard.service.js +295 -0
  68. package/esm5/lib/ra.event.enum.js +33 -0
  69. package/esm5/lib/ra.gridster.config.js +63 -0
  70. package/esm5/public-api.js +16 -0
  71. package/esm5/schneideress-dashboardframework.js +13 -0
  72. package/fesm2015/schneideress-dashboardframework.js +4811 -0
  73. package/fesm2015/schneideress-dashboardframework.js.map +1 -0
  74. package/fesm5/schneideress-dashboardframework.js +5613 -0
  75. package/fesm5/schneideress-dashboardframework.js.map +1 -0
  76. package/gridster/index.d.ts +11 -0
  77. package/gridster/lib/gridster.component.d.ts +67 -0
  78. package/gridster/lib/gridster.interface.d.ts +46 -0
  79. package/gridster/lib/gridster.module.d.ts +2 -0
  80. package/gridster/lib/gridsterCompact.service.d.ts +15 -0
  81. package/gridster/lib/gridsterConfig.constant.d.ts +2 -0
  82. package/gridster/lib/gridsterConfig.interface.d.ts +133 -0
  83. package/gridster/lib/gridsterConfigS.interface.d.ts +93 -0
  84. package/gridster/lib/gridsterDraggable.service.d.ts +59 -0
  85. package/gridster/lib/gridsterEmptyCell.service.d.ts +29 -0
  86. package/gridster/lib/gridsterItem.component.d.ts +32 -0
  87. package/gridster/lib/gridsterItem.interface.d.ts +21 -0
  88. package/gridster/lib/gridsterItemComponent.interface.d.ts +25 -0
  89. package/gridster/lib/gridsterPreview.component.d.ts +10 -0
  90. package/gridster/lib/gridsterPush.service.d.ts +33 -0
  91. package/gridster/lib/gridsterPushResize.service.d.ts +26 -0
  92. package/gridster/lib/gridsterRenderer.service.d.ts +38 -0
  93. package/gridster/lib/gridsterResizable.service.d.ts +67 -0
  94. package/gridster/lib/gridsterResizeEventType.interface.d.ts +6 -0
  95. package/gridster/lib/gridsterScroll.service.d.ts +4 -0
  96. package/gridster/lib/gridsterSwap.service.d.ts +13 -0
  97. package/gridster/lib/gridsterUtils.service.d.ts +16 -0
  98. package/lib/ra-dashboard-area/ra.dashboard.area.d.ts +37 -0
  99. package/lib/ra-widget-container/ra.widget.container.component.d.ts +37 -0
  100. package/lib/ra.base.dashboard.filter.d.ts +4 -0
  101. package/lib/ra.base.dashboard.template.d.ts +14 -0
  102. package/lib/ra.dashbard.event.bus.d.ts +20 -0
  103. package/lib/ra.dashboard.module.d.ts +2 -0
  104. package/lib/ra.dashboard.service.d.ts +73 -0
  105. package/lib/ra.event.enum.d.ts +24 -0
  106. package/lib/ra.gridster.config.d.ts +2 -0
  107. package/package.json +25 -0
  108. package/public-api.d.ts +8 -0
  109. package/schneideress-dashboardframework.d.ts +8 -0
  110. package/schneideress-dashboardframework.metadata.json +1 -0
@@ -0,0 +1,4811 @@
1
+ import { Injectable, Injector, ɵɵdefineInjectable, ɵɵinject, INJECTOR, Component, NgZone, Input, EventEmitter, ViewChild, Output, ViewEncapsulation, ElementRef, Renderer2, ChangeDetectorRef, Host, NgModule } from '@angular/core';
2
+ import { of, Subject } from 'rxjs';
3
+ import { BaseService } from '@schneideress/ess-util';
4
+ import { filter, map } from 'rxjs/operators';
5
+ import { BrowserModule } from '@angular/platform-browser';
6
+ import { HttpClientModule } from '@angular/common/http';
7
+ import { CommonModule } from '@angular/common';
8
+
9
+ /**
10
+ * @fileoverview added by tsickle
11
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
12
+ */
13
+ class RaDashboardService extends BaseService {
14
+ /**
15
+ * @param {?} injector
16
+ */
17
+ constructor(injector) {
18
+ super(injector, '');
19
+ this.loadedScripts = [];
20
+ this.widgets = [
21
+ {
22
+ dashboardId: '1',
23
+ id: '1',
24
+ customTag: 'ra-test-widget',
25
+ scriptUrl: './assets/ra-test-widget.bundle.js',
26
+ title: 'Test Widget',
27
+ widgetInstanceId: 1,
28
+ widgetId: 1,
29
+ position_x: 0,
30
+ position_y: 0,
31
+ width: 50,
32
+ height: 20,
33
+ widgetConfigInfo: {
34
+ scriptPath: "./assets/ra-test-widget-config.bundle.js",
35
+ configControlTag: "ra-test-widget-config",
36
+ config: { country: 'All' }
37
+ },
38
+ widgetName: '',
39
+ widgetTitle: 'Test Widget',
40
+ dashboardAreaId: 1,
41
+ dashboardAreaKey: '',
42
+ dashboardName: ''
43
+ },
44
+ {
45
+ dashboardId: '2',
46
+ id: '2',
47
+ customTag: 'ra-test-widget',
48
+ scriptUrl: './assets/ra-test-widget.bundle.js',
49
+ title: 'Test Widget',
50
+ widgetInstanceId: 2,
51
+ dashboardAreaKey: '',
52
+ widgetId: 1,
53
+ position_x: 0,
54
+ position_y: 0,
55
+ width: 50,
56
+ height: 20,
57
+ widgetConfigInfo: {
58
+ scriptPath: "./assets/ra-test-widget-config.bundle.js",
59
+ configControlTag: "ra-test-widget-config",
60
+ config: { country: 'All' }
61
+ },
62
+ widgetName: '',
63
+ widgetTitle: 'Test Widget',
64
+ dashboardAreaId: 1,
65
+ dashboardName: ''
66
+ },
67
+ ];
68
+ }
69
+ /*
70
+ * To load external scripts in the dom
71
+ */
72
+ /**
73
+ * @param {?} scriptPath
74
+ * @param {?} callback
75
+ * @return {?}
76
+ */
77
+ loadExternalScript(scriptPath, callback) {
78
+ if (this.loadedScripts.indexOf(scriptPath) == -1) {
79
+ /** @type {?} */
80
+ const script = document.createElement('script');
81
+ script.src = scriptPath;
82
+ // script.addEventListener("load", callback(), true);
83
+ script.onload = (/**
84
+ * @return {?}
85
+ */
86
+ function () {
87
+ callback();
88
+ });
89
+ document.body.appendChild(script);
90
+ this.loadedScripts.push(scriptPath);
91
+ }
92
+ else {
93
+ callback();
94
+ }
95
+ }
96
+ /*
97
+ * To retrieve the list of widgets based on dashboard id & areaId
98
+ */
99
+ /**
100
+ * @param {?} widgetInfo
101
+ * @param {?} appConfig
102
+ * @return {?}
103
+ */
104
+ getWidgetsByDashboardArea(widgetInfo, appConfig) {
105
+ this.baseUrl = appConfig.apiBaseUrl;
106
+ /** @type {?} */
107
+ var url = 'widget/GetWidgetByArea';
108
+ return this.post(url, widgetInfo);
109
+ }
110
+ /**
111
+ * @param {?} widgetInfo
112
+ * @return {?}
113
+ */
114
+ getWidgetConfigInfo(widgetInfo) {
115
+ return of();
116
+ }
117
+ /**
118
+ * @param {?} widgetId
119
+ * @return {?}
120
+ */
121
+ getWidgetById(widgetId) {
122
+ return this.widgets.filter((/**
123
+ * @param {?} t
124
+ * @return {?}
125
+ */
126
+ t => {
127
+ t.widgetId == widgetId;
128
+ }));
129
+ }
130
+ /*
131
+ * To update the configuration of a widget.
132
+ */
133
+ /**
134
+ * @param {?} config
135
+ * @param {?} widgetInstanceId
136
+ * @return {?}
137
+ */
138
+ updateConfig(config, widgetInstanceId) {
139
+ }
140
+ /**
141
+ * To add widget to the database
142
+ * @param {?} widgetInfo
143
+ * @param {?} appConfig
144
+ * @return {?}
145
+ */
146
+ addWidget(widgetInfo, appConfig) {
147
+ this.baseUrl = appConfig.apiBaseUrl;
148
+ /** @type {?} */
149
+ var url = 'widget/AddWidgetUser';
150
+ return this.post(url, widgetInfo);
151
+ }
152
+ /**
153
+ * To Delete current widget from DOM
154
+ * @param {?} widgetInfo
155
+ * @param {?} appConfig
156
+ * @return {?}
157
+ */
158
+ deleteWidget(widgetInfo, appConfig) {
159
+ this.baseUrl = appConfig.apiBaseUrl;
160
+ /** @type {?} */
161
+ var url = 'widget/DeleteWidgetUser';
162
+ return this.post(url, widgetInfo);
163
+ }
164
+ /**
165
+ * To Update widgetInfo in database
166
+ * @param {?} widgetInfo
167
+ * @param {?} appConfig
168
+ * @return {?}
169
+ */
170
+ updateWidget(widgetInfo, appConfig) {
171
+ this.baseUrl = appConfig.apiBaseUrl;
172
+ /** @type {?} */
173
+ var url = 'widget/UpdateUserWidget';
174
+ return this.post(url, widgetInfo);
175
+ }
176
+ /**
177
+ * To Move or change position if current widget container
178
+ * @param {?} widgetInfo
179
+ * @return {?}
180
+ */
181
+ moveWidget(widgetInfo) {
182
+ }
183
+ /**
184
+ * To Copy Current widget with same configuration
185
+ * @param {?} widgetInfo
186
+ * @return {?}
187
+ */
188
+ copyWidget(widgetInfo) {
189
+ }
190
+ /**
191
+ * To Collapse current widget
192
+ * @param {?} widgetInfo
193
+ * @return {?}
194
+ */
195
+ collapse(widgetInfo) {
196
+ }
197
+ }
198
+ RaDashboardService.decorators = [
199
+ { type: Injectable, args: [{
200
+ providedIn: 'root'
201
+ },] }
202
+ ];
203
+ /** @nocollapse */
204
+ RaDashboardService.ctorParameters = () => [
205
+ { type: Injector }
206
+ ];
207
+ /** @nocollapse */ RaDashboardService.ngInjectableDef = ɵɵdefineInjectable({ factory: function RaDashboardService_Factory() { return new RaDashboardService(ɵɵinject(INJECTOR)); }, token: RaDashboardService, providedIn: "root" });
208
+
209
+ /**
210
+ * @fileoverview added by tsickle
211
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
212
+ */
213
+ class RADashboardEventBus {
214
+ constructor() {
215
+ this.eventQueue = new Subject();
216
+ }
217
+ /**
218
+ * To emit an event with the name & data
219
+ * @param {?} eventName
220
+ * @param {?} data
221
+ * @return {?}
222
+ */
223
+ publish(eventName, data) {
224
+ this.eventQueue.next({ eventName, data });
225
+ }
226
+ /**
227
+ * To emit an event with the name, data, key & value
228
+ * @param {?} eventName
229
+ * @param {?} data
230
+ * @param {?} key
231
+ * @param {?} value
232
+ * @return {?}
233
+ */
234
+ publishWithKey(eventName, data, key, value) {
235
+ this.eventQueue.next({ eventName, data, key, value });
236
+ }
237
+ /**
238
+ * To subscribe to an event with the name
239
+ * @param {?} eventName
240
+ * @return {?}
241
+ */
242
+ subscribe(eventName) {
243
+ return this.eventQueue.asObservable().pipe(filter((/**
244
+ * @param {?} event
245
+ * @return {?}
246
+ */
247
+ (event) => {
248
+ return event.eventName == eventName;
249
+ })), map((/**
250
+ * @param {?} event
251
+ * @return {?}
252
+ */
253
+ event => event.data)));
254
+ }
255
+ /**
256
+ * To subscribe to an event with the name key & value
257
+ * @param {?} eventName
258
+ * @param {?} key
259
+ * @param {?} value
260
+ * @return {?}
261
+ */
262
+ subscribeWithKey(eventName, key, value) {
263
+ return this.eventQueue.asObservable().pipe(filter((/**
264
+ * @param {?} event
265
+ * @return {?}
266
+ */
267
+ (event) => {
268
+ return event.eventName == eventName && event.key == key && event.value == value;
269
+ })), map((/**
270
+ * @param {?} event
271
+ * @return {?}
272
+ */
273
+ event => event.data)));
274
+ }
275
+ }
276
+ RADashboardEventBus.decorators = [
277
+ { type: Injectable, args: [{
278
+ providedIn: 'root'
279
+ },] }
280
+ ];
281
+ /** @nocollapse */ RADashboardEventBus.ngInjectableDef = ɵɵdefineInjectable({ factory: function RADashboardEventBus_Factory() { return new RADashboardEventBus(); }, token: RADashboardEventBus, providedIn: "root" });
282
+
283
+ /**
284
+ * @fileoverview added by tsickle
285
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
286
+ */
287
+ /** @enum {string} */
288
+ const RAEvent = {
289
+ /** widget selection click on widget library */
290
+ WidgetSelected: "widgetSelected",
291
+ /** triggers when user click on the edit link in widget container */
292
+ WidgetEditClicked: "widgetEditClicked",
293
+ /** triggers when user clicks the cancel button on widget configuration window */
294
+ ConfigCancelClick: "configCancelClick",
295
+ /** triggers when user click on the close button on widget configuration window */
296
+ ConfigCloseClick: "configCloseClick",
297
+ /** add button click on widget configuration window */
298
+ ConfigAddClick: "configAddClick",
299
+ /** triggers when a user click on the save button in widget configuration window */
300
+ ConfigChanged: "configChanged",
301
+ /**dashboard customize button click */
302
+ DashboardCustomizeClick: "dashboardCustomizeClick",
303
+ /**triggers when user clicks on the dashboard change icon in header section */
304
+ DashboardChanged: "dashboardChanged",
305
+ /** triggers when user clicks the close button on library */
306
+ WidgetLibraryCloseBtnClicked: "WidgetLibraryCloseBtnClicked",
307
+ };
308
+ /** @enum {string} */
309
+ const RAEventKey = {
310
+ /** on edit widget click */
311
+ WidgetInstanceId: "widgetInstanceId",
312
+ };
313
+
314
+ /**
315
+ * @fileoverview added by tsickle
316
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
317
+ */
318
+ /** @enum {string} */
319
+ const GridType = {
320
+ Fit: 'fit',
321
+ ScrollVertical: 'scrollVertical',
322
+ ScrollHorizontal: 'scrollHorizontal',
323
+ Fixed: 'fixed',
324
+ VerticalFixed: 'verticalFixed',
325
+ HorizontalFixed: 'horizontalFixed',
326
+ };
327
+ /** @enum {string} */
328
+ const DisplayGrid = {
329
+ Always: 'always',
330
+ OnDragAndResize: 'onDrag&Resize',
331
+ None: 'none',
332
+ };
333
+ /** @enum {string} */
334
+ const CompactType = {
335
+ None: 'none',
336
+ CompactUp: 'compactUp',
337
+ CompactLeft: 'compactLeft',
338
+ CompactUpAndLeft: 'compactUp&Left',
339
+ CompactLeftAndUp: 'compactLeft&Up',
340
+ CompactRight: 'compactRight',
341
+ CompactUpAndRight: 'compactUp&Right',
342
+ CompactRightAndUp: 'compactRight&Up',
343
+ };
344
+
345
+ /**
346
+ * @fileoverview added by tsickle
347
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
348
+ */
349
+ /** @type {?} */
350
+ const GridsterConfigDefaultSettings = {
351
+ gridType: GridType.ScrollVertical,
352
+ compactType: CompactType.None,
353
+ margin: 0,
354
+ outerMargin: true,
355
+ outerMarginTop: null,
356
+ outerMarginRight: null,
357
+ outerMarginBottom: null,
358
+ outerMarginLeft: null,
359
+ useTransformPositioning: true,
360
+ mobileBreakpoint: 640,
361
+ minCols: 100,
362
+ maxCols: 100,
363
+ minRows: 100,
364
+ maxRows: 2000,
365
+ maxItemCols: 150,
366
+ minItemCols: 1,
367
+ maxItemRows: 150,
368
+ minItemRows: 1,
369
+ maxItemArea: 2500,
370
+ minItemArea: 1,
371
+ defaultItemCols: 5,
372
+ defaultItemRows: 5,
373
+ fixedColWidth: 5,
374
+ fixedRowHeight: 5,
375
+ keepFixedHeightInMobile: false,
376
+ keepFixedWidthInMobile: false,
377
+ scrollSensitivity: 10,
378
+ scrollSpeed: 20,
379
+ enableEmptyCellClick: false,
380
+ enableEmptyCellContextMenu: false,
381
+ enableEmptyCellDrop: false,
382
+ enableEmptyCellDrag: false,
383
+ emptyCellDragMaxCols: 50,
384
+ emptyCellDragMaxRows: 50,
385
+ ignoreMarginInRow: true,
386
+ draggable: {
387
+ enabled: true,
388
+ dragHandleClass: 'wcheader',
389
+ ignoreContent: true
390
+ },
391
+ resizable: {
392
+ enabled: true,
393
+ },
394
+ swap: true,
395
+ pushItems: false,
396
+ disablePushOnDrag: true,
397
+ disablePushOnResize: false,
398
+ pushDirections: { north: true, east: true, south: true, west: true },
399
+ pushResizeItems: true,
400
+ displayGrid: DisplayGrid.OnDragAndResize,
401
+ disableWindowResize: false,
402
+ disableWarnings: false,
403
+ scrollToNewItems: true,
404
+ autoResizeonDrag: false,
405
+ };
406
+
407
+ /**
408
+ * @fileoverview added by tsickle
409
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
410
+ */
411
+ class RADashboardArea {
412
+ /**
413
+ * @param {?} dashboardService
414
+ * @param {?} ngZone
415
+ */
416
+ constructor(dashboardService, ngZone) {
417
+ this.dashboardService = dashboardService;
418
+ this.ngZone = ngZone;
419
+ this.widgetList = Array();
420
+ this.gridheight = 300;
421
+ this.widgetHeight = 20;
422
+ this.widgetWidth = 50;
423
+ }
424
+ /**
425
+ * @return {?}
426
+ */
427
+ ngOnInit() {
428
+ /**
429
+ * To override default configuration values to the gridster control
430
+ * @type {?}
431
+ */
432
+ let areaContext = this;
433
+ this.options = GridsterConfigDefaultSettings;
434
+ this.options.itemChangeCallback = (/**
435
+ * @param {?} item
436
+ * @return {?}
437
+ */
438
+ function (item) {
439
+ areaContext.setAreaHeight();
440
+ });
441
+ }
442
+ /**
443
+ * @param {?} changes
444
+ * @return {?}
445
+ */
446
+ ngOnChanges(changes) {
447
+ if (changes.raDashboardEventBus && changes.raDashboardEventBus.currentValue != changes.raDashboardEventBus.previousValue) {
448
+ this.conifgAddClick = this.raDashboardEventBus.subscribe(RAEvent.ConfigAddClick).subscribe((/**
449
+ * @param {?} e
450
+ * @return {?}
451
+ */
452
+ (e) => {
453
+ this.ngZone.run((/**
454
+ * @return {?}
455
+ */
456
+ () => {
457
+ this.addWidget(e);
458
+ }));
459
+ }));
460
+ }
461
+ if (this.raDashboardEventBus && this.userDashboardId && this.areaKey) {
462
+ this.loadWidgets(this.userDashboardId, this.areaKey);
463
+ }
464
+ }
465
+ /**
466
+ * @return {?}
467
+ */
468
+ ngOnDestroy() {
469
+ this.conifgAddClick.unsubscribe();
470
+ }
471
+ /**
472
+ * To retrieve widgets based on userDashboardid and area name
473
+ * @param {?} userDashboarId
474
+ * @param {?} areaKey
475
+ * @return {?}
476
+ */
477
+ loadWidgets(userDashboarId, areaKey) {
478
+ /** @type {?} */
479
+ let widgetInfo = (/** @type {?} */ ({
480
+ dashboardId: userDashboarId.toString(),
481
+ dashboardAreaKey: areaKey
482
+ }));
483
+ /** @type {?} */
484
+ let widgets = this.dashboardService.getWidgetsByDashboardArea(widgetInfo, this.appConfig).subscribe((/**
485
+ * @param {?} widgets
486
+ * @return {?}
487
+ */
488
+ widgets => {
489
+ if (widgets)
490
+ this.widgetList = this.mapObjectListToGridsterItemList(widgets);
491
+ }));
492
+ }
493
+ /**
494
+ * To set Area(Gridster) height dynamically as widgets are added/removed
495
+ * @return {?}
496
+ */
497
+ setAreaHeight() {
498
+ /** @type {?} */
499
+ let areaScrollHeight = 0;
500
+ /** @type {?} */
501
+ let areaHeight = 0;
502
+ this.widgetList.forEach((/**
503
+ * @param {?} t
504
+ * @return {?}
505
+ */
506
+ (t) => {
507
+ /** @type {?} */
508
+ let currentHeight = t.y + t.rows;
509
+ if (currentHeight > areaScrollHeight) {
510
+ areaScrollHeight = currentHeight;
511
+ }
512
+ }));
513
+ areaHeight = areaScrollHeight * this.options.api.getCurrentRowHeight() + 2;
514
+ if (areaHeight < 300) {
515
+ areaHeight = 300;
516
+ }
517
+ this.gridheight = areaHeight;
518
+ }
519
+ /**
520
+ * To map IwidgetInfo object to gridsterItem
521
+ * @param {?} widget
522
+ * @return {?}
523
+ */
524
+ mapObjectsToGridsterItem(widget) {
525
+ /** @type {?} */
526
+ let gridsterItem = (/** @type {?} */ ({
527
+ cols: widget.width,
528
+ rows: widget.height,
529
+ x: widget.position_x,
530
+ y: widget.position_y,
531
+ widgetInfo: widget
532
+ }));
533
+ return gridsterItem;
534
+ }
535
+ /**
536
+ * @param {?} widgetList
537
+ * @return {?}
538
+ */
539
+ mapObjectListToGridsterItemList(widgetList) {
540
+ /** @type {?} */
541
+ let widgetArray = Array();
542
+ widgetList.forEach((/**
543
+ * @param {?} widget
544
+ * @return {?}
545
+ */
546
+ widget => {
547
+ widgetArray.push(this.mapObjectsToGridsterItem(widget));
548
+ }));
549
+ return widgetArray;
550
+ }
551
+ /**
552
+ * To remove a widget instance from dashboard and to save info in database
553
+ * @param {?} widgetInstanceId
554
+ * @return {?}
555
+ */
556
+ deleteWidget(widgetInstanceId) {
557
+ /** @type {?} */
558
+ let widget = this.widgetList.filter((/**
559
+ * @param {?} item
560
+ * @return {?}
561
+ */
562
+ function (item) {
563
+ return item.widgetInfo.widgetInstanceId === widgetInstanceId;
564
+ }));
565
+ if (widget.length > 0) {
566
+ this.widgetList.splice(this.widgetList.indexOf(widget[0]), 1);
567
+ this.setAreaHeight();
568
+ }
569
+ }
570
+ /**
571
+ * To add widget instance to the database with the next available position and to make changes in
572
+ * dashboard area.
573
+ * @param {?} data
574
+ * @return {?}
575
+ */
576
+ addWidget(data) {
577
+ /** @type {?} */
578
+ let widgetid = data.widgetId;
579
+ data.height = this.widgetHeight;
580
+ data.width = this.widgetWidth;
581
+ data.position_x = 0;
582
+ data.position_y = 0;
583
+ /** @type {?} */
584
+ let gridsterItem = this.mapObjectsToGridsterItem(data);
585
+ gridsterItem = this.options.api.getFirstPossiblePosition(gridsterItem);
586
+ data.position_x = gridsterItem.x;
587
+ data.position_y = gridsterItem.y;
588
+ data.dashboardAreaKey = this.areaKey;
589
+ data.dashboardId = this.userDashboardId;
590
+ this.dashboardService.addWidget(data, this.appConfig).subscribe((/**
591
+ * @param {?} widget
592
+ * @return {?}
593
+ */
594
+ widget => {
595
+ gridsterItem = this.mapObjectsToGridsterItem(widget);
596
+ this.widgetList.push(gridsterItem);
597
+ this.setAreaHeight();
598
+ }));
599
+ }
600
+ }
601
+ RADashboardArea.decorators = [
602
+ { type: Component, args: [{
603
+ selector: 'ra-dashboard-area',
604
+ template: "<div #gridWrapper class=\"wrap gridster\" [style.height.px]=\"gridheight\">\r\n<!-- <div #gridWrapper class=\"wrap gridster\"> -->\r\n <gridster [options]=\"options\" style=\"height:100%;\">\r\n <gridster-item [item]=\"item\" *ngFor=\"let item of widgetList\">\r\n <ra-widget-container [app-config]=\"appConfig\" [event-bus]=\"raDashboardEventBus\" (widgetDeleted)=\"deleteWidget($event)\" [data]=\"item\"\r\n [global-filter]=\"globalFilter\" [widget-instance-id]=\"item.widgetInstanceId\"></ra-widget-container>\r\n </gridster-item>\r\n </gridster>\r\n</div>\r\n",
605
+ styles: ["gridster{width:inherit;background:#f1f1f1;border:1px solid #ccc;resize:height;display:flex;min-height:300px}gridster-item{border:1px solid #ccc;background:#fff!important}.dvheader{width:100%;height:35px;background:#000;color:#fff;padding:7px 3px 5px 6px;text-transform:uppercase}"]
606
+ }] }
607
+ ];
608
+ /** @nocollapse */
609
+ RADashboardArea.ctorParameters = () => [
610
+ { type: RaDashboardService },
611
+ { type: NgZone }
612
+ ];
613
+ RADashboardArea.propDecorators = {
614
+ userDashboardId: [{ type: Input, args: ['user-dashboard-id',] }],
615
+ areaKey: [{ type: Input, args: ['area-key',] }],
616
+ globalFilter: [{ type: Input, args: ['global-filter',] }],
617
+ raDashboardEventBus: [{ type: Input, args: ['event-bus',] }],
618
+ widgetHeight: [{ type: Input, args: ['widget-height',] }],
619
+ widgetWidth: [{ type: Input, args: ['widget-width',] }],
620
+ appConfig: [{ type: Input, args: ['app-config',] }]
621
+ };
622
+
623
+ /**
624
+ * @fileoverview added by tsickle
625
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
626
+ */
627
+ class RAWidgetContainer {
628
+ /**
629
+ * @param {?} dashboardService
630
+ */
631
+ constructor(dashboardService) {
632
+ this.dashboardService = dashboardService;
633
+ this.isIEOrEdge = /msie\s|trident\/|edge\//i.test(window.navigator.userAgent);
634
+ this.widgetDeleted = new EventEmitter();
635
+ }
636
+ /**
637
+ * @param {?} changes
638
+ * @return {?}
639
+ */
640
+ ngOnChanges(changes) {
641
+ if (changes.raDashboardEventBus && changes.raDashboardEventBus.currentValue != changes.raDashboardEventBus.previousValue) {
642
+ this.configChanged = this.raDashboardEventBus.subscribeWithKey(RAEvent.ConfigChanged, RAEventKey.WidgetInstanceId, this.data.widgetInfo.widgetInstanceId.toString()).subscribe((/**
643
+ * @param {?} e
644
+ * @return {?}
645
+ */
646
+ (e) => {
647
+ this.configChangeEventHandler(e);
648
+ }));
649
+ }
650
+ if (this.widgetElement && changes.globalFilter.currentValue != changes.globalFilter.previousValue) {
651
+ this.refreshWidget(this.data.widgetInfo);
652
+ }
653
+ }
654
+ /**
655
+ * @return {?}
656
+ */
657
+ ngAfterViewInit() {
658
+ setTimeout((/**
659
+ * @return {?}
660
+ */
661
+ () => {
662
+ this.loadWidget(this.data.widgetInfo);
663
+ }));
664
+ }
665
+ /**
666
+ * @return {?}
667
+ */
668
+ ngOnDestroy() {
669
+ this.configChanged.unsubscribe();
670
+ }
671
+ /**
672
+ * To Edit current widget configuration
673
+ * @return {?}
674
+ */
675
+ editWidget() {
676
+ this.raDashboardEventBus.publish(RAEvent.WidgetEditClicked, this.data.widgetInfo);
677
+ }
678
+ /**
679
+ * To Delete current widget from DOM
680
+ * @return {?}
681
+ */
682
+ deleteWidget() {
683
+ this.dashboardService.deleteWidget(this.data.widgetInfo, this.appConfig).subscribe((/**
684
+ * @param {?} status
685
+ * @return {?}
686
+ */
687
+ status => {
688
+ {
689
+ this.widgetDeleted.emit(this.data.widgetInfo.widgetInstanceId);
690
+ }
691
+ }));
692
+ }
693
+ /**
694
+ * To Move or change position if current widget container
695
+ * @param {?} widgetInfo
696
+ * @return {?}
697
+ */
698
+ moveWidget(widgetInfo) {
699
+ this.dashboardService.moveWidget(widgetInfo);
700
+ }
701
+ /**
702
+ * To Copy Current widget with same configuration
703
+ * @param {?} widgetInfo
704
+ * @return {?}
705
+ */
706
+ copyWidget(widgetInfo) {
707
+ this.dashboardService.copyWidget(widgetInfo);
708
+ }
709
+ /**
710
+ * To Collapse current widget
711
+ * @param {?} widgetInfo
712
+ * @return {?}
713
+ */
714
+ collapse(widgetInfo) {
715
+ this.dashboardService.collapse(widgetInfo);
716
+ }
717
+ /**
718
+ * @param {?} config
719
+ * @return {?}
720
+ */
721
+ configChangeEventHandler(config) {
722
+ console.log('in config change config');
723
+ console.log(config);
724
+ this.data.widgetInfo.widgetConfigInfo.config = config;
725
+ this.refreshWidget(this.data.widgetInfo);
726
+ this.updateWidget(this.data.widgetInfo);
727
+ }
728
+ /**
729
+ * @param {?} widgetInfo
730
+ * @return {?}
731
+ */
732
+ updateWidget(widgetInfo) {
733
+ this.dashboardService.updateWidget(widgetInfo, this.appConfig);
734
+ }
735
+ /**
736
+ * To load external custom element to the widget container
737
+ * @param {?} widgetInfo
738
+ * @return {?}
739
+ */
740
+ loadWidget(widgetInfo) {
741
+ /** @type {?} */
742
+ let widgetConfigFilter = (/** @type {?} */ ({
743
+ config: widgetInfo.widgetConfigInfo.config,
744
+ globalFilter: this.globalFilter
745
+ }));
746
+ /** @type {?} */
747
+ let widgetCOntainer = this;
748
+ this.dashboardService.loadExternalScript(widgetInfo.scriptUrl, (/**
749
+ * @return {?}
750
+ */
751
+ () => {
752
+ this.widgetElement = document.createElement(widgetInfo.customTag);
753
+ this.ctlWidget.nativeElement.appendChild(this.widgetElement);
754
+ setTimeout((/**
755
+ * @return {?}
756
+ */
757
+ () => {
758
+ widgetCOntainer.widgetElement.loadContent(widgetConfigFilter, this.appConfig);
759
+ }), 2000);
760
+ }));
761
+ }
762
+ /**
763
+ * To refresh widget on input config changes
764
+ * @param {?} widgetInfo
765
+ * @return {?}
766
+ */
767
+ refreshWidget(widgetInfo) {
768
+ /** @type {?} */
769
+ let widgetConfigFilter = (/** @type {?} */ ({
770
+ config: widgetInfo.widgetConfigInfo.config,
771
+ globalFilter: this.globalFilter
772
+ }));
773
+ this.widgetElement.loadContent(widgetConfigFilter, this.appConfig);
774
+ }
775
+ }
776
+ RAWidgetContainer.decorators = [
777
+ { type: Component, args: [{
778
+ selector: 'ra-widget-container',
779
+ template: "<div class=\"wc-wrapper\">\r\n <div class=\"wcheader\">\r\n <div class=\"col-md-12 wc-mover\">\r\n <div class=\"row\">\r\n <div class=\"col-md-11 float-left\" style=\"width:96%;\">{{data.widgetInfo.title?data.widgetInfo.title:\"Title\"}}\r\n </div>\r\n <div class=\"col-md-1\">\r\n <div class=\"float-right\">\r\n <div class=\"dropdown\">\r\n <div class=\"dropbtn\"> <i class=\"fal fa-cog\"></i></div>\r\n <div class=\"dropdown-content\">\r\n <a (click)=\"editWidget()\">Edit</a>\r\n <a (click)=\"copyWidget(data)\">Copy</a>\r\n <a (click)=\"moveWidget(data)\">Move</a>\r\n <a (click)=\"collapse(data)\">Collapse</a>\r\n <hr class=\"hr\" style=\"\">\r\n <a (click)=\"deleteWidget()\">Delete</a>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"wcBody\">\r\n <div class=\"wcBodyBorder\" #ctlWidget></div>\r\n </div>\r\n</div>\r\n",
780
+ styles: [".wcheader{width:100%;height:26px;background:#fff;color:#3dcd58;padding:7px 7px 0 6px;font-family:\"Arial Rounded MT\";border-bottom:1px solid;border-color:#fff;font-size:16px}.wc-mover{cursor:all-scroll}.wcBody{padding:8px}.wcBodyBorder{border:1px dashed #e6e2e2}.sp_icon{float:left;margin:0 15% 0 0}.dropbtn{cursor:pointer;color:#42b4e6}.dropdown{display:none;position:relative}.dropdown-content{display:none;position:absolute;right:0;background-color:#f9f9f9;min-width:100px;box-shadow:0 8px 16px 8px rgba(0,0,0,.2);z-index:1;font-size:12px;font-family:\"Arial Rounded MT\"}.dropdown-content a{color:#000;padding:5px 16px;text-decoration:none;display:block;cursor:pointer}.dropdown-content a:hover{background-color:#f1f1f1}.dropdown:hover .dropdown-content,.wc-wrapper:hover .dropdown{display:block}.dropdown:hover .dropbtn{color:#2b7797}.hr{border:0;border-top:1px solid rgba(0,0,0,.1)}"]
781
+ }] }
782
+ ];
783
+ /** @nocollapse */
784
+ RAWidgetContainer.ctorParameters = () => [
785
+ { type: RaDashboardService }
786
+ ];
787
+ RAWidgetContainer.propDecorators = {
788
+ ctlWidget: [{ type: ViewChild, args: ['ctlWidget', { static: false },] }],
789
+ widgetInstanceId: [{ type: Input, args: ['widget-instance-id',] }],
790
+ globalFilter: [{ type: Input, args: ['global-filter',] }],
791
+ data: [{ type: Input, args: ['data',] }],
792
+ raDashboardEventBus: [{ type: Input, args: ['event-bus',] }],
793
+ appConfig: [{ type: Input, args: ['app-config',] }],
794
+ widgetDeleted: [{ type: Output }]
795
+ };
796
+
797
+ /**
798
+ * @fileoverview added by tsickle
799
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
800
+ */
801
+ /** @type {?} */
802
+ const GridsterConfigService = {
803
+ gridType: GridType.Fit,
804
+ // 'fit' will fit the items in the container without scroll;
805
+ // 'scrollVertical' will fit on width and height of the items will be the same as the width
806
+ // 'scrollHorizontal' will fit on height and width of the items will be the same as the height
807
+ // 'fixed' will set the rows and columns dimensions based on fixedColWidth and fixedRowHeight options
808
+ // 'verticalFixed' will set the rows to fixedRowHeight and columns width will fit the space available
809
+ // 'horizontalFixed' will set the columns to fixedColWidth and rows height will fit the space available
810
+ fixedColWidth: 250,
811
+ // fixed col width for gridType: 'fixed'
812
+ fixedRowHeight: 250,
813
+ // fixed row height for gridType: 'fixed'
814
+ keepFixedHeightInMobile: false,
815
+ // keep the height from fixed gridType in mobile layout
816
+ keepFixedWidthInMobile: false,
817
+ // keep the width from fixed gridType in mobile layout
818
+ setGridSize: false,
819
+ // sets grid size depending on content
820
+ compactType: CompactType.None,
821
+ // compact items: 'none' | 'compactUp' | 'compactLeft' | 'compactUp&Left' | 'compactLeft&Up'
822
+ mobileBreakpoint: 640,
823
+ // if the screen is not wider that this, remove the grid layout and stack the items
824
+ minCols: 1,
825
+ // minimum amount of columns in the grid
826
+ maxCols: 100,
827
+ // maximum amount of columns in the grid
828
+ minRows: 1,
829
+ // minimum amount of rows in the grid
830
+ maxRows: 100,
831
+ // maximum amount of rows in the grid
832
+ defaultItemCols: 1,
833
+ // default width of an item in columns
834
+ defaultItemRows: 1,
835
+ // default height of an item in rows
836
+ maxItemCols: 50,
837
+ // max item number of cols
838
+ maxItemRows: 50,
839
+ // max item number of rows
840
+ minItemCols: 1,
841
+ // min item number of columns
842
+ minItemRows: 1,
843
+ // min item number of rows
844
+ minItemArea: 1,
845
+ // min item area: cols * rows
846
+ maxItemArea: 2500,
847
+ // max item area: cols * rows
848
+ margin: 10,
849
+ // margin between grid items
850
+ outerMargin: true,
851
+ // if margins will apply to the sides of the container
852
+ outerMarginTop: null,
853
+ // override outer margin for grid
854
+ outerMarginRight: null,
855
+ // override outer margin for grid
856
+ outerMarginBottom: null,
857
+ // override outer margin for grid
858
+ outerMarginLeft: null,
859
+ // override outer margin for grid
860
+ useTransformPositioning: true,
861
+ // toggle between transform or top/left positioning of items
862
+ scrollSensitivity: 10,
863
+ // margin of the dashboard where to start scrolling
864
+ scrollSpeed: 20,
865
+ // how much to scroll each mouse move when in the scrollSensitivity zone
866
+ initCallback: undefined,
867
+ // callback to call after grid has initialized. Arguments: gridsterComponent
868
+ destroyCallback: undefined,
869
+ // callback to call after grid has destroyed. Arguments: gridsterComponent
870
+ gridSizeChangedCallback: undefined,
871
+ // callback to call after grid has changed size. Arguments: gridsterComponent
872
+ itemChangeCallback: undefined,
873
+ // callback to call for each item when is changes x, y, rows, cols.
874
+ // Arguments: gridsterItem, gridsterItemComponent
875
+ itemResizeCallback: undefined,
876
+ // callback to call for each item when width/height changes.
877
+ // Arguments: gridsterItem, gridsterItemComponent
878
+ itemInitCallback: undefined,
879
+ // callback to call for each item when is initialized.
880
+ // Arguments: gridsterItem, gridsterItemComponent
881
+ itemRemovedCallback: undefined,
882
+ // callback to call for each item when is initialized.
883
+ // Arguments: gridsterItem, gridsterItemComponent
884
+ itemValidateCallback: undefined,
885
+ // callback to call to validate item position/size. Return true if valid.
886
+ // Arguments: gridsterItem
887
+ enableEmptyCellClick: false,
888
+ // enable empty cell click events
889
+ enableEmptyCellContextMenu: false,
890
+ // enable empty cell context menu (right click) events
891
+ enableEmptyCellDrop: false,
892
+ // enable empty cell drop events
893
+ enableEmptyCellDrag: false,
894
+ // enable empty cell drag events
895
+ emptyCellClickCallback: undefined,
896
+ // empty cell click callback
897
+ emptyCellContextMenuCallback: undefined,
898
+ // empty cell context menu (right click) callback
899
+ emptyCellDropCallback: undefined,
900
+ // empty cell drag drop callback. HTML5 Drag & Drop
901
+ emptyCellDragCallback: undefined,
902
+ // empty cell drag and create item like excel cell selection
903
+ emptyCellDragMaxCols: 50,
904
+ // limit empty cell drag max cols
905
+ emptyCellDragMaxRows: 50,
906
+ // limit empty cell drag max rows
907
+ // Arguments: event, gridsterItem{x, y, rows: defaultItemRows, cols: defaultItemCols}
908
+ ignoreMarginInRow: false,
909
+ // ignore the gap between rows for items which span multiple rows (see #162, #224)
910
+ draggable: {
911
+ delayStart: 0,
912
+ // milliseconds to delay the start of drag, useful for touch interaction
913
+ enabled: false,
914
+ // enable/disable draggable items
915
+ ignoreContentClass: 'gridster-item-content',
916
+ // default content class to ignore the drag event from
917
+ ignoreContent: false,
918
+ // if true drag will start only from elements from `dragHandleClass`
919
+ dragHandleClass: 'drag-handler',
920
+ // drag event only from this class. If `ignoreContent` is true.
921
+ stop: undefined,
922
+ // callback when dragging an item stops. Accepts Promise return to cancel/approve drag.
923
+ start: undefined,
924
+ // callback when dragging an item starts.
925
+ // Arguments: item, gridsterItem, event
926
+ dropOverItems: false,
927
+ // enable drop items on top other item
928
+ dropOverItemsCallback: undefined // callback on drop over another item
929
+ // Arguments: source, target, gridComponent
930
+ },
931
+ resizable: {
932
+ delayStart: 0,
933
+ // milliseconds to delay the start of resize, useful for touch interaction
934
+ enabled: false,
935
+ // enable/disable resizable items
936
+ handles: {
937
+ s: true,
938
+ e: true,
939
+ n: true,
940
+ w: true,
941
+ se: true,
942
+ ne: true,
943
+ sw: true,
944
+ nw: true
945
+ },
946
+ // resizable edges of an item
947
+ stop: undefined,
948
+ // callback when resizing an item stops. Accepts Promise return to cancel/approve resize.
949
+ start: undefined // callback when resizing an item starts.
950
+ // Arguments: item, gridsterItem, event
951
+ },
952
+ swap: true,
953
+ // allow items to switch position if drop on top of another
954
+ pushItems: false,
955
+ // push items when resizing and dragging
956
+ disablePushOnDrag: false,
957
+ // disable push on drag
958
+ disablePushOnResize: false,
959
+ // disable push on resize
960
+ pushDirections: { north: true, east: true, south: true, west: true },
961
+ // control the directions items are pushed
962
+ pushResizeItems: false,
963
+ // on resize of item will shrink adjacent items
964
+ displayGrid: DisplayGrid.OnDragAndResize,
965
+ // display background grid of rows and columns
966
+ disableWindowResize: false,
967
+ // disable the window on resize listener. This will stop grid to recalculate on window resize.
968
+ disableWarnings: false,
969
+ // disable console log warnings about misplacement of grid items
970
+ scrollToNewItems: false,
971
+ // scroll to new items placed in a scrollable view
972
+ disableAutoPositionOnConflict: false,
973
+ };
974
+
975
+ /**
976
+ * @fileoverview added by tsickle
977
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
978
+ */
979
+ class GridsterUtils {
980
+ /**
981
+ * @param {?} obj1
982
+ * @param {?} obj2
983
+ * @param {?} properties
984
+ * @return {?}
985
+ */
986
+ static merge(obj1, obj2, properties) {
987
+ for (const p in obj2) {
988
+ if (obj2[p] !== void 0 && properties.hasOwnProperty(p)) {
989
+ if (typeof obj2[p] === 'object') {
990
+ obj1[p] = GridsterUtils.merge(obj1[p], obj2[p], properties[p]);
991
+ }
992
+ else {
993
+ obj1[p] = obj2[p];
994
+ }
995
+ }
996
+ }
997
+ return obj1;
998
+ }
999
+ /**
1000
+ * @param {?} func
1001
+ * @param {?} wait
1002
+ * @return {?}
1003
+ */
1004
+ static debounce(func, wait) {
1005
+ /** @type {?} */
1006
+ let timeout;
1007
+ return (/**
1008
+ * @return {?}
1009
+ */
1010
+ function () {
1011
+ /** @type {?} */
1012
+ const context = this;
1013
+ /** @type {?} */
1014
+ const args = arguments;
1015
+ /** @type {?} */
1016
+ const later = (/**
1017
+ * @return {?}
1018
+ */
1019
+ function () {
1020
+ timeout = null;
1021
+ func.apply(context, args);
1022
+ });
1023
+ clearTimeout(timeout);
1024
+ timeout = setTimeout(later, wait);
1025
+ });
1026
+ }
1027
+ /**
1028
+ * @param {?} e
1029
+ * @return {?}
1030
+ */
1031
+ static checkTouchEvent(e) {
1032
+ if (e.clientX === undefined && e.touches) {
1033
+ if (e.touches && e.touches.length) {
1034
+ e.clientX = e.touches[0].clientX;
1035
+ e.clientY = e.touches[0].clientY;
1036
+ }
1037
+ else if (e.changedTouches && e.changedTouches.length) {
1038
+ e.clientX = e.changedTouches[0].clientX;
1039
+ e.clientY = e.changedTouches[0].clientY;
1040
+ }
1041
+ }
1042
+ }
1043
+ /**
1044
+ * @param {?} gridster
1045
+ * @param {?} e
1046
+ * @return {?}
1047
+ */
1048
+ static checkContentClassForEvent(gridster, e) {
1049
+ if (gridster.$options.draggable.ignoreContent) {
1050
+ if (!GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.dragHandleClass)) {
1051
+ return true;
1052
+ }
1053
+ }
1054
+ else {
1055
+ if (GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.ignoreContentClass)) {
1056
+ return true;
1057
+ }
1058
+ }
1059
+ return false;
1060
+ }
1061
+ /**
1062
+ * @param {?} gridster
1063
+ * @param {?} e
1064
+ * @return {?}
1065
+ */
1066
+ static checkContentClassForEmptyCellClickEvent(gridster, e) {
1067
+ return GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.ignoreContentClass)
1068
+ || GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.dragHandleClass);
1069
+ }
1070
+ /**
1071
+ * @param {?} target
1072
+ * @param {?} current
1073
+ * @param {?} contentClass
1074
+ * @return {?}
1075
+ */
1076
+ static checkContentClass(target, current, contentClass) {
1077
+ if (!target || target === current) {
1078
+ return false;
1079
+ }
1080
+ if (target.hasAttribute('class') && target.getAttribute('class').split(' ').indexOf(contentClass) > -1) {
1081
+ return true;
1082
+ }
1083
+ else {
1084
+ return GridsterUtils.checkContentClass(target.parentNode, current, contentClass);
1085
+ }
1086
+ }
1087
+ /**
1088
+ * @param {?} a
1089
+ * @param {?} b
1090
+ * @return {?}
1091
+ */
1092
+ static compareItems(a, b) {
1093
+ if (a.y > b.y) {
1094
+ return -1;
1095
+ }
1096
+ else if (a.y < b.y) {
1097
+ return 1;
1098
+ }
1099
+ else if (a.x > b.x) {
1100
+ return -1;
1101
+ }
1102
+ else {
1103
+ return 1;
1104
+ }
1105
+ }
1106
+ }
1107
+ GridsterUtils.decorators = [
1108
+ { type: Injectable }
1109
+ ];
1110
+
1111
+ /**
1112
+ * @fileoverview added by tsickle
1113
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1114
+ */
1115
+ /**
1116
+ * @abstract
1117
+ */
1118
+ class GridsterComponentInterface {
1119
+ }
1120
+
1121
+ /**
1122
+ * @fileoverview added by tsickle
1123
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1124
+ */
1125
+ class GridsterEmptyCell {
1126
+ /**
1127
+ * @param {?} gridster
1128
+ */
1129
+ constructor(gridster) {
1130
+ this.gridster = gridster;
1131
+ }
1132
+ /**
1133
+ * @return {?}
1134
+ */
1135
+ destroy() {
1136
+ delete this.initialItem;
1137
+ delete this.gridster.movingItem;
1138
+ if (this.gridster.previewStyle) {
1139
+ this.gridster.previewStyle();
1140
+ }
1141
+ delete this.gridster;
1142
+ if (this.emptyCellExit) {
1143
+ this.emptyCellExit();
1144
+ this.emptyCellExit = null;
1145
+ }
1146
+ }
1147
+ /**
1148
+ * @return {?}
1149
+ */
1150
+ updateOptions() {
1151
+ if (this.gridster.$options.enableEmptyCellClick && !this.emptyCellClick && this.gridster.options.emptyCellClickCallback) {
1152
+ this.emptyCellClick = this.gridster.renderer.listen(this.gridster.el, 'click', this.emptyCellClickCb.bind(this));
1153
+ this.emptyCellClickTouch = this.gridster.renderer.listen(this.gridster.el, 'touchend', this.emptyCellClickCb.bind(this));
1154
+ }
1155
+ else if (!this.gridster.$options.enableEmptyCellClick && this.emptyCellClick && this.emptyCellClickTouch) {
1156
+ this.emptyCellClick();
1157
+ this.emptyCellClickTouch();
1158
+ this.emptyCellClick = null;
1159
+ this.emptyCellClickTouch = null;
1160
+ }
1161
+ if (this.gridster.$options.enableEmptyCellContextMenu && !this.emptyCellContextMenu &&
1162
+ this.gridster.options.emptyCellContextMenuCallback) {
1163
+ this.emptyCellContextMenu = this.gridster.renderer.listen(this.gridster.el, 'contextmenu', this.emptyCellContextMenuCb.bind(this));
1164
+ }
1165
+ else if (!this.gridster.$options.enableEmptyCellContextMenu && this.emptyCellContextMenu) {
1166
+ this.emptyCellContextMenu();
1167
+ this.emptyCellContextMenu = null;
1168
+ }
1169
+ if (this.gridster.$options.enableEmptyCellDrop && !this.emptyCellDrop && this.gridster.options.emptyCellDropCallback) {
1170
+ this.emptyCellDrop = this.gridster.renderer.listen(this.gridster.el, 'drop', this.emptyCellDragDrop.bind(this));
1171
+ this.gridster.zone.runOutsideAngular((/**
1172
+ * @return {?}
1173
+ */
1174
+ () => {
1175
+ this.emptyCellMove = this.gridster.renderer.listen(this.gridster.el, 'dragover', this.emptyCellDragOver.bind(this));
1176
+ }));
1177
+ this.emptyCellExit = this.gridster.renderer.listen('document', 'dragend', (/**
1178
+ * @return {?}
1179
+ */
1180
+ () => {
1181
+ this.gridster.movingItem = null;
1182
+ this.gridster.previewStyle();
1183
+ }));
1184
+ }
1185
+ else if (!this.gridster.$options.enableEmptyCellDrop && this.emptyCellDrop && this.emptyCellMove && this.emptyCellExit) {
1186
+ this.emptyCellDrop();
1187
+ this.emptyCellMove();
1188
+ this.emptyCellExit();
1189
+ this.emptyCellMove = null;
1190
+ this.emptyCellDrop = null;
1191
+ this.emptyCellExit = null;
1192
+ }
1193
+ if (this.gridster.$options.enableEmptyCellDrag && !this.emptyCellDrag && this.gridster.options.emptyCellDragCallback) {
1194
+ this.emptyCellDrag = this.gridster.renderer.listen(this.gridster.el, 'mousedown', this.emptyCellMouseDown.bind(this));
1195
+ this.emptyCellDragTouch = this.gridster.renderer.listen(this.gridster.el, 'touchstart', this.emptyCellMouseDown.bind(this));
1196
+ }
1197
+ else if (!this.gridster.$options.enableEmptyCellDrag && this.emptyCellDrag && this.emptyCellDragTouch) {
1198
+ this.emptyCellDrag();
1199
+ this.emptyCellDragTouch();
1200
+ this.emptyCellDrag = null;
1201
+ this.emptyCellDragTouch = null;
1202
+ }
1203
+ }
1204
+ /**
1205
+ * @param {?} e
1206
+ * @return {?}
1207
+ */
1208
+ emptyCellClickCb(e) {
1209
+ if (this.gridster.movingItem || GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
1210
+ return;
1211
+ }
1212
+ /** @type {?} */
1213
+ const item = this.getValidItemFromEvent(e);
1214
+ if (!item) {
1215
+ return;
1216
+ }
1217
+ if (this.gridster.options.emptyCellClickCallback) {
1218
+ this.gridster.options.emptyCellClickCallback(e, item);
1219
+ }
1220
+ this.gridster.cdRef.markForCheck();
1221
+ }
1222
+ /**
1223
+ * @param {?} e
1224
+ * @return {?}
1225
+ */
1226
+ emptyCellContextMenuCb(e) {
1227
+ if (this.gridster.movingItem || GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
1228
+ return;
1229
+ }
1230
+ e.preventDefault();
1231
+ e.stopPropagation();
1232
+ /** @type {?} */
1233
+ const item = this.getValidItemFromEvent(e);
1234
+ if (!item) {
1235
+ return;
1236
+ }
1237
+ if (this.gridster.options.emptyCellContextMenuCallback) {
1238
+ this.gridster.options.emptyCellContextMenuCallback(e, item);
1239
+ }
1240
+ this.gridster.cdRef.markForCheck();
1241
+ }
1242
+ /**
1243
+ * @param {?} e
1244
+ * @return {?}
1245
+ */
1246
+ emptyCellDragDrop(e) {
1247
+ /** @type {?} */
1248
+ const item = this.getValidItemFromEvent(e);
1249
+ if (!item) {
1250
+ return;
1251
+ }
1252
+ if (this.gridster.options.emptyCellDropCallback) {
1253
+ this.gridster.options.emptyCellDropCallback(e, item);
1254
+ }
1255
+ this.gridster.cdRef.markForCheck();
1256
+ }
1257
+ /**
1258
+ * @param {?} e
1259
+ * @return {?}
1260
+ */
1261
+ emptyCellDragOver(e) {
1262
+ e.preventDefault();
1263
+ e.stopPropagation();
1264
+ /** @type {?} */
1265
+ const item = this.getValidItemFromEvent(e);
1266
+ if (item) {
1267
+ e.dataTransfer.dropEffect = 'move';
1268
+ this.gridster.movingItem = item;
1269
+ }
1270
+ else {
1271
+ e.dataTransfer.dropEffect = 'none';
1272
+ this.gridster.movingItem = null;
1273
+ }
1274
+ this.gridster.previewStyle();
1275
+ }
1276
+ /**
1277
+ * @param {?} e
1278
+ * @return {?}
1279
+ */
1280
+ emptyCellMouseDown(e) {
1281
+ if (GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
1282
+ return;
1283
+ }
1284
+ e.preventDefault();
1285
+ e.stopPropagation();
1286
+ /** @type {?} */
1287
+ const item = this.getValidItemFromEvent(e);
1288
+ /** @type {?} */
1289
+ const leftMouseButtonCode = 1;
1290
+ if (!item || e.buttons !== leftMouseButtonCode) {
1291
+ return;
1292
+ }
1293
+ this.initialItem = item;
1294
+ this.gridster.movingItem = item;
1295
+ this.gridster.previewStyle();
1296
+ this.gridster.zone.runOutsideAngular((/**
1297
+ * @return {?}
1298
+ */
1299
+ () => {
1300
+ this.emptyCellMMove = this.gridster.renderer.listen('window', 'mousemove', this.emptyCellMouseMove.bind(this));
1301
+ this.emptyCellMMoveTouch = this.gridster.renderer.listen('window', 'touchmove', this.emptyCellMouseMove.bind(this));
1302
+ }));
1303
+ this.emptyCellUp = this.gridster.renderer.listen('window', 'mouseup', this.emptyCellMouseUp.bind(this));
1304
+ this.emptyCellUpTouch = this.gridster.renderer.listen('window', 'touchend', this.emptyCellMouseUp.bind(this));
1305
+ }
1306
+ /**
1307
+ * @param {?} e
1308
+ * @return {?}
1309
+ */
1310
+ emptyCellMouseMove(e) {
1311
+ e.preventDefault();
1312
+ e.stopPropagation();
1313
+ /** @type {?} */
1314
+ const item = this.getValidItemFromEvent(e, this.initialItem);
1315
+ if (!item) {
1316
+ return;
1317
+ }
1318
+ this.gridster.movingItem = item;
1319
+ this.gridster.previewStyle();
1320
+ }
1321
+ /**
1322
+ * @param {?} e
1323
+ * @return {?}
1324
+ */
1325
+ emptyCellMouseUp(e) {
1326
+ this.emptyCellMMove();
1327
+ this.emptyCellMMoveTouch();
1328
+ this.emptyCellUp();
1329
+ this.emptyCellUpTouch();
1330
+ /** @type {?} */
1331
+ const item = this.getValidItemFromEvent(e, this.initialItem);
1332
+ if (item) {
1333
+ this.gridster.movingItem = item;
1334
+ }
1335
+ if (this.gridster.options.emptyCellDragCallback && this.gridster.movingItem) {
1336
+ this.gridster.options.emptyCellDragCallback(e, this.gridster.movingItem);
1337
+ }
1338
+ setTimeout((/**
1339
+ * @return {?}
1340
+ */
1341
+ () => {
1342
+ this.initialItem = null;
1343
+ if (this.gridster) {
1344
+ this.gridster.movingItem = null;
1345
+ this.gridster.previewStyle();
1346
+ }
1347
+ }));
1348
+ this.gridster.cdRef.markForCheck();
1349
+ }
1350
+ /**
1351
+ * @param {?} e
1352
+ * @param {?=} oldItem
1353
+ * @return {?}
1354
+ */
1355
+ getValidItemFromEvent(e, oldItem) {
1356
+ e.preventDefault();
1357
+ e.stopPropagation();
1358
+ GridsterUtils.checkTouchEvent(e);
1359
+ /** @type {?} */
1360
+ const rect = this.gridster.el.getBoundingClientRect();
1361
+ /** @type {?} */
1362
+ const x = e.clientX + this.gridster.el.scrollLeft - rect.left - this.gridster.$options.margin;
1363
+ /** @type {?} */
1364
+ const y = e.clientY + this.gridster.el.scrollTop - rect.top - this.gridster.$options.margin;
1365
+ /** @type {?} */
1366
+ const item = {
1367
+ x: this.gridster.pixelsToPositionX(x, Math.floor, true),
1368
+ y: this.gridster.pixelsToPositionY(y, Math.floor, true),
1369
+ cols: this.gridster.$options.defaultItemCols,
1370
+ rows: this.gridster.$options.defaultItemRows
1371
+ };
1372
+ if (oldItem) {
1373
+ item.cols = Math.min(Math.abs(oldItem.x - item.x) + 1, this.gridster.$options.emptyCellDragMaxCols);
1374
+ item.rows = Math.min(Math.abs(oldItem.y - item.y) + 1, this.gridster.$options.emptyCellDragMaxRows);
1375
+ if (oldItem.x < item.x) {
1376
+ item.x = oldItem.x;
1377
+ }
1378
+ else if (oldItem.x - item.x > this.gridster.$options.emptyCellDragMaxCols - 1) {
1379
+ item.x = this.gridster.movingItem ? this.gridster.movingItem.x : 0;
1380
+ }
1381
+ if (oldItem.y < item.y) {
1382
+ item.y = oldItem.y;
1383
+ }
1384
+ else if (oldItem.y - item.y > this.gridster.$options.emptyCellDragMaxRows - 1) {
1385
+ item.y = this.gridster.movingItem ? this.gridster.movingItem.y : 0;
1386
+ }
1387
+ }
1388
+ if (this.gridster.checkCollision(item)) {
1389
+ return;
1390
+ }
1391
+ return item;
1392
+ }
1393
+ }
1394
+ GridsterEmptyCell.decorators = [
1395
+ { type: Injectable }
1396
+ ];
1397
+ /** @nocollapse */
1398
+ GridsterEmptyCell.ctorParameters = () => [
1399
+ { type: GridsterComponentInterface }
1400
+ ];
1401
+
1402
+ /**
1403
+ * @fileoverview added by tsickle
1404
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1405
+ */
1406
+ class GridsterCompact {
1407
+ /**
1408
+ * @param {?} gridster
1409
+ */
1410
+ constructor(gridster) {
1411
+ this.gridster = gridster;
1412
+ }
1413
+ /**
1414
+ * @return {?}
1415
+ */
1416
+ destroy() {
1417
+ delete this.gridster;
1418
+ }
1419
+ /**
1420
+ * @return {?}
1421
+ */
1422
+ checkCompact() {
1423
+ if (this.gridster.$options.compactType !== CompactType.None) {
1424
+ if (this.gridster.$options.compactType === CompactType.CompactUp) {
1425
+ this.checkCompactUp();
1426
+ }
1427
+ else if (this.gridster.$options.compactType === CompactType.CompactLeft) {
1428
+ this.checkCompactLeft();
1429
+ }
1430
+ else if (this.gridster.$options.compactType === CompactType.CompactUpAndLeft) {
1431
+ this.checkCompactUp();
1432
+ this.checkCompactLeft();
1433
+ }
1434
+ else if (this.gridster.$options.compactType === CompactType.CompactLeftAndUp) {
1435
+ this.checkCompactLeft();
1436
+ this.checkCompactUp();
1437
+ }
1438
+ else if (this.gridster.$options.compactType === CompactType.CompactRight) {
1439
+ this.checkCompactRight();
1440
+ }
1441
+ else if (this.gridster.$options.compactType === CompactType.CompactUpAndRight) {
1442
+ this.checkCompactUp();
1443
+ this.checkCompactRight();
1444
+ }
1445
+ else if (this.gridster.$options.compactType === CompactType.CompactRightAndUp) {
1446
+ this.checkCompactRight();
1447
+ this.checkCompactUp();
1448
+ }
1449
+ }
1450
+ }
1451
+ /**
1452
+ * @param {?} item
1453
+ * @return {?}
1454
+ */
1455
+ checkCompactItem(item) {
1456
+ if (this.gridster.$options.compactType !== CompactType.None) {
1457
+ if (this.gridster.$options.compactType === CompactType.CompactUp) {
1458
+ this.moveUpTillCollision(item);
1459
+ }
1460
+ else if (this.gridster.$options.compactType === CompactType.CompactLeft) {
1461
+ this.moveLeftTillCollision(item);
1462
+ }
1463
+ else if (this.gridster.$options.compactType === CompactType.CompactUpAndLeft) {
1464
+ this.moveUpTillCollision(item);
1465
+ this.moveLeftTillCollision(item);
1466
+ }
1467
+ else if (this.gridster.$options.compactType === CompactType.CompactLeftAndUp) {
1468
+ this.moveLeftTillCollision(item);
1469
+ this.moveUpTillCollision(item);
1470
+ }
1471
+ else if (this.gridster.$options.compactType === CompactType.CompactUpAndRight) {
1472
+ this.moveUpTillCollision(item);
1473
+ this.moveRightTillCollision(item);
1474
+ }
1475
+ }
1476
+ }
1477
+ /**
1478
+ * @return {?}
1479
+ */
1480
+ checkCompactUp() {
1481
+ /** @type {?} */
1482
+ let widgetMovedUp = false;
1483
+ /** @type {?} */
1484
+ let widget;
1485
+ /** @type {?} */
1486
+ let moved;
1487
+ /** @type {?} */
1488
+ const l = this.gridster.grid.length;
1489
+ for (let i = 0; i < l; i++) {
1490
+ widget = this.gridster.grid[i];
1491
+ if (widget.$item.compactEnabled === false) {
1492
+ continue;
1493
+ }
1494
+ moved = this.moveUpTillCollision(widget.$item);
1495
+ if (moved) {
1496
+ widgetMovedUp = true;
1497
+ widget.item.y = widget.$item.y;
1498
+ widget.itemChanged();
1499
+ }
1500
+ }
1501
+ if (widgetMovedUp) {
1502
+ this.checkCompact();
1503
+ }
1504
+ }
1505
+ /**
1506
+ * @param {?} item
1507
+ * @return {?}
1508
+ */
1509
+ moveUpTillCollision(item) {
1510
+ item.y -= 1;
1511
+ if (this.gridster.checkCollision(item)) {
1512
+ item.y += 1;
1513
+ return false;
1514
+ }
1515
+ else {
1516
+ this.moveUpTillCollision(item);
1517
+ return true;
1518
+ }
1519
+ }
1520
+ /**
1521
+ * @return {?}
1522
+ */
1523
+ checkCompactLeft() {
1524
+ /** @type {?} */
1525
+ let widgetMovedUp = false;
1526
+ /** @type {?} */
1527
+ let widget;
1528
+ /** @type {?} */
1529
+ let moved;
1530
+ /** @type {?} */
1531
+ const l = this.gridster.grid.length;
1532
+ for (let i = 0; i < l; i++) {
1533
+ widget = this.gridster.grid[i];
1534
+ if (widget.$item.compactEnabled === false) {
1535
+ continue;
1536
+ }
1537
+ moved = this.moveLeftTillCollision(widget.$item);
1538
+ if (moved) {
1539
+ widgetMovedUp = true;
1540
+ widget.item.x = widget.$item.x;
1541
+ widget.itemChanged();
1542
+ }
1543
+ }
1544
+ if (widgetMovedUp) {
1545
+ this.checkCompact();
1546
+ }
1547
+ }
1548
+ /**
1549
+ * @return {?}
1550
+ */
1551
+ checkCompactRight() {
1552
+ /** @type {?} */
1553
+ let widgetMovedUp = false;
1554
+ /** @type {?} */
1555
+ let widget;
1556
+ /** @type {?} */
1557
+ let moved;
1558
+ /** @type {?} */
1559
+ const l = this.gridster.grid.length;
1560
+ for (let i = 0; i < l; i++) {
1561
+ widget = this.gridster.grid[i];
1562
+ if (widget.$item.compactEnabled === false) {
1563
+ continue;
1564
+ }
1565
+ moved = this.moveRightTillCollision(widget.$item);
1566
+ if (moved) {
1567
+ widgetMovedUp = true;
1568
+ widget.item.x = widget.$item.x;
1569
+ widget.itemChanged();
1570
+ }
1571
+ }
1572
+ if (widgetMovedUp) {
1573
+ this.checkCompact();
1574
+ }
1575
+ }
1576
+ /**
1577
+ * @param {?} item
1578
+ * @return {?}
1579
+ */
1580
+ moveLeftTillCollision(item) {
1581
+ item.x -= 1;
1582
+ if (this.gridster.checkCollision(item)) {
1583
+ item.x += 1;
1584
+ return false;
1585
+ }
1586
+ else {
1587
+ this.moveLeftTillCollision(item);
1588
+ return true;
1589
+ }
1590
+ }
1591
+ /**
1592
+ * @param {?} item
1593
+ * @return {?}
1594
+ */
1595
+ moveRightTillCollision(item) {
1596
+ item.x += 1;
1597
+ if (this.gridster.checkCollision(item)) {
1598
+ item.x -= 1;
1599
+ return false;
1600
+ }
1601
+ else {
1602
+ this.moveRightTillCollision(item);
1603
+ return true;
1604
+ }
1605
+ }
1606
+ }
1607
+ GridsterCompact.decorators = [
1608
+ { type: Injectable }
1609
+ ];
1610
+ /** @nocollapse */
1611
+ GridsterCompact.ctorParameters = () => [
1612
+ { type: GridsterComponentInterface }
1613
+ ];
1614
+
1615
+ /**
1616
+ * @fileoverview added by tsickle
1617
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1618
+ */
1619
+ class GridsterRenderer {
1620
+ /**
1621
+ * @param {?} gridster
1622
+ */
1623
+ constructor(gridster) {
1624
+ this.gridster = gridster;
1625
+ }
1626
+ /**
1627
+ * @return {?}
1628
+ */
1629
+ destroy() {
1630
+ delete this.gridster;
1631
+ }
1632
+ /**
1633
+ * @param {?} el
1634
+ * @param {?} item
1635
+ * @param {?} renderer
1636
+ * @return {?}
1637
+ */
1638
+ updateItem(el, item, renderer) {
1639
+ if (this.gridster.mobile) {
1640
+ this.clearCellPosition(renderer, el);
1641
+ if (this.gridster.$options.keepFixedHeightInMobile) {
1642
+ renderer.setStyle(el, 'height', (item.rows * this.gridster.$options.fixedRowHeight) + 'px');
1643
+ }
1644
+ else {
1645
+ renderer.setStyle(el, 'height', (this.gridster.curWidth / 2 * item.rows) + 'px');
1646
+ }
1647
+ if (this.gridster.$options.keepFixedWidthInMobile) {
1648
+ renderer.setStyle(el, 'width', this.gridster.$options.fixedColWidth + 'px');
1649
+ }
1650
+ else {
1651
+ renderer.setStyle(el, 'width', '');
1652
+ }
1653
+ renderer.setStyle(el, 'margin-bottom', this.gridster.$options.margin + 'px');
1654
+ renderer.setStyle(el, 'margin-right', '');
1655
+ }
1656
+ else {
1657
+ /** @type {?} */
1658
+ const x = Math.round(this.gridster.curColWidth * item.x);
1659
+ /** @type {?} */
1660
+ const y = Math.round(this.gridster.curRowHeight * item.y);
1661
+ /** @type {?} */
1662
+ const width = this.gridster.curColWidth * item.cols - this.gridster.$options.margin;
1663
+ /** @type {?} */
1664
+ const height = (this.gridster.curRowHeight * item.rows - this.gridster.$options.margin);
1665
+ // set the cell style
1666
+ this.setCellPosition(renderer, el, x, y);
1667
+ renderer.setStyle(el, 'width', width + 'px');
1668
+ renderer.setStyle(el, 'height', height + 'px');
1669
+ /** @type {?} */
1670
+ let marginBottom = null;
1671
+ /** @type {?} */
1672
+ let marginRight = null;
1673
+ if (this.gridster.$options.outerMargin) {
1674
+ if (this.gridster.rows === item.rows + item.y) {
1675
+ if (this.gridster.$options.outerMarginBottom !== null) {
1676
+ marginBottom = this.gridster.$options.outerMarginBottom + 'px';
1677
+ }
1678
+ else {
1679
+ marginBottom = this.gridster.$options.margin + 'px';
1680
+ }
1681
+ }
1682
+ if (this.gridster.columns === item.cols + item.x) {
1683
+ if (this.gridster.$options.outerMarginBottom !== null) {
1684
+ marginRight = this.gridster.$options.outerMarginRight + 'px';
1685
+ }
1686
+ else {
1687
+ marginRight = this.gridster.$options.margin + 'px';
1688
+ }
1689
+ }
1690
+ }
1691
+ renderer.setStyle(el, 'margin-bottom', marginBottom);
1692
+ renderer.setStyle(el, 'margin-right', marginRight);
1693
+ }
1694
+ }
1695
+ /**
1696
+ * @return {?}
1697
+ */
1698
+ updateGridster() {
1699
+ /** @type {?} */
1700
+ let addClass = '';
1701
+ /** @type {?} */
1702
+ let removeClass1 = '';
1703
+ /** @type {?} */
1704
+ let removeClass2 = '';
1705
+ /** @type {?} */
1706
+ let removeClass3 = '';
1707
+ if (this.gridster.$options.gridType === GridType.Fit) {
1708
+ addClass = GridType.Fit;
1709
+ removeClass1 = GridType.ScrollVertical;
1710
+ removeClass2 = GridType.ScrollHorizontal;
1711
+ removeClass3 = GridType.Fixed;
1712
+ }
1713
+ else if (this.gridster.$options.gridType === GridType.ScrollVertical) {
1714
+ this.gridster.curRowHeight = this.gridster.curColWidth;
1715
+ addClass = GridType.ScrollVertical;
1716
+ removeClass1 = GridType.Fit;
1717
+ removeClass2 = GridType.ScrollHorizontal;
1718
+ removeClass3 = GridType.Fixed;
1719
+ }
1720
+ else if (this.gridster.$options.gridType === GridType.ScrollHorizontal) {
1721
+ this.gridster.curColWidth = this.gridster.curRowHeight;
1722
+ addClass = GridType.ScrollHorizontal;
1723
+ removeClass1 = GridType.Fit;
1724
+ removeClass2 = GridType.ScrollVertical;
1725
+ removeClass3 = GridType.Fixed;
1726
+ }
1727
+ else if (this.gridster.$options.gridType === GridType.Fixed) {
1728
+ this.gridster.curColWidth = this.gridster.$options.fixedColWidth +
1729
+ (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
1730
+ this.gridster.curRowHeight = this.gridster.$options.fixedRowHeight +
1731
+ (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
1732
+ addClass = GridType.Fixed;
1733
+ removeClass1 = GridType.Fit;
1734
+ removeClass2 = GridType.ScrollVertical;
1735
+ removeClass3 = GridType.ScrollHorizontal;
1736
+ }
1737
+ else if (this.gridster.$options.gridType === GridType.VerticalFixed) {
1738
+ this.gridster.curRowHeight = this.gridster.$options.fixedRowHeight +
1739
+ (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
1740
+ addClass = GridType.ScrollVertical;
1741
+ removeClass1 = GridType.Fit;
1742
+ removeClass2 = GridType.ScrollHorizontal;
1743
+ removeClass3 = GridType.Fixed;
1744
+ }
1745
+ else if (this.gridster.$options.gridType === GridType.HorizontalFixed) {
1746
+ this.gridster.curColWidth = this.gridster.$options.fixedColWidth +
1747
+ (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
1748
+ addClass = GridType.ScrollHorizontal;
1749
+ removeClass1 = GridType.Fit;
1750
+ removeClass2 = GridType.ScrollVertical;
1751
+ removeClass3 = GridType.Fixed;
1752
+ }
1753
+ if (this.gridster.mobile) {
1754
+ this.gridster.renderer.removeClass(this.gridster.el, addClass);
1755
+ }
1756
+ else {
1757
+ this.gridster.renderer.addClass(this.gridster.el, addClass);
1758
+ }
1759
+ this.gridster.renderer.removeClass(this.gridster.el, removeClass1);
1760
+ this.gridster.renderer.removeClass(this.gridster.el, removeClass2);
1761
+ this.gridster.renderer.removeClass(this.gridster.el, removeClass3);
1762
+ }
1763
+ /**
1764
+ * @param {?} i
1765
+ * @return {?}
1766
+ */
1767
+ getGridColumnStyle(i) {
1768
+ return Object.assign({}, this.getLeftPosition(this.gridster.curColWidth * i), { width: this.gridster.curColWidth - this.gridster.$options.margin + 'px', height: this.gridster.gridRows.length * this.gridster.curRowHeight - this.gridster.$options.margin + 'px' });
1769
+ }
1770
+ /**
1771
+ * @param {?} i
1772
+ * @return {?}
1773
+ */
1774
+ getGridRowStyle(i) {
1775
+ return Object.assign({}, this.getTopPosition(this.gridster.curRowHeight * i), { width: this.gridster.gridColumns.length * this.gridster.curColWidth - this.gridster.$options.margin + 'px', height: this.gridster.curRowHeight - this.gridster.$options.margin + 'px' });
1776
+ }
1777
+ /**
1778
+ * @param {?} d
1779
+ * @return {?}
1780
+ */
1781
+ getLeftPosition(d) {
1782
+ if (this.gridster.$options.useTransformPositioning) {
1783
+ return {
1784
+ transform: 'translateX(' + d + 'px)',
1785
+ };
1786
+ }
1787
+ else {
1788
+ return {
1789
+ left: (this.getLeftMargin() + d) + 'px'
1790
+ };
1791
+ }
1792
+ }
1793
+ /**
1794
+ * @param {?} d
1795
+ * @return {?}
1796
+ */
1797
+ getTopPosition(d) {
1798
+ if (this.gridster.$options.useTransformPositioning) {
1799
+ return {
1800
+ transform: 'translateY(' + d + 'px)',
1801
+ };
1802
+ }
1803
+ else {
1804
+ return {
1805
+ top: this.getTopMargin() + d + 'px'
1806
+ };
1807
+ }
1808
+ }
1809
+ /**
1810
+ * @param {?} renderer
1811
+ * @param {?} el
1812
+ * @return {?}
1813
+ */
1814
+ clearCellPosition(renderer, el) {
1815
+ if (this.gridster.$options.useTransformPositioning) {
1816
+ renderer.setStyle(el, 'transform', '');
1817
+ }
1818
+ else {
1819
+ renderer.setStyle(el, 'top', '');
1820
+ renderer.setStyle(el, 'left', '');
1821
+ }
1822
+ }
1823
+ /**
1824
+ * @param {?} renderer
1825
+ * @param {?} el
1826
+ * @param {?} x
1827
+ * @param {?} y
1828
+ * @return {?}
1829
+ */
1830
+ setCellPosition(renderer, el, x, y) {
1831
+ if (this.gridster.$options.useTransformPositioning) {
1832
+ /** @type {?} */
1833
+ const transform = 'translate3d(' + x + 'px, ' + y + 'px, 0)';
1834
+ renderer.setStyle(el, 'transform', transform);
1835
+ }
1836
+ else {
1837
+ renderer.setStyle(el, 'left', this.getLeftMargin() + x + 'px');
1838
+ renderer.setStyle(el, 'top', this.getTopMargin() + y + 'px');
1839
+ }
1840
+ }
1841
+ /**
1842
+ * @return {?}
1843
+ */
1844
+ getLeftMargin() {
1845
+ if (this.gridster.$options.outerMargin) {
1846
+ if (this.gridster.$options.outerMarginLeft !== null) {
1847
+ return this.gridster.$options.outerMarginLeft;
1848
+ }
1849
+ else {
1850
+ return this.gridster.$options.margin;
1851
+ }
1852
+ }
1853
+ else {
1854
+ return 0;
1855
+ }
1856
+ }
1857
+ /**
1858
+ * @return {?}
1859
+ */
1860
+ getTopMargin() {
1861
+ if (this.gridster.$options.outerMargin) {
1862
+ if (this.gridster.$options.outerMarginTop !== null) {
1863
+ return this.gridster.$options.outerMarginTop;
1864
+ }
1865
+ else {
1866
+ return this.gridster.$options.margin;
1867
+ }
1868
+ }
1869
+ else {
1870
+ return 0;
1871
+ }
1872
+ }
1873
+ }
1874
+ GridsterRenderer.decorators = [
1875
+ { type: Injectable }
1876
+ ];
1877
+ /** @nocollapse */
1878
+ GridsterRenderer.ctorParameters = () => [
1879
+ { type: GridsterComponentInterface }
1880
+ ];
1881
+
1882
+ /**
1883
+ * @fileoverview added by tsickle
1884
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1885
+ */
1886
+ class GridsterComponent {
1887
+ /**
1888
+ * @param {?} el
1889
+ * @param {?} renderer
1890
+ * @param {?} cdRef
1891
+ * @param {?} zone
1892
+ */
1893
+ constructor(el, renderer, cdRef, zone) {
1894
+ this.renderer = renderer;
1895
+ this.cdRef = cdRef;
1896
+ this.zone = zone;
1897
+ this.gridColumns = [];
1898
+ this.gridRows = [];
1899
+ this.el = el.nativeElement;
1900
+ this.$options = JSON.parse(JSON.stringify(GridsterConfigService));
1901
+ this.calculateLayoutDebounce = GridsterUtils.debounce(this.calculateLayout.bind(this), 0);
1902
+ this.mobile = false;
1903
+ this.curWidth = 0;
1904
+ this.curHeight = 0;
1905
+ this.grid = [];
1906
+ this.curColWidth = 0;
1907
+ this.curRowHeight = 0;
1908
+ this.dragInProgress = false;
1909
+ this.emptyCell = new GridsterEmptyCell(this);
1910
+ this.compact = new GridsterCompact(this);
1911
+ this.gridRenderer = new GridsterRenderer(this);
1912
+ }
1913
+ /**
1914
+ * @param {?} item
1915
+ * @param {?} item2
1916
+ * @return {?}
1917
+ */
1918
+ static checkCollisionTwoItems(item, item2) {
1919
+ return item.x < item2.x + item2.cols
1920
+ && item.x + item.cols > item2.x
1921
+ && item.y < item2.y + item2.rows
1922
+ && item.y + item.rows > item2.y;
1923
+ }
1924
+ /**
1925
+ * @return {?}
1926
+ */
1927
+ ngOnInit() {
1928
+ if (this.options.initCallback) {
1929
+ this.options.initCallback(this);
1930
+ }
1931
+ }
1932
+ /**
1933
+ * @param {?} changes
1934
+ * @return {?}
1935
+ */
1936
+ ngOnChanges(changes) {
1937
+ if (changes.options) {
1938
+ this.setOptions();
1939
+ this.options.api = {
1940
+ optionsChanged: this.optionsChanged.bind(this),
1941
+ resize: this.onResize.bind(this),
1942
+ getNextPossiblePosition: this.getNextPossiblePosition.bind(this),
1943
+ getFirstPossiblePosition: this.getFirstPossiblePosition.bind(this),
1944
+ getLastPossiblePosition: this.getLastPossiblePosition.bind(this),
1945
+ getCurrentRowHeight: this.getCurrentRowHeight.bind(this)
1946
+ };
1947
+ this.columns = this.$options.minCols;
1948
+ this.rows = this.$options.minRows;
1949
+ this.setGridSize();
1950
+ this.calculateLayout();
1951
+ }
1952
+ }
1953
+ /**
1954
+ * @return {?}
1955
+ */
1956
+ getCurrentRowHeight() {
1957
+ return this.curRowHeight;
1958
+ }
1959
+ /**
1960
+ * @return {?}
1961
+ */
1962
+ resize() {
1963
+ /** @type {?} */
1964
+ let height;
1965
+ /** @type {?} */
1966
+ let width;
1967
+ if (this.$options.gridType === 'fit' && !this.mobile) {
1968
+ width = this.el.offsetWidth;
1969
+ height = this.el.offsetHeight;
1970
+ }
1971
+ else {
1972
+ width = this.el.clientWidth;
1973
+ height = this.el.clientHeight;
1974
+ }
1975
+ if ((width !== this.curWidth || height !== this.curHeight) && this.checkIfToResize()) {
1976
+ this.onResize();
1977
+ }
1978
+ }
1979
+ /**
1980
+ * @return {?}
1981
+ */
1982
+ setOptions() {
1983
+ this.$options = GridsterUtils.merge(this.$options, this.options, this.$options);
1984
+ if (!this.$options.disableWindowResize && !this.windowResize) {
1985
+ this.windowResize = this.renderer.listen('window', 'resize', this.onResize.bind(this));
1986
+ }
1987
+ else if (this.$options.disableWindowResize && this.windowResize) {
1988
+ this.windowResize();
1989
+ this.windowResize = null;
1990
+ }
1991
+ this.emptyCell.updateOptions();
1992
+ }
1993
+ /**
1994
+ * @return {?}
1995
+ */
1996
+ optionsChanged() {
1997
+ this.setOptions();
1998
+ /** @type {?} */
1999
+ let widgetsIndex = this.grid.length - 1;
2000
+ /** @type {?} */
2001
+ let widget;
2002
+ for (; widgetsIndex >= 0; widgetsIndex--) {
2003
+ widget = this.grid[widgetsIndex];
2004
+ widget.updateOptions();
2005
+ }
2006
+ this.calculateLayout();
2007
+ }
2008
+ /**
2009
+ * @return {?}
2010
+ */
2011
+ ngOnDestroy() {
2012
+ if (this.windowResize) {
2013
+ this.windowResize();
2014
+ }
2015
+ if (this.options.destroyCallback) {
2016
+ this.options.destroyCallback(this);
2017
+ }
2018
+ if (this.options.api) {
2019
+ this.options.api.resize = undefined;
2020
+ this.options.api.optionsChanged = undefined;
2021
+ this.options.api.getNextPossiblePosition = undefined;
2022
+ this.options.api = undefined;
2023
+ }
2024
+ this.emptyCell.destroy();
2025
+ delete this.emptyCell;
2026
+ this.compact.destroy();
2027
+ delete this.compact;
2028
+ }
2029
+ /**
2030
+ * @return {?}
2031
+ */
2032
+ onResize() {
2033
+ this.setGridSize();
2034
+ this.calculateLayout();
2035
+ }
2036
+ /**
2037
+ * @return {?}
2038
+ */
2039
+ checkIfToResize() {
2040
+ /** @type {?} */
2041
+ const clientWidth = this.el.clientWidth;
2042
+ /** @type {?} */
2043
+ const offsetWidth = this.el.offsetWidth;
2044
+ /** @type {?} */
2045
+ const scrollWidth = this.el.scrollWidth;
2046
+ /** @type {?} */
2047
+ const clientHeight = this.el.clientHeight;
2048
+ /** @type {?} */
2049
+ const offsetHeight = this.el.offsetHeight;
2050
+ /** @type {?} */
2051
+ const scrollHeight = this.el.scrollHeight;
2052
+ /** @type {?} */
2053
+ const verticalScrollPresent = clientWidth < offsetWidth && scrollHeight > offsetHeight
2054
+ && scrollHeight - offsetHeight < offsetWidth - clientWidth;
2055
+ /** @type {?} */
2056
+ const horizontalScrollPresent = clientHeight < offsetHeight
2057
+ && scrollWidth > offsetWidth && scrollWidth - offsetWidth < offsetHeight - clientHeight;
2058
+ if (verticalScrollPresent) {
2059
+ return false;
2060
+ }
2061
+ return !horizontalScrollPresent;
2062
+ }
2063
+ /**
2064
+ * @return {?}
2065
+ */
2066
+ setGridSize() {
2067
+ /** @type {?} */
2068
+ const el = this.el;
2069
+ /** @type {?} */
2070
+ let width = el.clientWidth;
2071
+ /** @type {?} */
2072
+ let height = el.clientHeight;
2073
+ if (this.$options.setGridSize || this.$options.gridType === 'fit' && !this.mobile) {
2074
+ width = el.offsetWidth;
2075
+ height = el.offsetHeight;
2076
+ }
2077
+ else {
2078
+ width = el.clientWidth;
2079
+ height = el.clientHeight;
2080
+ }
2081
+ this.curWidth = width;
2082
+ this.curHeight = height;
2083
+ }
2084
+ /**
2085
+ * @return {?}
2086
+ */
2087
+ setGridDimensions() {
2088
+ this.setGridSize();
2089
+ if (!this.mobile && this.$options.mobileBreakpoint > this.curWidth) {
2090
+ this.mobile = !this.mobile;
2091
+ this.renderer.addClass(this.el, 'mobile');
2092
+ }
2093
+ else if (this.mobile && this.$options.mobileBreakpoint < this.curWidth) {
2094
+ this.mobile = !this.mobile;
2095
+ this.renderer.removeClass(this.el, 'mobile');
2096
+ }
2097
+ /** @type {?} */
2098
+ let rows = this.$options.minRows;
2099
+ /** @type {?} */
2100
+ let columns = this.$options.minCols;
2101
+ /** @type {?} */
2102
+ let widgetsIndex = this.grid.length - 1;
2103
+ /** @type {?} */
2104
+ let widget;
2105
+ for (; widgetsIndex >= 0; widgetsIndex--) {
2106
+ widget = this.grid[widgetsIndex];
2107
+ if (!widget.notPlaced) {
2108
+ rows = Math.max(rows, widget.$item.y + widget.$item.rows);
2109
+ columns = Math.max(columns, widget.$item.x + widget.$item.cols);
2110
+ }
2111
+ }
2112
+ if (this.columns !== columns || this.rows !== rows) {
2113
+ this.columns = columns;
2114
+ this.rows = rows;
2115
+ if (this.options.gridSizeChangedCallback) {
2116
+ this.options.gridSizeChangedCallback(this);
2117
+ }
2118
+ }
2119
+ }
2120
+ /**
2121
+ * @return {?}
2122
+ */
2123
+ calculateLayout() {
2124
+ if (this.compact) {
2125
+ this.compact.checkCompact();
2126
+ }
2127
+ this.setGridDimensions();
2128
+ if (this.$options.outerMargin) {
2129
+ /** @type {?} */
2130
+ let marginWidth = -this.$options.margin;
2131
+ if (this.$options.outerMarginLeft !== null) {
2132
+ marginWidth += this.$options.outerMarginLeft;
2133
+ this.renderer.setStyle(this.el, 'padding-left', this.$options.outerMarginLeft + 'px');
2134
+ }
2135
+ else {
2136
+ marginWidth += this.$options.margin;
2137
+ this.renderer.setStyle(this.el, 'padding-left', this.$options.margin + 'px');
2138
+ }
2139
+ if (this.$options.outerMarginRight !== null) {
2140
+ marginWidth += this.$options.outerMarginRight;
2141
+ this.renderer.setStyle(this.el, 'padding-right', this.$options.outerMarginRight + 'px');
2142
+ }
2143
+ else {
2144
+ marginWidth += this.$options.margin;
2145
+ this.renderer.setStyle(this.el, 'padding-right', this.$options.margin + 'px');
2146
+ }
2147
+ this.curColWidth = (this.curWidth - marginWidth) / this.columns;
2148
+ /** @type {?} */
2149
+ let marginHeight = -this.$options.margin;
2150
+ if (this.$options.outerMarginTop !== null) {
2151
+ marginHeight += this.$options.outerMarginTop;
2152
+ this.renderer.setStyle(this.el, 'padding-top', this.$options.outerMarginTop + 'px');
2153
+ }
2154
+ else {
2155
+ marginHeight += this.$options.margin;
2156
+ this.renderer.setStyle(this.el, 'padding-top', this.$options.margin + 'px');
2157
+ }
2158
+ if (this.$options.outerMarginBottom !== null) {
2159
+ marginHeight += this.$options.outerMarginBottom;
2160
+ this.renderer.setStyle(this.el, 'padding-bottom', this.$options.outerMarginBottom + 'px');
2161
+ }
2162
+ else {
2163
+ marginHeight += this.$options.margin;
2164
+ this.renderer.setStyle(this.el, 'padding-bottom', this.$options.margin + 'px');
2165
+ }
2166
+ this.curRowHeight = (this.curHeight - marginHeight) / this.rows;
2167
+ }
2168
+ else {
2169
+ this.curColWidth = (this.curWidth + this.$options.margin) / this.columns;
2170
+ this.curRowHeight = (this.curHeight + this.$options.margin) / this.rows;
2171
+ this.renderer.setStyle(this.el, 'padding-left', 0 + 'px');
2172
+ this.renderer.setStyle(this.el, 'padding-right', 0 + 'px');
2173
+ this.renderer.setStyle(this.el, 'padding-top', 0 + 'px');
2174
+ this.renderer.setStyle(this.el, 'padding-bottom', 0 + 'px');
2175
+ }
2176
+ this.gridRenderer.updateGridster();
2177
+ this.updateGrid();
2178
+ if (this.$options.setGridSize) {
2179
+ this.renderer.setStyle(this.el, 'width', (this.columns * this.curColWidth + this.$options.margin) + 'px');
2180
+ this.renderer.setStyle(this.el, 'height', (this.rows * this.curRowHeight + this.$options.margin) + 'px');
2181
+ }
2182
+ else {
2183
+ this.renderer.setStyle(this.el, 'width', '');
2184
+ this.renderer.setStyle(this.el, 'height', '');
2185
+ }
2186
+ /** @type {?} */
2187
+ let widgetsIndex = this.grid.length - 1;
2188
+ /** @type {?} */
2189
+ let widget;
2190
+ for (; widgetsIndex >= 0; widgetsIndex--) {
2191
+ widget = this.grid[widgetsIndex];
2192
+ widget.setSize();
2193
+ widget.drag.toggle();
2194
+ widget.resize.toggle();
2195
+ }
2196
+ setTimeout(this.resize.bind(this), 100);
2197
+ }
2198
+ /**
2199
+ * @return {?}
2200
+ */
2201
+ updateGrid() {
2202
+ if (this.$options.displayGrid === 'always' && !this.mobile) {
2203
+ this.renderer.addClass(this.el, 'display-grid');
2204
+ }
2205
+ else if (this.$options.displayGrid === 'onDrag&Resize' && this.dragInProgress) {
2206
+ this.renderer.addClass(this.el, 'display-grid');
2207
+ }
2208
+ else if (this.$options.displayGrid === 'none' || !this.dragInProgress || this.mobile) {
2209
+ this.renderer.removeClass(this.el, 'display-grid');
2210
+ }
2211
+ this.setGridDimensions();
2212
+ this.gridColumns.length = Math.max(this.columns, Math.floor(this.curWidth / this.curColWidth)) || 0;
2213
+ this.gridRows.length = Math.max(this.rows, Math.floor(this.curHeight / this.curRowHeight)) || 0;
2214
+ this.cdRef.markForCheck();
2215
+ }
2216
+ /**
2217
+ * @param {?} itemComponent
2218
+ * @return {?}
2219
+ */
2220
+ addItem(itemComponent) {
2221
+ if (itemComponent.$item.cols === undefined) {
2222
+ itemComponent.$item.cols = this.$options.defaultItemCols;
2223
+ itemComponent.item.cols = itemComponent.$item.cols;
2224
+ itemComponent.itemChanged();
2225
+ }
2226
+ if (itemComponent.$item.rows === undefined) {
2227
+ itemComponent.$item.rows = this.$options.defaultItemRows;
2228
+ itemComponent.item.rows = itemComponent.$item.rows;
2229
+ itemComponent.itemChanged();
2230
+ }
2231
+ if (itemComponent.$item.x === -1 || itemComponent.$item.y === -1) {
2232
+ this.autoPositionItem(itemComponent);
2233
+ }
2234
+ else if (this.checkCollision(itemComponent.$item)) {
2235
+ if (!this.$options.disableWarnings) {
2236
+ itemComponent.notPlaced = true;
2237
+ console.warn('Can\'t be placed in the bounds of the dashboard, trying to auto position!/n' +
2238
+ JSON.stringify(itemComponent.item, ['cols', 'rows', 'x', 'y']));
2239
+ }
2240
+ if (!this.$options.disableAutoPositionOnConflict) {
2241
+ this.autoPositionItem(itemComponent);
2242
+ }
2243
+ else {
2244
+ itemComponent.notPlaced = true;
2245
+ }
2246
+ }
2247
+ this.grid.push(itemComponent);
2248
+ this.calculateLayoutDebounce();
2249
+ }
2250
+ /**
2251
+ * @param {?} itemComponent
2252
+ * @return {?}
2253
+ */
2254
+ removeItem(itemComponent) {
2255
+ this.grid.splice(this.grid.indexOf(itemComponent), 1);
2256
+ this.calculateLayoutDebounce();
2257
+ if (this.options.itemRemovedCallback) {
2258
+ this.options.itemRemovedCallback(itemComponent.item, itemComponent);
2259
+ }
2260
+ }
2261
+ /**
2262
+ * @param {?} item
2263
+ * @return {?}
2264
+ */
2265
+ checkCollision(item) {
2266
+ /** @type {?} */
2267
+ let collision = false;
2268
+ if (this.options.itemValidateCallback) {
2269
+ collision = !this.options.itemValidateCallback(item);
2270
+ }
2271
+ if (!collision && this.checkGridCollision(item)) {
2272
+ collision = true;
2273
+ }
2274
+ if (!collision) {
2275
+ /** @type {?} */
2276
+ const c = this.findItemWithItem(item);
2277
+ if (c) {
2278
+ collision = c;
2279
+ }
2280
+ }
2281
+ return collision;
2282
+ }
2283
+ /**
2284
+ * @param {?} item
2285
+ * @return {?}
2286
+ */
2287
+ checkGridCollision(item) {
2288
+ /** @type {?} */
2289
+ const noNegativePosition = item.y > -1 && item.x > -1;
2290
+ /** @type {?} */
2291
+ const maxGridCols = item.cols + item.x <= this.$options.maxCols;
2292
+ /** @type {?} */
2293
+ const maxGridRows = item.rows + item.y <= this.$options.maxRows;
2294
+ /** @type {?} */
2295
+ const maxItemCols = item.maxItemCols === undefined ? this.$options.maxItemCols : item.maxItemCols;
2296
+ /** @type {?} */
2297
+ const minItemCols = item.minItemCols === undefined ? this.$options.minItemCols : item.minItemCols;
2298
+ /** @type {?} */
2299
+ const maxItemRows = item.maxItemRows === undefined ? this.$options.maxItemRows : item.maxItemRows;
2300
+ /** @type {?} */
2301
+ const minItemRows = item.minItemRows === undefined ? this.$options.minItemRows : item.minItemRows;
2302
+ /** @type {?} */
2303
+ const inColsLimits = item.cols <= maxItemCols && item.cols >= minItemCols;
2304
+ /** @type {?} */
2305
+ const inRowsLimits = item.rows <= maxItemRows && item.rows >= minItemRows;
2306
+ /** @type {?} */
2307
+ const minAreaLimit = item.minItemArea === undefined ? this.$options.minItemArea : item.minItemArea;
2308
+ /** @type {?} */
2309
+ const maxAreaLimit = item.maxItemArea === undefined ? this.$options.maxItemArea : item.maxItemArea;
2310
+ /** @type {?} */
2311
+ const area = item.cols * item.rows;
2312
+ /** @type {?} */
2313
+ const inMinArea = minAreaLimit <= area;
2314
+ /** @type {?} */
2315
+ const inMaxArea = maxAreaLimit >= area;
2316
+ return !(noNegativePosition && maxGridCols && maxGridRows && inColsLimits && inRowsLimits && inMinArea && inMaxArea);
2317
+ }
2318
+ /**
2319
+ * @param {?} item
2320
+ * @return {?}
2321
+ */
2322
+ findItemWithItem(item) {
2323
+ /** @type {?} */
2324
+ let widgetsIndex = this.grid.length - 1;
2325
+ /** @type {?} */
2326
+ let widget;
2327
+ for (; widgetsIndex > -1; widgetsIndex--) {
2328
+ widget = this.grid[widgetsIndex];
2329
+ if (widget.$item !== item && GridsterComponent.checkCollisionTwoItems(widget.$item, item)) {
2330
+ return widget;
2331
+ }
2332
+ }
2333
+ return false;
2334
+ }
2335
+ /**
2336
+ * @param {?} item
2337
+ * @return {?}
2338
+ */
2339
+ findItemsWithItem(item) {
2340
+ /** @type {?} */
2341
+ const a = [];
2342
+ /** @type {?} */
2343
+ let widgetsIndex = this.grid.length - 1;
2344
+ /** @type {?} */
2345
+ let widget;
2346
+ for (; widgetsIndex > -1; widgetsIndex--) {
2347
+ widget = this.grid[widgetsIndex];
2348
+ if (widget.$item !== item && GridsterComponent.checkCollisionTwoItems(widget.$item, item)) {
2349
+ a.push(widget);
2350
+ }
2351
+ }
2352
+ return a;
2353
+ }
2354
+ /**
2355
+ * @param {?} itemComponent
2356
+ * @return {?}
2357
+ */
2358
+ autoPositionItem(itemComponent) {
2359
+ if (this.getNextPossiblePosition(itemComponent.$item)) {
2360
+ itemComponent.notPlaced = false;
2361
+ itemComponent.item.x = itemComponent.$item.x;
2362
+ itemComponent.item.y = itemComponent.$item.y;
2363
+ itemComponent.itemChanged();
2364
+ }
2365
+ else {
2366
+ itemComponent.notPlaced = true;
2367
+ if (!this.$options.disableWarnings) {
2368
+ console.warn('Can\'t be placed in the bounds of the dashboard!/n' +
2369
+ JSON.stringify(itemComponent.item, ['cols', 'rows', 'x', 'y']));
2370
+ }
2371
+ }
2372
+ }
2373
+ /**
2374
+ * @param {?} newItem
2375
+ * @param {?=} startingFrom
2376
+ * @return {?}
2377
+ */
2378
+ getNextPossiblePosition(newItem, startingFrom = {}) {
2379
+ if (newItem.cols === -1) {
2380
+ newItem.cols = this.$options.defaultItemCols;
2381
+ }
2382
+ if (newItem.rows === -1) {
2383
+ newItem.rows = this.$options.defaultItemRows;
2384
+ }
2385
+ this.setGridDimensions();
2386
+ /** @type {?} */
2387
+ let rowsIndex = startingFrom.y || 0;
2388
+ /** @type {?} */
2389
+ let colsIndex;
2390
+ for (; rowsIndex < this.rows; rowsIndex++) {
2391
+ newItem.y = rowsIndex;
2392
+ colsIndex = startingFrom.x || 0;
2393
+ for (; colsIndex < this.columns; colsIndex++) {
2394
+ newItem.x = colsIndex;
2395
+ if (!this.checkCollision(newItem)) {
2396
+ return true;
2397
+ }
2398
+ }
2399
+ }
2400
+ /** @type {?} */
2401
+ const canAddToRows = this.$options.maxRows >= this.rows + newItem.rows;
2402
+ /** @type {?} */
2403
+ const canAddToColumns = this.$options.maxCols >= this.columns + newItem.cols;
2404
+ /** @type {?} */
2405
+ const addToRows = this.rows <= this.columns && canAddToRows;
2406
+ if (!addToRows && canAddToColumns) {
2407
+ newItem.x = this.columns;
2408
+ newItem.y = 0;
2409
+ return true;
2410
+ }
2411
+ else if (canAddToRows) {
2412
+ newItem.y = this.rows;
2413
+ newItem.x = 0;
2414
+ return true;
2415
+ }
2416
+ return false;
2417
+ }
2418
+ /**
2419
+ * @param {?} item
2420
+ * @return {?}
2421
+ */
2422
+ getFirstPossiblePosition(item) {
2423
+ /** @type {?} */
2424
+ const tmpItem = Object.assign({}, item);
2425
+ this.getNextPossiblePosition(tmpItem);
2426
+ return tmpItem;
2427
+ }
2428
+ /**
2429
+ * @param {?} item
2430
+ * @return {?}
2431
+ */
2432
+ getLastPossiblePosition(item) {
2433
+ /** @type {?} */
2434
+ let farthestItem = { y: 0, x: 0 };
2435
+ farthestItem = this.grid.reduce((/**
2436
+ * @param {?} prev
2437
+ * @param {?} curr
2438
+ * @return {?}
2439
+ */
2440
+ (prev, curr) => {
2441
+ /** @type {?} */
2442
+ const currCoords = { y: curr.$item.y + curr.$item.rows - 1, x: curr.$item.x + curr.$item.cols - 1 };
2443
+ if (GridsterUtils.compareItems(prev, currCoords) === 1) {
2444
+ return currCoords;
2445
+ }
2446
+ else {
2447
+ return prev;
2448
+ }
2449
+ }), farthestItem);
2450
+ /** @type {?} */
2451
+ const tmpItem = Object.assign({}, item);
2452
+ this.getNextPossiblePosition(tmpItem, farthestItem);
2453
+ return tmpItem;
2454
+ }
2455
+ /**
2456
+ * @param {?} x
2457
+ * @param {?} roundingMethod
2458
+ * @param {?=} noLimit
2459
+ * @return {?}
2460
+ */
2461
+ pixelsToPositionX(x, roundingMethod, noLimit) {
2462
+ /** @type {?} */
2463
+ const position = roundingMethod(x / this.curColWidth);
2464
+ if (noLimit) {
2465
+ return position;
2466
+ }
2467
+ else {
2468
+ return Math.max(position, 0);
2469
+ }
2470
+ }
2471
+ /**
2472
+ * @param {?} y
2473
+ * @param {?} roundingMethod
2474
+ * @param {?=} noLimit
2475
+ * @return {?}
2476
+ */
2477
+ pixelsToPositionY(y, roundingMethod, noLimit) {
2478
+ /** @type {?} */
2479
+ const position = roundingMethod(y / this.curRowHeight);
2480
+ if (noLimit) {
2481
+ return position;
2482
+ }
2483
+ else {
2484
+ return Math.max(position, 0);
2485
+ }
2486
+ }
2487
+ /**
2488
+ * @param {?} x
2489
+ * @return {?}
2490
+ */
2491
+ positionXToPixels(x) {
2492
+ return x * this.curColWidth;
2493
+ }
2494
+ /**
2495
+ * @param {?} y
2496
+ * @return {?}
2497
+ */
2498
+ positionYToPixels(y) {
2499
+ return y * this.curRowHeight;
2500
+ }
2501
+ }
2502
+ GridsterComponent.decorators = [
2503
+ { type: Component, args: [{
2504
+ selector: 'gridster',
2505
+ template: "<div class=\"gridster-column\" *ngFor=\"let column of gridColumns; let i = index;\"\r\n [ngStyle]=\"gridRenderer.getGridColumnStyle(i)\"></div>\r\n<div class=\"gridster-row\" *ngFor=\"let row of gridRows; let i = index;\"\r\n [ngStyle]=\"gridRenderer.getGridRowStyle(i)\"></div>\r\n<ng-content></ng-content>\r\n<gridster-preview class=\"gridster-preview\"></gridster-preview>\r\n",
2506
+ encapsulation: ViewEncapsulation.None,
2507
+ styles: ["gridster{clear:both;position:relative;box-sizing:border-box;background:grey;width:100%;height:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:block;overflow:auto}gridster.fit{overflow-x:hidden;overflow-y:hidden}gridster.scrollVertical{overflow-x:hidden;overflow-y:auto}gridster.scrollHorizontal{overflow-x:auto;overflow-y:hidden}gridster.fixed{overflow:auto}gridster.mobile{overflow-x:hidden;overflow-y:auto}gridster.mobile gridster-item{position:relative}gridster .gridster-column,gridster .gridster-row{position:absolute;display:none;transition:.3s;box-sizing:border-box}gridster.display-grid .gridster-column,gridster.display-grid .gridster-row{display:block}gridster .gridster-column{border-left:1px solid #ccc;border-right:1px solid #ccc}gridster .gridster-row{border-top:1px solid #ccc;border-bottom:1px solid #ccc}"]
2508
+ }] }
2509
+ ];
2510
+ /** @nocollapse */
2511
+ GridsterComponent.ctorParameters = () => [
2512
+ { type: ElementRef },
2513
+ { type: Renderer2 },
2514
+ { type: ChangeDetectorRef },
2515
+ { type: NgZone }
2516
+ ];
2517
+ GridsterComponent.propDecorators = {
2518
+ options: [{ type: Input }]
2519
+ };
2520
+
2521
+ /**
2522
+ * @fileoverview added by tsickle
2523
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2524
+ */
2525
+ /**
2526
+ * @abstract
2527
+ */
2528
+ class GridsterItemComponentInterface {
2529
+ }
2530
+
2531
+ /**
2532
+ * @fileoverview added by tsickle
2533
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2534
+ */
2535
+ class GridsterSwap {
2536
+ /**
2537
+ * @param {?} gridsterItem
2538
+ */
2539
+ constructor(gridsterItem) {
2540
+ this.gridsterItem = gridsterItem;
2541
+ this.gridster = gridsterItem.gridster;
2542
+ }
2543
+ /**
2544
+ * @return {?}
2545
+ */
2546
+ destroy() {
2547
+ delete this.gridster;
2548
+ delete this.gridsterItem;
2549
+ delete this.swapedItem;
2550
+ }
2551
+ /**
2552
+ * @return {?}
2553
+ */
2554
+ swapItems() {
2555
+ if (this.gridster.$options.swap) {
2556
+ this.checkSwapBack();
2557
+ this.checkSwap(this.gridsterItem);
2558
+ }
2559
+ }
2560
+ /**
2561
+ * @return {?}
2562
+ */
2563
+ checkSwapBack() {
2564
+ if (this.swapedItem) {
2565
+ /** @type {?} */
2566
+ const x = this.swapedItem.$item.x;
2567
+ /** @type {?} */
2568
+ const y = this.swapedItem.$item.y;
2569
+ this.swapedItem.$item.x = this.swapedItem.item.x || 0;
2570
+ this.swapedItem.$item.y = this.swapedItem.item.y || 0;
2571
+ if (this.gridster.checkCollision(this.swapedItem.$item)) {
2572
+ this.swapedItem.$item.x = x;
2573
+ this.swapedItem.$item.y = y;
2574
+ }
2575
+ else {
2576
+ this.swapedItem.setSize();
2577
+ this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
2578
+ this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
2579
+ this.swapedItem = undefined;
2580
+ }
2581
+ }
2582
+ }
2583
+ /**
2584
+ * @return {?}
2585
+ */
2586
+ restoreSwapItem() {
2587
+ if (this.swapedItem) {
2588
+ this.swapedItem.$item.x = this.swapedItem.item.x || 0;
2589
+ this.swapedItem.$item.y = this.swapedItem.item.y || 0;
2590
+ this.swapedItem.setSize();
2591
+ this.swapedItem = undefined;
2592
+ }
2593
+ }
2594
+ /**
2595
+ * @return {?}
2596
+ */
2597
+ setSwapItem() {
2598
+ if (this.swapedItem) {
2599
+ this.swapedItem.checkItemChanges(this.swapedItem.$item, this.swapedItem.item);
2600
+ this.swapedItem = undefined;
2601
+ }
2602
+ }
2603
+ /**
2604
+ * @param {?} pushedBy
2605
+ * @return {?}
2606
+ */
2607
+ checkSwap(pushedBy) {
2608
+ /** @type {?} */
2609
+ const gridsterItemCollision = this.gridster.checkCollision(pushedBy.$item);
2610
+ if (gridsterItemCollision && gridsterItemCollision !== true && gridsterItemCollision.canBeDragged()) {
2611
+ /** @type {?} */
2612
+ const gridsterItemCollide = gridsterItemCollision;
2613
+ /** @type {?} */
2614
+ const copyCollisionX = gridsterItemCollide.$item.x;
2615
+ /** @type {?} */
2616
+ const copyCollisionY = gridsterItemCollide.$item.y;
2617
+ /** @type {?} */
2618
+ const copyX = pushedBy.$item.x;
2619
+ /** @type {?} */
2620
+ const copyY = pushedBy.$item.y;
2621
+ gridsterItemCollide.$item.x = pushedBy.item.x || 0;
2622
+ gridsterItemCollide.$item.y = pushedBy.item.y || 0;
2623
+ pushedBy.$item.x = gridsterItemCollide.item.x || 0;
2624
+ pushedBy.$item.y = gridsterItemCollide.item.y || 0;
2625
+ if (this.gridster.checkCollision(gridsterItemCollide.$item) || this.gridster.checkCollision(pushedBy.$item)) {
2626
+ pushedBy.$item.x = copyX;
2627
+ pushedBy.$item.y = copyY;
2628
+ gridsterItemCollide.$item.x = copyCollisionX;
2629
+ gridsterItemCollide.$item.y = copyCollisionY;
2630
+ }
2631
+ else {
2632
+ gridsterItemCollide.setSize();
2633
+ this.swapedItem = gridsterItemCollide;
2634
+ }
2635
+ }
2636
+ }
2637
+ }
2638
+ GridsterSwap.decorators = [
2639
+ { type: Injectable }
2640
+ ];
2641
+ /** @nocollapse */
2642
+ GridsterSwap.ctorParameters = () => [
2643
+ { type: GridsterItemComponentInterface }
2644
+ ];
2645
+
2646
+ /**
2647
+ * @fileoverview added by tsickle
2648
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2649
+ */
2650
+ /** @type {?} */
2651
+ let scrollSensitivity;
2652
+ /** @type {?} */
2653
+ let scrollSpeed;
2654
+ /** @type {?} */
2655
+ const intervalDuration = 50;
2656
+ /** @type {?} */
2657
+ let gridsterElement;
2658
+ /** @type {?} */
2659
+ let resizeEvent;
2660
+ /** @type {?} */
2661
+ let resizeEventType;
2662
+ /** @type {?} */
2663
+ let intervalE;
2664
+ /** @type {?} */
2665
+ let intervalW;
2666
+ /** @type {?} */
2667
+ let intervalN;
2668
+ /** @type {?} */
2669
+ let intervalS;
2670
+ /**
2671
+ * @param {?} gridster
2672
+ * @param {?} left
2673
+ * @param {?} top
2674
+ * @param {?} width
2675
+ * @param {?} height
2676
+ * @param {?} e
2677
+ * @param {?} lastMouse
2678
+ * @param {?} calculateItemPosition
2679
+ * @param {?=} resize
2680
+ * @param {?=} resizeEventScrollType
2681
+ * @return {?}
2682
+ */
2683
+ function scroll(gridster, left, top, width, height, e, lastMouse, calculateItemPosition, resize, resizeEventScrollType) {
2684
+ scrollSensitivity = gridster.$options.scrollSensitivity;
2685
+ scrollSpeed = gridster.$options.scrollSpeed;
2686
+ gridsterElement = gridster.el;
2687
+ resizeEvent = resize;
2688
+ resizeEventType = resizeEventScrollType;
2689
+ /** @type {?} */
2690
+ const offsetWidth = gridsterElement.offsetWidth;
2691
+ /** @type {?} */
2692
+ const offsetHeight = gridsterElement.offsetHeight;
2693
+ /** @type {?} */
2694
+ const offsetLeft = gridsterElement.scrollLeft;
2695
+ /** @type {?} */
2696
+ const offsetTop = gridsterElement.scrollTop;
2697
+ /** @type {?} */
2698
+ const elemTopOffset = top - offsetTop;
2699
+ /** @type {?} */
2700
+ const elemBottomOffset = offsetHeight + offsetTop - top - height;
2701
+ if (lastMouse.clientY < e.clientY && elemBottomOffset < scrollSensitivity) {
2702
+ cancelN();
2703
+ if ((resizeEvent && resizeEventType && !resizeEventType.s) || intervalS) {
2704
+ return;
2705
+ }
2706
+ intervalS = startVertical(1, calculateItemPosition, lastMouse);
2707
+ }
2708
+ else if (lastMouse.clientY > e.clientY && offsetTop > 0 && elemTopOffset < scrollSensitivity) {
2709
+ cancelS();
2710
+ if ((resizeEvent && resizeEventType && !resizeEventType.n) || intervalN) {
2711
+ return;
2712
+ }
2713
+ intervalN = startVertical(-1, calculateItemPosition, lastMouse);
2714
+ }
2715
+ else if (lastMouse.clientY !== e.clientY) {
2716
+ cancelVertical();
2717
+ }
2718
+ /** @type {?} */
2719
+ const elemRightOffset = offsetLeft + offsetWidth - left - width;
2720
+ /** @type {?} */
2721
+ const elemLeftOffset = left - offsetLeft;
2722
+ if (lastMouse.clientX < e.clientX && elemRightOffset <= scrollSensitivity) {
2723
+ cancelW();
2724
+ if ((resizeEvent && resizeEventType && !resizeEventType.e) || intervalE) {
2725
+ return;
2726
+ }
2727
+ intervalE = startHorizontal(1, calculateItemPosition, lastMouse);
2728
+ }
2729
+ else if (lastMouse.clientX > e.clientX && offsetLeft > 0 && elemLeftOffset < scrollSensitivity) {
2730
+ cancelE();
2731
+ if ((resizeEvent && resizeEventType && !resizeEventType.w) || intervalW) {
2732
+ return;
2733
+ }
2734
+ intervalW = startHorizontal(-1, calculateItemPosition, lastMouse);
2735
+ }
2736
+ else if (lastMouse.clientX !== e.clientX) {
2737
+ cancelHorizontal();
2738
+ }
2739
+ }
2740
+ /**
2741
+ * @param {?} sign
2742
+ * @param {?} calculateItemPosition
2743
+ * @param {?} lastMouse
2744
+ * @return {?}
2745
+ */
2746
+ function startVertical(sign, calculateItemPosition, lastMouse) {
2747
+ /** @type {?} */
2748
+ let clientY = lastMouse.clientY;
2749
+ return setInterval((/**
2750
+ * @return {?}
2751
+ */
2752
+ () => {
2753
+ if (!gridsterElement || sign === -1 && gridsterElement.scrollTop - scrollSpeed < 0) {
2754
+ cancelVertical();
2755
+ }
2756
+ gridsterElement.scrollTop += sign * scrollSpeed;
2757
+ clientY += sign * scrollSpeed;
2758
+ calculateItemPosition({ clientX: lastMouse.clientX, clientY: clientY });
2759
+ }), intervalDuration);
2760
+ }
2761
+ /**
2762
+ * @param {?} sign
2763
+ * @param {?} calculateItemPosition
2764
+ * @param {?} lastMouse
2765
+ * @return {?}
2766
+ */
2767
+ function startHorizontal(sign, calculateItemPosition, lastMouse) {
2768
+ /** @type {?} */
2769
+ let clientX = lastMouse.clientX;
2770
+ return setInterval((/**
2771
+ * @return {?}
2772
+ */
2773
+ () => {
2774
+ if (!gridsterElement || sign === -1 && gridsterElement.scrollLeft - scrollSpeed < 0) {
2775
+ cancelHorizontal();
2776
+ }
2777
+ gridsterElement.scrollLeft += sign * scrollSpeed;
2778
+ clientX += sign * scrollSpeed;
2779
+ calculateItemPosition({ clientX: clientX, clientY: lastMouse.clientY });
2780
+ }), intervalDuration);
2781
+ }
2782
+ /**
2783
+ * @return {?}
2784
+ */
2785
+ function cancelScroll() {
2786
+ cancelHorizontal();
2787
+ cancelVertical();
2788
+ gridsterElement = undefined;
2789
+ }
2790
+ /**
2791
+ * @return {?}
2792
+ */
2793
+ function cancelHorizontal() {
2794
+ cancelE();
2795
+ cancelW();
2796
+ }
2797
+ /**
2798
+ * @return {?}
2799
+ */
2800
+ function cancelVertical() {
2801
+ cancelN();
2802
+ cancelS();
2803
+ }
2804
+ /**
2805
+ * @return {?}
2806
+ */
2807
+ function cancelE() {
2808
+ if (intervalE) {
2809
+ clearInterval(intervalE);
2810
+ intervalE = 0;
2811
+ }
2812
+ }
2813
+ /**
2814
+ * @return {?}
2815
+ */
2816
+ function cancelW() {
2817
+ if (intervalW) {
2818
+ clearInterval(intervalW);
2819
+ intervalW = 0;
2820
+ }
2821
+ }
2822
+ /**
2823
+ * @return {?}
2824
+ */
2825
+ function cancelS() {
2826
+ if (intervalS) {
2827
+ clearInterval(intervalS);
2828
+ intervalS = 0;
2829
+ }
2830
+ }
2831
+ /**
2832
+ * @return {?}
2833
+ */
2834
+ function cancelN() {
2835
+ if (intervalN) {
2836
+ clearInterval(intervalN);
2837
+ intervalN = 0;
2838
+ }
2839
+ }
2840
+
2841
+ /**
2842
+ * @fileoverview added by tsickle
2843
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2844
+ */
2845
+ class GridsterPush {
2846
+ /**
2847
+ * @param {?} gridsterItem
2848
+ */
2849
+ constructor(gridsterItem) {
2850
+ this.pushedItems = [];
2851
+ this.pushedItemsTemp = [];
2852
+ this.pushedItemsTempPath = [];
2853
+ this.pushedItemsPath = [];
2854
+ this.gridsterItem = gridsterItem;
2855
+ this.gridster = gridsterItem.gridster;
2856
+ this.tryPattern = {
2857
+ fromEast: [this.tryWest, this.trySouth, this.tryNorth, this.tryEast],
2858
+ fromWest: [this.tryEast, this.trySouth, this.tryNorth, this.tryWest],
2859
+ fromNorth: [this.trySouth, this.tryEast, this.tryWest, this.tryNorth],
2860
+ fromSouth: [this.tryNorth, this.tryEast, this.tryWest, this.trySouth]
2861
+ };
2862
+ this.fromSouth = 'fromSouth';
2863
+ this.fromNorth = 'fromNorth';
2864
+ this.fromEast = 'fromEast';
2865
+ this.fromWest = 'fromWest';
2866
+ }
2867
+ /**
2868
+ * @return {?}
2869
+ */
2870
+ destroy() {
2871
+ delete this.gridster;
2872
+ delete this.gridsterItem;
2873
+ }
2874
+ /**
2875
+ * @param {?} direction
2876
+ * @param {?=} disable
2877
+ * @return {?}
2878
+ */
2879
+ pushItems(direction, disable) {
2880
+ if (this.gridster.$options.pushItems && !disable) {
2881
+ this.pushedItemsOrder = [];
2882
+ /** @type {?} */
2883
+ const pushed = this.push(this.gridsterItem, direction);
2884
+ if (!pushed) {
2885
+ this.restoreTempItems();
2886
+ }
2887
+ this.pushedItemsOrder = [];
2888
+ this.pushedItemsTemp = [];
2889
+ this.pushedItemsTempPath = [];
2890
+ return pushed;
2891
+ }
2892
+ else {
2893
+ return false;
2894
+ }
2895
+ }
2896
+ /**
2897
+ * @return {?}
2898
+ */
2899
+ restoreTempItems() {
2900
+ /** @type {?} */
2901
+ let i = this.pushedItemsTemp.length - 1;
2902
+ for (; i > -1; i--) {
2903
+ this.removeFromTempPushed(this.pushedItemsTemp[i]);
2904
+ }
2905
+ }
2906
+ /**
2907
+ * @return {?}
2908
+ */
2909
+ restoreItems() {
2910
+ /** @type {?} */
2911
+ let i = 0;
2912
+ /** @type {?} */
2913
+ const l = this.pushedItems.length;
2914
+ /** @type {?} */
2915
+ let pushedItem;
2916
+ for (; i < l; i++) {
2917
+ pushedItem = this.pushedItems[i];
2918
+ pushedItem.$item.x = pushedItem.item.x || 0;
2919
+ pushedItem.$item.y = pushedItem.item.y || 0;
2920
+ pushedItem.setSize();
2921
+ }
2922
+ this.pushedItems = [];
2923
+ this.pushedItemsPath = [];
2924
+ }
2925
+ /**
2926
+ * @return {?}
2927
+ */
2928
+ setPushedItems() {
2929
+ /** @type {?} */
2930
+ let i = 0;
2931
+ /** @type {?} */
2932
+ const l = this.pushedItems.length;
2933
+ /** @type {?} */
2934
+ let pushedItem;
2935
+ for (; i < l; i++) {
2936
+ pushedItem = this.pushedItems[i];
2937
+ pushedItem.checkItemChanges(pushedItem.$item, pushedItem.item);
2938
+ }
2939
+ this.pushedItems = [];
2940
+ this.pushedItemsPath = [];
2941
+ }
2942
+ /**
2943
+ * @return {?}
2944
+ */
2945
+ checkPushBack() {
2946
+ /** @type {?} */
2947
+ let i = this.pushedItems.length - 1;
2948
+ /** @type {?} */
2949
+ let change = false;
2950
+ for (; i > -1; i--) {
2951
+ if (this.checkPushedItem(this.pushedItems[i], i)) {
2952
+ change = true;
2953
+ }
2954
+ }
2955
+ if (change) {
2956
+ this.checkPushBack();
2957
+ }
2958
+ }
2959
+ /**
2960
+ * @private
2961
+ * @param {?} gridsterItem
2962
+ * @param {?} direction
2963
+ * @return {?}
2964
+ */
2965
+ push(gridsterItem, direction) {
2966
+ if (this.gridster.checkGridCollision(gridsterItem.$item)) {
2967
+ return false;
2968
+ }
2969
+ if (direction === '') {
2970
+ return false;
2971
+ }
2972
+ /** @type {?} */
2973
+ const a = this.gridster.findItemsWithItem(gridsterItem.$item);
2974
+ /** @type {?} */
2975
+ let i = a.length - 1;
2976
+ /** @type {?} */
2977
+ let itemCollision;
2978
+ /** @type {?} */
2979
+ let makePush = true;
2980
+ /** @type {?} */
2981
+ const b = [];
2982
+ for (; i > -1; i--) {
2983
+ itemCollision = a[i];
2984
+ if (itemCollision === this.gridsterItem) {
2985
+ makePush = false;
2986
+ break;
2987
+ }
2988
+ if (!itemCollision.canBeDragged()) {
2989
+ makePush = false;
2990
+ break;
2991
+ }
2992
+ /** @type {?} */
2993
+ const compare = this.pushedItemsTemp.find((/**
2994
+ * @param {?} el
2995
+ * @return {?}
2996
+ */
2997
+ (el) => {
2998
+ return el.$item.x === itemCollision.$item.x && el.$item.y === itemCollision.$item.y;
2999
+ }));
3000
+ if (compare) {
3001
+ makePush = false;
3002
+ break;
3003
+ }
3004
+ if (this.tryPattern[direction][0].call(this, itemCollision, gridsterItem)) {
3005
+ this.pushedItemsOrder.push(itemCollision);
3006
+ b.push(itemCollision);
3007
+ }
3008
+ else if (this.tryPattern[direction][1].call(this, itemCollision, gridsterItem)) {
3009
+ this.pushedItemsOrder.push(itemCollision);
3010
+ b.push(itemCollision);
3011
+ }
3012
+ else if (this.tryPattern[direction][2].call(this, itemCollision, gridsterItem)) {
3013
+ this.pushedItemsOrder.push(itemCollision);
3014
+ b.push(itemCollision);
3015
+ }
3016
+ else if (this.tryPattern[direction][3].call(this, itemCollision, gridsterItem)) {
3017
+ this.pushedItemsOrder.push(itemCollision);
3018
+ b.push(itemCollision);
3019
+ }
3020
+ else {
3021
+ makePush = false;
3022
+ break;
3023
+ }
3024
+ }
3025
+ if (!makePush) {
3026
+ i = this.pushedItemsOrder.lastIndexOf(b[0]);
3027
+ if (i > -1) {
3028
+ /** @type {?} */
3029
+ let j = this.pushedItemsOrder.length - 1;
3030
+ for (; j >= i; j--) {
3031
+ itemCollision = this.pushedItemsOrder[j];
3032
+ this.pushedItemsOrder.pop();
3033
+ this.removeFromTempPushed(itemCollision);
3034
+ this.removeFromPushedItem(itemCollision);
3035
+ }
3036
+ }
3037
+ }
3038
+ return makePush;
3039
+ }
3040
+ /**
3041
+ * @private
3042
+ * @param {?} gridsterItemCollide
3043
+ * @param {?} gridsterItem
3044
+ * @return {?}
3045
+ */
3046
+ trySouth(gridsterItemCollide, gridsterItem) {
3047
+ if (!this.gridster.$options.pushDirections.south) {
3048
+ return false;
3049
+ }
3050
+ this.addToTempPushed(gridsterItemCollide);
3051
+ gridsterItemCollide.$item.y = gridsterItem.$item.y + gridsterItem.$item.rows;
3052
+ if (this.push(gridsterItemCollide, this.fromNorth)) {
3053
+ gridsterItemCollide.setSize();
3054
+ this.addToPushed(gridsterItemCollide);
3055
+ return true;
3056
+ }
3057
+ else {
3058
+ this.removeFromTempPushed(gridsterItemCollide);
3059
+ }
3060
+ return false;
3061
+ }
3062
+ /**
3063
+ * @private
3064
+ * @param {?} gridsterItemCollide
3065
+ * @param {?} gridsterItem
3066
+ * @return {?}
3067
+ */
3068
+ tryNorth(gridsterItemCollide, gridsterItem) {
3069
+ if (!this.gridster.$options.pushDirections.north) {
3070
+ return false;
3071
+ }
3072
+ this.addToTempPushed(gridsterItemCollide);
3073
+ gridsterItemCollide.$item.y = gridsterItem.$item.y - gridsterItemCollide.$item.rows;
3074
+ if (this.push(gridsterItemCollide, this.fromSouth)) {
3075
+ gridsterItemCollide.setSize();
3076
+ this.addToPushed(gridsterItemCollide);
3077
+ return true;
3078
+ }
3079
+ else {
3080
+ this.removeFromTempPushed(gridsterItemCollide);
3081
+ }
3082
+ return false;
3083
+ }
3084
+ /**
3085
+ * @private
3086
+ * @param {?} gridsterItemCollide
3087
+ * @param {?} gridsterItem
3088
+ * @return {?}
3089
+ */
3090
+ tryEast(gridsterItemCollide, gridsterItem) {
3091
+ if (!this.gridster.$options.pushDirections.east) {
3092
+ return false;
3093
+ }
3094
+ this.addToTempPushed(gridsterItemCollide);
3095
+ gridsterItemCollide.$item.x = gridsterItem.$item.x + gridsterItem.$item.cols;
3096
+ if (this.push(gridsterItemCollide, this.fromWest)) {
3097
+ gridsterItemCollide.setSize();
3098
+ this.addToPushed(gridsterItemCollide);
3099
+ return true;
3100
+ }
3101
+ else {
3102
+ this.removeFromTempPushed(gridsterItemCollide);
3103
+ }
3104
+ return false;
3105
+ }
3106
+ /**
3107
+ * @private
3108
+ * @param {?} gridsterItemCollide
3109
+ * @param {?} gridsterItem
3110
+ * @return {?}
3111
+ */
3112
+ tryWest(gridsterItemCollide, gridsterItem) {
3113
+ if (!this.gridster.$options.pushDirections.west) {
3114
+ return false;
3115
+ }
3116
+ this.addToTempPushed(gridsterItemCollide);
3117
+ gridsterItemCollide.$item.x = gridsterItem.$item.x - gridsterItemCollide.$item.cols;
3118
+ if (this.push(gridsterItemCollide, this.fromEast)) {
3119
+ gridsterItemCollide.setSize();
3120
+ this.addToPushed(gridsterItemCollide);
3121
+ return true;
3122
+ }
3123
+ else {
3124
+ this.removeFromTempPushed(gridsterItemCollide);
3125
+ }
3126
+ return false;
3127
+ }
3128
+ /**
3129
+ * @private
3130
+ * @param {?} gridsterItem
3131
+ * @return {?}
3132
+ */
3133
+ addToTempPushed(gridsterItem) {
3134
+ /** @type {?} */
3135
+ let i = this.pushedItemsTemp.indexOf(gridsterItem);
3136
+ if (i === -1) {
3137
+ i = this.pushedItemsTemp.push(gridsterItem) - 1;
3138
+ this.pushedItemsTempPath[i] = [];
3139
+ }
3140
+ this.pushedItemsTempPath[i].push({ x: gridsterItem.$item.x, y: gridsterItem.$item.y });
3141
+ }
3142
+ /**
3143
+ * @private
3144
+ * @param {?} gridsterItem
3145
+ * @return {?}
3146
+ */
3147
+ removeFromTempPushed(gridsterItem) {
3148
+ /** @type {?} */
3149
+ const i = this.pushedItemsTemp.indexOf(gridsterItem);
3150
+ /** @type {?} */
3151
+ const tempPosition = this.pushedItemsTempPath[i].pop();
3152
+ if (!tempPosition) {
3153
+ return;
3154
+ }
3155
+ gridsterItem.$item.x = tempPosition.x;
3156
+ gridsterItem.$item.y = tempPosition.y;
3157
+ gridsterItem.setSize();
3158
+ if (!this.pushedItemsTempPath[i].length) {
3159
+ this.pushedItemsTemp.splice(i, 1);
3160
+ this.pushedItemsTempPath.splice(i, 1);
3161
+ }
3162
+ }
3163
+ /**
3164
+ * @private
3165
+ * @param {?} gridsterItem
3166
+ * @return {?}
3167
+ */
3168
+ addToPushed(gridsterItem) {
3169
+ if (this.pushedItems.indexOf(gridsterItem) < 0) {
3170
+ this.pushedItems.push(gridsterItem);
3171
+ this.pushedItemsPath.push([{ x: gridsterItem.item.x || 0, y: gridsterItem.item.y || 0 },
3172
+ { x: gridsterItem.$item.x, y: gridsterItem.$item.y }]);
3173
+ }
3174
+ else {
3175
+ /** @type {?} */
3176
+ const i = this.pushedItems.indexOf(gridsterItem);
3177
+ this.pushedItemsPath[i].push({ x: gridsterItem.$item.x, y: gridsterItem.$item.y });
3178
+ }
3179
+ }
3180
+ /**
3181
+ * @private
3182
+ * @param {?} i
3183
+ * @return {?}
3184
+ */
3185
+ removeFromPushed(i) {
3186
+ if (i > -1) {
3187
+ this.pushedItems.splice(i, 1);
3188
+ this.pushedItemsPath.splice(i, 1);
3189
+ }
3190
+ }
3191
+ /**
3192
+ * @private
3193
+ * @param {?} gridsterItem
3194
+ * @return {?}
3195
+ */
3196
+ removeFromPushedItem(gridsterItem) {
3197
+ /** @type {?} */
3198
+ const i = this.pushedItems.indexOf(gridsterItem);
3199
+ if (i > -1) {
3200
+ this.pushedItemsPath[i].pop();
3201
+ if (!this.pushedItemsPath.length) {
3202
+ this.pushedItems.splice(i, 1);
3203
+ this.pushedItemsPath.splice(i, 1);
3204
+ }
3205
+ }
3206
+ }
3207
+ /**
3208
+ * @private
3209
+ * @param {?} pushedItem
3210
+ * @param {?} i
3211
+ * @return {?}
3212
+ */
3213
+ checkPushedItem(pushedItem, i) {
3214
+ /** @type {?} */
3215
+ const path = this.pushedItemsPath[i];
3216
+ /** @type {?} */
3217
+ let j = path.length - 2;
3218
+ /** @type {?} */
3219
+ let lastPosition;
3220
+ /** @type {?} */
3221
+ let x;
3222
+ /** @type {?} */
3223
+ let y;
3224
+ /** @type {?} */
3225
+ let change = false;
3226
+ for (; j > -1; j--) {
3227
+ lastPosition = path[j];
3228
+ x = pushedItem.$item.x;
3229
+ y = pushedItem.$item.y;
3230
+ pushedItem.$item.x = lastPosition.x;
3231
+ pushedItem.$item.y = lastPosition.y;
3232
+ if (!this.gridster.findItemWithItem(pushedItem.$item)) {
3233
+ pushedItem.setSize();
3234
+ path.splice(j + 1, path.length - j - 1);
3235
+ change = true;
3236
+ }
3237
+ else {
3238
+ pushedItem.$item.x = x;
3239
+ pushedItem.$item.y = y;
3240
+ }
3241
+ }
3242
+ if (path.length < 2) {
3243
+ this.removeFromPushed(i);
3244
+ }
3245
+ return change;
3246
+ }
3247
+ }
3248
+ GridsterPush.decorators = [
3249
+ { type: Injectable }
3250
+ ];
3251
+ /** @nocollapse */
3252
+ GridsterPush.ctorParameters = () => [
3253
+ { type: GridsterItemComponentInterface }
3254
+ ];
3255
+
3256
+ /**
3257
+ * @fileoverview added by tsickle
3258
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3259
+ */
3260
+ class GridsterDraggable {
3261
+ /**
3262
+ * @param {?} gridsterItem
3263
+ * @param {?} gridster
3264
+ * @param {?} zone
3265
+ */
3266
+ constructor(gridsterItem, gridster, zone) {
3267
+ this.zone = zone;
3268
+ this.collision = false;
3269
+ this.gridsterItem = gridsterItem;
3270
+ this.gridster = gridster;
3271
+ this.lastMouse = {
3272
+ clientX: 0,
3273
+ clientY: 0
3274
+ };
3275
+ this.path = [];
3276
+ }
3277
+ /**
3278
+ * @return {?}
3279
+ */
3280
+ destroy() {
3281
+ if (this.gridster.previewStyle) {
3282
+ this.gridster.previewStyle(true);
3283
+ }
3284
+ delete this.gridsterItem;
3285
+ delete this.gridster;
3286
+ delete this.collision;
3287
+ if (this.mousedown) {
3288
+ this.mousedown();
3289
+ this.touchstart();
3290
+ }
3291
+ }
3292
+ /**
3293
+ * @param {?} e
3294
+ * @return {?}
3295
+ */
3296
+ dragStart(e) {
3297
+ switch (e.which) {
3298
+ case 1:
3299
+ // left mouse button
3300
+ break;
3301
+ case 2:
3302
+ case 3:
3303
+ // right or middle mouse button
3304
+ return;
3305
+ }
3306
+ if (this.gridster.options.draggable && this.gridster.options.draggable.start) {
3307
+ this.gridster.options.draggable.start(this.gridsterItem.item, this.gridsterItem, e);
3308
+ }
3309
+ e.stopPropagation();
3310
+ e.preventDefault();
3311
+ this.dragFunction = this.dragMove.bind(this);
3312
+ this.dragStopFunction = this.dragStop.bind(this);
3313
+ this.zone.runOutsideAngular((/**
3314
+ * @return {?}
3315
+ */
3316
+ () => {
3317
+ this.mousemove = this.gridsterItem.renderer.listen('document', 'mousemove', this.dragFunction);
3318
+ this.touchmove = this.gridster.renderer.listen(this.gridster.el, 'touchmove', this.dragFunction);
3319
+ }));
3320
+ this.mouseup = this.gridsterItem.renderer.listen('document', 'mouseup', this.dragStopFunction);
3321
+ this.mouseleave = this.gridsterItem.renderer.listen('document', 'mouseleave', this.dragStopFunction);
3322
+ this.cancelOnBlur = this.gridsterItem.renderer.listen('window', 'blur', this.dragStopFunction);
3323
+ this.touchend = this.gridsterItem.renderer.listen('document', 'touchend', this.dragStopFunction);
3324
+ this.touchcancel = this.gridsterItem.renderer.listen('document', 'touchcancel', this.dragStopFunction);
3325
+ this.gridsterItem.renderer.addClass(this.gridsterItem.el, 'gridster-item-moving');
3326
+ this.margin = this.gridster.$options.margin;
3327
+ this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
3328
+ this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
3329
+ this.left = this.gridsterItem.left - this.margin;
3330
+ this.top = this.gridsterItem.top - this.margin;
3331
+ this.width = this.gridsterItem.width;
3332
+ this.height = this.gridsterItem.height;
3333
+ this.diffLeft = e.clientX + this.offsetLeft - this.margin - this.left;
3334
+ this.diffTop = e.clientY + this.offsetTop - this.margin - this.top;
3335
+ this.gridster.movingItem = this.gridsterItem.$item;
3336
+ this.gridster.previewStyle(true);
3337
+ this.push = new GridsterPush(this.gridsterItem);
3338
+ this.swap = new GridsterSwap(this.gridsterItem);
3339
+ this.gridster.dragInProgress = true;
3340
+ this.gridster.updateGrid();
3341
+ this.path.push({ x: this.gridsterItem.item.x || 0, y: this.gridsterItem.item.y || 0 });
3342
+ }
3343
+ /**
3344
+ * @param {?} e
3345
+ * @return {?}
3346
+ */
3347
+ dragMove(e) {
3348
+ e.stopPropagation();
3349
+ e.preventDefault();
3350
+ GridsterUtils.checkTouchEvent(e);
3351
+ this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
3352
+ this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
3353
+ scroll(this.gridster, this.left, this.top, this.width, this.height, e, this.lastMouse, this.calculateItemPositionFromMousePosition.bind(this));
3354
+ this.calculateItemPositionFromMousePosition(e);
3355
+ }
3356
+ /**
3357
+ * @param {?} e
3358
+ * @return {?}
3359
+ */
3360
+ calculateItemPositionFromMousePosition(e) {
3361
+ this.left = e.clientX + this.offsetLeft - this.diffLeft;
3362
+ this.top = e.clientY + this.offsetTop - this.diffTop;
3363
+ this.calculateItemPosition();
3364
+ this.lastMouse.clientX = e.clientX;
3365
+ this.lastMouse.clientY = e.clientY;
3366
+ this.zone.run((/**
3367
+ * @return {?}
3368
+ */
3369
+ () => {
3370
+ this.gridster.updateGrid();
3371
+ }));
3372
+ }
3373
+ /**
3374
+ * @param {?} e
3375
+ * @return {?}
3376
+ */
3377
+ dragStop(e) {
3378
+ e.stopPropagation();
3379
+ e.preventDefault();
3380
+ cancelScroll();
3381
+ this.cancelOnBlur();
3382
+ this.mousemove();
3383
+ this.mouseup();
3384
+ this.mouseleave();
3385
+ this.touchmove();
3386
+ this.touchend();
3387
+ this.touchcancel();
3388
+ this.gridsterItem.renderer.removeClass(this.gridsterItem.el, 'gridster-item-moving');
3389
+ this.gridster.dragInProgress = false;
3390
+ this.gridster.updateGrid();
3391
+ this.path = [];
3392
+ if (this.gridster.options.draggable && this.gridster.options.draggable.stop) {
3393
+ Promise.resolve(this.gridster.options.draggable.stop(this.gridsterItem.item, this.gridsterItem, e))
3394
+ .then(this.makeDrag.bind(this), this.cancelDrag.bind(this));
3395
+ }
3396
+ else {
3397
+ this.makeDrag();
3398
+ }
3399
+ setTimeout((/**
3400
+ * @return {?}
3401
+ */
3402
+ () => {
3403
+ if (this.gridster) {
3404
+ this.gridster.movingItem = null;
3405
+ this.gridster.previewStyle(true);
3406
+ }
3407
+ }));
3408
+ }
3409
+ /**
3410
+ * @return {?}
3411
+ */
3412
+ cancelDrag() {
3413
+ this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
3414
+ this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
3415
+ this.gridsterItem.setSize();
3416
+ if (this.push) {
3417
+ this.push.restoreItems();
3418
+ }
3419
+ if (this.swap) {
3420
+ this.swap.restoreSwapItem();
3421
+ }
3422
+ if (this.push) {
3423
+ this.push.destroy();
3424
+ delete this.push;
3425
+ }
3426
+ if (this.swap) {
3427
+ this.swap.destroy();
3428
+ delete this.swap;
3429
+ }
3430
+ }
3431
+ /**
3432
+ * @return {?}
3433
+ */
3434
+ makeDrag() {
3435
+ if (this.gridster.$options.draggable.dropOverItems && this.gridster.options.draggable
3436
+ && this.gridster.options.draggable.dropOverItemsCallback
3437
+ && this.collision && this.collision !== true && this.collision.$item) {
3438
+ this.gridster.options.draggable.dropOverItemsCallback(this.gridsterItem.item, this.collision.item, this.gridster);
3439
+ }
3440
+ this.collision = false;
3441
+ this.gridsterItem.setSize();
3442
+ this.gridsterItem.checkItemChanges(this.gridsterItem.$item, this.gridsterItem.item);
3443
+ if (this.push) {
3444
+ this.push.setPushedItems();
3445
+ }
3446
+ if (this.swap) {
3447
+ this.swap.setSwapItem();
3448
+ }
3449
+ if (this.push) {
3450
+ this.push.destroy();
3451
+ delete this.push;
3452
+ }
3453
+ if (this.swap) {
3454
+ this.swap.destroy();
3455
+ delete this.swap;
3456
+ }
3457
+ }
3458
+ /**
3459
+ * @return {?}
3460
+ */
3461
+ checkforavailableSpaceintheArea() {
3462
+ /** @type {?} */
3463
+ let itemRowsbackup = this.gridsterItem.$item.rows;
3464
+ /** @type {?} */
3465
+ let itemColsbackup = this.gridsterItem.$item.cols;
3466
+ this.gridsterItem.$item.x = this.positionX;
3467
+ this.gridsterItem.$item.y = this.positionY;
3468
+ /**
3469
+ * isCollide = 2 - no collision
3470
+ * @type {?}
3471
+ */
3472
+ var isCollide = 1;
3473
+ /** To iterate over the width of the gridster iTem and to check for collision */
3474
+ do {
3475
+ this.gridsterItem.$item.rows = itemRowsbackup;
3476
+ /** To iterate over the height of the gridster Item and check for collision */
3477
+ for (let rowcount = this.gridsterItem.$item.rows; rowcount >= 15; rowcount--) {
3478
+ if (!this.gridster.checkCollision(this.gridsterItem.$item)) {
3479
+ isCollide = 2;
3480
+ break;
3481
+ }
3482
+ else { /** has collision - check with x-1 position and*/
3483
+ /**
3484
+ * has collision - check with x-1 position and
3485
+ * @type {?}
3486
+ */
3487
+ let rowbkup = this.gridsterItem.$item.x;
3488
+ /** @type {?} */
3489
+ let lastPossiblePositionX = this.gridsterItem.$item.x;
3490
+ do {
3491
+ this.gridsterItem.$item.x = this.gridsterItem.$item.x - 1;
3492
+ if (!this.gridster.checkCollision(this.gridsterItem.$item)) {
3493
+ lastPossiblePositionX = this.gridsterItem.$item.x;
3494
+ }
3495
+ else {
3496
+ this.gridsterItem.$item.x = lastPossiblePositionX;
3497
+ /** @type {?} */
3498
+ let originalCols = this.gridsterItem.$item.cols;
3499
+ /** @type {?} */
3500
+ let lastPossibleCols = this.gridsterItem.$item.cols;
3501
+ do {
3502
+ this.gridsterItem.$item.cols = this.gridsterItem.$item.cols + 1;
3503
+ if (this.gridster.checkCollision(this.gridsterItem.$item)) {
3504
+ this.gridsterItem.$item.cols = lastPossibleCols;
3505
+ break;
3506
+ }
3507
+ else {
3508
+ lastPossibleCols = this.gridsterItem.$item.cols;
3509
+ }
3510
+ } while (this.gridsterItem.$item.cols - originalCols < 15);
3511
+ break;
3512
+ }
3513
+ } while (this.gridsterItem.$item.x > 0);
3514
+ if (this.gridster.checkCollision(this.gridsterItem.$item)) {
3515
+ this.gridsterItem.$item.rows = this.gridsterItem.$item.rows - 1;
3516
+ this.gridsterItem.$item.x = rowbkup;
3517
+ }
3518
+ else {
3519
+ isCollide = 2;
3520
+ break;
3521
+ }
3522
+ }
3523
+ }
3524
+ if (isCollide == 2) {
3525
+ break;
3526
+ }
3527
+ this.gridsterItem.$item.cols = this.gridsterItem.$item.cols - 1;
3528
+ } while (this.gridsterItem.$item.cols >= 15);
3529
+ // while (this.gridsterItem.$item.rows>=15 || this.gridsterItem.$item.cols>=15);
3530
+ if (isCollide == 1) {
3531
+ this.gridsterItem.$item.x = this.positionXBackup;
3532
+ this.gridsterItem.$item.y = this.positionYBackup;
3533
+ this.gridsterItem.$item.cols = itemColsbackup;
3534
+ this.gridsterItem.$item.rows = itemRowsbackup;
3535
+ }
3536
+ return this.gridsterItem.$item;
3537
+ }
3538
+ /**
3539
+ * @return {?}
3540
+ */
3541
+ calculateItemPosition() {
3542
+ this.gridster.movingItem = this.gridsterItem.$item;
3543
+ this.positionX = this.gridster.pixelsToPositionX(this.left, Math.round);
3544
+ this.positionY = this.gridster.pixelsToPositionY(this.top, Math.round);
3545
+ this.positionXBackup = this.gridsterItem.$item.x;
3546
+ this.positionYBackup = this.gridsterItem.$item.y;
3547
+ this.gridsterItem.$item.x = this.positionX;
3548
+ if (this.gridster.checkGridCollision(this.gridsterItem.$item)) {
3549
+ this.gridsterItem.$item.x = this.positionXBackup;
3550
+ }
3551
+ this.gridsterItem.$item.y = this.positionY;
3552
+ if (this.gridster.checkGridCollision(this.gridsterItem.$item)) {
3553
+ this.gridsterItem.$item.y = this.positionYBackup;
3554
+ }
3555
+ if (this.gridster.options.autoResizeonDrag) {
3556
+ this.gridsterItem.$item = this.checkforavailableSpaceintheArea();
3557
+ this.gridsterItem.setSize();
3558
+ }
3559
+ this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, this.left, this.top);
3560
+ if (this.positionXBackup !== this.gridsterItem.$item.x || this.positionYBackup !== this.gridsterItem.$item.y) {
3561
+ /** @type {?} */
3562
+ const lastPosition = this.path[this.path.length - 1];
3563
+ /** @type {?} */
3564
+ let direction = '';
3565
+ if (lastPosition.x < this.gridsterItem.$item.x) {
3566
+ direction = this.push.fromWest;
3567
+ }
3568
+ else if (lastPosition.x > this.gridsterItem.$item.x) {
3569
+ direction = this.push.fromEast;
3570
+ }
3571
+ else if (lastPosition.y < this.gridsterItem.$item.y) {
3572
+ direction = this.push.fromNorth;
3573
+ }
3574
+ else if (lastPosition.y > this.gridsterItem.$item.y) {
3575
+ direction = this.push.fromSouth;
3576
+ }
3577
+ this.push.pushItems(direction, this.gridster.$options.disablePushOnDrag);
3578
+ this.swap.swapItems();
3579
+ this.collision = this.gridster.checkCollision(this.gridsterItem.$item);
3580
+ if (this.collision) {
3581
+ this.gridsterItem.$item.x = this.positionXBackup;
3582
+ this.gridsterItem.$item.y = this.positionYBackup;
3583
+ if (this.gridster.$options.draggable.dropOverItems && this.collision !== true && this.collision.$item) {
3584
+ this.gridster.movingItem = null;
3585
+ }
3586
+ }
3587
+ else {
3588
+ this.path.push({ x: this.gridsterItem.$item.x, y: this.gridsterItem.$item.y });
3589
+ }
3590
+ this.push.checkPushBack();
3591
+ }
3592
+ this.gridster.previewStyle(true);
3593
+ }
3594
+ /**
3595
+ * @return {?}
3596
+ */
3597
+ toggle() {
3598
+ /** @type {?} */
3599
+ const enableDrag = this.gridsterItem.canBeDragged();
3600
+ if (!this.enabled && enableDrag) {
3601
+ this.enabled = !this.enabled;
3602
+ this.dragStartFunction = this.dragStartDelay.bind(this);
3603
+ this.mousedown = this.gridsterItem.renderer.listen(this.gridsterItem.el, 'mousedown', this.dragStartFunction);
3604
+ this.touchstart = this.gridsterItem.renderer.listen(this.gridsterItem.el, 'touchstart', this.dragStartFunction);
3605
+ }
3606
+ else if (this.enabled && !enableDrag) {
3607
+ this.enabled = !this.enabled;
3608
+ this.mousedown();
3609
+ this.touchstart();
3610
+ }
3611
+ }
3612
+ /**
3613
+ * @param {?} e
3614
+ * @return {?}
3615
+ */
3616
+ dragStartDelay(e) {
3617
+ if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('gridster-item-resizable-handler') > -1) {
3618
+ return;
3619
+ }
3620
+ if (GridsterUtils.checkContentClassForEvent(this.gridster, e)) {
3621
+ return;
3622
+ }
3623
+ GridsterUtils.checkTouchEvent(e);
3624
+ if (!this.gridster.$options.draggable.delayStart) {
3625
+ this.dragStart(e);
3626
+ return;
3627
+ }
3628
+ /** @type {?} */
3629
+ const timeout = setTimeout((/**
3630
+ * @return {?}
3631
+ */
3632
+ () => {
3633
+ this.dragStart(e);
3634
+ cancelDrag();
3635
+ }), this.gridster.$options.draggable.delayStart);
3636
+ /** @type {?} */
3637
+ const cancelMouse = this.gridsterItem.renderer.listen('document', 'mouseup', cancelDrag);
3638
+ /** @type {?} */
3639
+ const cancelMouseLeave = this.gridsterItem.renderer.listen('document', 'mouseleave', cancelDrag);
3640
+ /** @type {?} */
3641
+ const cancelOnBlur = this.gridsterItem.renderer.listen('window', 'blur', cancelDrag);
3642
+ /** @type {?} */
3643
+ const cancelTouchMove = this.gridsterItem.renderer.listen('document', 'touchmove', cancelMove);
3644
+ /** @type {?} */
3645
+ const cancelTouchEnd = this.gridsterItem.renderer.listen('document', 'touchend', cancelDrag);
3646
+ /** @type {?} */
3647
+ const cancelTouchCancel = this.gridsterItem.renderer.listen('document', 'touchcancel', cancelDrag);
3648
+ /**
3649
+ * @param {?} eventMove
3650
+ * @return {?}
3651
+ */
3652
+ function cancelMove(eventMove) {
3653
+ GridsterUtils.checkTouchEvent(eventMove);
3654
+ if (Math.abs(eventMove.clientX - e.clientX) > 9 || Math.abs(eventMove.clientY - e.clientY) > 9) {
3655
+ cancelDrag();
3656
+ }
3657
+ }
3658
+ /**
3659
+ * @return {?}
3660
+ */
3661
+ function cancelDrag() {
3662
+ clearTimeout(timeout);
3663
+ cancelOnBlur();
3664
+ cancelMouse();
3665
+ cancelMouseLeave();
3666
+ cancelTouchMove();
3667
+ cancelTouchEnd();
3668
+ cancelTouchCancel();
3669
+ }
3670
+ }
3671
+ }
3672
+ GridsterDraggable.decorators = [
3673
+ { type: Injectable }
3674
+ ];
3675
+ /** @nocollapse */
3676
+ GridsterDraggable.ctorParameters = () => [
3677
+ { type: GridsterItemComponentInterface },
3678
+ { type: GridsterComponentInterface },
3679
+ { type: NgZone }
3680
+ ];
3681
+
3682
+ /**
3683
+ * @fileoverview added by tsickle
3684
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3685
+ */
3686
+ class GridsterPushResize {
3687
+ /**
3688
+ * @param {?} gridsterItem
3689
+ */
3690
+ constructor(gridsterItem) {
3691
+ this.pushedItems = [];
3692
+ this.pushedItemsPath = [];
3693
+ this.gridsterItem = gridsterItem;
3694
+ this.gridster = gridsterItem.gridster;
3695
+ this.tryPattern = {
3696
+ fromEast: this.tryWest,
3697
+ fromWest: this.tryEast,
3698
+ fromNorth: this.trySouth,
3699
+ fromSouth: this.tryNorth
3700
+ };
3701
+ this.fromSouth = 'fromSouth';
3702
+ this.fromNorth = 'fromNorth';
3703
+ this.fromEast = 'fromEast';
3704
+ this.fromWest = 'fromWest';
3705
+ }
3706
+ /**
3707
+ * @return {?}
3708
+ */
3709
+ destroy() {
3710
+ delete this.gridster;
3711
+ delete this.gridsterItem;
3712
+ }
3713
+ /**
3714
+ * @param {?} direction
3715
+ * @return {?}
3716
+ */
3717
+ pushItems(direction) {
3718
+ if (this.gridster.$options.pushResizeItems) {
3719
+ return this.push(this.gridsterItem, direction);
3720
+ }
3721
+ else {
3722
+ return false;
3723
+ }
3724
+ }
3725
+ /**
3726
+ * @return {?}
3727
+ */
3728
+ restoreItems() {
3729
+ /** @type {?} */
3730
+ let i = 0;
3731
+ /** @type {?} */
3732
+ const l = this.pushedItems.length;
3733
+ /** @type {?} */
3734
+ let pushedItem;
3735
+ for (; i < l; i++) {
3736
+ pushedItem = this.pushedItems[i];
3737
+ pushedItem.$item.x = pushedItem.item.x || 0;
3738
+ pushedItem.$item.y = pushedItem.item.y || 0;
3739
+ pushedItem.$item.cols = pushedItem.item.cols || 1;
3740
+ pushedItem.$item.row = pushedItem.item.row || 1;
3741
+ pushedItem.setSize();
3742
+ }
3743
+ this.pushedItems = [];
3744
+ this.pushedItemsPath = [];
3745
+ }
3746
+ /**
3747
+ * @return {?}
3748
+ */
3749
+ setPushedItems() {
3750
+ /** @type {?} */
3751
+ let i = 0;
3752
+ /** @type {?} */
3753
+ const l = this.pushedItems.length;
3754
+ /** @type {?} */
3755
+ let pushedItem;
3756
+ for (; i < l; i++) {
3757
+ pushedItem = this.pushedItems[i];
3758
+ pushedItem.checkItemChanges(pushedItem.$item, pushedItem.item);
3759
+ }
3760
+ this.pushedItems = [];
3761
+ this.pushedItemsPath = [];
3762
+ }
3763
+ /**
3764
+ * @return {?}
3765
+ */
3766
+ checkPushBack() {
3767
+ /** @type {?} */
3768
+ let i = this.pushedItems.length - 1;
3769
+ /** @type {?} */
3770
+ let change = false;
3771
+ for (; i > -1; i--) {
3772
+ if (this.checkPushedItem(this.pushedItems[i], i)) {
3773
+ change = true;
3774
+ }
3775
+ }
3776
+ if (change) {
3777
+ this.checkPushBack();
3778
+ }
3779
+ }
3780
+ /**
3781
+ * @private
3782
+ * @param {?} gridsterItem
3783
+ * @param {?} direction
3784
+ * @return {?}
3785
+ */
3786
+ push(gridsterItem, direction) {
3787
+ /** @type {?} */
3788
+ const gridsterItemCollision = this.gridster.checkCollision(gridsterItem.$item);
3789
+ if (gridsterItemCollision && gridsterItemCollision !== true &&
3790
+ gridsterItemCollision !== this.gridsterItem && gridsterItemCollision.canBeResized()) {
3791
+ if (this.tryPattern[direction].call(this, gridsterItemCollision, gridsterItem, direction)) {
3792
+ return true;
3793
+ }
3794
+ }
3795
+ else if (gridsterItemCollision === false) {
3796
+ return true;
3797
+ }
3798
+ return false;
3799
+ }
3800
+ /**
3801
+ * @private
3802
+ * @param {?} gridsterItemCollide
3803
+ * @param {?} gridsterItem
3804
+ * @param {?} direction
3805
+ * @return {?}
3806
+ */
3807
+ trySouth(gridsterItemCollide, gridsterItem, direction) {
3808
+ /** @type {?} */
3809
+ const backUpY = gridsterItemCollide.$item.y;
3810
+ /** @type {?} */
3811
+ const backUpRows = gridsterItemCollide.$item.rows;
3812
+ gridsterItemCollide.$item.y = gridsterItem.$item.y + gridsterItem.$item.rows;
3813
+ gridsterItemCollide.$item.rows = backUpRows + backUpY - gridsterItemCollide.$item.y;
3814
+ if (!GridsterComponent.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item)
3815
+ && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
3816
+ gridsterItemCollide.setSize();
3817
+ this.addToPushed(gridsterItemCollide);
3818
+ this.push(gridsterItem, direction);
3819
+ return true;
3820
+ }
3821
+ else {
3822
+ gridsterItemCollide.$item.y = backUpY;
3823
+ gridsterItemCollide.$item.rows = backUpRows;
3824
+ }
3825
+ return false;
3826
+ }
3827
+ /**
3828
+ * @private
3829
+ * @param {?} gridsterItemCollide
3830
+ * @param {?} gridsterItem
3831
+ * @param {?} direction
3832
+ * @return {?}
3833
+ */
3834
+ tryNorth(gridsterItemCollide, gridsterItem, direction) {
3835
+ /** @type {?} */
3836
+ const backUpRows = gridsterItemCollide.$item.rows;
3837
+ gridsterItemCollide.$item.rows = gridsterItem.$item.y - gridsterItemCollide.$item.y;
3838
+ if (!GridsterComponent.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item)
3839
+ && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
3840
+ gridsterItemCollide.setSize();
3841
+ this.addToPushed(gridsterItemCollide);
3842
+ this.push(gridsterItem, direction);
3843
+ return true;
3844
+ }
3845
+ else {
3846
+ gridsterItemCollide.$item.rows = backUpRows;
3847
+ }
3848
+ return false;
3849
+ }
3850
+ /**
3851
+ * @private
3852
+ * @param {?} gridsterItemCollide
3853
+ * @param {?} gridsterItem
3854
+ * @param {?} direction
3855
+ * @return {?}
3856
+ */
3857
+ tryEast(gridsterItemCollide, gridsterItem, direction) {
3858
+ /** @type {?} */
3859
+ const backUpX = gridsterItemCollide.$item.x;
3860
+ /** @type {?} */
3861
+ const backUpCols = gridsterItemCollide.$item.cols;
3862
+ gridsterItemCollide.$item.x = gridsterItem.$item.x + gridsterItem.$item.cols;
3863
+ gridsterItemCollide.$item.cols = backUpCols + backUpX - gridsterItemCollide.$item.x;
3864
+ if (!GridsterComponent.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item)
3865
+ && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
3866
+ gridsterItemCollide.setSize();
3867
+ this.addToPushed(gridsterItemCollide);
3868
+ this.push(gridsterItem, direction);
3869
+ return true;
3870
+ }
3871
+ else {
3872
+ gridsterItemCollide.$item.x = backUpX;
3873
+ gridsterItemCollide.$item.cols = backUpCols;
3874
+ }
3875
+ return false;
3876
+ }
3877
+ /**
3878
+ * @private
3879
+ * @param {?} gridsterItemCollide
3880
+ * @param {?} gridsterItem
3881
+ * @param {?} direction
3882
+ * @return {?}
3883
+ */
3884
+ tryWest(gridsterItemCollide, gridsterItem, direction) {
3885
+ /** @type {?} */
3886
+ const backUpCols = gridsterItemCollide.$item.cols;
3887
+ gridsterItemCollide.$item.cols = gridsterItem.$item.x - gridsterItemCollide.$item.x;
3888
+ if (!GridsterComponent.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item)
3889
+ && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
3890
+ gridsterItemCollide.setSize();
3891
+ this.addToPushed(gridsterItemCollide);
3892
+ this.push(gridsterItem, direction);
3893
+ return true;
3894
+ }
3895
+ else {
3896
+ gridsterItemCollide.$item.cols = backUpCols;
3897
+ }
3898
+ return false;
3899
+ }
3900
+ /**
3901
+ * @private
3902
+ * @param {?} gridsterItem
3903
+ * @return {?}
3904
+ */
3905
+ addToPushed(gridsterItem) {
3906
+ if (this.pushedItems.indexOf(gridsterItem) < 0) {
3907
+ this.pushedItems.push(gridsterItem);
3908
+ this.pushedItemsPath.push([
3909
+ {
3910
+ x: gridsterItem.item.x || 0,
3911
+ y: gridsterItem.item.y || 0,
3912
+ cols: gridsterItem.item.cols || 0,
3913
+ rows: gridsterItem.item.rows || 0
3914
+ },
3915
+ {
3916
+ x: gridsterItem.$item.x,
3917
+ y: gridsterItem.$item.y,
3918
+ cols: gridsterItem.$item.cols,
3919
+ rows: gridsterItem.$item.rows
3920
+ }
3921
+ ]);
3922
+ }
3923
+ else {
3924
+ /** @type {?} */
3925
+ const i = this.pushedItems.indexOf(gridsterItem);
3926
+ this.pushedItemsPath[i].push({
3927
+ x: gridsterItem.$item.x,
3928
+ y: gridsterItem.$item.y,
3929
+ cols: gridsterItem.$item.cols,
3930
+ rows: gridsterItem.$item.rows
3931
+ });
3932
+ }
3933
+ }
3934
+ /**
3935
+ * @private
3936
+ * @param {?} i
3937
+ * @return {?}
3938
+ */
3939
+ removeFromPushed(i) {
3940
+ if (i > -1) {
3941
+ this.pushedItems.splice(i, 1);
3942
+ this.pushedItemsPath.splice(i, 1);
3943
+ }
3944
+ }
3945
+ /**
3946
+ * @private
3947
+ * @param {?} pushedItem
3948
+ * @param {?} i
3949
+ * @return {?}
3950
+ */
3951
+ checkPushedItem(pushedItem, i) {
3952
+ /** @type {?} */
3953
+ const path = this.pushedItemsPath[i];
3954
+ /** @type {?} */
3955
+ let j = path.length - 2;
3956
+ /** @type {?} */
3957
+ let lastPosition;
3958
+ /** @type {?} */
3959
+ let x;
3960
+ /** @type {?} */
3961
+ let y;
3962
+ /** @type {?} */
3963
+ let cols;
3964
+ /** @type {?} */
3965
+ let rows;
3966
+ for (; j > -1; j--) {
3967
+ lastPosition = path[j];
3968
+ x = pushedItem.$item.x;
3969
+ y = pushedItem.$item.y;
3970
+ cols = pushedItem.$item.cols;
3971
+ rows = pushedItem.$item.rows;
3972
+ pushedItem.$item.x = lastPosition.x;
3973
+ pushedItem.$item.y = lastPosition.y;
3974
+ pushedItem.$item.cols = lastPosition.cols;
3975
+ pushedItem.$item.rows = lastPosition.rows;
3976
+ if (!this.gridster.findItemWithItem(pushedItem.$item)) {
3977
+ pushedItem.setSize();
3978
+ path.splice(j + 1, path.length - 1 - j);
3979
+ }
3980
+ else {
3981
+ pushedItem.$item.x = x;
3982
+ pushedItem.$item.y = y;
3983
+ pushedItem.$item.cols = cols;
3984
+ pushedItem.$item.rows = rows;
3985
+ }
3986
+ }
3987
+ if (path.length < 2) {
3988
+ this.removeFromPushed(i);
3989
+ return true;
3990
+ }
3991
+ return false;
3992
+ }
3993
+ }
3994
+ GridsterPushResize.decorators = [
3995
+ { type: Injectable }
3996
+ ];
3997
+ /** @nocollapse */
3998
+ GridsterPushResize.ctorParameters = () => [
3999
+ { type: GridsterItemComponentInterface }
4000
+ ];
4001
+
4002
+ /**
4003
+ * @fileoverview added by tsickle
4004
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4005
+ */
4006
+ class GridsterResizable {
4007
+ /**
4008
+ * @param {?} gridsterItem
4009
+ * @param {?} gridster
4010
+ * @param {?} zone
4011
+ */
4012
+ constructor(gridsterItem, gridster, zone) {
4013
+ this.zone = zone;
4014
+ this.gridsterItem = gridsterItem;
4015
+ this.gridster = gridster;
4016
+ this.lastMouse = {
4017
+ clientX: 0,
4018
+ clientY: 0
4019
+ };
4020
+ this.itemBackup = [0, 0, 0, 0];
4021
+ this.resizeEventScrollType = { w: false, e: false, n: false, s: false };
4022
+ }
4023
+ /**
4024
+ * @return {?}
4025
+ */
4026
+ destroy() {
4027
+ if (this.gridster.previewStyle) {
4028
+ this.gridster.previewStyle();
4029
+ }
4030
+ delete this.gridsterItem;
4031
+ delete this.gridster;
4032
+ }
4033
+ /**
4034
+ * @param {?} e
4035
+ * @return {?}
4036
+ */
4037
+ dragStart(e) {
4038
+ switch (e.which) {
4039
+ case 1:
4040
+ // left mouse button
4041
+ break;
4042
+ case 2:
4043
+ case 3:
4044
+ // right or middle mouse button
4045
+ return;
4046
+ }
4047
+ if (this.gridster.options.resizable && this.gridster.options.resizable.start) {
4048
+ this.gridster.options.resizable.start(this.gridsterItem.item, this.gridsterItem, e);
4049
+ }
4050
+ e.stopPropagation();
4051
+ e.preventDefault();
4052
+ this.dragFunction = this.dragMove.bind(this);
4053
+ this.dragStopFunction = this.dragStop.bind(this);
4054
+ this.zone.runOutsideAngular((/**
4055
+ * @return {?}
4056
+ */
4057
+ () => {
4058
+ this.mousemove = this.gridsterItem.renderer.listen('document', 'mousemove', this.dragFunction);
4059
+ this.touchmove = this.gridster.renderer.listen(this.gridster.el, 'touchmove', this.dragFunction);
4060
+ }));
4061
+ this.mouseup = this.gridsterItem.renderer.listen('document', 'mouseup', this.dragStopFunction);
4062
+ this.mouseleave = this.gridsterItem.renderer.listen('document', 'mouseleave', this.dragStopFunction);
4063
+ this.cancelOnBlur = this.gridsterItem.renderer.listen('window', 'blur', this.dragStopFunction);
4064
+ this.touchend = this.gridsterItem.renderer.listen('document', 'touchend', this.dragStopFunction);
4065
+ this.touchcancel = this.gridsterItem.renderer.listen('document', 'touchcancel', this.dragStopFunction);
4066
+ this.gridsterItem.renderer.addClass(this.gridsterItem.el, 'gridster-item-resizing');
4067
+ this.lastMouse.clientX = e.clientX;
4068
+ this.lastMouse.clientY = e.clientY;
4069
+ this.left = this.gridsterItem.left;
4070
+ this.top = this.gridsterItem.top;
4071
+ this.width = this.gridsterItem.width;
4072
+ this.height = this.gridsterItem.height;
4073
+ this.bottom = this.gridsterItem.top + this.gridsterItem.height;
4074
+ this.right = this.gridsterItem.left + this.gridsterItem.width;
4075
+ this.margin = this.gridster.$options.margin;
4076
+ this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
4077
+ this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
4078
+ this.diffLeft = e.clientX + this.offsetLeft - this.left;
4079
+ this.diffRight = e.clientX + this.offsetLeft - this.right;
4080
+ this.diffTop = e.clientY + this.offsetTop - this.top;
4081
+ this.diffBottom = e.clientY + this.offsetTop - this.bottom;
4082
+ this.minHeight = this.gridster.positionYToPixels(this.gridsterItem.$item.minItemRows || this.gridster.$options.minItemRows)
4083
+ - this.margin;
4084
+ this.minWidth = this.gridster.positionXToPixels(this.gridsterItem.$item.minItemCols || this.gridster.$options.minItemCols)
4085
+ - this.margin;
4086
+ this.gridster.movingItem = this.gridsterItem.$item;
4087
+ this.gridster.previewStyle();
4088
+ this.push = new GridsterPush(this.gridsterItem);
4089
+ this.pushResize = new GridsterPushResize(this.gridsterItem);
4090
+ this.gridster.dragInProgress = true;
4091
+ this.gridster.updateGrid();
4092
+ if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-n') > -1) {
4093
+ this.resizeEventScrollType.n = true;
4094
+ this.directionFunction = this.handleN;
4095
+ }
4096
+ else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-w') > -1) {
4097
+ this.resizeEventScrollType.w = true;
4098
+ this.directionFunction = this.handleW;
4099
+ }
4100
+ else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-s') > -1) {
4101
+ this.resizeEventScrollType.s = true;
4102
+ this.directionFunction = this.handleS;
4103
+ }
4104
+ else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-e') > -1) {
4105
+ this.resizeEventScrollType.e = true;
4106
+ this.directionFunction = this.handleE;
4107
+ }
4108
+ else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-nw') > -1) {
4109
+ this.resizeEventScrollType.n = true;
4110
+ this.resizeEventScrollType.w = true;
4111
+ this.directionFunction = this.handleNW;
4112
+ }
4113
+ else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-ne') > -1) {
4114
+ this.resizeEventScrollType.n = true;
4115
+ this.resizeEventScrollType.e = true;
4116
+ this.directionFunction = this.handleNE;
4117
+ }
4118
+ else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-sw') > -1) {
4119
+ this.resizeEventScrollType.s = true;
4120
+ this.resizeEventScrollType.w = true;
4121
+ this.directionFunction = this.handleSW;
4122
+ }
4123
+ else if (e.target.hasAttribute('class') && e.target.getAttribute('class').split(' ').indexOf('handle-se') > -1) {
4124
+ this.resizeEventScrollType.s = true;
4125
+ this.resizeEventScrollType.e = true;
4126
+ this.directionFunction = this.handleSE;
4127
+ }
4128
+ }
4129
+ /**
4130
+ * @param {?} e
4131
+ * @return {?}
4132
+ */
4133
+ dragMove(e) {
4134
+ e.stopPropagation();
4135
+ e.preventDefault();
4136
+ GridsterUtils.checkTouchEvent(e);
4137
+ this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
4138
+ this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
4139
+ scroll(this.gridster, this.left, this.top, this.width, this.height, e, this.lastMouse, this.directionFunction.bind(this), true, this.resizeEventScrollType);
4140
+ this.directionFunction(e);
4141
+ this.lastMouse.clientX = e.clientX;
4142
+ this.lastMouse.clientY = e.clientY;
4143
+ this.zone.run((/**
4144
+ * @return {?}
4145
+ */
4146
+ () => {
4147
+ this.gridster.updateGrid();
4148
+ }));
4149
+ }
4150
+ /**
4151
+ * @param {?} e
4152
+ * @return {?}
4153
+ */
4154
+ dragStop(e) {
4155
+ e.stopPropagation();
4156
+ e.preventDefault();
4157
+ cancelScroll();
4158
+ this.mousemove();
4159
+ this.mouseup();
4160
+ this.mouseleave();
4161
+ this.cancelOnBlur();
4162
+ this.touchmove();
4163
+ this.touchend();
4164
+ this.touchcancel();
4165
+ this.gridster.dragInProgress = false;
4166
+ this.gridster.updateGrid();
4167
+ if (this.gridster.options.resizable && this.gridster.options.resizable.stop) {
4168
+ Promise.resolve(this.gridster.options.resizable.stop(this.gridsterItem.item, this.gridsterItem, e))
4169
+ .then(this.makeResize.bind(this), this.cancelResize.bind(this));
4170
+ }
4171
+ else {
4172
+ this.makeResize();
4173
+ }
4174
+ setTimeout((/**
4175
+ * @return {?}
4176
+ */
4177
+ () => {
4178
+ this.gridsterItem.renderer.removeClass(this.gridsterItem.el, 'gridster-item-resizing');
4179
+ if (this.gridster) {
4180
+ this.gridster.movingItem = null;
4181
+ this.gridster.previewStyle();
4182
+ }
4183
+ }));
4184
+ }
4185
+ /**
4186
+ * @return {?}
4187
+ */
4188
+ cancelResize() {
4189
+ this.gridsterItem.$item.cols = this.gridsterItem.item.cols || 1;
4190
+ this.gridsterItem.$item.rows = this.gridsterItem.item.rows || 1;
4191
+ this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
4192
+ this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
4193
+ this.gridsterItem.setSize();
4194
+ this.push.restoreItems();
4195
+ this.pushResize.restoreItems();
4196
+ this.push.destroy();
4197
+ delete this.push;
4198
+ this.pushResize.destroy();
4199
+ delete this.pushResize;
4200
+ }
4201
+ /**
4202
+ * @return {?}
4203
+ */
4204
+ makeResize() {
4205
+ this.gridsterItem.setSize();
4206
+ this.gridsterItem.checkItemChanges(this.gridsterItem.$item, this.gridsterItem.item);
4207
+ this.push.setPushedItems();
4208
+ this.pushResize.setPushedItems();
4209
+ this.push.destroy();
4210
+ delete this.push;
4211
+ this.pushResize.destroy();
4212
+ delete this.pushResize;
4213
+ }
4214
+ /**
4215
+ * @param {?} e
4216
+ * @return {?}
4217
+ */
4218
+ handleN(e) {
4219
+ this.top = e.clientY + this.offsetTop - this.diffTop;
4220
+ this.height = this.bottom - this.top;
4221
+ if (this.minHeight > this.height) {
4222
+ this.height = this.minHeight;
4223
+ this.top = this.bottom - this.minHeight;
4224
+ }
4225
+ this.newPosition = this.gridster.pixelsToPositionY(this.top + this.margin, Math.floor);
4226
+ if (this.gridsterItem.$item.y !== this.newPosition) {
4227
+ this.itemBackup[1] = this.gridsterItem.$item.y;
4228
+ this.itemBackup[3] = this.gridsterItem.$item.rows;
4229
+ this.gridsterItem.$item.rows += this.gridsterItem.$item.y - this.newPosition;
4230
+ this.gridsterItem.$item.y = this.newPosition;
4231
+ this.pushResize.pushItems(this.pushResize.fromSouth);
4232
+ this.push.pushItems(this.push.fromSouth, this.gridster.$options.disablePushOnResize);
4233
+ if (this.gridster.checkCollision(this.gridsterItem.$item)) {
4234
+ this.gridsterItem.$item.y = this.itemBackup[1];
4235
+ this.gridsterItem.$item.rows = this.itemBackup[3];
4236
+ this.setItemTop(this.gridster.positionYToPixels(this.gridsterItem.$item.y));
4237
+ this.setItemHeight(this.gridster.positionYToPixels(this.gridsterItem.$item.rows) - this.margin);
4238
+ return;
4239
+ }
4240
+ else {
4241
+ this.gridster.previewStyle();
4242
+ }
4243
+ this.pushResize.checkPushBack();
4244
+ this.push.checkPushBack();
4245
+ }
4246
+ this.setItemTop(this.top);
4247
+ this.setItemHeight(this.height);
4248
+ }
4249
+ /**
4250
+ * @param {?} e
4251
+ * @return {?}
4252
+ */
4253
+ handleW(e) {
4254
+ this.left = e.clientX + this.offsetLeft - this.diffLeft;
4255
+ this.width = this.right - this.left;
4256
+ if (this.minWidth > this.width) {
4257
+ this.width = this.minWidth;
4258
+ this.left = this.right - this.minWidth;
4259
+ }
4260
+ this.newPosition = this.gridster.pixelsToPositionX(this.left + this.margin, Math.floor);
4261
+ if (this.gridsterItem.$item.x !== this.newPosition) {
4262
+ this.itemBackup[0] = this.gridsterItem.$item.x;
4263
+ this.itemBackup[2] = this.gridsterItem.$item.cols;
4264
+ this.gridsterItem.$item.cols += this.gridsterItem.$item.x - this.newPosition;
4265
+ this.gridsterItem.$item.x = this.newPosition;
4266
+ this.pushResize.pushItems(this.pushResize.fromEast);
4267
+ this.push.pushItems(this.push.fromEast, this.gridster.$options.disablePushOnResize);
4268
+ if (this.gridster.checkCollision(this.gridsterItem.$item)) {
4269
+ this.gridsterItem.$item.x = this.itemBackup[0];
4270
+ this.gridsterItem.$item.cols = this.itemBackup[2];
4271
+ this.setItemLeft(this.gridster.positionXToPixels(this.gridsterItem.$item.x));
4272
+ this.setItemWidth(this.gridster.positionXToPixels(this.gridsterItem.$item.cols) - this.margin);
4273
+ return;
4274
+ }
4275
+ else {
4276
+ this.gridster.previewStyle();
4277
+ }
4278
+ this.pushResize.checkPushBack();
4279
+ this.push.checkPushBack();
4280
+ }
4281
+ this.setItemLeft(this.left);
4282
+ this.setItemWidth(this.width);
4283
+ }
4284
+ /**
4285
+ * @param {?} e
4286
+ * @return {?}
4287
+ */
4288
+ handleS(e) {
4289
+ this.height = e.clientY + this.offsetTop - this.diffBottom - this.top;
4290
+ if (this.minHeight > this.height) {
4291
+ this.height = this.minHeight;
4292
+ }
4293
+ this.bottom = this.top + this.height;
4294
+ this.newPosition = this.gridster.pixelsToPositionY(this.bottom, Math.ceil);
4295
+ if ((this.gridsterItem.$item.y + this.gridsterItem.$item.rows) !== this.newPosition) {
4296
+ this.itemBackup[3] = this.gridsterItem.$item.rows;
4297
+ this.gridsterItem.$item.rows = this.newPosition - this.gridsterItem.$item.y;
4298
+ this.pushResize.pushItems(this.pushResize.fromNorth);
4299
+ this.push.pushItems(this.push.fromNorth, this.gridster.$options.disablePushOnResize);
4300
+ if (this.gridster.checkCollision(this.gridsterItem.$item)) {
4301
+ this.gridsterItem.$item.rows = this.itemBackup[3];
4302
+ this.setItemHeight(this.gridster.positionYToPixels(this.gridsterItem.$item.rows) - this.margin);
4303
+ return;
4304
+ }
4305
+ else {
4306
+ this.gridster.previewStyle();
4307
+ }
4308
+ this.pushResize.checkPushBack();
4309
+ this.push.checkPushBack();
4310
+ }
4311
+ this.setItemHeight(this.height);
4312
+ }
4313
+ /**
4314
+ * @param {?} e
4315
+ * @return {?}
4316
+ */
4317
+ handleE(e) {
4318
+ this.width = e.clientX + this.offsetLeft - this.diffRight - this.left;
4319
+ if (this.minWidth > this.width) {
4320
+ this.width = this.minWidth;
4321
+ }
4322
+ this.right = this.left + this.width;
4323
+ this.newPosition = this.gridster.pixelsToPositionX(this.right, Math.ceil);
4324
+ if ((this.gridsterItem.$item.x + this.gridsterItem.$item.cols) !== this.newPosition) {
4325
+ this.itemBackup[2] = this.gridsterItem.$item.cols;
4326
+ this.gridsterItem.$item.cols = this.newPosition - this.gridsterItem.$item.x;
4327
+ this.pushResize.pushItems(this.pushResize.fromWest);
4328
+ this.push.pushItems(this.push.fromWest, this.gridster.$options.disablePushOnResize);
4329
+ if (this.gridster.checkCollision(this.gridsterItem.$item)) {
4330
+ this.gridsterItem.$item.cols = this.itemBackup[2];
4331
+ this.setItemWidth(this.gridster.positionXToPixels(this.gridsterItem.$item.cols) - this.margin);
4332
+ return;
4333
+ }
4334
+ else {
4335
+ this.gridster.previewStyle();
4336
+ }
4337
+ this.pushResize.checkPushBack();
4338
+ this.push.checkPushBack();
4339
+ }
4340
+ this.setItemWidth(this.width);
4341
+ }
4342
+ /**
4343
+ * @param {?} e
4344
+ * @return {?}
4345
+ */
4346
+ handleNW(e) {
4347
+ this.handleN(e);
4348
+ this.handleW(e);
4349
+ }
4350
+ /**
4351
+ * @param {?} e
4352
+ * @return {?}
4353
+ */
4354
+ handleNE(e) {
4355
+ this.handleN(e);
4356
+ this.handleE(e);
4357
+ }
4358
+ /**
4359
+ * @param {?} e
4360
+ * @return {?}
4361
+ */
4362
+ handleSW(e) {
4363
+ this.handleS(e);
4364
+ this.handleW(e);
4365
+ }
4366
+ /**
4367
+ * @param {?} e
4368
+ * @return {?}
4369
+ */
4370
+ handleSE(e) {
4371
+ this.handleS(e);
4372
+ this.handleE(e);
4373
+ }
4374
+ /**
4375
+ * @return {?}
4376
+ */
4377
+ toggle() {
4378
+ this.resizeEnabled = this.gridsterItem.canBeResized();
4379
+ }
4380
+ /**
4381
+ * @param {?} e
4382
+ * @return {?}
4383
+ */
4384
+ dragStartDelay(e) {
4385
+ GridsterUtils.checkTouchEvent(e);
4386
+ if (!this.gridster.$options.resizable.delayStart) {
4387
+ this.dragStart(e);
4388
+ return;
4389
+ }
4390
+ /** @type {?} */
4391
+ const timeout = setTimeout((/**
4392
+ * @return {?}
4393
+ */
4394
+ () => {
4395
+ this.dragStart(e);
4396
+ cancelDrag();
4397
+ }), this.gridster.$options.resizable.delayStart);
4398
+ /** @type {?} */
4399
+ const cancelMouse = this.gridsterItem.renderer.listen('document', 'mouseup', cancelDrag);
4400
+ /** @type {?} */
4401
+ const cancelMouseLeave = this.gridsterItem.renderer.listen('document', 'mouseleave', cancelDrag);
4402
+ /** @type {?} */
4403
+ const cancelOnBlur = this.gridsterItem.renderer.listen('window', 'blur', cancelDrag);
4404
+ /** @type {?} */
4405
+ const cancelTouchMove = this.gridsterItem.renderer.listen('document', 'touchmove', cancelMove);
4406
+ /** @type {?} */
4407
+ const cancelTouchEnd = this.gridsterItem.renderer.listen('document', 'touchend', cancelDrag);
4408
+ /** @type {?} */
4409
+ const cancelTouchCancel = this.gridsterItem.renderer.listen('document', 'touchcancel', cancelDrag);
4410
+ /**
4411
+ * @param {?} eventMove
4412
+ * @return {?}
4413
+ */
4414
+ function cancelMove(eventMove) {
4415
+ GridsterUtils.checkTouchEvent(eventMove);
4416
+ if (Math.abs(eventMove.clientX - e.clientX) > 9 || Math.abs(eventMove.clientY - e.clientY) > 9) {
4417
+ cancelDrag();
4418
+ }
4419
+ }
4420
+ /**
4421
+ * @return {?}
4422
+ */
4423
+ function cancelDrag() {
4424
+ clearTimeout(timeout);
4425
+ cancelOnBlur();
4426
+ cancelMouse();
4427
+ cancelMouseLeave();
4428
+ cancelTouchMove();
4429
+ cancelTouchEnd();
4430
+ cancelTouchCancel();
4431
+ }
4432
+ }
4433
+ /**
4434
+ * @param {?} top
4435
+ * @return {?}
4436
+ */
4437
+ setItemTop(top) {
4438
+ this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, this.left, top);
4439
+ }
4440
+ /**
4441
+ * @param {?} left
4442
+ * @return {?}
4443
+ */
4444
+ setItemLeft(left) {
4445
+ this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, left, this.top);
4446
+ }
4447
+ /**
4448
+ * @param {?} height
4449
+ * @return {?}
4450
+ */
4451
+ setItemHeight(height) {
4452
+ this.gridsterItem.renderer.setStyle(this.gridsterItem.el, 'height', height + 'px');
4453
+ }
4454
+ /**
4455
+ * @param {?} width
4456
+ * @return {?}
4457
+ */
4458
+ setItemWidth(width) {
4459
+ this.gridsterItem.renderer.setStyle(this.gridsterItem.el, 'width', width + 'px');
4460
+ }
4461
+ }
4462
+ GridsterResizable.decorators = [
4463
+ { type: Injectable }
4464
+ ];
4465
+ /** @nocollapse */
4466
+ GridsterResizable.ctorParameters = () => [
4467
+ { type: GridsterItemComponentInterface },
4468
+ { type: GridsterComponentInterface },
4469
+ { type: NgZone }
4470
+ ];
4471
+
4472
+ /**
4473
+ * @fileoverview added by tsickle
4474
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4475
+ */
4476
+ class GridsterItemComponent {
4477
+ /**
4478
+ * @param {?} el
4479
+ * @param {?} gridster
4480
+ * @param {?} renderer
4481
+ * @param {?} zone
4482
+ */
4483
+ constructor(el, gridster, renderer, zone) {
4484
+ this.renderer = renderer;
4485
+ this.zone = zone;
4486
+ this.el = el.nativeElement;
4487
+ this.$item = {
4488
+ cols: -1,
4489
+ rows: -1,
4490
+ x: -1,
4491
+ y: -1,
4492
+ };
4493
+ this.gridster = gridster;
4494
+ this.drag = new GridsterDraggable(this, gridster, this.zone);
4495
+ this.resize = new GridsterResizable(this, gridster, this.zone);
4496
+ }
4497
+ /**
4498
+ * @return {?}
4499
+ */
4500
+ ngOnInit() {
4501
+ this.updateOptions();
4502
+ this.gridster.addItem(this);
4503
+ }
4504
+ /**
4505
+ * @return {?}
4506
+ */
4507
+ updateOptions() {
4508
+ this.$item = GridsterUtils.merge(this.$item, this.item, {
4509
+ cols: undefined,
4510
+ rows: undefined,
4511
+ x: undefined,
4512
+ y: undefined,
4513
+ dragEnabled: undefined,
4514
+ resizeEnabled: undefined,
4515
+ compactEnabled: undefined,
4516
+ maxItemRows: undefined,
4517
+ minItemRows: undefined,
4518
+ maxItemCols: undefined,
4519
+ minItemCols: undefined,
4520
+ maxItemArea: undefined,
4521
+ minItemArea: undefined,
4522
+ });
4523
+ }
4524
+ /**
4525
+ * @return {?}
4526
+ */
4527
+ ngOnDestroy() {
4528
+ this.gridster.removeItem(this);
4529
+ this.gridster.movingItem = null;
4530
+ delete this.gridster;
4531
+ this.drag.destroy();
4532
+ delete this.drag;
4533
+ this.resize.destroy();
4534
+ delete this.resize;
4535
+ }
4536
+ /**
4537
+ * @return {?}
4538
+ */
4539
+ setSize() {
4540
+ this.renderer.setStyle(this.el, 'display', this.notPlaced ? '' : 'block');
4541
+ this.gridster.gridRenderer.updateItem(this.el, this.$item, this.renderer);
4542
+ this.updateItemSize();
4543
+ }
4544
+ /**
4545
+ * @return {?}
4546
+ */
4547
+ updateItemSize() {
4548
+ /** @type {?} */
4549
+ const top = this.$item.y * this.gridster.curRowHeight;
4550
+ /** @type {?} */
4551
+ const left = this.$item.x * this.gridster.curColWidth;
4552
+ /** @type {?} */
4553
+ const width = this.$item.cols * this.gridster.curColWidth - this.gridster.$options.margin;
4554
+ /** @type {?} */
4555
+ const height = this.$item.rows * this.gridster.curRowHeight - this.gridster.$options.margin;
4556
+ if (!this.init && width > 0 && height > 0) {
4557
+ this.init = true;
4558
+ if (this.item.initCallback) {
4559
+ this.item.initCallback(this.item, this);
4560
+ }
4561
+ if (this.gridster.options.itemInitCallback) {
4562
+ this.item.curRowHeight = this.gridster.curRowHeight;
4563
+ this.gridster.options.itemInitCallback(this.item, this);
4564
+ }
4565
+ if (this.gridster.$options.scrollToNewItems) {
4566
+ this.el.scrollIntoView(false);
4567
+ }
4568
+ }
4569
+ if (width !== this.width || height !== this.height) {
4570
+ this.width = width;
4571
+ this.height = height;
4572
+ if (this.gridster.options.itemResizeCallback) {
4573
+ this.gridster.options.itemResizeCallback(this.item, this);
4574
+ }
4575
+ }
4576
+ this.top = top;
4577
+ this.left = left;
4578
+ }
4579
+ /**
4580
+ * @return {?}
4581
+ */
4582
+ itemChanged() {
4583
+ if (this.gridster.options.itemChangeCallback) {
4584
+ this.item.curRowHeight = this.gridster.curRowHeight;
4585
+ this.gridster.options.itemChangeCallback(this.item, this);
4586
+ }
4587
+ }
4588
+ /**
4589
+ * @param {?} newValue
4590
+ * @param {?} oldValue
4591
+ * @return {?}
4592
+ */
4593
+ checkItemChanges(newValue, oldValue) {
4594
+ if (newValue.rows === oldValue.rows && newValue.cols === oldValue.cols && newValue.x === oldValue.x && newValue.y === oldValue.y) {
4595
+ return;
4596
+ }
4597
+ if (this.gridster.checkCollision(this.$item)) {
4598
+ this.$item.x = oldValue.x || 0;
4599
+ this.$item.y = oldValue.y || 0;
4600
+ this.$item.cols = oldValue.cols || 1;
4601
+ this.$item.rows = oldValue.rows || 1;
4602
+ this.setSize();
4603
+ }
4604
+ else {
4605
+ this.item.cols = this.$item.cols;
4606
+ this.item.rows = this.$item.rows;
4607
+ this.item.x = this.$item.x;
4608
+ this.item.y = this.$item.y;
4609
+ this.gridster.calculateLayoutDebounce();
4610
+ this.itemChanged();
4611
+ }
4612
+ }
4613
+ /**
4614
+ * @return {?}
4615
+ */
4616
+ canBeDragged() {
4617
+ return !this.gridster.mobile &&
4618
+ (this.$item.dragEnabled === undefined ? this.gridster.$options.draggable.enabled : this.$item.dragEnabled);
4619
+ }
4620
+ /**
4621
+ * @return {?}
4622
+ */
4623
+ canBeResized() {
4624
+ return !this.gridster.mobile &&
4625
+ (this.$item.resizeEnabled === undefined ? this.gridster.$options.resizable.enabled : this.$item.resizeEnabled);
4626
+ }
4627
+ }
4628
+ GridsterItemComponent.decorators = [
4629
+ { type: Component, args: [{
4630
+ selector: 'gridster-item',
4631
+ template: "<ng-content></ng-content>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.s || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-s\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.e || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-e\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.n || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-n\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.w || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-w\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.se || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-se\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.ne || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-ne\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.sw || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-sw\"></div>\r\n<div (mousedown)=\"resize.dragStartDelay($event)\" (touchstart)=\"resize.dragStartDelay($event)\"\r\n [hidden]=\"!gridster.$options.resizable.handles.nw || !resize.resizeEnabled\"\r\n class=\"gridster-item-resizable-handler handle-nw\"></div>\r\n",
4632
+ encapsulation: ViewEncapsulation.None,
4633
+ styles: ["gridster-item{box-sizing:border-box;z-index:1;position:absolute;overflow:hidden;transition:.3s;display:none;background:#fff;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text}gridster-item.gridster-item-moving{cursor:move}gridster-item.gridster-item-moving,gridster-item.gridster-item-resizing{transition:none;z-index:2;box-shadow:0 0 5px 5px rgba(0,0,0,.2),0 6px 10px 0 rgba(0,0,0,.14),0 1px 18px 0 rgba(0,0,0,.12)}.gridster-item-resizable-handler{position:absolute;z-index:2}.gridster-item-resizable-handler.handle-n{cursor:n-resize;height:10px;right:0;top:0;left:0}.gridster-item-resizable-handler.handle-e{cursor:e-resize;width:10px;bottom:0;right:0;top:0}.gridster-item-resizable-handler.handle-s{cursor:s-resize;height:10px;right:0;bottom:0;left:0}.gridster-item-resizable-handler.handle-w{cursor:w-resize;width:10px;left:0;top:0;bottom:0}.gridster-item-resizable-handler.handle-ne{cursor:ne-resize;width:10px;height:10px;right:0;top:0}.gridster-item-resizable-handler.handle-nw{cursor:nw-resize;width:10px;height:10px;left:0;top:0}.gridster-item-resizable-handler.handle-se{cursor:se-resize;width:0;height:0;right:0;bottom:0;border-style:solid;border-width:0 0 10px 10px;border-color:transparent}.gridster-item-resizable-handler.handle-sw{cursor:sw-resize;width:10px;height:10px;left:0;bottom:0}gridster-item:hover .gridster-item-resizable-handler.handle-se{border-color:transparent transparent #ccc}"]
4634
+ }] }
4635
+ ];
4636
+ /** @nocollapse */
4637
+ GridsterItemComponent.ctorParameters = () => [
4638
+ { type: ElementRef },
4639
+ { type: GridsterComponent, decorators: [{ type: Host }] },
4640
+ { type: Renderer2 },
4641
+ { type: NgZone }
4642
+ ];
4643
+ GridsterItemComponent.propDecorators = {
4644
+ item: [{ type: Input }]
4645
+ };
4646
+
4647
+ /**
4648
+ * @fileoverview added by tsickle
4649
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4650
+ */
4651
+ class GridsterPreviewComponent {
4652
+ /**
4653
+ * @param {?} el
4654
+ * @param {?} gridster
4655
+ * @param {?} renderer
4656
+ */
4657
+ constructor(el, gridster, renderer) {
4658
+ this.renderer = renderer;
4659
+ this.el = el.nativeElement;
4660
+ this.gridster = gridster;
4661
+ this.gridster.previewStyle = this.previewStyle.bind(this);
4662
+ }
4663
+ /**
4664
+ * @return {?}
4665
+ */
4666
+ ngOnDestroy() {
4667
+ delete this.el;
4668
+ delete this.gridster.previewStyle;
4669
+ delete this.gridster;
4670
+ }
4671
+ /**
4672
+ * @param {?=} drag
4673
+ * @return {?}
4674
+ */
4675
+ previewStyle(drag) {
4676
+ if (!this.gridster.movingItem) {
4677
+ this.renderer.setStyle(this.el, 'display', '');
4678
+ }
4679
+ else {
4680
+ if (this.gridster.compact && drag) {
4681
+ this.gridster.compact.checkCompactItem(this.gridster.movingItem);
4682
+ }
4683
+ this.renderer.setStyle(this.el, 'display', 'block');
4684
+ this.gridster.gridRenderer.updateItem(this.el, this.gridster.movingItem, this.renderer);
4685
+ }
4686
+ }
4687
+ }
4688
+ GridsterPreviewComponent.decorators = [
4689
+ { type: Component, args: [{
4690
+ selector: 'gridster-preview',
4691
+ template: '',
4692
+ encapsulation: ViewEncapsulation.None,
4693
+ styles: ["gridster-preview{position:absolute;display:none;background:#ccc}"]
4694
+ }] }
4695
+ ];
4696
+ /** @nocollapse */
4697
+ GridsterPreviewComponent.ctorParameters = () => [
4698
+ { type: ElementRef },
4699
+ { type: GridsterComponent, decorators: [{ type: Host }] },
4700
+ { type: Renderer2 }
4701
+ ];
4702
+
4703
+ /**
4704
+ * @fileoverview added by tsickle
4705
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4706
+ */
4707
+ class GridsterModule {
4708
+ }
4709
+ GridsterModule.decorators = [
4710
+ { type: NgModule, args: [{
4711
+ declarations: [
4712
+ GridsterComponent,
4713
+ GridsterItemComponent,
4714
+ GridsterPreviewComponent
4715
+ ],
4716
+ imports: [
4717
+ CommonModule
4718
+ ],
4719
+ exports: [GridsterComponent, GridsterItemComponent],
4720
+ providers: [],
4721
+ bootstrap: []
4722
+ },] }
4723
+ ];
4724
+
4725
+ /**
4726
+ * @fileoverview added by tsickle
4727
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4728
+ */
4729
+ class DashboardFrameworkModule {
4730
+ }
4731
+ DashboardFrameworkModule.decorators = [
4732
+ { type: NgModule, args: [{
4733
+ declarations: [
4734
+ RADashboardArea,
4735
+ RAWidgetContainer
4736
+ ],
4737
+ imports: [
4738
+ BrowserModule,
4739
+ GridsterModule,
4740
+ HttpClientModule
4741
+ ],
4742
+ exports: [
4743
+ RADashboardArea
4744
+ ],
4745
+ providers: [],
4746
+ bootstrap: [RADashboardArea]
4747
+ },] }
4748
+ ];
4749
+
4750
+ /**
4751
+ * @fileoverview added by tsickle
4752
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4753
+ */
4754
+ /**
4755
+ * @abstract
4756
+ */
4757
+ class RaBaseDashboardTemplate {
4758
+ /**
4759
+ * @param {?} ngZone
4760
+ */
4761
+ constructor(ngZone) {
4762
+ this.ngZone = ngZone;
4763
+ this.initialize = (/**
4764
+ * @param {?} eventBus
4765
+ * @param {?} userDashboardId
4766
+ * @param {?} appConfig
4767
+ * @return {?}
4768
+ */
4769
+ (eventBus, userDashboardId, appConfig) => {
4770
+ this.ngZone.run((/**
4771
+ * @return {?}
4772
+ */
4773
+ () => {
4774
+ this.userDashboardId = userDashboardId;
4775
+ this.appConfig = appConfig;
4776
+ this.raDashboardEventBus = eventBus;
4777
+ }));
4778
+ this.init();
4779
+ });
4780
+ }
4781
+ }
4782
+ RaBaseDashboardTemplate.propDecorators = {
4783
+ dashboardId: [{ type: Input, args: ['dashboard-id',] }],
4784
+ globalFilter: [{ type: Input, args: ['global-filter',] }],
4785
+ initialize: [{ type: Input }]
4786
+ };
4787
+
4788
+ /**
4789
+ * @fileoverview added by tsickle
4790
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4791
+ */
4792
+ /**
4793
+ * @abstract
4794
+ */
4795
+ class RaBaseDashboardFilter {
4796
+ constructor() {
4797
+ this.getAllFilterConfig = (/**
4798
+ * @param {?} async
4799
+ * @return {?}
4800
+ */
4801
+ (async) => {
4802
+ return this.getFilterConfig();
4803
+ });
4804
+ }
4805
+ }
4806
+ RaBaseDashboardFilter.propDecorators = {
4807
+ getAllFilterConfig: [{ type: Input }]
4808
+ };
4809
+
4810
+ export { DashboardFrameworkModule, RADashboardArea, RADashboardEventBus, RAEvent, RAEventKey, RAWidgetContainer, RaBaseDashboardFilter, RaBaseDashboardTemplate, RaDashboardService, GridsterModule as ɵa, GridsterComponent as ɵb, GridsterItemComponent as ɵc, GridsterPreviewComponent as ɵd };
4811
+ //# sourceMappingURL=schneideress-dashboardframework.js.map