handsontable 0.34.1 → 0.34.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (95) hide show
  1. package/.travis.yml +2 -0
  2. package/README.md +127 -96
  3. package/commonjs/core.js +11 -6
  4. package/commonjs/helpers/dom/element.js +4 -3
  5. package/commonjs/helpers/mixed.js +8 -4
  6. package/commonjs/index.js +5 -4
  7. package/commonjs/pluginHooks.js +18 -2
  8. package/commonjs/plugins/copyPaste/clipboardData.js +31 -0
  9. package/commonjs/plugins/copyPaste/contextMenuItem/copy.js +1 -2
  10. package/commonjs/plugins/copyPaste/contextMenuItem/cut.js +1 -2
  11. package/commonjs/plugins/copyPaste/copyPaste.js +127 -134
  12. package/commonjs/plugins/copyPaste/pasteEvent.js +19 -0
  13. package/commonjs/plugins/copyPaste/test/copyPaste.e2e.js +90 -189
  14. package/commonjs/plugins/copyPaste/test/textarea.unit.js +2 -2
  15. package/commonjs/plugins/copyPaste/textarea.js +2 -1
  16. package/commonjs/plugins/manualColumnMove/manualColumnMove.js +8 -11
  17. package/commonjs/plugins/manualColumnMove/test/manualColumnMoveUI.e2e.js +35 -0
  18. package/commonjs/plugins/manualRowMove/manualRowMove.js +9 -12
  19. package/commonjs/plugins/manualRowMove/test/manualRowMove.e2e.js +256 -60
  20. package/commonjs/plugins/manualRowMove/test/manualRowMoveUI.e2e.js +40 -182
  21. package/commonjs/plugins/manualRowMove/ui/_base.js +2 -2
  22. package/commonjs/tableView.js +1 -0
  23. package/dist/handsontable.css +6 -5
  24. package/dist/handsontable.css.map +1 -1
  25. package/dist/handsontable.full.css +6 -5
  26. package/dist/handsontable.full.js +37721 -42290
  27. package/dist/handsontable.full.min.css +4 -4
  28. package/dist/handsontable.full.min.js +5 -5
  29. package/dist/handsontable.js +28732 -28433
  30. package/dist/handsontable.js.map +1 -1
  31. package/dist/handsontable.min.css +4 -4
  32. package/dist/handsontable.min.js +3 -3
  33. package/es/core.js +11 -6
  34. package/es/helpers/dom/element.js +4 -3
  35. package/es/helpers/mixed.js +4 -4
  36. package/es/index.js +3 -4
  37. package/es/pluginHooks.js +18 -2
  38. package/es/plugins/copyPaste/clipboardData.js +27 -0
  39. package/es/plugins/copyPaste/contextMenuItem/copy.js +1 -2
  40. package/es/plugins/copyPaste/contextMenuItem/cut.js +1 -2
  41. package/es/plugins/copyPaste/copyPaste.js +124 -132
  42. package/es/plugins/copyPaste/pasteEvent.js +11 -0
  43. package/es/plugins/copyPaste/test/copyPaste.e2e.js +90 -189
  44. package/es/plugins/copyPaste/test/textarea.unit.js +2 -2
  45. package/es/plugins/copyPaste/textarea.js +2 -1
  46. package/es/plugins/manualColumnMove/manualColumnMove.js +8 -11
  47. package/es/plugins/manualColumnMove/test/manualColumnMoveUI.e2e.js +35 -0
  48. package/es/plugins/manualRowMove/manualRowMove.js +9 -12
  49. package/es/plugins/manualRowMove/test/manualRowMove.e2e.js +256 -60
  50. package/es/plugins/manualRowMove/test/manualRowMoveUI.e2e.js +40 -182
  51. package/es/plugins/manualRowMove/ui/_base.js +2 -2
  52. package/es/tableView.js +1 -0
  53. package/handsontable.jquery.json +1 -1
  54. package/hot.config.js +1 -1
  55. package/package.json +5 -5
  56. package/src/3rdparty/walkontable/dist/walkontable.js +27234 -11175
  57. package/src/3rdparty/walkontable/dist/walkontable.js.map +1 -1
  58. package/src/3rdparty/walkontable/test/dist/helpers.entry.js +32 -36
  59. package/src/3rdparty/walkontable/test/dist/helpers.entry.js.map +1 -1
  60. package/src/3rdparty/walkontable/test/dist/specs.entry.js +36 -39
  61. package/src/3rdparty/walkontable/test/dist/specs.entry.js.map +1 -1
  62. package/src/core.js +11 -6
  63. package/src/css/handsontable.css +1 -2
  64. package/src/helpers/dom/element.js +4 -3
  65. package/src/helpers/mixed.js +3 -3
  66. package/src/index.js +1 -2
  67. package/src/pluginHooks.js +18 -2
  68. package/src/plugins/copyPaste/clipboardData.js +11 -0
  69. package/src/plugins/copyPaste/contextMenuItem/copy.js +1 -2
  70. package/src/plugins/copyPaste/contextMenuItem/cut.js +1 -2
  71. package/src/plugins/copyPaste/copyPaste.css +3 -1
  72. package/src/plugins/copyPaste/copyPaste.js +120 -127
  73. package/src/plugins/copyPaste/pasteEvent.js +7 -0
  74. package/src/plugins/copyPaste/test/copyPaste.e2e.js +75 -193
  75. package/src/plugins/copyPaste/test/textarea.unit.js +2 -2
  76. package/src/plugins/copyPaste/textarea.js +2 -1
  77. package/src/plugins/manualColumnMove/manualColumnMove.js +6 -9
  78. package/src/plugins/manualColumnMove/test/manualColumnMoveUI.e2e.js +35 -0
  79. package/src/plugins/manualRowMove/manualRowMove.js +7 -10
  80. package/src/plugins/manualRowMove/test/manualRowMove.e2e.js +282 -86
  81. package/src/plugins/manualRowMove/test/manualRowMoveUI.e2e.js +51 -190
  82. package/src/plugins/manualRowMove/ui/_base.js +2 -2
  83. package/test/dist/e2e.entry.js +31381 -31131
  84. package/test/dist/e2e.entry.js.map +1 -1
  85. package/test/dist/helpers.entry.js +16 -19
  86. package/test/dist/helpers.entry.js.map +1 -1
  87. package/test/e2e/Core_listen.spec.js +32 -0
  88. package/test/e2e/Core_selection.spec.js +1 -1
  89. package/test/e2e/Core_validate.spec.js +29 -0
  90. package/test/e2e/renderers/checkboxRenderer.spec.js +20 -7
  91. package/test/e2e/settings/fragmentSelection.spec.js +12 -9
  92. package/test/scripts/trigger-pro-tests.sh +41 -0
  93. package/yarn.lock +260 -208
  94. package/.npmignore +0 -19
  95. package/demo/bower_components/numbro/package.json +0 -63
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
+
3
5
  function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
