1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521 | 1×
1×
1×
1×
79×
79×
79×
79×
79×
79×
79×
79×
79×
79×
79×
79×
79×
1×
9×
9×
9×
1×
6×
6×
6×
6×
6×
6×
6×
1×
130×
130×
302×
103×
199×
25×
25×
25×
16×
9×
18×
1×
28×
28×
28×
130×
130×
125×
5×
3×
130×
9×
28×
4×
28×
1×
11×
11×
11×
11×
11×
1×
1×
10×
10×
10×
10×
10×
10×
1×
1×
9×
9×
1×
1×
3×
1×
1×
1×
1×
2×
1×
1×
1×
1×
1×
8×
8×
8×
8×
8×
7×
1×
1×
1×
1×
1×
53×
1×
53×
53×
2×
2×
51×
51×
51×
51×
2×
3×
2×
2×
2×
2×
2×
6×
2×
2×
51×
4×
47×
47×
47×
47×
47×
11×
9×
37×
13×
2×
1×
1×
1×
47×
47×
47×
47×
47×
47×
11×
11×
11×
11×
1×
22×
84×
84×
84×
11×
1×
23×
23×
23×
23×
23×
4×
23×
23×
23×
23×
1×
4×
4×
65×
9×
9×
56×
29×
4×
1×
30×
1×
105×
105×
105×
1×
24×
24×
24×
1×
1×
23×
23×
23×
23×
23×
21×
1×
6×
6×
6×
2×
4×
8×
8×
4×
8×
8×
8×
8×
8×
8×
8×
3×
1×
11×
10×
1×
8×
1×
4×
7×
1×
30×
24×
24×
6×
6×
1×
2×
1×
5×
1×
4×
1×
13×
1×
1×
184×
1×
184×
184×
184×
1×
39×
39×
39×
39×
26×
1×
127×
127×
67×
60×
59×
60×
59×
60×
60×
60×
60×
60×
60×
60×
60×
60×
1×
28×
28×
28×
28×
3×
3×
2×
2×
2×
2×
2×
1×
3×
1×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
5×
5×
1×
1×
6×
6×
1×
6×
6×
6×
6×
6×
6×
6×
6×
1×
1×
1×
1×
1×
13×
1×
5×
5×
5×
5×
5×
5×
5×
5×
1×
14×
14×
14×
14×
2×
12×
12×
12×
1×
7×
7×
7×
7×
6×
7×
1×
19×
19×
1×
20551×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/util", "../base/constant", "../base/string-literals"], function (require, exports, ej2_base_1, ej2_base_2, util_1, events, literals) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Reorder = (function () {
function Reorder(parent) {
this.idx = 0;
this.parent = parent;
Iif (this.parent.isDestroyed) {
return;
}
this.parent.on(events.headerDrop, this.headerDrop, this);
this.parent.on(events.uiUpdate, this.enableAfterRender, this);
this.parent.on(events.reorderComplete, this.onActionComplete, this);
this.parent.on(events.columnDrag, this.drag, this);
this.parent.on(events.columnDragStart, this.dragStart, this);
this.parent.on(events.columnDragStop, this.dragStop, this);
this.parent.on(events.headerDrop, this.headerDrop, this);
this.parent.on(events.headerRefreshed, this.createReorderElement, this);
this.parent.on(events.keyPressed, this.keyPressHandler, this);
this.parent.on(events.destroy, this.destroy, this);
}
Reorder.prototype.chkDropPosition = function (srcElem, destElem) {
var col = this.parent.getColumnByUid(destElem.firstElementChild.getAttribute('e-mappinguid'));
var bool = col ? !col.lockColumn : true;
return ((srcElem.parentElement.isEqualNode(destElem.parentElement) || this.parent.enableColumnVirtualization)
|| (this.parent.isFrozenGrid()
&& Array.prototype.indexOf.call(ej2_base_2.closest(srcElem, 'thead').children, srcElem.parentElement)
=== Array.prototype.indexOf.call(ej2_base_2.closest(destElem, 'thead').children, destElem.parentElement)))
&& this.targetParentContainerIndex(srcElem, destElem) > -1 && bool;
};
Reorder.prototype.chkDropAllCols = function (srcElem, destElem) {
var isFound;
var headers = this.getHeaderCells();
var header;
while (!isFound && headers.length > 0) {
header = headers.pop();
isFound = srcElem !== header && this.targetParentContainerIndex(srcElem, destElem) > -1;
}
return isFound;
};
Reorder.prototype.findColParent = function (col, cols, parent) {
parent = parent;
for (var i = 0, len = cols.length; i < len; i++) {
if (col === cols[parseInt(i.toString(), 10)]) {
return true;
}
else if (cols[parseInt(i.toString(), 10)].columns) {
var cnt = parent.length;
parent.push(cols[parseInt(i.toString(), 10)]);
if (!this.findColParent(col, cols[parseInt(i.toString(), 10)].columns, parent)) {
parent.splice(cnt, parent.length - cnt);
}
else {
return true;
}
}
}
return false;
};
Reorder.prototype.getColumnsModel = function (cols, isNotStackedHeader) {
var columnModel = [];
var subCols = [];
for (var i = 0, len = cols.length; i < len; i++) {
Eif (!ej2_base_1.isNullOrUndefined(cols[parseInt(i.toString(), 10)])) {
if (cols[parseInt(i.toString(), 10)].visible) {
columnModel.push(cols[parseInt(i.toString(), 10)]);
}
else if (isNotStackedHeader) {
columnModel.push(cols[parseInt(i.toString(), 10)]);
}
if (cols[parseInt(i.toString(), 10)].columns) {
subCols = subCols.concat(cols[parseInt(i.toString(), 10)].columns);
}
}
}
if (subCols.length) {
columnModel = columnModel.concat(this.getColumnsModel(subCols));
}
return columnModel;
};
Reorder.prototype.headerDrop = function (e) {
var gObj = this.parent;
var dropElement = this.element.querySelector('.e-headercelldiv') || this.element.querySelector('.e-stackedheadercelldiv');
var uId = dropElement.getAttribute('e-mappinguid');
var column = gObj.getColumnByUid(uId);
if (!ej2_base_2.closest(e.target, 'th') || (!ej2_base_1.isNullOrUndefined(column) && (!column.allowReordering || column.lockColumn))) {
this.parent.log('action_disabled_column', { moduleName: this.getModuleName(), column: column });
return;
}
var destElem = ej2_base_2.closest(e.target, '.e-headercell');
var destElemDiv = destElem.querySelector('.e-headercelldiv') || destElem.querySelector('.e-stackedheadercelldiv');
var destElemUid = destElemDiv.getAttribute('e-mappinguid');
Eif (!ej2_base_1.isNullOrUndefined(destElemUid)) {
var destColumn = gObj.getColumnByUid(destElemUid);
if (ej2_base_1.isNullOrUndefined(destColumn) || !destColumn.allowReordering || destColumn.lockColumn) {
this.parent.log('action_disabled_column', { moduleName: this.getModuleName(), column: column, destColumn: destColumn });
return;
}
}
Eif (destElem && !(!this.chkDropPosition(this.element, destElem) || !this.chkDropAllCols(this.element, destElem))) {
if (this.parent.enableColumnVirtualization) {
var columns = this.parent.columns;
var sourceUid_1 = this.element.querySelector('.e-headercelldiv').getAttribute('e-mappinguid');
var col = this.parent.columns.filter(function (col) { return col.uid === sourceUid_1; });
var colMatchIndex_1 = null;
var column_1 = col[0];
var destUid_1 = destElem.querySelector('.e-headercelldiv').getAttribute('e-mappinguid');
columns.some(function (col, index) {
if (col.uid === destUid_1) {
colMatchIndex_1 = index;
return col.uid === destUid_1;
}
return false;
});
Eif (!ej2_base_1.isNullOrUndefined(colMatchIndex_1)) {
this.moveColumns(colMatchIndex_1, column_1);
}
}
else {
var newIndex = this.targetParentContainerIndex(this.element, destElem);
var uid = this.element.firstElementChild.getAttribute('e-mappinguid');
this.destElement = destElem;
this.parent.notify(events.setReorderDestinationElement, { ele: destElem });
if (uid) {
this.moveColumns(newIndex, this.parent.getColumnByUid(uid));
}
else {
var headers = this.getHeaderCells();
var oldIdx = util_1.getElementIndex(this.element, headers);
var columns = this.getColumnsModel(this.parent.columns);
this.moveColumns(newIndex, columns[parseInt(oldIdx.toString(), 10)]);
}
}
}
};
Reorder.prototype.isActionPrevent = function (gObj) {
return util_1.isActionPrevent(gObj);
};
Reorder.prototype.moveColumns = function (destIndex, column, reorderByColumn, preventRefresh) {
var gObj = this.parent;
if (this.isActionPrevent(gObj)) {
gObj.notify(events.preventBatch, { instance: this, handler: this.moveColumns, arg1: destIndex, arg2: column });
return;
}
var parent = this.getColParent(column, this.parent.columns);
var cols = parent ? parent.columns : this.parent.columns;
var srcIdx = util_1.inArray(column, cols);
if ((parent || this.parent.lockcolPositionCount) && !reorderByColumn &&
!this.parent.enableColumnVirtualization) {
for (var i = 0; i < cols.length; i++) {
if (cols[parseInt(i.toString(), 10)].field === column.field) {
srcIdx = i;
break;
}
}
var col = this.parent.getColumnByUid(this.destElement.firstElementChild.getAttribute('e-mappinguid'));
Eif (col) {
for (var i = 0; i < cols.length; i++) {
if (cols[parseInt(i.toString(), 10)].field === col.field) {
destIndex = i;
break;
}
}
}
else {
for (var i = 0; i < cols.length; i++) {
if (cols[parseInt(i.toString(), 10)].headerText === this.destElement.innerText.trim()) {
destIndex = i;
}
}
}
}
if (!gObj.allowReordering || srcIdx === destIndex || srcIdx === -1 || destIndex === -1) {
return;
}
cols.splice(destIndex, 0, cols.splice(srcIdx, 1)[0]);
var args = { column: column, destIndex: destIndex, columns: cols, parent: parent, cancel: false };
gObj.notify(events.refreshFrozenColumns, args);
Iif (args.cancel) {
return;
}
if (this.parent.isFrozenGrid()) {
if (this.parent.frozenColumns) {
for (var i = 0; i < cols.length; i++) {
if (cols[parseInt(i.toString(), 10)].freeze === 'Left') {
cols[parseInt(i.toString(), 10)].freeze = undefined;
}
}
}
else if (!(parent && parent.columns)) {
Iif (this.parent.getFrozenLeftCount() > destIndex) {
column.freeze = 'Left';
}
else Iif ((cols.length - this.parent.getFrozenRightColumnsCount()) <= destIndex) {
column.freeze = 'Right';
}
else {
column.freeze = column.freeze === 'Fixed' ? 'Fixed' : undefined;
}
}
}
gObj.getColumns(true);
gObj.preventAutoFit = true;
gObj.notify(events.columnPositionChanged, { fromIndex: destIndex, toIndex: srcIdx });
Eif (preventRefresh !== false) {
gObj.notify(events.modelChanged, {
type: events.actionBegin, requestType: 'reorder', fromIndex: destIndex, toIndex: srcIdx, toColumnUid: column.uid
});
}
if (this.parent.isFrozenGrid()) {
var cols_1 = this.parent.columns;
this.idx = 0;
this.refreshColumnIndex(cols_1);
this.parent.notify(events.refreshFrozenPosition, {});
}
};
Reorder.prototype.refreshColumnIndex = function (cols) {
for (var i = 0; i < cols.length; i++) {
cols[parseInt(i.toString(), 10)].index = this.idx;
this.idx++;
if (cols[parseInt(i.toString(), 10)].columns && cols[parseInt(i.toString(), 10)].columns.length) {
this.refreshColumnIndex(cols[parseInt(i.toString(), 10)].columns);
}
}
};
Reorder.prototype.targetParentContainerIndex = function (srcElem, destElem) {
var cols = this.parent.columns;
var headers = this.getHeaderCells();
var stackedHdrColumn = this.parent.getStackedColumns(cols);
var stackedCols = [];
if (stackedHdrColumn.length) {
stackedCols = this.getAllStackedheaderParentColumns(headers);
}
var flatColumns = stackedHdrColumn.length && stackedCols.length ?
this.getColumnsModel(stackedCols) : this.getColumnsModel(cols, true);
var parent = this.getColParent(flatColumns[util_1.getElementIndex(srcElem, headers)], cols);
cols = parent ? parent.columns : cols;
return util_1.inArray(flatColumns[util_1.getElementIndex(destElem, headers)], cols);
};
Reorder.prototype.getAllStackedheaderParentColumns = function (headers) {
var stackedCols = [];
for (var i = 0; i < headers.length; i++) {
if (headers[parseInt(i.toString(), 10)].classList.contains('e-hide')) {
headers.splice(i, 1);
i--;
}
else if (headers[parseInt(i.toString(), 10)].closest('thead').firstChild === headers[parseInt(i.toString(), 10)].parentElement) {
stackedCols.push(this.parent.getColumnByUid(headers[parseInt(i.toString(), 10)].firstElementChild.getAttribute('e-mappinguid')));
}
}
return stackedCols;
};
Reorder.prototype.getHeaderCells = function () {
return [].slice.call(this.parent.element.getElementsByClassName('e-headercell'));
};
Reorder.prototype.getColParent = function (column, columns) {
var parents = [];
this.findColParent(column, columns, parents);
return parents[parents.length - 1];
};
Reorder.prototype.reorderSingleColumn = function (fromFName, toFName) {
var fColumn = this.parent.enableColumnVirtualization ?
this.parent.columns.filter(function (col) { return col.field === fromFName; })[0]
: this.parent.getColumnByField(fromFName);
var toColumn = this.parent.enableColumnVirtualization ?
this.parent.columns.filter(function (col) { return col.field === toFName; })[0]
: this.parent.getColumnByField(toFName);
if ((!ej2_base_1.isNullOrUndefined(fColumn) && (!fColumn.allowReordering || fColumn.lockColumn)) ||
(!ej2_base_1.isNullOrUndefined(toColumn) && (!toColumn.allowReordering || toColumn.lockColumn))) {
this.parent.log('action_disabled_column', { moduleName: this.getModuleName(), column: fColumn, destColumn: toColumn });
return;
}
var column = toColumn;
var parent = this.getColParent(column, this.parent.columns);
var columns = parent ? parent.columns : this.parent.columns;
var destIndex = util_1.inArray(column, columns);
if (destIndex > -1) {
this.moveColumns(destIndex, fColumn, true);
}
};
Reorder.prototype.reorderMultipleColumns = function (fromFNames, toFName) {
var toIndex = this.parent.getColumnIndexByField(toFName);
var toColumn = this.parent.getColumnByField(toFName);
if (toIndex < 0 || (!ej2_base_1.isNullOrUndefined(toColumn) && (!toColumn.allowReordering || toColumn.lockColumn))) {
return;
}
for (var i = 0; i < fromFNames.length; i++) {
var column = this.parent.getColumnByField(fromFNames[parseInt(i.toString(), 10)]);
Iif (!ej2_base_1.isNullOrUndefined(column) && (!column.allowReordering || column.lockColumn)) {
return;
}
}
for (var i = 0; i < fromFNames.length; i++) {
var column = this.parent.getColumnByIndex(toIndex);
var parent_1 = this.getColParent(column, this.parent.columns);
var columns = parent_1 ? parent_1.columns : this.parent.columns;
var destIndex = util_1.inArray(column, columns);
Eif (destIndex > -1) {
this.moveColumns(destIndex, this.parent.getColumnByField(fromFNames[parseInt(i.toString(), 10)]), true, true);
}
if (this.parent.getColumnIndexByField(fromFNames[i + 1]) >= destIndex) {
toIndex++;
}
}
};
Reorder.prototype.moveTargetColumn = function (column, toIndex) {
if (toIndex > -1) {
this.moveColumns(toIndex, column, true);
}
};
Reorder.prototype.reorderSingleColumnByTarget = function (fieldName, toIndex) {
this.moveTargetColumn(this.parent.getColumnByField(fieldName), toIndex);
};
Reorder.prototype.reorderMultipleColumnByTarget = function (fieldName, toIndex) {
for (var i = 0; i < fieldName.length; i++) {
this.reorderSingleColumnByTarget(fieldName[parseInt(i.toString(), 10)], toIndex);
}
};
Reorder.prototype.reorderColumns = function (fromFName, toFName) {
if (typeof fromFName === 'string') {
this.reorderSingleColumn(fromFName, toFName);
this.fromCol = fromFName;
}
else {
this.reorderMultipleColumns(fromFName, toFName);
this.fromCol = fromFName[0];
}
};
Reorder.prototype.reorderColumnByIndex = function (fromIndex, toIndex) {
this.moveTargetColumn(this.parent.getColumnByIndex(fromIndex), toIndex);
};
Reorder.prototype.reorderColumnByTargetIndex = function (fieldName, toIndex) {
if (typeof fieldName === 'string') {
this.reorderSingleColumnByTarget(fieldName, toIndex);
}
else {
this.reorderMultipleColumnByTarget(fieldName, toIndex);
}
};
Reorder.prototype.enableAfterRender = function (e) {
if (e.module === this.getModuleName() && e.enable) {
this.createReorderElement();
}
};
Reorder.prototype.createReorderElement = function (e) {
if (e && e.args && e.args.isXaxis) {
this.setDisplay('none');
}
var header = this.parent.element.querySelector('.' + literals.headerContent);
this.upArrow = header.appendChild(this.parent
.createElement('div', { className: 'e-icons e-icon-reorderuparrow e-reorderuparrow', attrs: { style: 'display:none' } }));
this.downArrow = header.appendChild(this.parent
.createElement('div', { className: 'e-icons e-icon-reorderdownarrow e-reorderdownarrow', attrs: { style: 'display:none' } }));
};
Reorder.prototype.onActionComplete = function (e) {
this.parent.preventAutoFit = false;
this.parent.trigger(events.actionComplete, ej2_base_1.extend(e, { type: events.actionComplete }));
var target = this.fromCol && this.parent.getColumnHeaderByField(this.fromCol);
if (target) {
this.parent.focusModule.onClick({ target: target }, true);
}
};
Reorder.prototype.destroy = function () {
var gridElement = this.parent.element;
if (this.parent.isDestroyed || !gridElement || (!gridElement.querySelector('.' + literals.gridHeader) &&
!gridElement.querySelector('.' + literals.gridContent))) {
return;
}
if (this.upArrow.parentNode) {
ej2_base_2.remove(this.upArrow);
}
if (this.downArrow.parentNode) {
ej2_base_2.remove(this.downArrow);
}
this.parent.off(events.headerDrop, this.headerDrop);
this.parent.off(events.uiUpdate, this.enableAfterRender);
this.parent.off(events.reorderComplete, this.onActionComplete);
this.parent.off(events.columnDrag, this.drag);
this.parent.off(events.columnDragStart, this.dragStart);
this.parent.off(events.columnDragStop, this.dragStop);
this.parent.off(events.headerRefreshed, this.createReorderElement);
this.parent.off(events.keyPressed, this.keyPressHandler);
this.parent.off(events.destroy, this.destroy);
};
Reorder.prototype.keyPressHandler = function (e) {
var gObj = this.parent;
var isMacLike = /(Mac)/i.test(navigator.platform);
Iif (isMacLike && e.metaKey) {
if (e.action === 'leftArrow') {
e.action = 'ctrlLeftArrow';
}
else if (e.action === 'rightArrow') {
e.action = 'ctrlRightArrow';
}
}
switch (e.action) {
case 'ctrlLeftArrow':
case 'ctrlRightArrow':
var element = gObj.focusModule.currentInfo.element;
if (element && element.classList.contains('e-headercell')) {
var column = gObj.getColumnByUid(element.firstElementChild.getAttribute('e-mappinguid'));
var visibleCols = gObj.getVisibleColumns();
var index = visibleCols.indexOf(column);
var toCol = e.action === 'ctrlLeftArrow' ? visibleCols[index - 1] : visibleCols[index + 1];
if (toCol && toCol.field && column.field) {
this.reorderColumns(column.field, toCol.field);
}
}
break;
}
};
Reorder.prototype.drag = function (e) {
var gObj = this.parent;
var target = e.target;
var closest = ej2_base_2.closest(target, '.e-headercell:not(.e-stackedHeaderCell)');
var cloneElement = gObj.element.querySelector('.e-cloneproperties');
var content = gObj.getContent().firstElementChild;
var isLeft = this.x > util_1.getPosition(e.event).x + content.scrollLeft;
ej2_base_2.removeClass([].slice.call(gObj.getHeaderTable().getElementsByClassName('e-reorderindicate')), ['e-reorderindicate']);
this.setDisplay('none');
this.stopTimer();
ej2_base_2.classList(cloneElement, ['e-defaultcur'], ['e-notallowedcur']);
this.updateScrollPostion(e.event);
Eif (closest && !closest.isEqualNode(this.element)) {
target = closest;
var uid = target.querySelector('.e-headercelldiv, .e-stackedheadercelldiv').getAttribute('e-mappinguid');
if (!(!this.chkDropPosition(this.element, target) || !this.chkDropAllCols(this.element, target)) &&
gObj.getColumnByUid(uid).allowReordering && e.column.allowReordering) {
this.updateArrowPosition(target, isLeft);
ej2_base_2.classList(target, ['e-allowDrop', 'e-reorderindicate'], []);
}
else Eif (!(gObj.allowGrouping && util_1.parentsUntil(e.target, 'e-groupdroparea'))) {
ej2_base_2.classList(cloneElement, ['e-notallowedcur'], ['e-defaultcur']);
}
}
else {
if (closest && closest.isEqualNode(this.element) &&
!((gObj.allowGrouping && e.column.allowGrouping) || e.column.allowReordering)) {
ej2_base_2.classList(cloneElement, ['e-notallowedcur'], ['e-defaultcur']);
}
else if (!closest && !(gObj.allowGrouping && util_1.parentsUntil(e.target, 'e-groupdroparea'))) {
ej2_base_2.classList(cloneElement, ['e-notallowedcur'], ['e-defaultcur']);
}
}
Iif (!e.column.allowReordering || e.column.lockColumn) {
return;
}
gObj.trigger(events.columnDrag, { target: target, draggableType: 'headercell', column: e.column });
};
Reorder.prototype.updateScrollPostion = function (e) {
var _this = this;
var x = util_1.getPosition(e).x;
var cliRect = this.parent.element.getBoundingClientRect();
var cliRectBaseRight = cliRect.right;
var cliRectBaseLeft = cliRect.left;
var scrollElem = this.parent.getContent().firstElementChild;
Eif (x > cliRectBaseLeft && x < cliRectBaseLeft + 35) {
this.timer = window.setInterval(function () { _this.setScrollLeft(scrollElem, true); }, 50);
}
else if (x < cliRectBaseRight && x > cliRectBaseRight - 35) {
this.timer = window.setInterval(function () { _this.setScrollLeft(scrollElem, false); }, 50);
}
};
Reorder.prototype.setScrollLeft = function (scrollElem, isLeft) {
var scrollLeft = scrollElem.scrollLeft;
scrollElem.scrollLeft = scrollElem.scrollLeft + (isLeft ? -5 : 5);
Iif (scrollLeft !== scrollElem.scrollLeft) {
this.setDisplay('none');
}
};
Reorder.prototype.stopTimer = function () {
window.clearInterval(this.timer);
};
Reorder.prototype.updateArrowPosition = function (target, isLeft) {
var cliRect = target.getBoundingClientRect();
var cliRectBase = this.parent.element.getBoundingClientRect();
Iif ((isLeft && cliRect.left < cliRectBase.left) || (!isLeft && cliRect.right > cliRectBase.right)) {
return;
}
var isSticky = this.parent.getHeaderContent().classList.contains('e-sticky');
this.upArrow.style.top = isSticky ? cliRect.top + cliRect.height + 'px' : cliRect.top + cliRect.height - cliRectBase.top + 'px';
this.downArrow.style.top = isSticky ? cliRect.top - 7 + 'px' : cliRect.top - cliRectBase.top - 7 + 'px';
this.upArrow.style.left = this.downArrow.style.left = isSticky ? (isLeft ? cliRect.left : cliRect.right) - 4 + 'px' :
(isLeft ? cliRect.left : cliRect.right) - cliRectBase.left - 4 + 'px';
this.setDisplay('');
};
Reorder.prototype.dragStart = function (e) {
var gObj = this.parent;
var target = e.target;
this.element = target.classList.contains('e-headercell') ? target :
util_1.parentsUntil(target, 'e-headercell');
if (!e.column.allowReordering || e.column.lockColumn) {
return;
}
var content = gObj.getContent().firstElementChild;
this.x = util_1.getPosition(e.event).x + content.scrollLeft;
gObj.trigger(events.columnDragStart, {
target: target, draggableType: 'headercell', column: e.column
});
};
Reorder.prototype.dragStop = function (e) {
var gObj = this.parent;
this.setDisplay('none');
this.stopTimer();
if (!e.cancel) {
gObj.trigger(events.columnDrop, { target: e.target, draggableType: 'headercell', column: e.column });
}
ej2_base_2.removeClass([].slice.call(gObj.getHeaderTable().getElementsByClassName('e-reorderindicate')), ['e-reorderindicate']);
};
Reorder.prototype.setDisplay = function (display) {
this.upArrow.style.display = display;
this.downArrow.style.display = display;
};
Reorder.prototype.getModuleName = function () {
return 'reorder';
};
return Reorder;
}());
exports.Reorder = Reorder;
});
|