@refinitiv-ui/efx-grid 6.0.96 → 6.0.98

Sign up to get free protection for your applications and to get access to all the features.
@@ -154,29 +154,28 @@ import { CoralItems } from "../../tr-grid-util/es6/CoralItems.js";
154
154
  * @param {InCellEditingPlugin~Options=} options
155
155
  * @extends {GridPlugin}
156
156
  */
157
- var InCellEditingPlugin = function InCellEditingPlugin(options) {
158
- var t = this;
159
- t._onDoubleClick = t._onDoubleClick.bind(t);
160
- t._onPopupHide = t._onPopupHide.bind(t);
161
- t._onScroll = t._onScroll.bind(t);
162
- t._onTextKeyDown = t._onTextKeyDown.bind(t);
163
- t._onTextKeyUp = t._onTextKeyUp.bind(t);
164
- t._onTouchStart = t._onTouchStart.bind(t);
165
- t._onTouchEnd = t._onTouchEnd.bind(t);
166
- t._onTouchTimer = t._onTouchTimer.bind(t);
167
- t._createContentEditor = t._createContentEditor.bind(t);
168
- t._createTitleEditor = t._createTitleEditor.bind(t);
169
- t._onColumnAdded = t._onColumnAdded.bind(t);
170
- t._onValueChanged = t._onValueChanged.bind(t);
171
- t._onMultiSelectionValueChanged = t._onMultiSelectionValueChanged.bind(t);
172
- t._onMultiSelectionEditorChanged = t._onMultiSelectionEditorChanged.bind(t);
173
- t._onAutoSuggestItemSelected = t._onAutoSuggestItemSelected.bind(t);
174
- t._hosts = [];
175
- if (options) {
176
- this.config({
177
- "inCellEditing": options
178
- });
179
- }
157
+ let InCellEditingPlugin = function (options) {
158
+ let t = this;
159
+ t._onDoubleClick = t._onDoubleClick.bind(t);
160
+ t._onPopupHide = t._onPopupHide.bind(t);
161
+ t._onScroll = t._onScroll.bind(t);
162
+ t._onTextKeyDown = t._onTextKeyDown.bind(t);
163
+ t._onTextKeyUp = t._onTextKeyUp.bind(t);
164
+ t._onTouchStart = t._onTouchStart.bind(t);
165
+ t._onTouchEnd = t._onTouchEnd.bind(t);
166
+ t._onTouchTimer = t._onTouchTimer.bind(t);
167
+ t._createContentEditor = t._createContentEditor.bind(t);
168
+ t._createTitleEditor = t._createTitleEditor.bind(t);
169
+ t._onColumnAdded = t._onColumnAdded.bind(t);
170
+ t._onValueChanged = t._onValueChanged.bind(t);
171
+ t._onMultiSelectionValueChanged = t._onMultiSelectionValueChanged.bind(t);
172
+ t._onMultiSelectionEditorChanged = t._onMultiSelectionEditorChanged.bind(t);
173
+ t._onAutoSuggestItemSelected = t._onAutoSuggestItemSelected.bind(t);
174
+ t._hosts = [];
175
+
176
+ if(options) {
177
+ this.config({"inCellEditing": options});
178
+ }
180
179
  };
181
180
  Ext.inherits(InCellEditingPlugin, GridPlugin);
182
181
 
@@ -185,15 +184,15 @@ Ext.inherits(InCellEditingPlugin, GridPlugin);
185
184
  * @static
186
185
  */
187
186
  InCellEditingPlugin._uiElementTypesMap = {
188
- "input": "input",
189
- "text": "input",
190
- "number": "ef-number-field",
191
- "select": "ef-select",
192
- "dropdown": "ef-select",
193
- "date": "ef-datetime-picker",
194
- "checkbox": "ef-checkbox",
195
- "boolean": "ef-checkbox",
196
- "combobox": "ef-combo-box"
187
+ "input": "input",
188
+ "text": "input",
189
+ "number": "ef-number-field",
190
+ "select": "ef-select",
191
+ "dropdown": "ef-select",
192
+ "date": "ef-datetime-picker",
193
+ "checkbox": "ef-checkbox",
194
+ "boolean": "ef-checkbox",
195
+ "combobox": "ef-combo-box"
197
196
  };
198
197
 
199
198
  /** @type {boolean}
@@ -351,6 +350,7 @@ InCellEditingPlugin.prototype._editorTimerId = 0;
351
350
  */
352
351
  InCellEditingPlugin._scrolling = false;
353
352
 
353
+
354
354
  /** @type {number}
355
355
  * @private
356
356
  */
@@ -363,13 +363,20 @@ InCellEditingPlugin._primaryColor = "";
363
363
  /** @type {string}
364
364
  * @private
365
365
  */
366
- InCellEditingPlugin._styles = prettifyCss([":host .cell.editing input[type=text]", ["border-style: solid;"], ":host .cell.editing", ["z-index: 2;"]]);
366
+ InCellEditingPlugin._styles = prettifyCss([
367
+ ":host .cell.editing input[type=text]", [
368
+ "border-style: solid;"
369
+ ],
370
+ ":host .cell.editing", [
371
+ "z-index: 2;"
372
+ ]
373
+ ]);
367
374
 
368
375
  /** @private
369
376
  */
370
377
  InCellEditingPlugin._onThemeLoaded = function () {
371
- var colors = ElfUtil.getColors();
372
- InCellEditingPlugin._primaryColor = colors.primary;
378
+ let colors = ElfUtil.getColors();
379
+ InCellEditingPlugin._primaryColor = colors.primary;
373
380
  };
374
381
 
375
382
  /** @private
@@ -378,64 +385,71 @@ InCellEditingPlugin._onThemeLoaded = function () {
378
385
  * @return {Element} input element
379
386
  */
380
387
  InCellEditingPlugin.prototype._createInputElement = function (tag, attributes) {
381
- var t = this;
382
- var elem = document.createElement(tag);
383
- for (var attribute in attributes) {
384
- elem.setAttribute(attribute, attributes[attribute]);
385
- }
386
- var typeMap = InCellEditingPlugin._uiElementTypesMap;
387
- // Resolve elf theme style
388
- elem.style.width = "100%";
389
- elem.style.height = "100%";
390
- elem.style.margin = "0";
391
- elem.style.borderColor = InCellEditingPlugin._primaryColor || "#ee7600";
392
- elem.style.maxHeight = "unset";
393
- if (tag === typeMap.checkbox) {
394
- elem.style.borderStyle = "solid";
395
- elem.style.borderWidth = "1px";
396
- elem.style.boxSizing = "border-box";
397
- elem.style.display = "flex";
398
- elem.style.justifyContent = "center";
399
- elem.addEventListener("keydown", function (e) {
400
- if (e.keyCode === 13) {
401
- e.preventDefault();
402
- }
403
- });
404
- } else if (tag === typeMap.select || tag === typeMap.combobox || tag === typeMap.date) {
405
- if (tag === typeMap.combobox && attributes && attributes["multiple"]) {
406
- elem.addEventListener("value-changed", t._onMultiSelectionValueChanged);
407
- elem.addEventListener("opened-changed", t._onMultiSelectionEditorChanged);
408
- } else {
409
- elem.addEventListener("value-changed", t._onValueChanged);
410
- }
411
- } else if (tag === "ef-input") {
412
- elem.setAttribute("type", "number");
413
- } else if (tag === typeMap.input) {
414
- elem.setAttribute("type", "text");
415
- }
416
- if (this._autoSuggest) {
417
- this._autoSuggest.addEventListener("item-select", t._onAutoSuggestItemSelected);
418
- this._autoSuggest.addEventListener("wheel", t._stopPropagation, false);
419
- }
420
- elem.addEventListener("keydown", t._onTextKeyDown, false);
421
- elem.addEventListener("keyup", t._onTextKeyUp, false);
422
- elem.addEventListener("mousedown", t._stopPropagation, false);
423
- elem.addEventListener("mouseup", t._stopPropagation, false);
424
- elem.addEventListener("click", t._stopPropagation, false);
425
- elem.addEventListener("copy", t._stopPropagation, false);
426
- elem.addEventListener("cut", t._stopPropagation, false);
427
- elem.addEventListener("paste", t._stopPropagation, false);
428
- return elem;
388
+ let t = this;
389
+ let elem = document.createElement(tag);
390
+ for(let attribute in attributes) {
391
+ elem.setAttribute(attribute, attributes[attribute]);
392
+ }
393
+
394
+ let typeMap = InCellEditingPlugin._uiElementTypesMap;
395
+ // Resolve elf theme style
396
+ elem.style.width = "100%";
397
+ elem.style.height = "100%";
398
+ elem.style.margin = "0";
399
+ elem.style.borderColor = InCellEditingPlugin._primaryColor || "#ee7600";
400
+ elem.style.maxHeight = "unset";
401
+
402
+ if(tag === typeMap.checkbox) {
403
+ elem.style.borderStyle = "solid";
404
+ elem.style.borderWidth = "1px";
405
+ elem.style.boxSizing = "border-box";
406
+ elem.style.display = "flex";
407
+ elem.style.justifyContent = "center";
408
+ elem.addEventListener("keydown", function (e) {
409
+ if(e.keyCode === 13) {
410
+ e.preventDefault();
411
+ }
412
+ });
413
+ } else if(
414
+ tag === typeMap.select ||
415
+ tag === typeMap.combobox ||
416
+ tag === typeMap.date) {
417
+
418
+ if(tag === typeMap.combobox && attributes && attributes["multiple"]){
419
+ elem.addEventListener("value-changed", t._onMultiSelectionValueChanged);
420
+ elem.addEventListener("opened-changed", t._onMultiSelectionEditorChanged);
421
+ } else {
422
+ elem.addEventListener("value-changed", t._onValueChanged);
423
+ }
424
+ } else if(tag === "ef-input") {
425
+ elem.setAttribute("type", "number");
426
+ } else if(tag === typeMap.input) {
427
+ elem.setAttribute("type", "text");
428
+ }
429
+ if(this._autoSuggest) {
430
+ this._autoSuggest.addEventListener("item-select", t._onAutoSuggestItemSelected);
431
+ this._autoSuggest.addEventListener("wheel", t._stopPropagation, false);
432
+ }
433
+
434
+ elem.addEventListener("keydown", t._onTextKeyDown, false);
435
+ elem.addEventListener("keyup", t._onTextKeyUp, false);
436
+ elem.addEventListener("mousedown", t._stopPropagation, false);
437
+ elem.addEventListener("mouseup", t._stopPropagation, false);
438
+ elem.addEventListener("click", t._stopPropagation, false);
439
+ elem.addEventListener("copy", t._stopPropagation, false);
440
+ elem.addEventListener("cut", t._stopPropagation, false);
441
+ elem.addEventListener("paste", t._stopPropagation, false);
442
+ return elem;
429
443
  };
430
444
 
431
445
  /** @private
432
446
  * @return {Element}
433
447
  */
434
448
  InCellEditingPlugin.prototype._createEditor = function () {
435
- var editor = document.createElement("div");
436
- editor.className = "cell editing";
437
- editor.style.position = "absolute";
438
- return editor;
449
+ let editor = document.createElement("div");
450
+ editor.className = "cell editing";
451
+ editor.style.position = "absolute";
452
+ return editor;
439
453
  };
440
454
 
441
455
  /** @private
@@ -443,10 +457,8 @@ InCellEditingPlugin.prototype._createEditor = function () {
443
457
  * @return {Popup} popup instance
444
458
  */
445
459
  InCellEditingPlugin.prototype._createBalloonPopup = function (editor) {
446
- var popup = new Popup(editor, {
447
- positioning: "over"
448
- });
449
- return popup;
460
+ let popup = new Popup(editor, { positioning: "over" });
461
+ return popup;
450
462
  };
451
463
 
452
464
  /** @private
@@ -456,19 +468,19 @@ InCellEditingPlugin.prototype._createBalloonPopup = function (editor) {
456
468
  * @return {object} inCellCache
457
469
  */
458
470
  InCellEditingPlugin.prototype._createInCellCache = function (grid, elemTag, attributes) {
459
- var t = this;
460
- var editor = t._createEditor();
461
- var inputElement = t._createInputElement(elemTag, attributes);
462
- var balloonPopup = new Popup(editor, {
463
- positioning: "over"
464
- });
465
- editor.appendChild(inputElement);
466
- return {
467
- grid: grid,
468
- inputElement: inputElement,
469
- editor: editor,
470
- balloonPopup: balloonPopup
471
- };
471
+ let t = this;
472
+
473
+ let editor = t._createEditor();
474
+ let inputElement = t._createInputElement(elemTag, attributes);
475
+ let balloonPopup = new Popup(editor, { positioning: "over" });
476
+ editor.appendChild(inputElement);
477
+
478
+ return {
479
+ grid: grid,
480
+ inputElement: inputElement,
481
+ editor: editor,
482
+ balloonPopup: balloonPopup
483
+ };
472
484
  };
473
485
 
474
486
  /** @private
@@ -476,11 +488,12 @@ InCellEditingPlugin.prototype._createInCellCache = function (grid, elemTag, attr
476
488
  * @return {object} inCellCache
477
489
  */
478
490
  InCellEditingPlugin.prototype._createTitleEditor = function (grid) {
479
- var t = this;
480
- if (!t._headerInCellCache) {
481
- t._headerInCellCache = t._createInCellCache(grid, "input");
482
- }
483
- return t._headerInCellCache;
491
+ let t = this;
492
+ if(!t._headerInCellCache) {
493
+ t._headerInCellCache = t._createInCellCache(grid, "input");
494
+ }
495
+
496
+ return t._headerInCellCache;
484
497
  };
485
498
 
486
499
  /** @private
@@ -489,38 +502,40 @@ InCellEditingPlugin.prototype._createTitleEditor = function (grid) {
489
502
  * @return {object} inCellCache
490
503
  */
491
504
  InCellEditingPlugin.prototype._createContentEditor = function (columnIndex, grid) {
492
- var t = this;
493
- var typeMap = InCellEditingPlugin._uiElementTypesMap;
494
- var columnData = t._getColumnData(columnIndex, grid);
495
- var inCellColumnConfig = columnData["inCellEditing"];
496
- var elemTag = typeMap[inCellColumnConfig && inCellColumnConfig.type] || t._defaultTag;
497
- if (!columnData["inCellCache"]) {
498
- var attributes = inCellColumnConfig ? inCellColumnConfig.attributes : null;
499
- columnData["inCellCache"] = t._createInCellCache(grid, elemTag, attributes);
500
- }
501
- var inCellCache = columnData["inCellCache"];
502
-
503
- // Setup initial value for the editor
504
- if (elemTag === typeMap.select || elemTag === typeMap.combobox) {
505
- inCellCache["inputElement"].data = inCellColumnConfig && inCellColumnConfig.entries;
506
- }
507
- return inCellCache;
505
+ let t = this;
506
+ let typeMap = InCellEditingPlugin._uiElementTypesMap;
507
+ let columnData = t._getColumnData(columnIndex, grid);
508
+ let inCellColumnConfig = columnData["inCellEditing"];
509
+ let elemTag = typeMap[inCellColumnConfig && inCellColumnConfig.type] || t._defaultTag;
510
+
511
+ if(!columnData["inCellCache"]) {
512
+ let attributes = inCellColumnConfig ? inCellColumnConfig.attributes : null;
513
+ columnData["inCellCache"] = t._createInCellCache(grid, elemTag, attributes);
514
+ }
515
+ let inCellCache = columnData["inCellCache"];
516
+
517
+ // Setup initial value for the editor
518
+ if(elemTag === typeMap.select || elemTag === typeMap.combobox) {
519
+ inCellCache["inputElement"].data = inCellColumnConfig && inCellColumnConfig.entries;
520
+ }
521
+
522
+ return inCellCache;
508
523
  };
509
524
  /** @override
510
525
  * @return {string}
511
526
  */
512
527
  InCellEditingPlugin.prototype.getName = function () {
513
- return "InCellEditingPlugin";
528
+ return "InCellEditingPlugin";
514
529
  };
515
530
 
516
531
  /** @private
517
532
  * @param {Event|Element} e
518
533
  */
519
- InCellEditingPlugin.prototype._onColumnAdded = function (e) {
520
- if (e.context && e.colIndex != null) {
521
- // e.context is a columnOption;
522
- this._retrieveColumnOption(e.context, e.colIndex);
523
- }
534
+ InCellEditingPlugin.prototype._onColumnAdded = function(e) {
535
+ if(e.context && e.colIndex != null) {
536
+ // e.context is a columnOption;
537
+ this._retrieveColumnOption(e.context, e.colIndex);
538
+ }
524
539
  };
525
540
 
526
541
  /** Called by grid system when initial plugins.
@@ -529,40 +544,46 @@ InCellEditingPlugin.prototype._onColumnAdded = function (e) {
529
544
  * @param {Object} options
530
545
  */
531
546
  InCellEditingPlugin.prototype.initialize = function (host, options) {
532
- if (this._hosts.indexOf(host) >= 0) {
533
- return;
534
- }
535
- if (!this._hosts.length) {
536
- window.addEventListener("scroll", this._onScroll);
537
- }
538
- host.listen("columnAdded", this._onColumnAdded);
539
- host.getVScrollbar().listen("scroll", this._onScroll);
540
- host.getHScrollbar().listen("scroll", this._onScroll);
541
- if (this._dblClick) {
542
- host.listen("dblclick", this._onDoubleClick);
543
-
544
- // Make a comparable functionality for touchscreen
545
- if (isTouchDevice()) {
546
- host.listen("touchstart", this._onTouchStart);
547
- host.listen("touchend", this._onTouchEnd);
548
- host.listen("touchcancel", this._onTouchEnd);
549
- }
550
- }
551
- this._hosts.push(host);
552
- if (ElfUtil.getElfVersion() < 4) {
553
- // ef-input available in elf version < 4
554
- InCellEditingPlugin._uiElementTypesMap["number"] = "ef-input";
555
- }
556
- if (ElfUtil.isHaloTheme()) {
557
- if (!host._inCellEditingStyles) {
558
- host._inCellEditingStyles = true;
559
- injectCss(InCellEditingPlugin._styles, host.getElement());
560
- }
561
- }
562
- this.config(options);
563
- if (!InCellEditingPlugin._primaryColor) {
564
- ElfUtil.getThemeColors().then(InCellEditingPlugin._onThemeLoaded)["catch"](InCellEditingPlugin._onThemeLoaded);
565
- }
547
+ if(this._hosts.indexOf(host) >= 0) { return; }
548
+
549
+ if(!this._hosts.length) {
550
+ window.addEventListener("scroll", this._onScroll);
551
+ }
552
+
553
+ host.listen("columnAdded", this._onColumnAdded);
554
+ host.getVScrollbar().listen("scroll", this._onScroll);
555
+ host.getHScrollbar().listen("scroll", this._onScroll);
556
+
557
+ if(this._dblClick) {
558
+ host.listen("dblclick", this._onDoubleClick);
559
+
560
+ // Make a comparable functionality for touchscreen
561
+ if(isTouchDevice()) {
562
+ host.listen("touchstart", this._onTouchStart);
563
+ host.listen("touchend", this._onTouchEnd);
564
+ host.listen("touchcancel", this._onTouchEnd);
565
+ }
566
+ }
567
+
568
+ this._hosts.push(host);
569
+
570
+ if(ElfUtil.getElfVersion() < 4) {
571
+ // ef-input available in elf version < 4
572
+ InCellEditingPlugin._uiElementTypesMap["number"] = "ef-input";
573
+ }
574
+
575
+ if(ElfUtil.isHaloTheme()) {
576
+ if(!host._inCellEditingStyles) {
577
+ host._inCellEditingStyles = true;
578
+ injectCss(InCellEditingPlugin._styles, host.getElement());
579
+ }
580
+ }
581
+
582
+ this.config(options);
583
+
584
+ if(!InCellEditingPlugin._primaryColor) {
585
+ ElfUtil.getThemeColors().then(InCellEditingPlugin._onThemeLoaded).catch(InCellEditingPlugin._onThemeLoaded);
586
+ }
566
587
  };
567
588
  /** Remove redundant built-in composite-grid feature
568
589
  * @public
@@ -571,79 +592,102 @@ InCellEditingPlugin.prototype.initialize = function (host, options) {
571
592
  * @return {*} The transformed value of the option
572
593
  */
573
594
  InCellEditingPlugin.prototype.beforeProcessOption = function (optionName, optionVal) {
574
- if (optionName == "cellEditing") {
575
- return null; // eslint-disable-line
576
- }
577
-
578
- return; // eslint-disable-line
595
+ if(optionName == "cellEditing") {
596
+ return null; // eslint-disable-line
597
+ }
598
+ return; // eslint-disable-line
579
599
  };
580
600
  /** @private
581
601
  * @override
582
602
  */
583
603
  InCellEditingPlugin.prototype._afterInit = function () {
584
- this._elfVersion = ElfUtil.getElfVersion();
604
+ this._elfVersion = ElfUtil.getElfVersion();
585
605
  };
586
606
 
587
607
  /** @public
588
608
  * @param {Object=} options
589
609
  */
590
- InCellEditingPlugin.prototype.config = function (options) {
591
- if (!options) {
592
- return;
593
- }
594
- var t = this;
595
-
596
- // config column
597
- var columns = options["columns"];
598
- if (columns) {
599
- var len = columns.length;
600
- for (var c = 0; c < len; ++c) {
601
- t._retrieveColumnOption(columns[c], c);
602
- }
603
- }
604
- var pluginOption = options["inCellEditing"];
605
- if (!pluginOption) return;
606
-
607
- // options
608
- if (pluginOption["type"]) t._defaultTag = InCellEditingPlugin._uiElementTypesMap[pluginOption["type"]];
609
- if (pluginOption["balloonMode"]) t.enableBalloonMode(pluginOption["balloonMode"]);
610
- if (pluginOption["editableTitle"]) t.enableTitleEditing(pluginOption["editableTitle"]);
611
- if (pluginOption["editableContent"]) t._editableContent = true;
612
- if (pluginOption["tabToMove"]) t._tabToMove = true;
613
- if (pluginOption["autoCommitText"]) t.enableAutoCommitText(pluginOption["autoCommitText"]);
614
- if (pluginOption["dataBinding"] != null) t.disableDataBinding(!pluginOption["dataBinding"]);
615
- if (pluginOption["contentSource"] != null) t._contentSource = pluginOption["contentSource"];
616
- if (pluginOption["popupElement"]) {
617
- t.setPopupElement(pluginOption["popupElement"]);
618
- }
619
- if (pluginOption["doubleClick"] != null) t.disableDblClick(!pluginOption["doubleClick"]);
620
- if (pluginOption["inlineStyling"]) {
621
- t._inlineStyling = true;
622
- }
623
- if (pluginOption["disablingScroll"]) {
624
- t._disablingScroll = true;
625
- }
626
- if (pluginOption["uiBlocking"]) {
627
- t._uiBlocking = true;
628
- }
629
- if (pluginOption["autoSuggest"]) {
630
- t._autoSuggest = pluginOption["autoSuggest"];
631
- }
632
- if (pluginOption["closingOnScroll"] == false) {
633
- t._closingOnScroll = false;
634
- }
635
- if (pluginOption["autoHiding"] == false) {
636
- t._autoHiding = false;
637
- }
638
-
639
- // event callback
640
- t.addListener(pluginOption, "preEditorOpening");
641
- t.addListener(pluginOption, "editorOpened");
642
- t.addListener(pluginOption, "beforeCommit");
643
- t.addListener(pluginOption, "editorClosed");
644
- t.addListener(pluginOption, "keyUp");
645
- t.addListener(pluginOption, "beforeRowCommit");
646
- t.addListener(pluginOption, "rowEditorClosed");
610
+ InCellEditingPlugin.prototype.config = function(options) {
611
+ if(!options) {
612
+ return;
613
+ }
614
+ let t = this;
615
+
616
+ // config column
617
+ let columns = options["columns"];
618
+ if(columns) {
619
+ let len = columns.length;
620
+ for(let c = 0; c < len; ++c) {
621
+ t._retrieveColumnOption(columns[c], c);
622
+ }
623
+ }
624
+
625
+ let pluginOption = options["inCellEditing"];
626
+ if(!pluginOption) return;
627
+
628
+ // options
629
+ if(pluginOption["type"])
630
+ t._defaultTag = InCellEditingPlugin._uiElementTypesMap[pluginOption["type"]];
631
+
632
+ if(pluginOption["balloonMode"])
633
+ t.enableBalloonMode(pluginOption["balloonMode"]);
634
+
635
+ if(pluginOption["editableTitle"])
636
+ t.enableTitleEditing(pluginOption["editableTitle"]);
637
+
638
+ if(pluginOption["editableContent"])
639
+ t._editableContent = true;
640
+
641
+ if(pluginOption["tabToMove"])
642
+ t._tabToMove = true;
643
+
644
+ if(pluginOption["autoCommitText"])
645
+ t.enableAutoCommitText(pluginOption["autoCommitText"]);
646
+
647
+ if(pluginOption["dataBinding"] != null)
648
+ t.disableDataBinding(!pluginOption["dataBinding"]);
649
+
650
+ if(pluginOption["contentSource"] != null)
651
+ t._contentSource = pluginOption["contentSource"];
652
+
653
+ if(pluginOption["popupElement"]){
654
+ t.setPopupElement(pluginOption["popupElement"]);
655
+ }
656
+
657
+ if(pluginOption["doubleClick"] != null)
658
+ t.disableDblClick(!pluginOption["doubleClick"]);
659
+
660
+ if(pluginOption["inlineStyling"]) {
661
+ t._inlineStyling = true;
662
+ }
663
+
664
+ if(pluginOption["disablingScroll"]) {
665
+ t._disablingScroll = true;
666
+ }
667
+
668
+ if(pluginOption["uiBlocking"]) {
669
+ t._uiBlocking = true;
670
+ }
671
+
672
+ if(pluginOption["autoSuggest"]) {
673
+ t._autoSuggest = pluginOption["autoSuggest"];
674
+ }
675
+
676
+ if(pluginOption["closingOnScroll"] == false) {
677
+ t._closingOnScroll = false;
678
+ }
679
+ if(pluginOption["autoHiding"] == false) {
680
+ t._autoHiding = false;
681
+ }
682
+
683
+ // event callback
684
+ t.addListener(pluginOption, "preEditorOpening");
685
+ t.addListener(pluginOption, "editorOpened");
686
+ t.addListener(pluginOption, "beforeCommit");
687
+ t.addListener(pluginOption, "editorClosed");
688
+ t.addListener(pluginOption, "keyUp");
689
+ t.addListener(pluginOption, "beforeRowCommit");
690
+ t.addListener(pluginOption, "rowEditorClosed");
647
691
  };
648
692
 
649
693
  /** @private
@@ -653,17 +697,17 @@ InCellEditingPlugin.prototype.config = function (options) {
653
697
  * @param {boolean} defaultValue
654
698
  * @returns {number} dirty
655
699
  */
656
- var _setBooleanOption = function _setBooleanOption(obj, propName, propValue, defaultValue) {
657
- if (defaultValue) {
658
- if (!propValue) {
659
- obj[propName] = false;
660
- return true;
661
- }
662
- } else if (propValue) {
663
- obj[propName] = true;
664
- return true;
665
- }
666
- return false;
700
+ let _setBooleanOption = function(obj, propName, propValue, defaultValue) {
701
+ if(defaultValue) {
702
+ if(!propValue) {
703
+ obj[propName] = false;
704
+ return true;
705
+ }
706
+ } else if(propValue) {
707
+ obj[propName] = true;
708
+ return true;
709
+ }
710
+ return false;
667
711
  };
668
712
  /** Get a current state of grid and extension config
669
713
  * @public
@@ -671,65 +715,75 @@ var _setBooleanOption = function _setBooleanOption(obj, propName, propValue, def
671
715
  * @returns {!Object}
672
716
  */
673
717
  InCellEditingPlugin.prototype.getConfigObject = function (out_obj) {
674
- var obj = out_obj || {};
675
- var columns = obj.columns;
676
- if (!columns) {
677
- columns = obj.columns = [];
678
- }
679
- var len = this.getColumnCount();
680
- var val, opt;
681
- for (var i = 0; i < len; ++i) {
682
- var col = columns[i];
683
- if (!col) {
684
- col = columns[i] = {};
685
- }
686
- opt = this._getColumnData(i);
687
- if (!opt) {
688
- continue;
689
- }
690
- if (opt.editableContent != null) {
691
- col.editableContent = opt.editableContent;
692
- }
693
- if (opt.inCellEditing != null) {
694
- col.inCellEditing = {};
695
- val = opt.inCellEditing["type"];
696
- if (val != null) {
697
- col.inCellEditing["type"] = val;
698
- }
699
- val = opt.inCellEditing["entries"];
700
- if (val != null) {
701
- col.inCellEditing["entries"] = val;
702
- }
703
- val = opt.inCellEditing["attributes"];
704
- if (val != null) {
705
- col.inCellEditing["attributes"] = val;
706
- }
707
- }
708
- }
709
- var extOptions = obj.inCellEditing;
710
- var dirty = 0;
711
- if (!extOptions) {
712
- extOptions = {};
713
- }
714
- dirty |= _setBooleanOption(extOptions, "balloonMode", this._balloonMode, false);
715
- dirty |= _setBooleanOption(extOptions, "editableTitle", this._editableTitle, false);
716
- dirty |= _setBooleanOption(extOptions, "tabToMove", this._tabToMove, false);
717
- dirty |= _setBooleanOption(extOptions, "autoCommitText", this._autoCommitText, false);
718
- dirty |= _setBooleanOption(extOptions, "dataBinding", this._dataBinding, true);
719
- dirty |= _setBooleanOption(extOptions, "doubleClick", this._dblClick, true);
720
- dirty |= _setBooleanOption(extOptions, "inlineStyling", this._inlineStyling, false);
721
- dirty |= _setBooleanOption(extOptions, "disablingScroll", this._disablingScroll, false);
722
- dirty |= _setBooleanOption(extOptions, "uiBlocking", this._uiBlocking, false);
723
- dirty |= _setBooleanOption(extOptions, "closingOnScroll", this._closingOnScroll, true);
724
- dirty |= _setBooleanOption(extOptions, "autoHiding", this._autoHiding, true);
725
- if (this._contentSource !== "textContent") {
726
- dirty = 1;
727
- extOptions.contentSource = this._contentSource;
728
- }
729
- if (dirty) {
730
- obj.inCellEditing = extOptions;
731
- }
732
- return obj;
718
+ let obj = out_obj || {};
719
+
720
+ let columns = obj.columns;
721
+ if(!columns) {
722
+ columns = obj.columns = [];
723
+ }
724
+
725
+ let len = this.getColumnCount();
726
+ let val, opt;
727
+ for(let i = 0; i < len; ++i) {
728
+ let col = columns[i];
729
+ if(!col) {
730
+ col = columns[i] = {};
731
+ }
732
+
733
+ opt = this._getColumnData(i);
734
+
735
+ if(!opt) { continue; }
736
+ if(opt.editableContent != null) {
737
+ col.editableContent = opt.editableContent;
738
+ }
739
+ if(opt.inCellEditing != null) {
740
+ col.inCellEditing = {};
741
+
742
+ val = opt.inCellEditing["type"];
743
+ if(val != null) {
744
+ col.inCellEditing["type"] = val;
745
+ }
746
+
747
+ val = opt.inCellEditing["entries"];
748
+ if(val != null) {
749
+ col.inCellEditing["entries"] = val;
750
+ }
751
+
752
+ val = opt.inCellEditing["attributes"];
753
+ if(val != null) {
754
+ col.inCellEditing["attributes"] = val;
755
+ }
756
+ }
757
+ }
758
+
759
+ let extOptions = obj.inCellEditing;
760
+ let dirty = 0;
761
+ if(!extOptions) {
762
+ extOptions = {};
763
+ }
764
+ dirty |= _setBooleanOption(extOptions, "balloonMode", this._balloonMode, false);
765
+ dirty |= _setBooleanOption(extOptions, "editableTitle", this._editableTitle, false);
766
+ dirty |= _setBooleanOption(extOptions, "editableContent", this._editableContent, false);
767
+ dirty |= _setBooleanOption(extOptions, "tabToMove", this._tabToMove, false);
768
+ dirty |= _setBooleanOption(extOptions, "autoCommitText", this._autoCommitText, false);
769
+ dirty |= _setBooleanOption(extOptions, "dataBinding", this._dataBinding, true);
770
+ dirty |= _setBooleanOption(extOptions, "doubleClick", this._dblClick, true);
771
+ dirty |= _setBooleanOption(extOptions, "inlineStyling", this._inlineStyling, false);
772
+ dirty |= _setBooleanOption(extOptions, "disablingScroll", this._disablingScroll, false);
773
+ dirty |= _setBooleanOption(extOptions, "uiBlocking", this._uiBlocking, false);
774
+ dirty |= _setBooleanOption(extOptions, "closingOnScroll", this._closingOnScroll, true);
775
+ dirty |= _setBooleanOption(extOptions, "autoHiding", this._autoHiding, true);
776
+
777
+ if(this._contentSource !== "textContent") {
778
+ dirty = 1;
779
+ extOptions.contentSource = this._contentSource;
780
+ }
781
+
782
+ if(dirty) {
783
+ obj.inCellEditing = extOptions;
784
+ }
785
+
786
+ return obj;
733
787
  };
734
788
 
735
789
  /** @private
@@ -737,41 +791,47 @@ InCellEditingPlugin.prototype.getConfigObject = function (out_obj) {
737
791
  * @param {number} colIndex
738
792
  */
739
793
  InCellEditingPlugin.prototype._retrieveColumnOption = function (columnOption, colIndex) {
740
- var pluginOptions = columnOption["inCellEditing"];
741
- var editableContent = columnOption["editableContent"];
742
- if (pluginOptions != null || editableContent != null) {
743
- var colData = this._newColumnData(colIndex);
744
- if (pluginOptions != null) {
745
- colData["inCellEditing"] = pluginOptions;
746
- pluginOptions.entries = CoralItems.create(pluginOptions.entries); // Create entries for coral select and combobox
747
- }
794
+ let pluginOptions = columnOption["inCellEditing"];
795
+ let editableContent = columnOption["editableContent"];
748
796
 
749
- if (editableContent != null) {
750
- colData["editableContent"] = editableContent;
751
- }
752
- }
797
+ if(pluginOptions != null || editableContent != null) {
798
+ let colData = this._newColumnData(colIndex);
799
+ if(pluginOptions != null) {
800
+ colData["inCellEditing"] = pluginOptions;
801
+ pluginOptions.entries = CoralItems.create(pluginOptions.entries); // Create entries for coral select and combobox
802
+ }
803
+ if(editableContent != null) {
804
+ colData["editableContent"] = editableContent;
805
+ }
806
+ }
753
807
  };
754
808
 
755
809
  /** @override */
756
810
  InCellEditingPlugin.prototype.unload = function (host) {
757
- var at = this._hosts.indexOf(host);
758
- if (at < 0) {
759
- return;
760
- }
761
- this._hosts.splice(at, 1);
762
- host.unlisten("columnAdded", this._onColumnAdded);
763
- host.getVScrollbar().unlisten("scroll", this._onScroll);
764
- host.getHScrollbar().unlisten("scroll", this._onScroll);
765
- host.unlisten("dblclick", this._onDoubleClick);
766
- host.unlisten("touchstart", this._onTouchStart);
767
- host.unlisten("touchend", this._onTouchEnd);
768
- host.unlisten("touchcancel", this._onTouchEnd);
769
- if (!this._hosts.length) {
770
- this._touchTimerId = 0;
771
- this._editorTimerId = 0;
772
- window.removeEventListener("scroll", this._onScroll);
773
- }
774
- this._dispose();
811
+ let at = this._hosts.indexOf(host);
812
+ if(at < 0) { return; }
813
+ this._hosts.splice(at, 1);
814
+
815
+ host.unlisten("columnAdded", this._onColumnAdded);
816
+ host.getVScrollbar().unlisten("scroll", this._onScroll);
817
+ host.getHScrollbar().unlisten("scroll", this._onScroll);
818
+
819
+ host.unlisten("dblclick", this._onDoubleClick);
820
+ host.unlisten("touchstart", this._onTouchStart);
821
+ host.unlisten("touchend", this._onTouchEnd);
822
+ host.unlisten("touchcancel", this._onTouchEnd);
823
+
824
+ if(!this._hosts.length) {
825
+ if(this._touchTimerId) {
826
+ clearTimeout(this._touchTimerId);
827
+ }
828
+ if(this._editorTimerId) {
829
+ clearTimeout(this._editorTimerId);
830
+ }
831
+ window.removeEventListener("scroll", this._onScroll);
832
+ }
833
+
834
+ this._dispose();
775
835
  };
776
836
 
777
837
  /** @public
@@ -782,33 +842,38 @@ InCellEditingPlugin.prototype.unload = function (host) {
782
842
  * @fires InCellEditingPlugin#editorOpened
783
843
  */
784
844
  InCellEditingPlugin.prototype.openEditor = function (colIndex, rowIndex, sectionRef, grid) {
785
- if (!grid) {
786
- grid = this._hosts[0];
787
- if (!grid) {
788
- return;
789
- }
790
- }
791
- var sectionSettings = grid.getSectionSettings(sectionRef || "content");
792
- var activePos = this._activePos;
793
- if (activePos) {
794
- var sectionName = sectionSettings ? sectionSettings.getType() : "";
795
- if (activePos["colIndex"] === colIndex && activePos["rowIndex"] === rowIndex && activePos["sectionName"] === sectionName && activePos["grid"] === grid) {
796
- return; // The same cell is open twice
797
- }
798
-
799
- this.closeCellEditor(); // Close previously opened cell editor
800
- }
801
-
802
- var section = sectionSettings ? sectionSettings.getSection() : null;
803
- var cell = section ? section.getCell(colIndex, rowIndex) : null;
804
- if (!cell) {
805
- return; // Some input is invalid
806
- }
807
-
808
- grid.scrollToColumn(colIndex);
809
- grid.scrollToRow(null, rowIndex); // TODO: Fix this workaround
810
-
811
- setTimeout(this._openEditor.bind(this, cell, grid), 100);
845
+ if(!grid) {
846
+ grid = this._hosts[0];
847
+ if(!grid) {
848
+ return;
849
+ }
850
+ }
851
+
852
+ let sectionSettings = grid.getSectionSettings(sectionRef || "content");
853
+ let activePos = this._activePos;
854
+ if(activePos) {
855
+ let sectionName = sectionSettings ? sectionSettings.getType() : "";
856
+
857
+ if(activePos["colIndex"] === colIndex &&
858
+ activePos["rowIndex"] === rowIndex &&
859
+ activePos["sectionName"] === sectionName &&
860
+ activePos["grid"] === grid
861
+ ) {
862
+ return; // The same cell is open twice
863
+ }
864
+
865
+ this.closeCellEditor(); // Close previously opened cell editor
866
+ }
867
+ let section = sectionSettings ? sectionSettings.getSection() : null;
868
+ let cell = section ? section.getCell(colIndex, rowIndex) : null;
869
+ if(!cell) {
870
+ return; // Some input is invalid
871
+ }
872
+
873
+ grid.scrollToColumn(colIndex);
874
+ grid.scrollToRow(null, rowIndex); // TODO: Fix this workaround
875
+
876
+ setTimeout(this._openEditor.bind(this, cell, grid), 100);
812
877
  };
813
878
 
814
879
  /** @public
@@ -816,21 +881,21 @@ InCellEditingPlugin.prototype.openEditor = function (colIndex, rowIndex, section
816
881
  * @fires InCellEditingPlugin#cancelled
817
882
  */
818
883
  InCellEditingPlugin.prototype.closeCellEditor = function (opt_forceCommit) {
819
- this._commitText(opt_forceCommit || this._autoCommitText);
884
+ this._commitText(opt_forceCommit || this._autoCommitText);
820
885
  };
821
886
 
822
887
  /** @public
823
888
  * @param {boolean=} opt_enabled
824
889
  */
825
890
  InCellEditingPlugin.prototype.enableBalloonMode = function (opt_enabled) {
826
- this._balloonMode = opt_enabled !== false;
891
+ this._balloonMode = opt_enabled !== false;
827
892
  };
828
893
 
829
894
  /** @public
830
895
  * @param {boolean=} opt_enabled
831
896
  */
832
897
  InCellEditingPlugin.prototype.enableTitleEditing = function (opt_enabled) {
833
- this._editableTitle = opt_enabled !== false;
898
+ this._editableTitle = opt_enabled !== false;
834
899
  };
835
900
 
836
901
  /** Disable editing on all title sections
@@ -838,7 +903,7 @@ InCellEditingPlugin.prototype.enableTitleEditing = function (opt_enabled) {
838
903
  * @param {boolean=} opt_disabled
839
904
  */
840
905
  InCellEditingPlugin.prototype.disableTitleEditing = function (opt_disabled) {
841
- this._editableTitle = opt_disabled === false;
906
+ this._editableTitle = opt_disabled === false;
842
907
  };
843
908
 
844
909
  /** Disable editing on a per cell basis
@@ -847,29 +912,29 @@ InCellEditingPlugin.prototype.disableTitleEditing = function (opt_disabled) {
847
912
  * @param {boolean=} opt_disabled
848
913
  */
849
914
  InCellEditingPlugin.prototype.disableCellEditing = function (cell, opt_disabled) {
850
- if (cell) {
851
- cell.enableClass("no-editing", opt_disabled !== false);
852
- }
915
+ if(cell) {
916
+ cell.enableClass("no-editing", opt_disabled !== false);
917
+ }
853
918
  };
854
919
 
855
920
  /** @public
856
921
  * @param {boolean=} opt_disabled
857
922
  */
858
923
  InCellEditingPlugin.prototype.disableDataBinding = function (opt_disabled) {
859
- this._dataBinding = opt_disabled === false;
924
+ this._dataBinding = (opt_disabled === false);
860
925
  };
861
926
 
862
927
  /** @public
863
928
  * @param {boolean=} opt_disabled
864
929
  */
865
930
  InCellEditingPlugin.prototype.disableDblClick = function (opt_disabled) {
866
- var dblClick = opt_disabled === false;
867
- if (this._dblClick !== dblClick) {
868
- this._dblClick = dblClick;
869
- for (var i = this._hosts.length; --i >= 0;) {
870
- this._listenForTriggering(this._hosts[i], dblClick);
871
- }
872
- }
931
+ let dblClick = (opt_disabled === false);
932
+ if(this._dblClick !== dblClick) {
933
+ this._dblClick = dblClick;
934
+ for(let i = this._hosts.length; --i >= 0;) {
935
+ this._listenForTriggering(this._hosts[i], dblClick);
936
+ }
937
+ }
873
938
  };
874
939
 
875
940
  /** Checking Editing is in process.
@@ -877,7 +942,7 @@ InCellEditingPlugin.prototype.disableDblClick = function (opt_disabled) {
877
942
  * @return {boolean}
878
943
  */
879
944
  InCellEditingPlugin.prototype.isEditing = function () {
880
- return this._editing;
945
+ return this._editing;
881
946
  };
882
947
 
883
948
  /**
@@ -890,29 +955,28 @@ InCellEditingPlugin.prototype.isEditing = function () {
890
955
  * for cell editing mode. function not require param since only one editor can be opened at a time.
891
956
  */
892
957
  InCellEditingPlugin.prototype.getTextBox = function (columnIndex, grid) {
893
- if (this._activeRowId) {
894
- // for row editing mode
895
- // get rowEditor that's stored in column data
896
- grid = grid || this._hosts[0];
897
- if (grid) {
898
- var columnData = this._getColumnData(columnIndex, grid);
899
- var inCellCache = columnData["inCellCache"];
900
- if (inCellCache) {
901
- return inCellCache["inputElement"];
902
- }
903
- }
904
- } else if (this._activeInCellCache) {
905
- // for cell editing mode
906
- return this._activeInCellCache["inputElement"];
907
- }
908
- return null; // no editor open
958
+ if(this._activeRowId) { // for row editing mode
959
+ // get rowEditor that's stored in column data
960
+ grid = grid || this._hosts[0];
961
+ if(grid) {
962
+ let columnData = this._getColumnData(columnIndex, grid);
963
+ let inCellCache = columnData["inCellCache"];
964
+ if(inCellCache) {
965
+ return inCellCache["inputElement"];
966
+ }
967
+ }
968
+ } else if(this._activeInCellCache) { // for cell editing mode
969
+ return this._activeInCellCache["inputElement"];
970
+ }
971
+
972
+ return null; // no editor open
909
973
  };
910
974
 
911
975
  /** @public
912
976
  * @return {string}
913
977
  */
914
978
  InCellEditingPlugin.prototype.getInitialText = function () {
915
- return this._initialText;
979
+ return this._initialText;
916
980
  };
917
981
 
918
982
  /** @private
@@ -920,29 +984,31 @@ InCellEditingPlugin.prototype.getInitialText = function () {
920
984
  * @param {number} rowIndex
921
985
  * @param {string} field
922
986
  * @param {Element=} content element that get from cell.getContent
987
+ * @param {string} sectionType
923
988
  * @return {*}
924
989
  */
925
- InCellEditingPlugin.prototype._getSourceContent = function (dataSource, rowIndex, field, content) {
926
- if (this._contentSource == "field") {
927
- return this._getData(dataSource, rowIndex, field);
928
- } else {
929
- var textNode, str;
930
- if (content) {
931
- var len = content.childNodes.length;
932
- for (var i = 0; i < len; ++i) {
933
- if (content.childNodes[i].nodeType === 3) {
934
- textNode = content.childNodes[i]; // To preserve current content structure
935
- break;
936
- }
937
- }
938
- }
939
- if (textNode) {
940
- str = textNode.textContent;
941
- } else if (content) {
942
- str = content.textContent;
943
- }
944
- return str;
945
- }
990
+ InCellEditingPlugin.prototype._getSourceContent = function (dataSource, rowIndex, field, content, sectionType) {
991
+ if(this._contentSource == "field" && sectionType !== "title") {
992
+ return this._getData(dataSource, rowIndex, field);
993
+ } else {
994
+ let textNode, str;
995
+ if(content) {
996
+ let len = content.childNodes.length;
997
+ for(let i = 0; i < len; ++i) {
998
+ if(content.childNodes[i].nodeType === 3) {
999
+ textNode = content.childNodes[i]; // To preserve current content structure
1000
+ break;
1001
+ }
1002
+ }
1003
+ }
1004
+
1005
+ if(textNode) {
1006
+ str = textNode.textContent;
1007
+ } else if(content) {
1008
+ str = content.textContent;
1009
+ }
1010
+ return str;
1011
+ }
946
1012
  };
947
1013
 
948
1014
  /**
@@ -951,11 +1017,11 @@ InCellEditingPlugin.prototype._getSourceContent = function (dataSource, rowIndex
951
1017
  * @return {!number} row index will return -1 if not found
952
1018
  */
953
1019
  InCellEditingPlugin.prototype._getRowIndex = function (rowId) {
954
- if (rowId && this._lastActiveGrid) {
955
- var dv = this._lastActiveGrid.getDataSource();
956
- if (dv) return dv.getRowIndex(rowId);
957
- }
958
- return -1;
1020
+ if(rowId && this._lastActiveGrid) {
1021
+ let dv = this._lastActiveGrid.getDataSource();
1022
+ if(dv) return dv.getRowIndex(rowId);
1023
+ }
1024
+ return -1;
959
1025
  };
960
1026
 
961
1027
  /**
@@ -964,18 +1030,18 @@ InCellEditingPlugin.prototype._getRowIndex = function (rowId) {
964
1030
  * @return {!string} return empty string if not found
965
1031
  */
966
1032
  InCellEditingPlugin.prototype._getRowId = function (rowIndex) {
967
- if (rowIndex != null && this._lastActiveGrid) {
968
- var dv = this._lastActiveGrid.getDataSource();
969
- if (dv) return dv.getRowId(rowIndex);
970
- }
971
- return "";
1033
+ if(rowIndex != null && this._lastActiveGrid) {
1034
+ let dv = this._lastActiveGrid.getDataSource();
1035
+ if(dv) return dv.getRowId(rowIndex);
1036
+ }
1037
+ return "";
972
1038
  };
973
1039
 
974
1040
  /** @private
975
1041
  * @return {Object|null} core grid object
976
1042
  */
977
1043
  InCellEditingPlugin.prototype.getActiveGrid = function () {
978
- return this._activePos ? this._activePos["grid"] : null;
1044
+ return this._activePos ? this._activePos["grid"] : null;
979
1045
  };
980
1046
 
981
1047
  /** get active column index that editor had opended. Function can work only in cell editing mode.
@@ -983,11 +1049,11 @@ InCellEditingPlugin.prototype.getActiveGrid = function () {
983
1049
  * @return {number} column index will return -1 if not found
984
1050
  */
985
1051
  InCellEditingPlugin.prototype.getActiveColIndex = function () {
986
- if (this._activePos) {
987
- var colIndex = this._activePos["colIndex"];
988
- if (colIndex != null) return colIndex;
989
- }
990
- return -1;
1052
+ if(this._activePos) {
1053
+ let colIndex = this._activePos["colIndex"];
1054
+ if(colIndex != null) return colIndex;
1055
+ }
1056
+ return -1;
991
1057
  };
992
1058
 
993
1059
  /** get active row index that editor had opended. Function Can work in both cell/row editing modes.
@@ -995,29 +1061,27 @@ InCellEditingPlugin.prototype.getActiveColIndex = function () {
995
1061
  * @return {number} row index will return -1 if not found
996
1062
  */
997
1063
  InCellEditingPlugin.prototype.getActiveRowIndex = function () {
998
- if (this._activeRowId) {
999
- // row editing mode
1000
- return this._getRowIndex(this._activeRowId);
1001
- } else if (this._activePos) {
1002
- // cell editing mode
1003
- var rowIndex = this._activePos["rowIndex"];
1004
- if (rowIndex != null) return rowIndex;
1005
- }
1006
- return -1;
1064
+ if(this._activeRowId) { // row editing mode
1065
+ return this._getRowIndex(this._activeRowId);
1066
+ } else if(this._activePos) { // cell editing mode
1067
+ let rowIndex = this._activePos["rowIndex"];
1068
+ if(rowIndex != null) return rowIndex;
1069
+ }
1070
+ return -1;
1007
1071
  };
1008
1072
 
1009
1073
  /** @public
1010
1074
  * @return {Object}
1011
1075
  */
1012
1076
  InCellEditingPlugin.prototype.getInputElementPosition = function () {
1013
- return this._activePos || null;
1077
+ return this._activePos || null;
1014
1078
  };
1015
1079
 
1016
1080
  /** @public
1017
1081
  * @param {boolean=} opt_enable
1018
1082
  */
1019
1083
  InCellEditingPlugin.prototype.enableAutoCommitText = function (opt_enable) {
1020
- this._autoCommitText = opt_enable !== false;
1084
+ this._autoCommitText = (opt_enable !== false);
1021
1085
  };
1022
1086
 
1023
1087
  /** Check if the column can be edited by double click
@@ -1026,8 +1090,30 @@ InCellEditingPlugin.prototype.enableAutoCommitText = function (opt_enable) {
1026
1090
  * @return {boolean}
1027
1091
  */
1028
1092
  InCellEditingPlugin.prototype.isColumnEditable = function (colIndex) {
1029
- var val = this._getColumnOption(colIndex, "editableContent");
1030
- return val == null ? this._editableContent : val;
1093
+ let val = this._getColumnOption(colIndex, "editableContent");
1094
+ return val == null ? this._editableContent : val;
1095
+ };
1096
+ /** @public
1097
+ * @description Supply an keyboard input. This is for testing purpose.
1098
+ * @ignore
1099
+ * @param {string} keyName
1100
+ * @param {Object=} context
1101
+ */
1102
+ InCellEditingPlugin.prototype.supplyKey = function(keyName, context) {
1103
+ let eventObj = this._mockKeyboardEvent(keyName, context);
1104
+ this._onTextKeyDown(eventObj);
1105
+ this._onTextKeyUp(eventObj);
1106
+ };
1107
+ /** @public
1108
+ * @description Supply an double click event. This is for testing purpose.
1109
+ * @ignore
1110
+ * @param {number} colIndex
1111
+ * @param {number} rowIndex
1112
+ * @param {Object=} context
1113
+ */
1114
+ InCellEditingPlugin.prototype.mockDoubleClick = function(colIndex, rowIndex, context) {
1115
+ let eventObj = this._mockMouseEvent(colIndex, rowIndex, context);
1116
+ this._onDoubleClick(eventObj);
1031
1117
  };
1032
1118
  /** @private
1033
1119
  * @param {Event|Element} e
@@ -1035,33 +1121,34 @@ InCellEditingPlugin.prototype.isColumnEditable = function (colIndex) {
1035
1121
  * @fires InCellEditingPlugin#editorOpened
1036
1122
  */
1037
1123
  InCellEditingPlugin.prototype._onDoubleClick = function (e, opt_host) {
1038
- var t = this;
1039
- var host = opt_host || t.getRelativeGrid(e);
1040
- if (t.isEditing() || !host) {
1041
- return;
1042
- }
1043
- var arg = host.getRelativePosition(e);
1044
- var sectionType = arg["sectionType"];
1045
- if (sectionType === "content" && !t.isColumnEditable(arg["colIndex"])) {
1046
- return;
1047
- } else if (sectionType === "title" && !t._editableTitle) {
1048
- return;
1049
- } else if (sectionType === "header") {
1050
- return;
1051
- }
1052
- var dataSource = arg["dataSource"];
1053
- if (dataSource != null) {
1054
- var rowId = dataSource.getRowId(arg["rowIndex"]);
1055
- if (dataSource.getGroupByRowId(rowId)) {
1056
- return;
1057
- }
1058
- }
1059
-
1060
- // Initialize internal states
1061
- if (e["preventDefault"]) {
1062
- Dom.preventDefault(e);
1063
- }
1064
- t.openEditor(arg.colIndex, arg.rowIndex, arg.section, host);
1124
+ let t = this;
1125
+ let host = opt_host || t.getRelativeGrid(e);
1126
+ if(t.isEditing() || !host) { return; }
1127
+
1128
+ let arg = host.getRelativePosition(e);
1129
+ let sectionType = arg["sectionType"];
1130
+
1131
+ if(sectionType === "content" && !t.isColumnEditable(arg["colIndex"])) {
1132
+ return;
1133
+ } else if(sectionType === "title" && !t._editableTitle) {
1134
+ return;
1135
+ } else if(sectionType === "header") {
1136
+ return;
1137
+ }
1138
+
1139
+ let dataSource = arg["dataSource"];
1140
+ if(dataSource != null) {
1141
+ let rowId = dataSource.getRowId(arg["rowIndex"]);
1142
+ if(dataSource.getGroupByRowId(rowId)) {
1143
+ return;
1144
+ }
1145
+ }
1146
+
1147
+ // Initialize internal states
1148
+ if(e["preventDefault"]) {
1149
+ Dom.preventDefault(e);
1150
+ }
1151
+ t.openEditor(arg.colIndex, arg.rowIndex, arg.section, host);
1065
1152
  };
1066
1153
 
1067
1154
  /** @private
@@ -1070,159 +1157,175 @@ InCellEditingPlugin.prototype._onDoubleClick = function (e, opt_host) {
1070
1157
  * @param {Object=} arg
1071
1158
  */
1072
1159
  InCellEditingPlugin.prototype._openEditor = function (e, host, arg) {
1073
- var t = this;
1074
- if (!host.getElement() || this._hosts.indexOf(host) < 0) {
1075
- // Check validity due to asyncronous call
1076
- return;
1077
- }
1078
- if (!arg) {
1079
- arg = host.getRelativePosition(e);
1080
- }
1081
- if (!arg["hit"]) {
1082
- // The specified cell could be gone during the asyncronous process
1083
- return;
1084
- }
1085
- t._dispatch("preEditorOpening", arg);
1086
- if (arg["cancel"]) {
1087
- return;
1088
- }
1089
- var colIndex = arg["colIndex"];
1090
- var rowIndex = arg["rowIndex"];
1091
- var section = arg["section"];
1092
- var cell = section.getCell(colIndex, rowIndex);
1093
- var rowSpan = 1;
1094
- var stretchedCell = section.getStretchedCell(cell, rowIndex);
1095
- if (stretchedCell) {
1096
- cell = stretchedCell;
1097
- } else {
1098
- rowSpan = section.getCellRowSpan(colIndex, rowIndex);
1099
- }
1100
- if (!cell || cell.hasClass("no-editing")) {
1101
- return;
1102
- }
1103
- // Everything has been verified at this point. We can start the opening process.
1104
-
1105
- // close row editor first
1106
- t.closeRowEditor(false, host);
1107
- section.addClass("edit-mode");
1108
- t._lastActiveGrid = host;
1109
- t._activePos = arg;
1110
- arg["cell"] = t._activeCell = cell;
1111
- arg["content"] = t._prevContent = cell.getContent();
1112
- arg["field"] = t._getField(colIndex);
1113
- var dataSource = arg["dataSource"];
1114
- if (dataSource != null) {
1115
- var rowId = arg["rowId"] = this._getRowId(arg["rowIndex"]);
1116
- arg["segmentSeparator"] = dataSource.isSegmentSeparator(rowId);
1117
- arg["groupHeader"] = dataSource.getGroupByRowId(rowId);
1118
- arg["rowData"] = this._getRow(dataSource, rowId);
1119
- if (dataSource["stall"]) {
1120
- dataSource["stall"](true);
1121
- }
1122
- }
1123
-
1124
- // Initialize UIs
1125
- if (arg["sectionType"] === "title") {
1126
- t._activeInCellCache = t._createTitleEditor(host);
1127
- } else {
1128
- t._activeInCellCache = t._createContentEditor(colIndex, host);
1129
- }
1130
- var inputElement = arg["inputElement"] = t._activeInCellCache["inputElement"];
1131
- var editor = arg["editor"] = t._activeInCellCache["editor"];
1132
- var balloonPopup = t._activeInCellCache["balloonPopup"];
1133
- var sourceContent = arg ? t._getSourceContent(arg["dataSource"], arg["rowIndex"], arg["field"], arg["content"]) : "";
1134
- if (rowIndex + 1 >= section.getRowCount()) {
1135
- inputElement.classList.add("bottom");
1136
- } else {
1137
- inputElement.classList.remove("bottom");
1138
- }
1139
-
1140
- // Initialize Balloon
1141
- t._usingBalloon = t._isBalloonMode(cell);
1142
- if (t._usingBalloon) {
1143
- editor.classList.add("balloon");
1144
- } else {
1145
- editor.classList.remove("balloon");
1146
- }
1147
- var editorStyle = editor.style;
1148
- if (this._elfVersion || t._inlineStyling) {
1149
- editorStyle.backgroundColor = section.getComputedStyle().backgroundColor;
1150
- }
1151
- var rowH = section.getRowHeight(rowIndex);
1152
- var width = cell.getWidth();
1153
- if (!host.isPinnedColumn(colIndex)) {
1154
- var hScrollbar = host.getHScrollbar();
1155
- if (hScrollbar.isActive()) {
1156
- var paneSize = hScrollbar.getPaneSize();
1157
- if (width > paneSize) {
1158
- width = paneSize;
1159
- }
1160
- }
1161
- }
1162
- if (!t._usingBalloon || width > 208) {
1163
- editorStyle.width = width + "px";
1164
- } else {
1165
- editorStyle.width = "";
1166
- }
1167
- if (rowSpan > 1) {
1168
- editorStyle.height = cell.getHeight() + "px";
1169
- } else {
1170
- editorStyle.height = rowH + "px";
1171
- }
1172
-
1173
- // Attach our popup (balloon element)
1174
- var parentElement = document.body;
1175
- if (t._compositeGrid || t._realTimeGrid) {
1176
- var activeGrid = t.getActiveGrid();
1177
- if (activeGrid) {
1178
- parentElement = activeGrid.getElement().parentElement;
1179
- }
1180
- }
1181
- balloonPopup.enableUIBlocking(t._uiBlocking);
1182
- balloonPopup.addEventListener("hidden", t._onPopupHide);
1183
- balloonPopup.disableAutoHiding(!t._autoHiding);
1184
- balloonPopup.disableHideOnScroll(true);
1185
- balloonPopup.attachTo(cell.getElement());
1186
- balloonPopup.show(true, parentElement);
1187
- this._updateEditorPopup(t._activeInCellCache, cell, host);
1188
-
1189
- // Attach user element
1190
- if (t._customElement) {
1191
- t._customElementPopup.attachTo(editor);
1192
- t._customElementPopup.show(true, parentElement);
1193
- t._customElementPopup.disableAutoHiding(false);
1194
- arg["popupElement"] = t._customElement;
1195
- }
1196
-
1197
- // WARNING: value-changed event from ELF v3 component may NOT be triggered due to their design flaw
1198
- t._setText(sourceContent, inputElement);
1199
- arg["initialText"] = t._initialText = sourceContent;
1200
- if (t._disablingScroll) {
1201
- t._freezeScrolling(host, true);
1202
- }
1203
- arg["autoSuggest"] = t._autoSuggest;
1204
- if (t._autoSuggest) {
1205
- if (t._autoSuggest.attach === inputElement) {
1206
- t._autoSuggest.attach = null; // WORKAROUND: reset attach for re-attach target
1207
- }
1208
-
1209
- if (t._autoSuggest.parentNode !== editor) {
1210
- // if we appendChild all time when open editor, events won't work
1211
- editor.appendChild(t._autoSuggest);
1212
- }
1213
- t._autoSuggest.attach = inputElement;
1214
- t._autoSuggest.positionTarget = inputElement; // for re-position of autosuggest
1215
- }
1216
-
1217
- // Dispatch an event for user to setup stuff
1218
- t._dispatch("editorOpened", arg); // User may modify the editor
1219
-
1220
- inputElement.focus();
1221
- if (typeof inputElement.select === "function") {
1222
- inputElement.select();
1223
- }
1224
- arg["initialText"] = t._initialText = t.getText(); // After all modifications, cache the string for text change event
1225
- t._editing = true; // Editing state cannot be false until a text has been committed or cancelled
1160
+ let t = this;
1161
+ if(!host.getElement() || this._hosts.indexOf(host) < 0) { // Check validity due to asyncronous call
1162
+ return;
1163
+ }
1164
+
1165
+ if(!arg) {
1166
+ arg = host.getRelativePosition(e);
1167
+ }
1168
+
1169
+ if(!arg["hit"]) { // The specified cell could be gone during the asyncronous process
1170
+ return;
1171
+ }
1172
+
1173
+ t._dispatch("preEditorOpening", arg);
1174
+
1175
+ if(arg["cancel"]) {
1176
+ return;
1177
+ }
1178
+
1179
+ let colIndex = arg["colIndex"];
1180
+ let rowIndex = arg["rowIndex"];
1181
+ let section = arg["section"];
1182
+ let cell = section.getCell(colIndex, rowIndex);
1183
+ let rowSpan = 1;
1184
+ let stretchedCell = section.getStretchedCell(cell, rowIndex);
1185
+ if(stretchedCell){
1186
+ cell = stretchedCell;
1187
+ } else {
1188
+ rowSpan = section.getCellRowSpan(colIndex, rowIndex);
1189
+ }
1190
+
1191
+ if(!cell || cell.hasClass("no-editing")) {
1192
+ return;
1193
+ }
1194
+ // Everything has been verified at this point. We can start the opening process.
1195
+
1196
+ // close row editor first
1197
+ t.closeRowEditor(false, host);
1198
+
1199
+ section.addClass("edit-mode");
1200
+ t._lastActiveGrid = host;
1201
+ t._activePos = arg;
1202
+ arg["cell"] = t._activeCell = cell;
1203
+ arg["content"] = t._prevContent = cell.getContent();
1204
+ arg["field"] = t._getField(colIndex);
1205
+
1206
+ let dataSource = arg["dataSource"];
1207
+ if(dataSource != null) {
1208
+ let rowId = arg["rowId"] = this._getRowId(arg["rowIndex"]);
1209
+ arg["segmentSeparator"] = dataSource.isSegmentSeparator(rowId);
1210
+ arg["groupHeader"] = dataSource.getGroupByRowId(rowId);
1211
+ arg["rowData"] = this._getRow(dataSource, rowId);
1212
+
1213
+ if(dataSource["stall"]) {
1214
+ dataSource["stall"](true);
1215
+ }
1216
+ }
1217
+
1218
+ // Initialize UIs
1219
+ if(arg["sectionType"] === "title") {
1220
+ t._activeInCellCache = t._createTitleEditor(host);
1221
+ } else {
1222
+ t._activeInCellCache = t._createContentEditor(colIndex, host);
1223
+ }
1224
+
1225
+ let inputElement = arg["inputElement"] = t._activeInCellCache["inputElement"];
1226
+ let editor = arg["editor"] = t._activeInCellCache["editor"];
1227
+ let balloonPopup = t._activeInCellCache["balloonPopup"];
1228
+ let sourceContent = arg ? t._getSourceContent(arg["dataSource"], arg["rowIndex"], arg["field"], arg["content"], arg["sectionType"]) : "";
1229
+
1230
+ if(rowIndex + 1 >= section.getRowCount()) {
1231
+ inputElement.classList.add("bottom");
1232
+ } else {
1233
+ inputElement.classList.remove("bottom");
1234
+ }
1235
+
1236
+ // Initialize Balloon
1237
+ t._usingBalloon = t._isBalloonMode(cell);
1238
+ if(t._usingBalloon) {
1239
+ editor.classList.add("balloon");
1240
+ } else {
1241
+ editor.classList.remove("balloon");
1242
+ }
1243
+
1244
+ let editorStyle = editor.style;
1245
+ if(this._elfVersion || t._inlineStyling) {
1246
+ editorStyle.backgroundColor = section.getComputedStyle().backgroundColor;
1247
+ }
1248
+
1249
+ let rowH = section.getRowHeight(rowIndex);
1250
+ let width = cell.getWidth();
1251
+ if(!host.isPinnedColumn(colIndex)) {
1252
+ let hScrollbar = host.getHScrollbar();
1253
+ if(hScrollbar.isActive()) {
1254
+ let paneSize = hScrollbar.getPaneSize();
1255
+ if(width > paneSize) {
1256
+ width = paneSize;
1257
+ }
1258
+ }
1259
+ }
1260
+ if(!t._usingBalloon || width > 208) {
1261
+ editorStyle.width = width + "px";
1262
+ } else {
1263
+ editorStyle.width = "";
1264
+ }
1265
+
1266
+ if(rowSpan > 1) {
1267
+ editorStyle.height = cell.getHeight() + "px";
1268
+ } else {
1269
+ editorStyle.height = rowH + "px";
1270
+ }
1271
+
1272
+ // Attach our popup (balloon element)
1273
+ let parentElement = document.body;
1274
+ if(t._compositeGrid || t._realTimeGrid) {
1275
+ let activeGrid = t.getActiveGrid();
1276
+ if(activeGrid) {
1277
+ parentElement = activeGrid.getElement().parentElement;
1278
+ }
1279
+ }
1280
+
1281
+ balloonPopup.enableUIBlocking(t._uiBlocking);
1282
+ balloonPopup.addEventListener("hidden", t._onPopupHide);
1283
+ balloonPopup.disableAutoHiding(!t._autoHiding);
1284
+ balloonPopup.disableHideOnScroll(true);
1285
+ balloonPopup.attachTo(cell.getElement());
1286
+ balloonPopup.show(true, parentElement);
1287
+
1288
+ this._updateEditorPopup(t._activeInCellCache, cell, host);
1289
+
1290
+ // Attach user element
1291
+ if(t._customElement) {
1292
+ t._customElementPopup.attachTo(editor);
1293
+ t._customElementPopup.show(true, parentElement);
1294
+ t._customElementPopup.disableAutoHiding(false);
1295
+ arg["popupElement"] = t._customElement;
1296
+ }
1297
+
1298
+ // WARNING: value-changed event from ELF v3 component may NOT be triggered due to their design flaw
1299
+ t._setText(sourceContent, inputElement);
1300
+ arg["initialText"] = t._initialText = sourceContent;
1301
+
1302
+ if(t._disablingScroll) {
1303
+ t._freezeScrolling(host, true);
1304
+ }
1305
+
1306
+ arg["autoSuggest"] = t._autoSuggest;
1307
+ if(t._autoSuggest) {
1308
+ if(t._autoSuggest.attach === inputElement) {
1309
+ t._autoSuggest.attach = null; // WORKAROUND: reset attach for re-attach target
1310
+ }
1311
+
1312
+ if(t._autoSuggest.parentNode !== editor ) { // if we appendChild all time when open editor, events won't work
1313
+ editor.appendChild(t._autoSuggest);
1314
+ }
1315
+ t._autoSuggest.attach = inputElement;
1316
+ t._autoSuggest.positionTarget = inputElement; // for re-position of autosuggest
1317
+ }
1318
+
1319
+ // Dispatch an event for user to setup stuff
1320
+ t._dispatch("editorOpened", arg); // User may modify the editor
1321
+
1322
+ inputElement.focus();
1323
+ if(typeof inputElement.select === "function") {
1324
+ inputElement.select();
1325
+ }
1326
+
1327
+ arg["initialText"] = t._initialText = t.getText(); // After all modifications, cache the string for text change event
1328
+ t._editing = true; // Editing state cannot be false until a text has been committed or cancelled
1226
1329
  };
1227
1330
 
1228
1331
  /** Using to open row editor.
@@ -1231,98 +1334,102 @@ InCellEditingPlugin.prototype._openEditor = function (e, host, arg) {
1231
1334
  * @param {Object=} grid core grid object
1232
1335
  */
1233
1336
  InCellEditingPlugin.prototype.openRowEditor = function (rowIndex, grid) {
1234
- var t = this;
1235
- grid = grid || t._hosts[0];
1236
- // if open same row we will do nothing
1237
- if (t._getRowIndex(t._activeRowId) === rowIndex || !grid) {
1238
- return;
1239
- }
1240
-
1241
- // close all open editor
1242
- t.closeRowEditor(false, grid);
1243
- t._commitText(false);
1244
- var firstInput, firstPopup;
1245
- var section = grid.getSection("content");
1246
- var dataSource = grid.getDataSource();
1247
- var lastIndex = (section.getColumnCount() || 0) - 1;
1248
- var isBottom = rowIndex + 1 >= section.getRowCount();
1249
- var sectionBGColor = this._elfVersion || t._inlineStyling ? section.getComputedStyle().backgroundColor : null;
1250
- var rowH = section.getRowHeight(rowIndex);
1251
-
1252
- // if normally parent popup will be document.body
1253
- var parentElement = document.body;
1254
-
1255
- // but if grid is _compositeGrid or _realTimeGrid then
1256
- // then we will use grid parent instead
1257
- if (t._compositeGrid || t._realTimeGrid) {
1258
- parentElement = grid.getElement().parentElement;
1259
- }
1260
-
1261
- // loop for all column
1262
- for (var columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
1263
- // ignore column that can't edit
1264
- if (!t.isColumnEditable(columnIndex)) {
1265
- continue;
1266
- }
1267
- var cell = section.getCell(columnIndex, rowIndex);
1268
- if (!cell || cell.hasClass("no-editing")) {
1269
- continue;
1270
- } // all verify is done
1271
-
1272
- // create editor, popup, inputElement
1273
- var inCellCache = t._createContentEditor(columnIndex, grid);
1274
- var content = cell.getContent();
1275
- var field = t._getField(columnIndex);
1276
- var sourceContent = t._getSourceContent(dataSource, rowIndex, field, content);
1277
- var inputElement = inCellCache["inputElement"];
1278
- var editor = inCellCache["editor"];
1279
- var balloonPopup = inCellCache["balloonPopup"];
1280
- if (!firstInput) {
1281
- firstInput = inputElement;
1282
- firstPopup = balloonPopup;
1283
- balloonPopup.enableUIBlocking(t._uiBlocking);
1284
- } else {
1285
- balloonPopup.enableUIBlocking(false);
1286
- }
1287
- t._setText(sourceContent, inputElement); // WARNING: value-changed event from ELF v3 component may be triggered due to their design flaw
1288
-
1289
- if (isBottom) {
1290
- inputElement.classList.add("bottom");
1291
- } else {
1292
- inputElement.classList.remove("bottom");
1293
- }
1294
- var editorStyle = editor.style;
1295
- if (sectionBGColor) {
1296
- editorStyle.backgroundColor = sectionBGColor;
1297
- }
1298
- editorStyle.height = rowH + "px";
1299
-
1300
- // this is different from single edit mode
1301
- // row edit mode not support balloon mode
1302
- var width = section.getCellWidth(columnIndex, rowIndex);
1303
- editorStyle.width = width + "px";
1304
- editor.classList.remove("balloon");
1305
- balloonPopup.disableAutoHiding(true);
1306
- balloonPopup.disableHideOnScroll(true);
1307
- balloonPopup.attachTo(cell.getElement());
1308
- balloonPopup.show(true, parentElement);
1309
- this._updateEditorPopup(inCellCache, cell, grid);
1310
-
1311
- // this._updateEditorLayout(inputElement); // Adjust sizes after append to the DOM
1312
- }
1313
-
1314
- // if firstInput not undefined that mean at lease one popup is open
1315
- if (firstInput) {
1316
- firstPopup.addEventListener("hidden", t._onPopupHide);
1317
- t._lastActiveGrid = grid;
1318
- t._editing = true; // Editing state cannot be false until a text has been committed or cancelled
1319
- t._activeRowId = this._getRowId(rowIndex);
1320
- firstInput.focus();
1321
- section.addClass("edit-mode");
1322
- if (t._disablingScroll) {
1323
- t._freezeScrolling(grid, true);
1324
- }
1325
- }
1337
+ let t = this;
1338
+ grid = grid || t._hosts[0];
1339
+ // if open same row we will do nothing
1340
+ if(t._getRowIndex(t._activeRowId) === rowIndex || !grid) { return; }
1341
+
1342
+ // close all open editor
1343
+ t.closeRowEditor(false, grid);
1344
+ t._commitText(false);
1345
+
1346
+ let firstInput, firstPopup;
1347
+ let sectionType = "content";
1348
+ let section = grid.getSection(sectionType);
1349
+ let dataSource = grid.getDataSource();
1350
+ let lastIndex = (section.getColumnCount() || 0) - 1;
1351
+ let isBottom = (rowIndex + 1) >= section.getRowCount();
1352
+ let sectionBGColor = (this._elfVersion || t._inlineStyling) ? section.getComputedStyle().backgroundColor : null;
1353
+ let rowH = section.getRowHeight(rowIndex);
1354
+
1355
+ // if normally parent popup will be document.body
1356
+ let parentElement = document.body;
1357
+
1358
+ // but if grid is _compositeGrid or _realTimeGrid then
1359
+ // then we will use grid parent instead
1360
+ if(t._compositeGrid || t._realTimeGrid) {
1361
+ parentElement = grid.getElement().parentElement;
1362
+ }
1363
+
1364
+ // loop for all column
1365
+ for(let columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
1366
+ // ignore column that can't edit
1367
+ if(!t.isColumnEditable(columnIndex)) { continue; }
1368
+ let cell = section.getCell(columnIndex, rowIndex);
1369
+ if(!cell || cell.hasClass("no-editing")) {
1370
+ continue;
1371
+ } // all verify is done
1372
+
1373
+ // create editor, popup, inputElement
1374
+ let inCellCache = t._createContentEditor(columnIndex, grid);
1375
+
1376
+ let content = cell.getContent();
1377
+ let field = t._getField(columnIndex);
1378
+ let sourceContent = t._getSourceContent(dataSource, rowIndex, field, content, sectionType);
1379
+ let inputElement = inCellCache["inputElement"];
1380
+ let editor = inCellCache["editor"];
1381
+ let balloonPopup = inCellCache["balloonPopup"];
1382
+
1383
+ if(!firstInput) {
1384
+ firstInput = inputElement;
1385
+ firstPopup = balloonPopup;
1386
+ balloonPopup.enableUIBlocking(t._uiBlocking);
1387
+ } else {
1388
+ balloonPopup.enableUIBlocking(false);
1389
+ }
1390
+
1391
+ t._setText(sourceContent, inputElement); // WARNING: value-changed event from ELF v3 component may be triggered due to their design flaw
1392
+
1393
+ if(isBottom) {
1394
+ inputElement.classList.add("bottom");
1395
+ } else {
1396
+ inputElement.classList.remove("bottom");
1397
+ }
1398
+
1399
+ let editorStyle = editor.style;
1400
+ if(sectionBGColor) {
1401
+ editorStyle.backgroundColor = sectionBGColor;
1402
+ }
1403
+ editorStyle.height = rowH + "px";
1404
+
1405
+ // this is different from single edit mode
1406
+ // row edit mode not support balloon mode
1407
+ let width = section.getCellWidth(columnIndex, rowIndex);
1408
+ editorStyle.width = width + "px";
1409
+ editor.classList.remove("balloon");
1410
+
1411
+ balloonPopup.disableAutoHiding(true);
1412
+ balloonPopup.disableHideOnScroll(true);
1413
+ balloonPopup.attachTo(cell.getElement());
1414
+ balloonPopup.show(true, parentElement);
1415
+
1416
+ this._updateEditorPopup(inCellCache, cell, grid);
1417
+
1418
+ // this._updateEditorLayout(inputElement); // Adjust sizes after append to the DOM
1419
+ }
1420
+
1421
+ // if firstInput not undefined that mean at lease one popup is open
1422
+ if(firstInput) {
1423
+ firstPopup.addEventListener("hidden", t._onPopupHide);
1424
+ t._lastActiveGrid = grid;
1425
+ t._editing = true; // Editing state cannot be false until a text has been committed or cancelled
1426
+ t._activeRowId = this._getRowId(rowIndex);
1427
+ firstInput.focus();
1428
+ section.addClass("edit-mode");
1429
+ if(t._disablingScroll) {
1430
+ t._freezeScrolling(grid, true);
1431
+ }
1432
+ }
1326
1433
  };
1327
1434
 
1328
1435
  /** Using to close row editor.
@@ -1332,105 +1439,108 @@ InCellEditingPlugin.prototype.openRowEditor = function (rowIndex, grid) {
1332
1439
  * @fires InCellEditingPlugin#rowEditorClosed
1333
1440
  */
1334
1441
  InCellEditingPlugin.prototype.closeRowEditor = function (isCommit) {
1335
- var t = this;
1336
- var grid = t._lastActiveGrid;
1337
- // if no row active then do nothing
1338
- if (!t._activeRowId || !grid) {
1339
- return;
1340
- }
1341
- var rowId = t._activeRowId;
1342
- var rowIndex = t._getRowIndex(rowId);
1343
- if (rowIndex <= -1) {
1344
- isCommit = false; // rowIndex -1 mean row is not found or already disposed
1345
- } else {
1346
- isCommit = isCommit !== false; // default is true
1347
- }
1348
-
1349
- var section = grid.getSection("content");
1350
- var columnLength = grid.getColumnCount();
1351
- var fieldValue = {};
1352
- var inCellCaches = [];
1353
- var inCellCache;
1354
-
1355
- // in this section we just prepare data
1356
- for (var columnIndex = 0; columnIndex < columnLength; columnIndex++) {
1357
- var columnData = t._getColumnData(columnIndex, grid);
1358
- inCellCache = columnData && columnData["inCellCache"];
1359
-
1360
- // if not have inCellCache then this column not have editor
1361
- if (!inCellCache) {
1362
- continue;
1363
- }
1364
- inCellCache.columnIndex = columnIndex;
1365
- inCellCaches.push(inCellCache);
1366
- if (isCommit) {
1367
- var field = t._getField(columnIndex);
1368
- inCellCache.field = field;
1369
- fieldValue[field] = this._getValue(inCellCache["inputElement"]);
1370
- }
1371
- }
1372
- var length = inCellCaches.length;
1373
- var i, e;
1374
-
1375
- // dispatch event beforeRowCommit
1376
- if (isCommit) {
1377
- if (t.hasListener("beforeRowCommit")) {
1378
- e = {
1379
- grid: grid,
1380
- rowIndex: rowIndex,
1381
- fieldValue: fieldValue,
1382
- cancel: false,
1383
- rowId: t._activeRowId
1384
- };
1385
- t._dispatch("beforeRowCommit", e);
1386
- // e.cancel = true mean user want to cancel closeRowEditor operation
1387
- isCommit = !e.cancel;
1388
- }
1389
- if (isCommit) {
1390
- var dataSource = grid.getDataSource();
1391
- for (i = 0; i < length; i++) {
1392
- inCellCache = inCellCaches[i];
1393
- var value = fieldValue[inCellCache.field];
1394
- // set data to datasource
1395
- if (dataSource) {
1396
- // only use value from fieldValue
1397
- // because fieldValue maybe mutate from beforeRowCommit event
1398
- t._setData(dataSource, rowIndex, inCellCache.field, value);
1399
- }
1400
-
1401
- // set value to ui if content is a build in text
1402
- var cell = section.getCell(inCellCache.columnIndex, rowIndex);
1403
- var content = cell.getContent();
1404
- if (content && content.classList.contains("text")) {
1405
- cell.setContent(value);
1406
- }
1407
- }
1408
- }
1409
- }
1410
- if (t.hasListener("rowEditorClosed")) {
1411
- e = {
1412
- grid: grid,
1413
- rowIndex: rowIndex,
1414
- fieldValue: fieldValue,
1415
- committed: isCommit
1416
- };
1417
- t._dispatch("rowEditorClosed", e);
1418
- }
1419
-
1420
- // hide editor by remove popup from dom
1421
- for (i = 0; i < length; i++) {
1422
- var popup = inCellCaches[i].balloonPopup;
1423
- popup.removeEventListener("hidden", t._onPopupHide); // remove event every popup to make sure nothing left
1424
- popup.hide();
1425
- }
1426
- t._freezeScrolling(grid, false);
1427
-
1428
- // reset status and resource
1429
- section.removeClass("edit-mode");
1430
- t._editing = false;
1431
- t._activeRowId = "";
1432
- t._lastActiveGrid = null;
1433
- grid.focus();
1442
+ let t = this;
1443
+ let grid = t._lastActiveGrid;
1444
+ // if no row active then do nothing
1445
+ if(!t._activeRowId || !grid) { return; }
1446
+
1447
+ let rowId = t._activeRowId;
1448
+ let rowIndex = t._getRowIndex(rowId);
1449
+ if(rowIndex <= -1) {
1450
+ isCommit = false; // rowIndex -1 mean row is not found or already disposed
1451
+ } else {
1452
+ isCommit = isCommit !== false; // default is true
1453
+ }
1454
+
1455
+ let section = grid.getSection("content");
1456
+ let columnLength = grid.getColumnCount();
1457
+ let fieldValue = {};
1458
+ let inCellCaches = [];
1459
+ let inCellCache;
1460
+
1461
+ // in this section we just prepare data
1462
+ for(let columnIndex = 0; columnIndex < columnLength; columnIndex++) {
1463
+ let columnData = t._getColumnData(columnIndex, grid);
1464
+ inCellCache = columnData && columnData["inCellCache"];
1465
+
1466
+ // if not have inCellCache then this column not have editor
1467
+ if(!inCellCache) { continue; }
1468
+
1469
+ inCellCache.columnIndex = columnIndex;
1470
+ inCellCaches.push(inCellCache);
1471
+
1472
+ if(isCommit) {
1473
+ let field = t._getField(columnIndex);
1474
+ inCellCache.field = field;
1475
+ fieldValue[field] = this._getValue(inCellCache["inputElement"]);
1476
+ }
1477
+ }
1478
+
1479
+ let length = inCellCaches.length;
1480
+ let i, e;
1481
+
1482
+ // dispatch event beforeRowCommit
1483
+ if(isCommit) {
1484
+ if(t.hasListener("beforeRowCommit")) {
1485
+ e = {
1486
+ grid: grid,
1487
+ rowIndex: rowIndex,
1488
+ fieldValue: fieldValue,
1489
+ cancel: false,
1490
+ rowId: t._activeRowId
1491
+ };
1492
+ t._dispatch("beforeRowCommit", e);
1493
+ // e.cancel = true mean user want to cancel closeRowEditor operation
1494
+ isCommit = !e.cancel;
1495
+ }
1496
+
1497
+ if(isCommit) {
1498
+ let dataSource = grid.getDataSource();
1499
+ for(i = 0; i < length; i++) {
1500
+ inCellCache = inCellCaches[i];
1501
+ let value = fieldValue[inCellCache.field];
1502
+ // set data to datasource
1503
+ if(dataSource) {
1504
+ // only use value from fieldValue
1505
+ // because fieldValue maybe mutate from beforeRowCommit event
1506
+ t._setData(dataSource, rowIndex, inCellCache.field, value);
1507
+ }
1508
+
1509
+ // set value to ui if content is a build in text
1510
+ let cell = section.getCell(inCellCache.columnIndex, rowIndex);
1511
+ let content = cell.getContent();
1512
+ if(content && content.classList.contains("text")) {
1513
+ cell.setContent(value);
1514
+ }
1515
+ }
1516
+ }
1517
+ }
1518
+
1519
+ if(t.hasListener("rowEditorClosed")) {
1520
+ e = {
1521
+ grid: grid,
1522
+ rowIndex: rowIndex,
1523
+ fieldValue: fieldValue,
1524
+ committed: isCommit
1525
+ };
1526
+ t._dispatch("rowEditorClosed", e);
1527
+ }
1528
+
1529
+ // hide editor by remove popup from dom
1530
+ for(i = 0; i < length; i++) {
1531
+ let popup = inCellCaches[i].balloonPopup;
1532
+ popup.removeEventListener("hidden", t._onPopupHide); // remove event every popup to make sure nothing left
1533
+ popup.hide();
1534
+ }
1535
+
1536
+ t._freezeScrolling(grid, false);
1537
+
1538
+ // reset status and resource
1539
+ section.removeClass("edit-mode");
1540
+ t._editing = false;
1541
+ t._activeRowId = "";
1542
+ t._lastActiveGrid = null;
1543
+ grid.focus();
1434
1544
  };
1435
1545
 
1436
1546
  /** open row editor if no any row editor opened, and close row editor if it already opened
@@ -1442,14 +1552,14 @@ InCellEditingPlugin.prototype.closeRowEditor = function (isCommit) {
1442
1552
  * @fires InCellEditingPlugin#rowEditorClosed
1443
1553
  */
1444
1554
  InCellEditingPlugin.prototype.toggleRowEditor = function (rowIndex, isCommit, grid) {
1445
- if (this._getRowIndex(this._activeRowId) === rowIndex) {
1446
- this.closeRowEditor(isCommit, grid);
1447
- } else if (this._activeRowId) {
1448
- this.closeRowEditor(isCommit, grid);
1449
- this.openRowEditor(rowIndex, grid);
1450
- } else {
1451
- this.openRowEditor(rowIndex, grid);
1452
- }
1555
+ if(this._getRowIndex(this._activeRowId) === rowIndex) {
1556
+ this.closeRowEditor(isCommit, grid);
1557
+ } else if(this._activeRowId) {
1558
+ this.closeRowEditor(isCommit, grid);
1559
+ this.openRowEditor(rowIndex, grid);
1560
+ } else {
1561
+ this.openRowEditor(rowIndex, grid);
1562
+ }
1453
1563
  };
1454
1564
 
1455
1565
  /** handle grid scrolling not window scroll
@@ -1457,30 +1567,31 @@ InCellEditingPlugin.prototype.toggleRowEditor = function (rowIndex, isCommit, gr
1457
1567
  * @param {Object} e
1458
1568
  */
1459
1569
  InCellEditingPlugin.prototype._onScroll = function (e) {
1460
- this._scrolling = true;
1461
- if (!this._closingOnScroll && this._editing) {
1462
- if (this._activeInCellCache) {
1463
- var popup = this._activeInCellCache.balloonPopup;
1464
- popup.hide();
1465
- } else if (this._activeRowId) {
1466
- var grid = this.getActiveGrid() || this._lastActiveGrid;
1467
- var section = grid.getSection("content");
1468
- var lastIndex = (section.getColumnCount() || 0) - 1;
1469
- for (var columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
1470
- var columnData = this._getColumnData(columnIndex, grid);
1471
- var inCellCache = columnData["inCellCache"];
1472
- if (!inCellCache) {
1473
- continue;
1474
- }
1475
- var popupCache = inCellCache["balloonPopup"];
1476
- if (popupCache) {
1477
- popupCache.hide();
1478
- }
1479
- }
1480
- }
1481
- }
1482
- this._onPopupHide();
1483
- this._scrolling = false;
1570
+ this._scrolling = true;
1571
+ if(!this._closingOnScroll && this._editing){
1572
+ if(this._activeInCellCache){
1573
+ let popup = this._activeInCellCache.balloonPopup;
1574
+ popup.hide();
1575
+ }
1576
+ else if(this._activeRowId){
1577
+ let grid = this.getActiveGrid() || this._lastActiveGrid;
1578
+ let section = grid.getSection("content");
1579
+ let lastIndex = (section.getColumnCount() || 0) - 1;
1580
+ for(let columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
1581
+ let columnData = this._getColumnData(columnIndex, grid);
1582
+ let inCellCache = columnData["inCellCache"];
1583
+ if(!inCellCache){
1584
+ continue;
1585
+ }
1586
+ let popupCache = inCellCache["balloonPopup"];
1587
+ if(popupCache) {
1588
+ popupCache.hide();
1589
+ }
1590
+ }
1591
+ }
1592
+ }
1593
+ this._onPopupHide();
1594
+ this._scrolling = false;
1484
1595
  };
1485
1596
 
1486
1597
  /** handle popup hidden event
@@ -1488,152 +1599,157 @@ InCellEditingPlugin.prototype._onScroll = function (e) {
1488
1599
  * @param {Object} e
1489
1600
  */
1490
1601
  InCellEditingPlugin.prototype._onPopupHide = function (e) {
1491
- if (!this._closingOnScroll) {
1492
- if (this._scrolling) {
1493
- this.requestShowEditorPopup();
1494
- return;
1495
- }
1496
- }
1497
- // in cell editing mode, when popup hide for any reason
1498
- // cell editing will be close and make a commit. (depend on _autoCommitText flag)
1499
- // WARNING: when user scroll outside grid. it will call _onPopupHide as well
1500
- this._commitText(this._autoCommitText);
1501
-
1502
- // for row editing mode if editor hide by any reason
1503
- // we will call close closeRowEditor to reset all internal flag status
1504
- // row editing mode not care about _autoCommitText. (for the time being)
1505
- this.closeRowEditor(false);
1602
+ if(!this._closingOnScroll){
1603
+ if(this._scrolling){
1604
+ this.requestShowEditorPopup();
1605
+ return;
1606
+ }
1607
+ }
1608
+ // in cell editing mode, when popup hide for any reason
1609
+ // cell editing will be close and make a commit. (depend on _autoCommitText flag)
1610
+ // WARNING: when user scroll outside grid. it will call _onPopupHide as well
1611
+ this._commitText(this._autoCommitText);
1612
+
1613
+ // for row editing mode if editor hide by any reason
1614
+ // we will call close closeRowEditor to reset all internal flag status
1615
+ // row editing mode not care about _autoCommitText. (for the time being)
1616
+ this.closeRowEditor(false);
1506
1617
  };
1507
1618
 
1508
1619
  /** @private
1509
1620
  * @param {Object} event
1510
1621
  */
1511
- InCellEditingPlugin.prototype._onAutoSuggestItemSelected = function (event) {
1512
- var eventDetail = event.detail;
1513
- if (!eventDetail) {
1514
- return;
1515
- }
1516
- var targetSelected = eventDetail.target;
1517
- if (!targetSelected) {
1518
- return;
1519
- }
1520
- var suggestionMethod = eventDetail.method;
1521
- // Need to check the details of the methods, another method like a navigation, reset, clear shouldn't commit text
1522
- // TODO: We need to handled tab to move. Currently, the property suggestionDetail in 'beforeCommit' event doesn't handlded when we use autosuggest with tab to move.
1523
- if (suggestionMethod === "click" || suggestionMethod === "enter") {
1524
- this.setText(targetSelected.value);
1525
- this._commitText(true, eventDetail.suggestion);
1526
- }
1622
+ InCellEditingPlugin.prototype._onAutoSuggestItemSelected = function(event) {
1623
+ let eventDetail = event.detail;
1624
+ if(!eventDetail) {
1625
+ return;
1626
+ }
1627
+
1628
+ let targetSelected = eventDetail.target;
1629
+
1630
+ if(!targetSelected) {
1631
+ return;
1632
+ }
1633
+
1634
+ let suggestionMethod = eventDetail.method;
1635
+ // Need to check the details of the methods, another method like a navigation, reset, clear shouldn't commit text
1636
+ // TODO: We need to handled tab to move. Currently, the property suggestionDetail in 'beforeCommit' event doesn't handlded when we use autosuggest with tab to move.
1637
+ if(suggestionMethod === "click" || suggestionMethod === "enter") {
1638
+ this.setText(targetSelected.value);
1639
+ this._commitText(true, eventDetail.suggestion);
1640
+ }
1527
1641
  };
1528
1642
 
1529
1643
  /** @private
1530
1644
  * @param {Object} e
1531
1645
  */
1532
1646
  InCellEditingPlugin.prototype._onValueChanged = function (e) {
1533
- if (this._activeRowId) {
1534
- return;
1535
- } // do nothing in rowEditMode
1647
+ if(this._activeRowId) { return; } // do nothing in rowEditMode
1536
1648
 
1537
- this._commitText(true);
1649
+ this._commitText(true);
1538
1650
  };
1539
1651
  /** @private
1540
1652
  * @param {Object} e
1541
1653
  */
1542
1654
  InCellEditingPlugin.prototype._onMultiSelectionValueChanged = function (e) {
1543
- e.currentTarget.dirty = true;
1655
+ e.currentTarget.dirty = true;
1544
1656
  };
1545
1657
  /** @private
1546
1658
  * @param {Object} e
1547
1659
  */
1548
1660
  InCellEditingPlugin.prototype._onMultiSelectionEditorChanged = function (e) {
1549
- if (e.detail && e.detail.value === false) {
1550
- if (this._activePos) {
1551
- var inputElement = this._activePos["inputElement"];
1552
- if (inputElement.dirty) {
1553
- this._onValueChanged(e);
1554
- inputElement.dirty = false;
1555
- }
1556
- }
1557
- }
1661
+ if(e.detail && e.detail.value === false){
1662
+ if(this._activePos){
1663
+ let inputElement = this._activePos["inputElement"];
1664
+ if(inputElement.dirty){
1665
+ this._onValueChanged(e);
1666
+ inputElement.dirty = false;
1667
+ }
1668
+ }
1669
+ }
1558
1670
  };
1559
1671
 
1560
1672
  /** @private
1561
1673
  * @param {Object} e
1562
1674
  */
1563
1675
  InCellEditingPlugin.prototype._onTextKeyDown = function (e) {
1564
- e.stopPropagation();
1565
- if (this._activeRowId) {
1566
- return;
1567
- } // do nothing in rowEditMode
1568
-
1569
- // KeyCodes.ESC = 27
1570
- if (e.keyCode === 27) {
1571
- this._commitText(this._autoCommitText);
1572
- }
1573
- // KeyCodes.TAB = 9
1574
- if (e.keyCode === 9) {
1575
- // For check press tab key when user tab on auto suggest list
1576
- // When user tab on auto suggest, the focus should be in input and data doesn't commit
1577
- if (this._autoSuggest && this._autoSuggest.suggestions.length > 0) {
1578
- this._activeInCellCache.inputElement.focus();
1579
- }
1580
- e.preventDefault(); // stop losing focus
1581
- }
1676
+ e.stopPropagation();
1677
+
1678
+ if(this._activeRowId) { return; } // do nothing in rowEditMode
1679
+
1680
+ // KeyCodes.ESC = 27
1681
+ if(e.keyCode === 27) {
1682
+ this._commitText(this._autoCommitText);
1683
+ }
1684
+ // KeyCodes.TAB = 9
1685
+ if(e.keyCode === 9) {
1686
+ // For check press tab key when user tab on auto suggest list
1687
+ // When user tab on auto suggest, the focus should be in input and data doesn't commit
1688
+ if(this._autoSuggest && this._autoSuggest.suggestions.length > 0) {
1689
+ this._activeInCellCache.inputElement.focus();
1690
+ }
1691
+ e.preventDefault(); // stop losing focus
1692
+ }
1582
1693
  };
1583
1694
 
1584
1695
  /** @private
1585
1696
  * @param {Object} e
1586
1697
  */
1587
1698
  InCellEditingPlugin.prototype._onTextKeyUp = function (e) {
1588
- e.stopPropagation();
1589
- if (this._activeRowId) {
1590
- return;
1591
- } // do nothing in rowEditMode
1592
-
1593
- if (this.hasListener("keyUp")) {
1594
- this._activePos["text"] = this._activePos["enteredText"] = this._activeInCellCache["inputElement"].value;
1595
- this._dispatch("keyUp", this._activePos);
1596
- }
1597
-
1598
- // KeyCodes.ENTER = 13 && KeyCodes.TAB = 9
1599
- var tabKey = e.keyCode === 9;
1600
- if (tabKey || e.keyCode === 13) {
1601
- var text = this.getText();
1602
- var cellInfo = this._activePos;
1603
- if (this._initialText !== text) {
1604
- e.preventDefault(); // TODO: Check if this is needed
1605
- // Clear auto suggest and doesn't commit when user tab on auto suggest item
1606
- if (this._autoSuggest && this._autoSuggest.suggestions.length > 0) {
1607
- this._activeInCellCache.inputElement.focus();
1608
- this._autoSuggest.suggestions = [];
1609
- return; // when use tabToMove with auto suggest, it shouldn't be effect when doesn't commit text
1610
- } else {
1611
- this._commitText(true);
1612
- }
1613
- } else {
1614
- this._commitText(false);
1615
- }
1616
- if (tabKey && this._tabToMove && !e.altKey && !e.ctrlKey) {
1617
- var host = cellInfo ? cellInfo["grid"] : null;
1618
- if (host && host["getCellInfo"]) {
1619
- var dv = host.getDataSource();
1620
- while (cellInfo) {
1621
- cellInfo = e.shiftKey ? host.getPrevCell(cellInfo) : host.getNextCell(cellInfo);
1622
- if (cellInfo && cellInfo["cell"]) {
1623
- if (dv.getRowDataAt(cellInfo["rowIndex"])) {
1624
- // Check group header row
1625
- if (this.isColumnEditable(cellInfo["colIndex"])) {
1626
- this.openEditor(cellInfo["colIndex"], cellInfo["rowIndex"], cellInfo["sectionName"], cellInfo["grid"]);
1627
- break;
1628
- }
1629
- }
1630
- } else {
1631
- cellInfo = null;
1632
- }
1633
- }
1634
- }
1635
- }
1636
- }
1699
+ e.stopPropagation();
1700
+
1701
+ if(this._activeRowId) { return; } // do nothing in rowEditMode
1702
+
1703
+ if(this.hasListener("keyUp")) {
1704
+ this._activePos["text"] = this._activePos["enteredText"] = this._activeInCellCache["inputElement"].value;
1705
+ this._dispatch("keyUp", this._activePos);
1706
+ }
1707
+
1708
+ // KeyCodes.ENTER = 13 && KeyCodes.TAB = 9
1709
+ let tabKey = e.keyCode === 9;
1710
+ if(tabKey || e.keyCode === 13) {
1711
+ let text = this.getText();
1712
+ let cellInfo = this._activePos;
1713
+
1714
+ if(this._initialText !== text) {
1715
+ e.preventDefault(); // TODO: Check if this is needed
1716
+ // Clear auto suggest and doesn't commit when user tab on auto suggest item
1717
+ if(this._autoSuggest && this._autoSuggest.suggestions.length > 0) {
1718
+ this._activeInCellCache.inputElement.focus();
1719
+ this._autoSuggest.suggestions = [];
1720
+ return; // when use tabToMove with auto suggest, it shouldn't be effect when doesn't commit text
1721
+ } else {
1722
+ this._commitText(true);
1723
+ }
1724
+ } else {
1725
+ this._commitText(false);
1726
+ }
1727
+
1728
+ if(tabKey && this._tabToMove && !e.altKey && !e.ctrlKey) {
1729
+ let host = cellInfo ? cellInfo["grid"] : null;
1730
+ if(host && host["getCellInfo"]) {
1731
+ let dv = host.getDataSource();
1732
+ while (cellInfo) {
1733
+ cellInfo = (e.shiftKey) ? host.getPrevCell(cellInfo) : host.getNextCell(cellInfo);
1734
+ if(cellInfo && cellInfo["cell"]) {
1735
+ if(dv.getRowDataAt(cellInfo["rowIndex"])) { // Check group header row
1736
+ if(this.isColumnEditable(cellInfo["colIndex"])) {
1737
+ this.openEditor(
1738
+ cellInfo["colIndex"],
1739
+ cellInfo["rowIndex"],
1740
+ cellInfo["sectionName"],
1741
+ cellInfo["grid"]
1742
+ );
1743
+ break;
1744
+ }
1745
+ }
1746
+ } else {
1747
+ cellInfo = null;
1748
+ }
1749
+ }
1750
+ }
1751
+ }
1752
+ }
1637
1753
  };
1638
1754
  /** Commit text from editor to cell.
1639
1755
  * @private
@@ -1641,97 +1757,103 @@ InCellEditingPlugin.prototype._onTextKeyUp = function (e) {
1641
1757
  * @param {Object} suggestionDetail suggestion detail for auto suggest element
1642
1758
  */
1643
1759
  InCellEditingPlugin.prototype._commitText = function (committed, suggestionDetail) {
1644
- var t = this;
1645
- var arg = t._activePos;
1646
- if (!t.isEditing() || !arg) {
1647
- return;
1648
- }
1649
- arg["section"].removeClass("edit-mode");
1650
- t._editing = false;
1651
- var enteredValue = arg["text"] = this.getValue();
1652
- var groupHeader = arg["groupHeader"] || false;
1653
- if (committed) {
1654
- if (suggestionDetail) {
1655
- // This property is only available when the user commits text from the 'item-select' event of the auto suggest.
1656
- arg["suggestionDetail"] = suggestionDetail;
1657
- }
1658
- if (t.hasListener("beforeCommit")) {
1659
- t._dispatch("beforeCommit", arg);
1660
- committed = !arg["cancel"];
1661
- enteredValue = arg["text"];
1662
- }
1663
- if (committed && t._dataBinding && !groupHeader) {
1664
- var sectionSettings = arg["sectionSettings"];
1665
- var sectionType = sectionSettings.getType();
1666
- // case edit content
1667
- if ("content" === sectionType) {
1668
- if (this._realTimeGrid && arg["field"] === "X_RIC_NAME") {
1669
- var ricOpt = null;
1670
- if (suggestionDetail) {
1671
- var suggestionVal = suggestionDetail["value"];
1672
- if (suggestionVal["p"]) {
1673
- var permId = suggestionVal["p"]["PermId"];
1674
- if (permId) {
1675
- ricOpt = {
1676
- permId: permId
1677
- };
1678
- }
1679
- }
1680
- }
1681
- this._realTimeGrid.setRic(arg["rowId"], enteredValue, ricOpt);
1682
- } else {
1683
- var dv = sectionSettings.getDataSource();
1684
- if (dv) {
1685
- if (this._realTimeGrid) {
1686
- t._setStaticData(dv, arg["rowIndex"], arg["field"], enteredValue);
1687
- } else {
1688
- t._setData(dv, arg["rowIndex"], arg["field"], enteredValue);
1689
- }
1690
- }
1691
- }
1692
- if (!t._prevContent || t._prevContent.classList.contains("text")) {
1693
- // Bind data only if previous content is a build in text
1694
- t._activeCell.setContent(enteredValue);
1695
- }
1696
- } else if ("title" === sectionType) {
1697
- var gridApi = this.getGridApi();
1698
- if (gridApi) {
1699
- gridApi.setColumnName(arg["colIndex"], enteredValue);
1700
- }
1701
- } else {
1702
- t._activeCell.setContent(enteredValue);
1703
- }
1704
- }
1705
- }
1706
- if (t.hasListener("editorClosed")) {
1707
- arg["canceled"] = arg["cancelled"] = !committed;
1708
- arg["committed"] = committed;
1709
- t._dispatch("editorClosed", arg);
1710
- }
1711
- if (t._activeInCellCache && t._activeInCellCache.balloonPopup) {
1712
- t._activeInCellCache.balloonPopup.removeEventListener("hidden", t._onPopupHide);
1713
- t._activeInCellCache.balloonPopup.hide();
1714
- }
1715
- Dom.removeParent(t._customElement);
1716
- var grid = arg["grid"];
1717
- if (grid) {
1718
- t._freezeScrolling(grid, false);
1719
- grid.focus();
1720
- }
1721
- var dataSource = arg["dataSource"];
1722
- if (dataSource) {
1723
- if (dataSource["stall"]) {
1724
- dataSource["stall"](false);
1725
- }
1726
- }
1727
- t._activePos = t._activeCell = t._prevContent = t._lastActiveGrid = t._activeInCellCache = null;
1760
+ let t = this;
1761
+ let arg = t._activePos;
1762
+ if(!t.isEditing() || !arg) {
1763
+ return;
1764
+ }
1765
+
1766
+ arg["section"].removeClass("edit-mode");
1767
+ t._editing = false;
1768
+
1769
+ let enteredValue = arg["text"] = this.getValue();
1770
+ let groupHeader = arg["groupHeader"] || false;
1771
+
1772
+ if(committed){
1773
+ if(suggestionDetail) { // This property is only available when the user commits text from the 'item-select' event of the auto suggest.
1774
+ arg["suggestionDetail"] = suggestionDetail;
1775
+ }
1776
+ if(t.hasListener("beforeCommit")) {
1777
+ t._dispatch("beforeCommit", arg);
1778
+ committed = !arg["cancel"];
1779
+ enteredValue = arg["text"];
1780
+ }
1781
+
1782
+ if(committed && t._dataBinding && !groupHeader) {
1783
+ let sectionSettings = arg["sectionSettings"];
1784
+ let sectionType = sectionSettings.getType();
1785
+ // case edit content
1786
+ if("content" === sectionType) {
1787
+ if(this._realTimeGrid && arg["field"] === "X_RIC_NAME") {
1788
+ let ricOpt = null;
1789
+ if(suggestionDetail) {
1790
+ let suggestionVal = suggestionDetail["value"];
1791
+ if(suggestionVal["p"]) {
1792
+ let permId = suggestionVal["p"]["PermId"];
1793
+ if(permId) {
1794
+ ricOpt = { permId: permId };
1795
+ }
1796
+ }
1797
+ }
1798
+
1799
+ this._realTimeGrid.setRic(arg["rowId"], enteredValue, ricOpt);
1800
+ } else {
1801
+ let dv = sectionSettings.getDataSource();
1802
+ if(dv) {
1803
+ if(this._realTimeGrid) {
1804
+ t._setStaticData(dv, arg["rowIndex"], arg["field"], enteredValue);
1805
+ } else {
1806
+ t._setData(dv, arg["rowIndex"], arg["field"], enteredValue);
1807
+ }
1808
+ }
1809
+ }
1810
+
1811
+ if(!t._prevContent || t._prevContent.classList.contains("text")) { // Bind data only if previous content is a build in text
1812
+ t._activeCell.setContent(enteredValue);
1813
+ }
1814
+ } else if("title" === sectionType) {
1815
+ let gridApi = this.getGridApi();
1816
+ if(gridApi) {
1817
+ gridApi.setColumnName(arg["colIndex"], enteredValue);
1818
+ }
1819
+ } else {
1820
+ t._activeCell.setContent(enteredValue);
1821
+ }
1822
+ }
1823
+ }
1824
+
1825
+ if(t.hasListener("editorClosed")) {
1826
+ arg["canceled"] = arg["cancelled"] = !committed;
1827
+ arg["committed"] = committed;
1828
+ t._dispatch("editorClosed", arg);
1829
+ }
1830
+
1831
+ if(t._activeInCellCache && t._activeInCellCache.balloonPopup) {
1832
+ t._activeInCellCache.balloonPopup.removeEventListener("hidden", t._onPopupHide);
1833
+ t._activeInCellCache.balloonPopup.hide();
1834
+ }
1835
+ Dom.removeParent(t._customElement);
1836
+
1837
+ let grid = arg["grid"];
1838
+ if(grid) {
1839
+ t._freezeScrolling(grid, false);
1840
+ grid.focus();
1841
+ }
1842
+ let dataSource = arg["dataSource"];
1843
+ if(dataSource) {
1844
+ if(dataSource["stall"]) {
1845
+ dataSource["stall"](false);
1846
+ }
1847
+ }
1848
+
1849
+ t._activePos = t._activeCell = t._prevContent = t._lastActiveGrid = t._activeInCellCache = null;
1728
1850
  };
1729
1851
 
1730
1852
  /** @private
1731
1853
  * @param {Event} e
1732
1854
  */
1733
1855
  InCellEditingPlugin.prototype._stopPropagation = function (e) {
1734
- e.stopPropagation();
1856
+ e.stopPropagation();
1735
1857
  };
1736
1858
 
1737
1859
  /** Using for Check balloon mode is turn on/off.
@@ -1740,9 +1862,10 @@ InCellEditingPlugin.prototype._stopPropagation = function (e) {
1740
1862
  * @return {boolean}
1741
1863
  */
1742
1864
  InCellEditingPlugin.prototype._isBalloonMode = function (cell) {
1743
- var cellElem = cell.getElement();
1744
- var compStyles = cellElem ? window.getComputedStyle(cellElem) : {};
1745
- return this._balloonMode || compStyles.display === "none" || compStyles.visibility === "hidden";
1865
+ let cellElem = cell.getElement();
1866
+ let compStyles = (cellElem) ? window.getComputedStyle(cellElem) : {};
1867
+
1868
+ return (this._balloonMode || compStyles.display === "none" || compStyles.visibility === "hidden");
1746
1869
  };
1747
1870
 
1748
1871
  /** @private
@@ -1750,30 +1873,31 @@ InCellEditingPlugin.prototype._isBalloonMode = function (cell) {
1750
1873
  * @param {boolean} bool
1751
1874
  */
1752
1875
  InCellEditingPlugin.prototype._listenForTriggering = function (host, bool) {
1753
- if (bool) {
1754
- host.listen("dblclick", this._onDoubleClick);
1755
-
1756
- // Make a comparable functionality for touchscreen
1757
- if (isTouchDevice()) {
1758
- host.listen("touchstart", this._onTouchStart);
1759
- host.listen("touchend", this._onTouchEnd);
1760
- host.listen("touchcancel", this._onTouchEnd);
1761
- }
1762
- } else {
1763
- host.unlisten("dblclick", this._onDoubleClick);
1764
- host.unlisten("touchstart", this._onTouchStart);
1765
- host.unlisten("touchend", this._onTouchEnd);
1766
- host.unlisten("touchcancel", this._onTouchEnd);
1767
- }
1876
+ if(bool) {
1877
+ host.listen("dblclick", this._onDoubleClick);
1878
+
1879
+ // Make a comparable functionality for touchscreen
1880
+ if(isTouchDevice()) {
1881
+ host.listen("touchstart", this._onTouchStart);
1882
+ host.listen("touchend", this._onTouchEnd);
1883
+ host.listen("touchcancel", this._onTouchEnd);
1884
+ }
1885
+ } else {
1886
+ host.unlisten("dblclick", this._onDoubleClick);
1887
+ host.unlisten("touchstart", this._onTouchStart);
1888
+ host.unlisten("touchend", this._onTouchEnd);
1889
+ host.unlisten("touchcancel", this._onTouchEnd);
1890
+ }
1768
1891
  };
1769
1892
 
1893
+
1770
1894
  /** Use only On-Touch-Start event on mobile devices.
1771
1895
  * @private
1772
1896
  * @param {Object} e
1773
1897
  */
1774
1898
  InCellEditingPlugin.prototype._onTouchStart = function (e) {
1775
- this._resetTouchTimer();
1776
- this._touchTimerId = setTimeout(this._onTouchTimer, this._longPressTime);
1899
+ this._resetTouchTimer();
1900
+ this._touchTimerId = setTimeout(this._onTouchTimer, this._longPressTime);
1777
1901
  };
1778
1902
 
1779
1903
  /** Use only press time on mobile devices.
@@ -1781,7 +1905,7 @@ InCellEditingPlugin.prototype._onTouchStart = function (e) {
1781
1905
  * @param {Object} e
1782
1906
  */
1783
1907
  InCellEditingPlugin.prototype._onTouchTimer = function (e) {
1784
- this._touchTimerId = 0;
1908
+ this._touchTimerId = 0;
1785
1909
  };
1786
1910
 
1787
1911
  /** Use only On-Touch-End event on mobile devices.
@@ -1789,9 +1913,9 @@ InCellEditingPlugin.prototype._onTouchTimer = function (e) {
1789
1913
  * @param {Event} e
1790
1914
  */
1791
1915
  InCellEditingPlugin.prototype._onTouchEnd = function (e) {
1792
- if (!this._resetTouchTimer()) {
1793
- this._onDoubleClick(e); // Trigger cell editor
1794
- }
1916
+ if(!this._resetTouchTimer()) {
1917
+ this._onDoubleClick(e); // Trigger cell editor
1918
+ }
1795
1919
  };
1796
1920
 
1797
1921
  /** Use only to reset timer on mobile devices.
@@ -1799,12 +1923,12 @@ InCellEditingPlugin.prototype._onTouchEnd = function (e) {
1799
1923
  * @return {boolean}
1800
1924
  */
1801
1925
  InCellEditingPlugin.prototype._resetTouchTimer = function () {
1802
- if (this._touchTimerId) {
1803
- clearTimeout(this._touchTimerId);
1804
- this._touchTimerId = 0;
1805
- return true;
1806
- }
1807
- return false;
1926
+ if(this._touchTimerId) {
1927
+ clearTimeout(this._touchTimerId);
1928
+ this._touchTimerId = 0;
1929
+ return true;
1930
+ }
1931
+ return false;
1808
1932
  };
1809
1933
 
1810
1934
  /** Set other elements to using like popup when editing cell.
@@ -1812,17 +1936,19 @@ InCellEditingPlugin.prototype._resetTouchTimer = function () {
1812
1936
  * @param {Element} elm
1813
1937
  */
1814
1938
  InCellEditingPlugin.prototype.setPopupElement = function (elm) {
1815
- var balloonPopup = this._activeInCellCache && this._activeInCellCache["balloonPopup"];
1816
- if (this._customElement) {
1817
- balloonPopup && balloonPopup.removeFocusElement(this._customElement);
1818
- this._customElementPopup.dispose();
1819
- this._customElementPopup = null;
1820
- }
1821
- this._customElement = elm;
1822
- if (this._customElement) {
1823
- this._customElementPopup = new Popup(this._customElement);
1824
- balloonPopup && balloonPopup.addFocusElement(this._customElement);
1825
- }
1939
+ let balloonPopup = this._activeInCellCache && this._activeInCellCache["balloonPopup"];
1940
+ if(this._customElement) {
1941
+ balloonPopup && balloonPopup.removeFocusElement(this._customElement);
1942
+ this._customElementPopup.dispose();
1943
+ this._customElementPopup = null;
1944
+ }
1945
+
1946
+ this._customElement = elm;
1947
+
1948
+ if(this._customElement) {
1949
+ this._customElementPopup = new Popup(this._customElement);
1950
+ balloonPopup && balloonPopup.addFocusElement(this._customElement);
1951
+ }
1826
1952
  };
1827
1953
 
1828
1954
  /** Set content to the editor but do not commit anything to internal storage.
@@ -1830,9 +1956,9 @@ InCellEditingPlugin.prototype.setPopupElement = function (elm) {
1830
1956
  * @param {*} content
1831
1957
  */
1832
1958
  InCellEditingPlugin.prototype.setText = function (content) {
1833
- // TODO: since we have inputElement per each column
1834
- // we should receive column index to set value in specific column
1835
- this._activeInCellCache && this._setText(content, this._activeInCellCache["inputElement"]);
1959
+ // TODO: since we have inputElement per each column
1960
+ // we should receive column index to set value in specific column
1961
+ this._activeInCellCache && this._setText(content, this._activeInCellCache["inputElement"]);
1836
1962
  };
1837
1963
 
1838
1964
  /** @private
@@ -1840,43 +1966,41 @@ InCellEditingPlugin.prototype.setText = function (content) {
1840
1966
  * @param {Element} inputElement editor element
1841
1967
  */
1842
1968
  InCellEditingPlugin.prototype._setText = function (content, inputElement) {
1843
- inputElement._origValue = content;
1844
- var inputTag = inputElement.tagName.toLowerCase();
1845
- var typeMap = InCellEditingPlugin._uiElementTypesMap;
1846
- if (inputTag === typeMap.checkbox) {
1847
- var checked = content ? !(content === "f" || content === "false") : false;
1848
- if (checked) {
1849
- inputElement.setAttribute("checked", "true");
1850
- } else {
1851
- inputElement.removeAttribute("checked");
1852
- }
1853
- } else if (inputTag === typeMap.combobox) {
1854
- var isMultiple = inputElement.getAttribute("multiple");
1855
- if (isMultiple) {
1856
- inputElement.values = content.split(/, */);
1857
- } else if (this._elfVersion <= 3) {
1858
- inputElement.value = "";
1859
- inputElement.value = {
1860
- value: content,
1861
- label: content
1862
- };
1863
- } else {
1864
- inputElement.value = content;
1865
- }
1866
- } else if (inputTag === typeMap.date) {
1867
- ElfDate.setDate(inputElement, content);
1868
- } else {
1869
- var txt = "";
1870
- if (content != null) {
1871
- if (typeof content === "string") {
1872
- txt = content;
1873
- } else {
1874
- // content could be false, 0, NaN or etc.
1875
- txt = content + "";
1876
- }
1877
- }
1878
- inputElement.value = txt;
1879
- }
1969
+ inputElement._origValue = content;
1970
+
1971
+ let inputTag = inputElement.tagName.toLowerCase();
1972
+ let typeMap = InCellEditingPlugin._uiElementTypesMap;
1973
+ if(inputTag === typeMap.checkbox) {
1974
+ let checked = (content) ? !(content === "f" || content === "false") : false;
1975
+ if(checked) {
1976
+ inputElement.setAttribute("checked", "true");
1977
+ } else {
1978
+ inputElement.removeAttribute("checked");
1979
+ }
1980
+ } else if(inputTag === typeMap.combobox) {
1981
+ let isMultiple = inputElement.getAttribute("multiple");
1982
+
1983
+ if(isMultiple){
1984
+ inputElement.values = content.split(/, */);
1985
+ } else if(this._elfVersion <= 3) {
1986
+ inputElement.value = "";
1987
+ inputElement.value = { value: content, label: content };
1988
+ } else {
1989
+ inputElement.value = content;
1990
+ }
1991
+ } else if(inputTag === typeMap.date) {
1992
+ ElfDate.setDate(inputElement, content);
1993
+ } else {
1994
+ let txt = "";
1995
+ if(content != null) {
1996
+ if(typeof content === "string") {
1997
+ txt = content;
1998
+ } else { // content could be false, 0, NaN or etc.
1999
+ txt = content + "";
2000
+ }
2001
+ }
2002
+ inputElement.value = txt;
2003
+ }
1880
2004
  };
1881
2005
 
1882
2006
  /** Get current text from the editor
@@ -1885,9 +2009,12 @@ InCellEditingPlugin.prototype._setText = function (content, inputElement) {
1885
2009
  * @see {@link InCellEditingPlugin#getValue}
1886
2010
  */
1887
2011
  InCellEditingPlugin.prototype.getText = function () {
1888
- // TODO: since we have inputElement per each column
1889
- // we should receive column index to return text of inputElement in specific column
1890
- if (this._activeInCellCache) return this._getText(this._activeInCellCache["inputElement"]);else return "";
2012
+ // TODO: since we have inputElement per each column
2013
+ // we should receive column index to return text of inputElement in specific column
2014
+ if(this._activeInCellCache)
2015
+ return this._getText(this._activeInCellCache["inputElement"]);
2016
+ else
2017
+ return "";
1891
2018
  };
1892
2019
 
1893
2020
  /** @private
@@ -1895,18 +2022,18 @@ InCellEditingPlugin.prototype.getText = function () {
1895
2022
  * @return {string}
1896
2023
  */
1897
2024
  InCellEditingPlugin.prototype._getText = function (inputElement) {
1898
- var inputTag = inputElement.tagName.toLowerCase();
1899
- var typeMap = InCellEditingPlugin._uiElementTypesMap;
1900
- if (inputTag === typeMap.checkbox) {
1901
- return inputElement.checked + "";
1902
- } else if (inputTag === typeMap.combobox) {
1903
- if (this._elfVersion <= 3) {
1904
- return inputElement.value ? inputElement.value.value : "";
1905
- }
1906
- } else if (inputTag === typeMap.date) {
1907
- return inputElement.value + "";
1908
- }
1909
- return inputElement.value;
2025
+ let inputTag = inputElement.tagName.toLowerCase();
2026
+ let typeMap = InCellEditingPlugin._uiElementTypesMap;
2027
+ if(inputTag === typeMap.checkbox) {
2028
+ return inputElement.checked + "";
2029
+ } else if(inputTag === typeMap.combobox) {
2030
+ if(this._elfVersion <= 3) {
2031
+ return inputElement.value ? inputElement.value.value : "";
2032
+ }
2033
+ } else if(inputTag === typeMap.date) {
2034
+ return inputElement.value + "";
2035
+ }
2036
+ return inputElement.value;
1910
2037
  };
1911
2038
 
1912
2039
  /** Convert current text from the editor to value corresponding to the type of the editor
@@ -1915,9 +2042,9 @@ InCellEditingPlugin.prototype._getText = function (inputElement) {
1915
2042
  * @see {@link InCellEditingPlugin#getText}
1916
2043
  */
1917
2044
  InCellEditingPlugin.prototype.getValue = function () {
1918
- // TODO: since we have inputElement per each column
1919
- // we should receive column index to return value of inputElement in specific column
1920
- return this._activeInCellCache ? this._getValue(this._activeInCellCache["inputElement"]) : null;
2045
+ // TODO: since we have inputElement per each column
2046
+ // we should receive column index to return value of inputElement in specific column
2047
+ return this._activeInCellCache ? this._getValue(this._activeInCellCache["inputElement"]) : null;
1921
2048
  };
1922
2049
 
1923
2050
  /** @private
@@ -1925,26 +2052,29 @@ InCellEditingPlugin.prototype.getValue = function () {
1925
2052
  * @return {*} Returned type is based on the type of the editor
1926
2053
  */
1927
2054
  InCellEditingPlugin.prototype._getValue = function (inputElement) {
1928
- var inputTag = inputElement.tagName.toLowerCase();
1929
- var typeMap = InCellEditingPlugin._uiElementTypesMap;
1930
- if (inputTag === typeMap.checkbox) {
1931
- return inputElement.checked ? true : false;
1932
- } else if (inputTag === typeMap.date) {
1933
- return ElfDate.getDate(inputElement);
1934
- } else if (inputTag === typeMap.number || typeof inputElement._origValue === "number" // Smart data conversion based orignal value
1935
- ) {
1936
- return +inputElement.value;
1937
- } else if (inputTag === typeMap.combobox && inputElement.getAttribute("multiple")) {
1938
- return inputElement.values.join(", ");
1939
- }
1940
- return this._getText(inputElement);
2055
+ let inputTag = inputElement.tagName.toLowerCase();
2056
+ let typeMap = InCellEditingPlugin._uiElementTypesMap;
2057
+ if(inputTag === typeMap.checkbox) {
2058
+ return inputElement.checked ? true : false;
2059
+ } else if(inputTag === typeMap.date) {
2060
+ return ElfDate.getDate(inputElement);
2061
+ } else if(
2062
+ inputTag === typeMap.number ||
2063
+ typeof inputElement._origValue === "number" // Smart data conversion based orignal value
2064
+ ) {
2065
+ return +inputElement.value;
2066
+ } else if(inputTag === typeMap.combobox && inputElement.getAttribute("multiple")) {
2067
+ return inputElement.values.join(", ");
2068
+ }
2069
+
2070
+ return this._getText(inputElement);
1941
2071
  };
1942
2072
 
1943
2073
  /** Use to clear text in text editor.
1944
2074
  * @public
1945
2075
  */
1946
2076
  InCellEditingPlugin.prototype.clearText = function () {
1947
- this.setText("");
2077
+ this.setText("");
1948
2078
  };
1949
2079
 
1950
2080
  /** Use to append text in text editor. WARNING: Only works with the text type editor
@@ -1952,11 +2082,11 @@ InCellEditingPlugin.prototype.clearText = function () {
1952
2082
  * @param {string} word
1953
2083
  */
1954
2084
  InCellEditingPlugin.prototype.appendText = function (word) {
1955
- // TODO: since we have inputElement per each column
1956
- // we should receive column index to return append text in specific column
1957
- if (word && this._activeInCellCache) {
1958
- this._activeInCellCache["inputElement"].value += word;
1959
- }
2085
+ // TODO: since we have inputElement per each column
2086
+ // we should receive column index to return append text in specific column
2087
+ if(word && this._activeInCellCache) {
2088
+ this._activeInCellCache["inputElement"].value += word;
2089
+ }
1960
2090
  };
1961
2091
 
1962
2092
  /** Commit text will set text and commit to cell.
@@ -1964,10 +2094,10 @@ InCellEditingPlugin.prototype.appendText = function (word) {
1964
2094
  * @param {string=} word
1965
2095
  */
1966
2096
  InCellEditingPlugin.prototype.commitText = function (word) {
1967
- if (word) {
1968
- this.setText(word);
1969
- }
1970
- this._commitText(true);
2097
+ if(word) {
2098
+ this.setText(word);
2099
+ }
2100
+ this._commitText(true);
1971
2101
  };
1972
2102
 
1973
2103
  /** Get Balloon Popup Element to access any API provided.
@@ -1975,9 +2105,9 @@ InCellEditingPlugin.prototype.commitText = function (word) {
1975
2105
  * @return {Popup|null}
1976
2106
  */
1977
2107
  InCellEditingPlugin.prototype.getBalloonPopup = function () {
1978
- // TODO: since we have balloonPopup per each column
1979
- // we should receive column index to return balloonPopup in specific column
1980
- return this._activeInCellCache ? this._activeInCellCache["balloonPopup"] : null;
2108
+ // TODO: since we have balloonPopup per each column
2109
+ // we should receive column index to return balloonPopup in specific column
2110
+ return this._activeInCellCache ? this._activeInCellCache["balloonPopup"] : null;
1981
2111
  };
1982
2112
 
1983
2113
  /** Get ef-autosuggest or atlas-autosuggest
@@ -1985,7 +2115,7 @@ InCellEditingPlugin.prototype.getBalloonPopup = function () {
1985
2115
  * @return {Element}
1986
2116
  */
1987
2117
  InCellEditingPlugin.prototype.getAutoSuggest = function () {
1988
- return this._autoSuggest;
2118
+ return this._autoSuggest;
1989
2119
  };
1990
2120
 
1991
2121
  /**
@@ -1994,9 +2124,9 @@ InCellEditingPlugin.prototype.getAutoSuggest = function () {
1994
2124
  * @return {boolean} previous disablingScroll status
1995
2125
  */
1996
2126
  InCellEditingPlugin.prototype.setDisablingScroll = function (disabled) {
1997
- var prev = disabled;
1998
- this._disablingScroll = disabled;
1999
- return prev;
2127
+ let prev = disabled;
2128
+ this._disablingScroll = disabled;
2129
+ return prev;
2000
2130
  };
2001
2131
 
2002
2132
  /** stop scrolling to move to prevent editor close
@@ -2005,71 +2135,77 @@ InCellEditingPlugin.prototype.setDisablingScroll = function (disabled) {
2005
2135
  * @param {boolean=} frozen
2006
2136
  */
2007
2137
  InCellEditingPlugin.prototype._freezeScrolling = function (grid, frozen) {
2008
- if (!grid) return;
2009
- var vs = grid.getVScrollbar();
2010
- var hs = grid.getHScrollbar();
2011
- vs && vs.freezeScrolling(frozen);
2012
- hs && hs.freezeScrolling(frozen);
2138
+ if(!grid) return;
2139
+
2140
+ let vs = grid.getVScrollbar();
2141
+ let hs = grid.getHScrollbar();
2142
+ vs && vs.freezeScrolling(frozen);
2143
+ hs && hs.freezeScrolling(frozen);
2013
2144
  };
2014
2145
 
2015
2146
  /** Set a timer to call onUpdateEditorPopup only once to avoid performance issue
2016
2147
  * @public
2017
2148
  */
2018
- InCellEditingPlugin.prototype.requestShowEditorPopup = function () {
2019
- if (!this._editorTimerId) {
2020
- this._editorTimerId = setTimeout(this._onUpdateEditorPopup.bind(this), 100);
2021
- }
2149
+ InCellEditingPlugin.prototype.requestShowEditorPopup = function() {
2150
+ if(!this._editorTimerId) {
2151
+ this._editorTimerId = setTimeout(this._onUpdateEditorPopup.bind(this), 100);
2152
+ }
2022
2153
  };
2023
2154
 
2024
2155
  /** @private */
2025
- InCellEditingPlugin.prototype._onUpdateEditorPopup = function () {
2026
- this._editorTimerId = 0;
2027
- var grid = this.getActiveGrid() || this._lastActiveGrid;
2028
- if (!grid) {
2029
- return;
2030
- }
2031
- var parentElement = document.body;
2032
- if (this._compositeGrid || this._realTimeGrid) {
2033
- parentElement = grid.getElement().parentElement;
2034
- }
2035
- var rowIndex, colIndex;
2036
- if (this._activeInCellCache) {
2037
- var activePos = this._activePos;
2038
- if (activePos) {
2039
- rowIndex = activePos["rowIndex"];
2040
- colIndex = activePos["colIndex"];
2041
- var section = grid.getSection(activePos["sectionType"]);
2042
- var cell = section.getCell(colIndex, rowIndex);
2043
- var stretchedCell = section.getStretchedCell(cell, rowIndex);
2044
- if (stretchedCell) {
2045
- cell = stretchedCell;
2046
- }
2047
- if (cell) {
2048
- var popup = this._activeInCellCache["balloonPopup"];
2049
- popup.attachTo(cell.getElement());
2050
- popup.show(true, parentElement);
2051
- this._updateEditorPopup(this._activeInCellCache, cell, grid);
2052
- }
2053
- }
2054
- } else if (this._activeRowId) {
2055
- var sectionContent = grid.getSection("content");
2056
- rowIndex = this._getRowIndex(this._activeRowId);
2057
- if (sectionContent.isRowVisible(rowIndex)) {
2058
- var lastIndex = (sectionContent.getColumnCount() || 0) - 1;
2059
- for (var columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
2060
- var columnData = this._getColumnData(columnIndex, grid);
2061
- var inCellCache = columnData["inCellCache"];
2062
- var cellContent = sectionContent.getCell(columnIndex, rowIndex);
2063
- if (!inCellCache || !cellContent) {
2064
- continue;
2065
- }
2066
- var popupCache = inCellCache["balloonPopup"];
2067
- popupCache.attachTo(cellContent.getElement());
2068
- popupCache.show(true, parentElement);
2069
- this._updateEditorPopup(inCellCache, cellContent, grid);
2070
- }
2071
- }
2072
- }
2156
+ InCellEditingPlugin.prototype._onUpdateEditorPopup = function() {
2157
+ this._editorTimerId = 0;
2158
+ let grid = this.getActiveGrid() || this._lastActiveGrid;
2159
+ if(!grid){
2160
+ return;
2161
+ }
2162
+ let parentElement = document.body;
2163
+ if(this._compositeGrid || this._realTimeGrid) {
2164
+ parentElement = grid.getElement().parentElement;
2165
+ }
2166
+
2167
+ let rowIndex, colIndex;
2168
+
2169
+ if(this._activeInCellCache){
2170
+ let activePos = this._activePos;
2171
+ if(activePos){
2172
+ rowIndex = activePos["rowIndex"];
2173
+ colIndex = activePos["colIndex"];
2174
+ let section = grid.getSection(activePos["sectionType"]);
2175
+ let cell = section.getCell(colIndex, rowIndex);
2176
+ let stretchedCell = section.getStretchedCell(cell, rowIndex);
2177
+ if(stretchedCell){
2178
+ cell = stretchedCell;
2179
+ }
2180
+ if(cell){
2181
+ let popup = this._activeInCellCache["balloonPopup"];
2182
+ popup.attachTo(cell.getElement());
2183
+ popup.show(true, parentElement);
2184
+
2185
+ this._updateEditorPopup(this._activeInCellCache, cell, grid);
2186
+ }
2187
+ }
2188
+ }
2189
+ else if(this._activeRowId){
2190
+ let sectionContent = grid.getSection("content");
2191
+ rowIndex = this._getRowIndex(this._activeRowId);
2192
+ if(sectionContent.isRowVisible(rowIndex)){
2193
+ let lastIndex = (sectionContent.getColumnCount() || 0) - 1;
2194
+ for(let columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
2195
+ let columnData = this._getColumnData(columnIndex, grid);
2196
+ let inCellCache = columnData["inCellCache"];
2197
+ let cellContent = sectionContent.getCell(columnIndex, rowIndex);
2198
+ if(!inCellCache || !cellContent){
2199
+ continue;
2200
+ }
2201
+ let popupCache = inCellCache["balloonPopup"];
2202
+ popupCache.attachTo(cellContent.getElement());
2203
+ popupCache.show(true, parentElement);
2204
+
2205
+ this._updateEditorPopup(inCellCache, cellContent, grid);
2206
+ }
2207
+ }
2208
+ }
2073
2209
  };
2074
2210
  /** Update editor popup position and styles
2075
2211
  * @private
@@ -2077,82 +2213,92 @@ InCellEditingPlugin.prototype._onUpdateEditorPopup = function () {
2077
2213
  * @param {Object} cell
2078
2214
  * @param {Object} grid grid instance
2079
2215
  */
2080
- InCellEditingPlugin.prototype._updateEditorPopup = function (contentEditor, cell, grid) {
2081
- var popup = contentEditor["balloonPopup"];
2082
- var editor = contentEditor["editor"];
2083
- var inputElement = contentEditor["inputElement"];
2084
- var popupElem = popup.getElement();
2085
- var pos = grid.getRelativePosition(cell);
2086
- var width = cell.getWidth();
2087
- var height = cell.getHeight();
2088
- var colRect = grid.getColumnRect(0, grid.getColumnCount());
2089
- var rowRect = grid.getRowRect(0, grid.getRowCount());
2090
- var offsetWidth = colRect.scrollViewSize;
2091
- var offsetHeight = rowRect.scrollViewSize;
2092
- var offsetLeft = 0;
2093
- var offsetTop = pos["sectionType"] == "content" ? rowRect.scrollViewTop : 0;
2094
- var newHeight = height;
2095
- var newWidth = width;
2096
- var displayStyle = "inline-block";
2097
- var marginLeft = 0;
2098
- var marginTop = 0;
2099
- if (colRect.leftPinnedIndex != -1) {
2100
- var diff = 0;
2101
- if (grid.getVScrollbar().isActive()) {
2102
- diff -= 8; // If column is left pinned, scrollbar width need to be subtracted
2103
- }
2104
-
2105
- diff += colRect.width - colRect.scrollViewSize;
2106
- offsetWidth += diff;
2107
- offsetLeft += diff;
2108
- }
2109
- if (editor.classList.contains("balloon") && !this._activeRowId) {
2110
- popupElem.style.display = "";
2111
- editor.style.width = "";
2112
- editor.style.marginLeft = "";
2113
- editor.style.marginTop = "";
2114
- marginLeft = -4;
2115
- marginTop = -4;
2116
- newWidth = popup.getElement().offsetWidth;
2117
- }
2118
- if (!pos["hit"]) {
2119
- displayStyle = "none";
2120
- } else {
2121
- var acquiredWidth = pos["x"] + newWidth;
2122
- var acquiredHeight = pos["y"] - offsetTop + newHeight;
2123
- var isPinned = grid.isPinnedColumn(pos["colIndex"]);
2124
- // if column is pinned, doesn't need to calculate left overflow
2125
- if (!isPinned) {
2126
- // Left overflow
2127
- if (pos["x"] < offsetLeft) {
2128
- newWidth = newWidth - (offsetLeft - pos["x"]);
2129
- marginLeft = marginLeft + Math.abs(pos["x"] - offsetLeft);
2130
- }
2131
- }
2132
-
2133
- // Right overflow
2134
- if (acquiredWidth > offsetWidth) {
2135
- newWidth = newWidth - (acquiredWidth - offsetWidth);
2136
- }
2137
- // Top overflow
2138
- if (pos["y"] < offsetTop) {
2139
- newHeight = newHeight + pos["y"] - offsetTop;
2140
- marginTop = marginTop + Math.abs(pos["y"] - offsetTop);
2141
- }
2142
- // Bottom overflow
2143
- if (acquiredHeight > offsetHeight) {
2144
- newHeight = newHeight - (acquiredHeight - offsetHeight);
2145
- }
2146
- if (newWidth < 48 && newWidth != width || newHeight < 16 && newHeight != height) {
2147
- displayStyle = "none";
2148
- }
2149
- }
2150
- popupElem.style.display = displayStyle;
2151
- editor.style.width = newWidth ? newWidth + "px" : "";
2152
- editor.style.height = newHeight ? newHeight + "px" : "";
2153
- editor.style.marginLeft = marginLeft ? marginLeft + "px" : 0;
2154
- editor.style.marginTop = marginTop ? marginTop + "px" : 0;
2155
- inputElement.focus();
2216
+ InCellEditingPlugin.prototype._updateEditorPopup = function(contentEditor, cell, grid) {
2217
+ let popup = contentEditor["balloonPopup"];
2218
+ let editor = contentEditor["editor"];
2219
+ let inputElement = contentEditor["inputElement"];
2220
+ let popupElem = popup.getElement();
2221
+ let pos = grid.getRelativePosition(cell);
2222
+ let width = cell.getWidth();
2223
+ let height = cell.getHeight();
2224
+ let colRect = grid.getColumnRect(0, grid.getColumnCount());
2225
+ let rowRect = grid.getRowRect(0, grid.getRowCount());
2226
+ let offsetWidth = colRect.scrollViewSize;
2227
+ let offsetHeight = rowRect.scrollViewSize;
2228
+ let offsetLeft = 0;
2229
+ let offsetTop = pos["sectionType"] == "content" ? rowRect.scrollViewTop : 0;
2230
+
2231
+ let newHeight = height;
2232
+ let newWidth = width;
2233
+ let displayStyle = "inline-block";
2234
+ let marginLeft = 0;
2235
+ let marginTop = 0;
2236
+
2237
+ if(colRect.leftPinnedIndex != -1){
2238
+ let diff = 0;
2239
+ if(grid.getVScrollbar().isActive()){
2240
+ diff -= 8; // If column is left pinned, scrollbar width need to be subtracted
2241
+ }
2242
+ diff += colRect.width - colRect.scrollViewSize;
2243
+ offsetWidth += diff;
2244
+ offsetLeft += diff;
2245
+ }
2246
+
2247
+ if(editor.classList.contains("balloon") && !this._activeRowId){
2248
+ popupElem.style.display = "";
2249
+ editor.style.width = "";
2250
+ editor.style.marginLeft = "";
2251
+ editor.style.marginTop = "";
2252
+ marginLeft = -4;
2253
+ marginTop = -4;
2254
+
2255
+ newWidth = popup.getElement().offsetWidth;
2256
+ }
2257
+
2258
+ if(!pos["hit"]){
2259
+ displayStyle = "none";
2260
+ } else {
2261
+ let acquiredWidth = pos["x"] + newWidth;
2262
+ let acquiredHeight = pos["y"] - offsetTop + newHeight;
2263
+
2264
+ let isPinned = grid.isPinnedColumn(pos["colIndex"]);
2265
+ // if column is pinned, doesn't need to calculate left overflow
2266
+ if(!isPinned) {
2267
+ // Left overflow
2268
+ if(pos["x"] < offsetLeft){
2269
+ newWidth = (newWidth - (offsetLeft - pos["x"]));
2270
+ marginLeft = marginLeft + Math.abs(pos["x"] - offsetLeft);
2271
+ }
2272
+ }
2273
+
2274
+ // Right overflow
2275
+ if(acquiredWidth > offsetWidth){
2276
+ newWidth = newWidth - (acquiredWidth - offsetWidth);
2277
+ }
2278
+ // Top overflow
2279
+ if(pos["y"] < offsetTop){
2280
+ newHeight = (newHeight + pos["y"] - offsetTop);
2281
+ marginTop = marginTop + Math.abs(pos["y"] - offsetTop);
2282
+ }
2283
+ // Bottom overflow
2284
+ if(acquiredHeight > offsetHeight){
2285
+ newHeight = newHeight - (acquiredHeight - offsetHeight);
2286
+ }
2287
+
2288
+ if((newWidth < 48 && newWidth != width) || (newHeight < 16 && newHeight != height)){
2289
+ displayStyle = "none";
2290
+ }
2291
+ }
2292
+
2293
+ popupElem.style.display = displayStyle;
2294
+ editor.style.width = newWidth ? newWidth + "px" : "";
2295
+ editor.style.height = newHeight ? newHeight + "px" : "";
2296
+ editor.style.marginLeft = marginLeft ? marginLeft + "px" : 0;
2297
+ editor.style.marginTop = marginTop ? marginTop + "px" : 0;
2298
+ inputElement.focus();
2156
2299
  };
2300
+
2301
+
2302
+
2157
2303
  export default InCellEditingPlugin;
2158
- export { InCellEditingPlugin, InCellEditingPlugin as InCellEditing, InCellEditingPlugin as InCellEditingExtension };
2304
+ export { InCellEditingPlugin, InCellEditingPlugin as InCellEditing, InCellEditingPlugin as InCellEditingExtension };