4
6
 
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+
5
9
  describe('CopyPaste', function () {
6
10
  var id = 'testContainer';
7
11
 
@@ -16,6 +20,37 @@ describe('CopyPaste', function () {
16
20
  }
17
21
  });
18
22
 
23
+ var DataTransferObject = function () {
24
+ function DataTransferObject() {
25
+ _classCallCheck(this, DataTransferObject);
26
+
27
+ this.data = '';
28
+ }
29
+
30
+ _createClass(DataTransferObject, [{
31
+ key: 'getData',
32
+ value: function getData() {
33
+ return this.data;
34
+ }
35
+ }, {
36
+ key: 'setData',
37
+ value: function setData(type, value) {
38
+ this.data = value;
39
+ }
40
+ }]);
41
+
42
+ return DataTransferObject;
43
+ }();
44
+
45
+ ;
46
+
47
+ function getClipboardEvent() {
48
+ var event = {};
49
+ event.clipboardData = new DataTransferObject();
50
+ event.preventDefault = function () {};
51
+ return event;
52
+ }
53
+
19
54
  var arrayOfArrays = function arrayOfArrays() {
20
55
  return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
21
56
  };
@@ -80,67 +115,7 @@ describe('CopyPaste', function () {
80
115
  });
81
116
  });
82
117
 
83
- describe('setting values copyable', function () {
84
- it('should set copyable text when selecting a single cell and hitting ctrl', function () {
85
- handsontable({
86
- data: Handsontable.helper.createSpreadsheetData(2, 2)
87
- });
88
-
89
- var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
90
-
91
- expect(copyPasteTextarea.value.length).toEqual(0);
92
-
93
- selectCell(0, 0);
94
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
95
-
96
- expect(copyPasteTextarea.value).toEqual('A1');
97
- });
98
-
99
- it('should set copyable text when selecting a single cell and hitting left command', function () {
100
- handsontable({
101
- data: Handsontable.helper.createSpreadsheetData(2, 2)
102
- });
103
-
104
- var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
105
-
106
- expect(copyPasteTextarea.value.length).toEqual(0);
107
-
108
- selectCell(0, 0);
109
- keyDownUp(Handsontable.helper.KEY_CODES.COMMAND_LEFT);
110
-
111
- expect(copyPasteTextarea.value).toEqual('A1');
112
- });
113
-
114
- it('should set copyable text when selecting a single cell and hitting right command', function () {
115
- handsontable({
116
- data: Handsontable.helper.createSpreadsheetData(2, 2)
117
- });
118
-
119
- var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
120
-
121
- expect(copyPasteTextarea.value.length).toEqual(0);
122
-
123
- selectCell(0, 0);
124
- keyDownUp(Handsontable.helper.KEY_CODES.COMMAND_RIGHT);
125
-
126
- expect(copyPasteTextarea.value).toEqual('A1');
127
- });
128
-
129
- it('should set copyable text when selecting multiple cells and hitting ctrl', function () {
130
- handsontable({
131
- data: Handsontable.helper.createSpreadsheetData(2, 2)
132
- });
133
-
134
- var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
135
-
136
- expect(copyPasteTextarea.value.length).toEqual(0);
137
-
138
- selectCell(0, 0, 1, 0);
139
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
140
-
141
- expect(copyPasteTextarea.value).toEqual('A1\nA2');
142
- });
143
-
118
+ xdescribe('setting values copyable', function () {
144
119
  it('should set copyable text when selecting all cells with CTRL+A', function (done) {
145
120
  handsontable({
146
121
  data: Handsontable.helper.createSpreadsheetData(2, 2)
@@ -161,24 +136,6 @@ describe('CopyPaste', function () {
161
136
  }, 10);
162
137
  });
163
138
 
164
- it('should not throw error when no cell is selected (#1221)', function () {
165
- handsontable({
166
- data: Handsontable.helper.createSpreadsheetData(2, 2)
167
- });
168
-
169
- selectCell(0, 0);
170
- deselectCell();
171
-
172
- function keydownCtrl() {
173
- $(document).simulate('keydown', {
174
- keyCode: Handsontable.helper.KEY_CODES.COMMAND_LEFT
175
- });
176
- }
177
-
178
- // expect no to throw any exception
179
- expect(keydownCtrl).not.toThrow();
180
- });
181
-
182
139
  it('should not throw error when no cell is selected and contextmenu options was clicked', function () {
183
140
  // This is ugly trick to check problematic thing (#4390).
184
141
  // Unfortunately we cannot open the context menu, when event.target is not an TD element.
@@ -209,22 +166,6 @@ describe('CopyPaste', function () {
209
166
  expect(copyPasteTextarea.value).toEqual('A\t1\nB\t2');
210
167
  });
211
168
 
212
- it('should set copyable text when selecting a single cell with editor type as false (#2574)', function () {
213
- handsontable({
214
- data: [['A', 1], ['B', 2]],
215
- columns: [{ type: 'text' }, { editor: false }]
216
- });
217
-
218
- var copyPasteTextarea = $('#HandsontableCopyPaste')[0];
219
-
220
- expect(copyPasteTextarea.value.length).toEqual(0);
221
-
222
- selectCell(1, 1, 1, 1);
223
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
224
-
225
- expect(copyPasteTextarea.value).toEqual('2');
226
- });
227
-
228
169
  it('should set copyable text until copyRowsLimit is reached', function () {
229
170
  handsontable({
230
171
  data: arrayOfArrays(),
@@ -276,67 +217,46 @@ describe('CopyPaste', function () {
276
217
  });
277
218
 
278
219
  describe('copy', function () {
279
- it('should be possible to copy data by keyboard shortcut', function () {
280
- handsontable({
281
- data: Handsontable.helper.createSpreadsheetData(2, 2)
282
- });
283
-
284
- selectCell(1, 1);
285
- keyDown('ctrl');
286
- keyDown('ctrl+c');
220
+ xit('should be possible to copy data by keyboard shortcut', function () {
221
+ // simulated keyboard shortcuts doesn't run the true events
222
+ });
287
223
 
288
- expect($('#HandsontableCopyPaste')[0]).toBe(document.activeElement);
289
- // unfortunately we have not access to read data from the system clipboard
224
+ xit('should be possible to copy data by contextMenu option', function () {
225
+ // simulated mouse events doesn't run the true browser event
290
226
  });
291
227
 
292
228
  it('should be possible to copy data by API', function () {
293
229
  var hot = handsontable({
294
230
  data: Handsontable.helper.createSpreadsheetData(2, 2)
295
231
  });
232
+ var copyEvent = getClipboardEvent('copy');
233
+ var plugin = hot.getPlugin('CopyPaste');
296
234
 
297
235
  selectCell(1, 0);
298
236
 
299
- hot.getPlugin('CopyPaste').setCopyableText();
300
- // below line is cause of console warning in FF about execCommand
301
- hot.getPlugin('CopyPaste').copy(true);
302
-
303
- expect($('#HandsontableCopyPaste')[0]).toBe(document.activeElement);
304
- // unfortunately we have not access to read data from the system clipboard
305
- });
306
-
307
- it('should be possible to copy data by contextMenu option', function () {
308
- var beforeCopySpy = jasmine.createSpy('beforeCopy');
309
-
310
- handsontable({
311
- data: Handsontable.helper.createSpreadsheetData(2, 2),
312
- beforeCopy: beforeCopySpy,
313
- contextMenu: ['copy']
314
- });
315
-
316
- selectCell(0, 1);
317
- contextMenu();
318
-
319
- var items = $('.htContextMenu tbody td');
320
- var actions = items.not('.htSeparator');
321
-
322
- actions.simulate('mousedown');
237
+ plugin.setCopyableText();
238
+ plugin.onCopy(copyEvent);
323
239
 
324
- expect(beforeCopySpy).toHaveBeenCalledTimes(1);
240
+ expect(copyEvent.clipboardData.getData()).toBe('A2');
325
241
  });
326
242
 
327
243
  it('should call beforeCopy and afterCopy during copying operation', function () {
328
244
  var beforeCopySpy = jasmine.createSpy('beforeCopy');
329
245
  var afterCopySpy = jasmine.createSpy('afterCopy');
330
246
 
331
- handsontable({
247
+ var hot = handsontable({
332
248
  data: Handsontable.helper.createSpreadsheetData(2, 2),
333
249
  beforeCopy: beforeCopySpy,
334
250
  afterCopy: afterCopySpy
335
251
  });
336
252
 
253
+ var copyEvent = getClipboardEvent('copy');
254
+ var plugin = hot.getPlugin('CopyPaste');
255
+
337
256
  selectCell(0, 0);
338
- keyDown('ctrl');
339
- keyDown('ctrl+c');
257
+
258
+ plugin.setCopyableText();
259
+ plugin.onCopy(copyEvent);
340
260
 
341
261
  expect(beforeCopySpy.calls.count()).toEqual(1);
342
262
  expect(beforeCopySpy).toHaveBeenCalledWith([['A1']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
@@ -345,112 +265,93 @@ describe('CopyPaste', function () {
345
265
  });
346
266
 
347
267
  it('should be possible to block copying', function () {
268
+ var beforeCopySpy = jasmine.createSpy('beforeCopy');
348
269
  var afterCopySpy = jasmine.createSpy('afterCopy');
349
270
 
350
- handsontable({
271
+ var hot = handsontable({
351
272
  data: Handsontable.helper.createSpreadsheetData(2, 2),
352
273
  beforeCopy: function beforeCopy() {
274
+ beforeCopySpy();
353
275
  return false;
354
276
  },
355
277
 
356
278
  afterCopy: afterCopySpy
357
279
  });
358
280
 
281
+ var copyEvent = getClipboardEvent('copy');
282
+ var plugin = hot.getPlugin('CopyPaste');
283
+
359
284
  selectCell(0, 0);
360
- keyDown('ctrl');
361
- keyDown('ctrl+c');
362
285
 
286
+ plugin.setCopyableText();
287
+ plugin.onCopy(copyEvent);
288
+
289
+ expect(beforeCopySpy.calls.count()).toEqual(1);
363
290
  expect(afterCopySpy.calls.count()).toEqual(0);
364
291
  });
365
292
 
366
- it('should be possible modification of changes during copying', _asyncToGenerator(function* () {
367
- handsontable({
293
+ it('should be possible modification of changes during copying', function () {
294
+ var hot = handsontable({
368
295
  data: Handsontable.helper.createSpreadsheetData(2, 2),
369
296
  beforeCopy: function beforeCopy(changes) {
370
297
  changes.splice(0, 1);
371
298
  }
372
299
  });
373
300
 
301
+ var copyEvent = getClipboardEvent('copy');
302
+ var plugin = hot.getPlugin('CopyPaste');
374
303
  selectCell(0, 0, 1, 0);
375
- keyDown('ctrl');
376
- keyDown('ctrl+c');
377
304
 
378
- yield sleep(60);
305
+ plugin.setCopyableText();
306
+ plugin.onCopy(copyEvent);
379
307
 
380
- expect($('#HandsontableCopyPaste')[0].value).toEqual('A2');
381
- }));
308
+ expect(copyEvent.clipboardData.getData()).toEqual('A2');
309
+ });
382
310
  });
383
311
 
384
312
  describe('cut', function () {
385
- it('should be possible to cut data by keyboard shortcut', _asyncToGenerator(function* () {
386
- var hot = handsontable({
387
- data: Handsontable.helper.createSpreadsheetData(2, 2)
388
- });
389
-
390
- selectCell(1, 1);
391
- keyDown('ctrl');
392
- keyDown('ctrl+x');
393
-
394
- expect($('#HandsontableCopyPaste')[0]).toBe(document.activeElement);
395
-
396
- yield sleep(100);
313
+ xit('should be possible to cut data by keyboard shortcut', function () {
314
+ // simulated keyboard shortcuts doesn't run the true events
315
+ });
397
316
 
398
- expect(hot.getDataAtCell(1, 1)).toBe('');
399
- // unfortunately we have not access to read data from the system clipboard
400
- }));
317
+ xit('should be possible to cut data by contextMenu option', function () {
318
+ // simulated mouse events doesn't run the true browser event
319
+ });
401
320
 
402
- it('should be possible to cut data by API', _asyncToGenerator(function* () {
321
+ it('should be possible to cut data by API', function () {
403
322
  var hot = handsontable({
404
323
  data: Handsontable.helper.createSpreadsheetData(2, 2)
405
324
  });
325
+ var cutEvent = getClipboardEvent('cut');
326
+ var plugin = hot.getPlugin('CopyPaste');
406
327
 
407
328
  selectCell(1, 0);
408
329
 
409
- hot.getPlugin('CopyPaste').setCopyableText();
410
- // below line is cause of console warning in FF about execCommand
411
- hot.getPlugin('CopyPaste').cut(true);
330
+ plugin.setCopyableText();
331
+ plugin.onCut(cutEvent);
412
332
 
413
- expect($('#HandsontableCopyPaste')[0]).toBe(document.activeElement);
414
-
415
- yield sleep(100);
333
+ expect(cutEvent.clipboardData.getData()).toBe('A2');
416
334
 
335
+ // await sleep(100);
417
336
  expect(hot.getDataAtCell(1, 0)).toBe('');
418
- // unfortunately we have not access to read data from the system clipboard
419
- }));
420
-
421
- it('should be possible to cut data by contextMenu option', function () {
422
- var beforeCutSpy = jasmine.createSpy('beforeCopy');
423
-
424
- handsontable({
425
- data: Handsontable.helper.createSpreadsheetData(2, 2),
426
- beforeCut: beforeCutSpy,
427
- contextMenu: ['cut']
428
- });
429
-
430
- selectCell(0, 1);
431
- contextMenu();
432
-
433
- var items = $('.htContextMenu tbody td');
434
- var actions = items.not('.htSeparator');
435
-
436
- actions.simulate('mousedown');
437
-
438
- expect(beforeCutSpy).toHaveBeenCalledTimes(1);
439
337
  });
440
338
 
441
339
  it('should call beforeCut and afterCut during cutting out operation', function () {
442
340
  var beforeCutSpy = jasmine.createSpy('beforeCut');
443
341
  var afterCutSpy = jasmine.createSpy('afterCut');
444
342
 
445
- handsontable({
343
+ var hot = handsontable({
446
344
  data: Handsontable.helper.createSpreadsheetData(2, 2),
447
345
  beforeCut: beforeCutSpy,
448
346
  afterCut: afterCutSpy
449
347
  });
348
+ var cutEvent = getClipboardEvent('cut');
349
+ var plugin = hot.getPlugin('CopyPaste');
450
350
 
451
351
  selectCell(0, 0);
452
- keyDown('ctrl');
453
- keyDown('ctrl+x');
352
+
353
+ plugin.setCopyableText();
354
+ plugin.onCut(cutEvent);
454
355
 
455
356
  expect(beforeCutSpy.calls.count()).toEqual(1);
456
357
  expect(beforeCutSpy).toHaveBeenCalledWith([['A1']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
@@ -62,7 +62,7 @@ describe('CopyPaste', function () {
62
62
  var textarea = _textarea2.default.getSingleton();
63
63
  var newValue = 'zxcvb';
64
64
 
65
- expect(textarea.element.value.length).toBe(0);
65
+ expect(textarea.element.value.length).toBe(1);
66
66
 
67
67
  textarea.setValue(newValue);
68
68
 
@@ -75,7 +75,7 @@ describe('CopyPaste', function () {
75
75
  var textarea = _textarea2.default.getSingleton();
76
76
  var newValue = 'zxcvb';
77
77
 
78
- expect(textarea.getValue().length).toBe(0);
78
+ expect(textarea.getValue().length).toBe(1);
79
79
 
80
80
  textarea.setValue(newValue);
81
81
 
@@ -78,7 +78,8 @@ var Textarea = function () {
78
78
  this.element.className = 'copyPaste';
79
79
  this.element.tabIndex = -1;
80
80
  this.element.autocomplete = 'off';
81
- this.element.wrap = 'off';
81
+ this.element.wrap = 'hard';
82
+ this.element.value = ' ';
82
83
  }
83
84
 
84
85
  /**
@@ -177,14 +177,14 @@ var ManualColumnMove = function (_BasePlugin) {
177
177
  this.addHook('beforeRemoveCol', function (index, amount) {
178
178
  return _this2.onBeforeRemoveCol(index, amount);
179
179
  });
180
- this.addHook('afterRemoveCol', function (index, amount) {
181
- return _this2.onAfterRemoveCol(index, amount);
180
+ this.addHook('afterRemoveCol', function () {
181
+ return _this2.onAfterRemoveCol();
182
182
  });
183
183
  this.addHook('afterCreateCol', function (index, amount) {
184
184
  return _this2.onAfterCreateCol(index, amount);
185
185
  });
186
- this.addHook('afterLoadData', function (firstTime) {
187
- return _this2.onAfterLoadData(firstTime);
186
+ this.addHook('afterLoadData', function () {
187
+ return _this2.onAfterLoadData();
188
188
  });
189
189
  this.addHook('unmodifyCol', function (column) {
190
190
  return _this2.onUnmodifyCol(column);
@@ -324,7 +324,7 @@ var ManualColumnMove = function (_BasePlugin) {
324
324
  var columnWidth = 0;
325
325
 
326
326
  if (i < 0) {
327
- columnWidth = this.hot.view.wt.wtTable.getColumnWidth(i) || 0;
327
+ columnWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth() || 0;
328
328
  } else {
329
329
  columnWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(i) || 0;
330
330
  }
@@ -530,7 +530,7 @@ var ManualColumnMove = function (_BasePlugin) {
530
530
  var maxIndex = countCols - 1;
531
531
  var columnsToRemove = [];
532
532
 
533
- (0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index, array) {
533
+ (0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index) {
534
534
  if (value > maxIndex) {
535
535
  columnsToRemove.push(index);
536
536
  }
@@ -805,13 +805,11 @@ var ManualColumnMove = function (_BasePlugin) {
805
805
  * `afterRemoveCol` hook callback.
806
806
  *
807
807
  * @private
808
- * @param {Number} index Visual column index of the removed column.
809
- * @param {Number} amount Amount of removed columns.
810
808
  */
811
809
 
812
810
  }, {
813
811
  key: 'onAfterRemoveCol',
814
- value: function onAfterRemoveCol(index, amount) {
812
+ value: function onAfterRemoveCol() {
815
813
  this.columnsMapper.unshiftItems(this.removedColumns);
816
814
  }
817
815
 
@@ -819,12 +817,11 @@ var ManualColumnMove = function (_BasePlugin) {
819
817
  * `afterLoadData` hook callback.
820
818
  *
821
819
  * @private
822
- * @param {Boolean} firstTime True if that was loading data during the initialization.
823
820
  */
824
821
 
825
822
  }, {
826
823
  key: 'onAfterLoadData',
827
- value: function onAfterLoadData(firstTime) {
824
+ value: function onAfterLoadData() {
828
825
  this.updateColumnsMapper();
829
826
  }
830
827
 
@@ -104,6 +104,41 @@ describe('manualColumnMove', function () {
104
104
  expect(this.$container.find('.ht__manualColumnMove--backlight')[0].offsetWidth).toBe($headerTH[0].offsetWidth);
105
105
  });
106
106
 
107
+ it('should set proper left position of the backlight element when colWidths is undefined', function () {
108
+ handsontable({
109
+ data: Handsontable.helper.createSpreadsheetData(10, 10),
110
+ manualColumnMove: true,
111
+ rowHeaders: true,
112
+ colHeaders: true
113
+ });
114
+
115
+ var header = spec().$container.find('thead tr:eq(0) th:eq(2)');
116
+
117
+ header.simulate('mousedown');
118
+ header.simulate('mouseup');
119
+ header.simulate('mousedown');
120
+
121
+ expect(spec().$container.find('.ht__manualColumnMove--backlight')[0].offsetLeft).toBe(100);
122
+ });
123
+
124
+ it('should set proper left position of the backlight element when colWidths is defined', function () {
125
+ handsontable({
126
+ data: Handsontable.helper.createSpreadsheetData(10, 10),
127
+ manualColumnMove: true,
128
+ rowHeaders: true,
129
+ colWidths: 100,
130
+ colHeaders: true
131
+ });
132
+
133
+ var header = spec().$container.find('thead tr:eq(0) th:eq(2)');
134
+
135
+ header.simulate('mousedown');
136
+ header.simulate('mouseup');
137
+ header.simulate('mousedown');
138
+
139
+ expect(spec().$container.find('.ht__manualColumnMove--backlight')[0].offsetLeft).toBe(150);
140
+ });
141
+
107
142
  it('should not run moving ui if mousedown was fired on sorting element', function () {
108
143
  var hot = handsontable({
109
144
  data: arrayOfArrays.slice(),
@@ -175,14 +175,14 @@ var ManualRowMove = function (_BasePlugin) {
175
175
  this.addHook('beforeRemoveRow', function (index, amount) {
176
176
  return _this2.onBeforeRemoveRow(index, amount);
177
177
  });
178
- this.addHook('afterRemoveRow', function (index, amount) {
179
- return _this2.onAfterRemoveRow(index, amount);
178
+ this.addHook('afterRemoveRow', function () {
179
+ return _this2.onAfterRemoveRow();
180
180
  });
181
181
  this.addHook('afterCreateRow', function (index, amount) {
182
182
  return _this2.onAfterCreateRow(index, amount);
183
183
  });
184
- this.addHook('afterLoadData', function (firstTime) {
185
- return _this2.onAfterLoadData(firstTime);
184
+ this.addHook('afterLoadData', function () {
185
+ return _this2.onAfterLoadData();
186
186
  });
187
187
  this.addHook('beforeColumnSort', function (column, order) {
188
188
  return _this2.onBeforeColumnSort(column, order);
@@ -545,7 +545,7 @@ var ManualRowMove = function (_BasePlugin) {
545
545
  var maxIndex = countRows - 1;
546
546
  var rowsToRemove = [];
547
547
 
548
- (0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index, array) {
548
+ (0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index) {
549
549
  if (value > maxIndex) {
550
550
  rowsToRemove.push(index);
551
551
  }
@@ -649,7 +649,7 @@ var ManualRowMove = function (_BasePlugin) {
649
649
  priv.target.TD = TD;
650
650
  priv.rowsToMove = this.prepareRowsToMoving();
651
651
 
652
- var leftPos = wtTable.holder.scrollLeft + wtTable.getColumnWidth(-1);
652
+ var leftPos = wtTable.holder.scrollLeft + this.hot.view.wt.wtViewport.getRowHeaderWidth();
653
653
 
654
654
  this.backlight.setPosition(null, leftPos);
655
655
  this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end + 1));
@@ -778,7 +778,7 @@ var ManualRowMove = function (_BasePlugin) {
778
778
  key: 'onAfterScrollHorizontally',
779
779
  value: function onAfterScrollHorizontally() {
780
780
  var wtTable = this.hot.view.wt.wtTable;
781
- var headerWidth = wtTable.getColumnWidth(-1);
781
+ var headerWidth = this.hot.view.wt.wtViewport.getRowHeaderWidth();
782
782
  var scrollLeft = wtTable.holder.scrollLeft;
783
783
  var posLeft = headerWidth + scrollLeft;
784
784
 
@@ -827,13 +827,11 @@ var ManualRowMove = function (_BasePlugin) {
827
827
  * `afterRemoveRow` hook callback.
828
828
  *
829
829
  * @private
830
- * @param {Number} index Visual index of the removed row.
831
- * @param {Number} amount Amount of removed rows.
832
830
  */
833
831
 
834
832
  }, {
835
833
  key: 'onAfterRemoveRow',
836
- value: function onAfterRemoveRow(index, amount) {
834
+ value: function onAfterRemoveRow() {
837
835
  this.rowsMapper.unshiftItems(this.removedRows);
838
836
  }
839
837
 
@@ -841,12 +839,11 @@ var ManualRowMove = function (_BasePlugin) {
841
839
  * `afterLoadData` hook callback.
842
840
  *
843
841
  * @private
844
- * @param {Boolean} firstTime True if that was loading data during the initialization.
845
842
  */
846
843
 
847
844
  }, {
848
845
  key: 'onAfterLoadData',
849
- value: function onAfterLoadData(firstTime) {
846
+ value: function onAfterLoadData() {
850
847
  this.updateRowsMapper();
851
848
  }
852
849