all files / base/ gantt-chart.js

75.93% Statements 757/997
69.63% Branches 674/968
83.58% Functions 56/67
76.23% Lines 757/993
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562   1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137×   1137× 1137× 1137× 1137×   1137× 1137× 1137× 1137× 1137×   1111× 1111×   1137× 1137× 1137× 1137×   1137×   97× 4253× 4253× 1006×     97× 97× 18×   97× 96×     1366× 35× 35× 35×     1331× 1331× 968× 968× 968×   1331× 1331× 19272× 11662× 11662× 11662×     7610× 6490×   6490× 6484×     1120×   1048×       1331× 1331× 56×   1331× 95×     1366× 1366× 1111×   1366×     194× 194× 194× 194× 194× 194× 2368× 2368× 2368× 671×         411× 411× 411×       411× 53×   358×   416× 71×   345×     671× 671× 671× 260×       411×   671× 671× 165×   671×     671×   18×   653×   650× 535× 535× 535× 119×       416×   535×       535×         535× 535× 535×   650×   1137×   1137× 23× 23×   1137× 1137×   1137× 1137× 1137×     1137× 1137× 1137× 91×     1046×   1137× 1137× 1137× 821×   1137×     1582× 1582×   1582× 1582× 855×     727× 727× 696×     31×     1582×           1580×         1582×       1582× 1582× 1582× 1582×   1618× 107× 107× 107× 107× 107× 107× 26× 26× 11×     15× 15×   26× 26×     81×       2719× 2495×   2495× 2495× 2495× 2495× 2495× 2495×   2495× 1502× 1501× 1501× 1501×   1501× 1501× 336×     1165× 1165× 1165×                   1137×     1137× 1137× 1137× 1137× 1137×   186× 186×       186×   22× 22×                     186× 186× 180× 180×   186× 186× 180×   186×                                                                                                             28× 28×       19× 19× 19× 19× 19×   19× 19×       19×           868× 868× 868×   94×     1534×       1534× 175×   1534× 1534×     1534× 23×   1534× 285× 285×       1534× 1332×   1534×   202×         202× 202×           202× 46× 46×     202×     202× 202× 137×   202× 202× 146× 146× 146×   202× 202×     164×   202× 202× 202× 202×     201×   202×         202× 38× 38×   38×   34× 28×     202× 175×   202×                                     171×                       171× 171×                       171× 171× 143×       269× 41×   269× 23× 23×             184×                                                                                                                 189×             94097× 94097×                   1097× 1097× 1097× 1097× 1097× 1097× 1097× 62×     237× 237× 237× 11×   237×     185× 185× 76×   109× 109×       109×   109× 10× 10× 10×         10×   10×     99×   109× 109×   109× 82×   109× 109× 109×   144× 144× 144×   144×     93× 93×     93× 93×       93×   93×               87× 87×   87×   93× 93×   93× 93×   93× 93× 93×   202× 11×   191×     474× 474× 249× 249× 93×   249× 249× 138× 138×     225× 225× 225× 109×   225× 225× 226× 226×     474× 447× 447× 447× 447× 17757×       1590×     447× 1590× 1590×         272×         21×     13× 13× 13×       21× 21×         1111× 1111× 1111× 1111× 1111× 1111× 1111× 1111× 1111× 1111×   1111× 1106× 1106×   1111× 1111× 1111× 1111×   1137× 1137× 1137× 1137× 1137× 1137× 1137×   1137× 1137× 1137× 1137× 1137×   1137× 16× 16× 16×     1137× 1121× 1121×   1121× 1121×     1137× 1137×   1137× 1137× 1137× 1137×     1137× 1137×                                                         748× 748×       748×   748×                               17× 17× 17×   17×     17× 17×   17×   17×   17× 14×   17×   17× 17× 17×       17×                                       17×     17×                           17×                   17×     17×               17× 17× 11×       11×       10×     17×       17× 17×     17×   17×       17×   11×                                                                                                                                                           17×   17×   11× 11×       11×                         11×         17×       17× 17×         16×                                                                                                       15×     15×                       29× 11× 11×                 11×                           11×         18×     13× 13× 13×       1075× 1075× 1075× 106×     969×   1075× 19× 19×     1056× 1056× 1056×       1056×             1056×       1075×   1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137× 1137×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/css-constants", "../actions/chart-scroll", "@syncfusion/ej2-grids", "../renderer/virtual-content-render"], function (require, exports, ej2_base_1, ej2_base_2, cls, chart_scroll_1, ej2_grids_1, virtual_content_render_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var GanttChart = (function () {
        function GanttChart(parent) {
            this.isExpandCollapseFromChart = false;
            this.isExpandAll = false;
            this.isCollapseAll = false;
            this.debounceTimeoutNext = 0;
            this.debounceTimeout = 0;
            this.isGanttElement = false;
            this.previousPinchDistance = 0;
            this.currentToolbarIndex = -1;
            this.isPinching = false;
            this.parent = parent;
            this.chartTimelineContainer = null;
            this.rangeViewContainer =
                ej2_base_1.createElement('div', { className: cls.rangeContainer });
            this.rangeViewContainer.setAttribute('role', 'button');
            this.rangeViewContainer.setAttribute('aria-label', 'RangeContainer');
            this.virtualRender = new virtual_content_render_1.VirtualContentRenderer(this.parent);
            this.addEventListener();
        }
        GanttChart.prototype.addEventListener = function () {
            this.parent.on('renderPanels', this.renderChartContainer, this);
            this.parent.on('recordsUpdated', this.renderChartElements, this);
            this.parent.on('dataReady', this.renderInitialContents, this);
            this.parent.on('tree-grid-created', this.renderChartContents, this);
            this.parent.on('destroy', this.destroy, this);
        };
        GanttChart.prototype.renderChartContents = function () {
            this.parent.notify('refreshDayMarkers', {});
            this.wireEvents();
        };
        GanttChart.prototype.renderChartContainer = function () {
            this.chartElement = ej2_base_1.createElement('div', { id: this.parent.element.id + 'GanttChart', className: cls.ganttChart });
            this.parent.chartPane.appendChild(this.chartElement);
            this.renderTimelineContainer();
            this.renderBodyContainers();
        };
        GanttChart.prototype.renderInitialContents = function () {
            this.parent.timelineModule.createTimelineSeries();
        };
        GanttChart.prototype.renderOverAllocationContainer = function () {
            for (var i = 0; i < this.parent.flatData.length; i++) {
                var data = this.parent.flatData[i];
                if (data.childRecords.length > 0) {
                    this.parent.dataOperation.updateOverlappingValues(data);
                }
            }
            var rangeContainer = this.parent.element.querySelector('.' + cls.rangeContainer);
            if (rangeContainer) {
                rangeContainer.innerHTML = '';
            }
            if (this.parent.treeGrid.grid.filterSettings.columns.length === 0) {
                this.renderRangeContainer(this.parent.currentViewData);
            }
        };
        GanttChart.prototype.renderChartElements = function () {
            if (this.parent.isFromOnPropertyChange) {
                this.rangeViewContainer.innerHTML = '';
                this.parent.updateProjectDates(this.parent.cloneProjectStartDate, this.parent.cloneProjectEndDate, this.parent.isTimelineRoundOff);
                this.parent.isFromOnPropertyChange = false;
            }
            else {
                this.parent.chartRowsModule.renderChartRows();
                if (this.parent.predecessorModule && this.parent.taskFields.dependency) {
                    this.parent.connectorLineIds = [];
                    this.parent.updatedConnectorLineCollection = [];
                    this.parent.predecessorModule.createConnectorLinesCollection();
                }
                this.parent.connectorLineModule.renderConnectorLines(this.parent.updatedConnectorLineCollection);
                for (var i = 0; i < this.parent.chartRowsModule.ganttChartTableBody.children.length; i++) {
                    if (this.parent.chartRowsModule.ganttChartTableBody.children[i].children[0].children[1].children[4]) {
                        this.parent.chartRowsModule.ganttChartTableBody.children[i].children[0].children[1].children[1].setAttribute('tabindex', '-1');
                        this.parent.chartRowsModule.ganttChartTableBody.children[i].children[0].children[1].children[2].setAttribute('tabindex', '-1');
                        this.parent.chartRowsModule.ganttChartTableBody.children[i].children[0].children[1].children[4].setAttribute('tabindex', '-1');
                    }
                    else {
                        if (this.parent.viewType === 'ProjectView') {
                            var node = this.parent.chartRowsModule.ganttChartTableBody.
                                children[parseInt(i.toString(), 10)].children[0].children[1].children[1];
                            if (!ej2_base_2.isNullOrUndefined(node)) {
                                this.parent.chartRowsModule.ganttChartTableBody.children[i].children[0].children[1].children[1].setAttribute('tabindex', '-1');
                            }
                        }
                        else if (this.parent.chartRowsModule.ganttChartTableBody.children[parseInt(i.toString(), 10)].children[0].
                            children[1].children[0]) {
                            this.parent.chartRowsModule.ganttChartTableBody.children[i].children[0].children[1].children[0].setAttribute('tabindex', '-1');
                        }
                    }
                }
                var criticalModule = this.parent.criticalPathModule;
                if (this.parent.enableCriticalPath && criticalModule && criticalModule.criticalPathCollection) {
                    this.parent.criticalPathModule.criticalConnectorLine(criticalModule.criticalPathCollection, criticalModule.detailPredecessorCollection, this.parent.enableCriticalPath, criticalModule.predecessorCollectionTaskIds);
                }
                if (this.parent.showOverAllocation) {
                    this.renderOverAllocationContainer();
                }
            }
            this.updateWidthAndHeight();
            if (this.parent.isLoad) {
                this.parent.notify('selectRowByIndex', {});
            }
            if (this.parent.timelineModule.isZoomToFit) {
                this.parent.timelineModule.processZoomToFit();
            }
        };
        GanttChart.prototype.renderRangeContainer = function (records) {
            var recordLength = records.length;
            var count;
            var ganttRecord;
            var rangeCollection;
            Eif (this.parent.treeGrid.grid.filterSettings.columns.length === 0) {
                for (count = 0; count < recordLength; count++) {
                    ganttRecord = records[count];
                    rangeCollection = ganttRecord.ganttProperties.workTimelineRanges;
                    if (rangeCollection) {
                        this.renderRange(rangeCollection, ganttRecord);
                    }
                }
            }
        };
        GanttChart.prototype.getTopValue = function (currentRecord) {
            var updatedRecords = this.parent.getExpandedRecords(this.parent.currentViewData);
            var recordIndex = updatedRecords.indexOf(currentRecord);
            Iif (currentRecord.parentItem && recordIndex === -1) {
                var nestedParent = this.parent.getRecordByID(currentRecord.parentItem.taskId);
                recordIndex = updatedRecords.indexOf(nestedParent);
            }
            if (!currentRecord.expanded) {
                return (recordIndex * this.parent.rowHeight);
            }
            return ((recordIndex + 1) * this.parent.rowHeight);
        };
        GanttChart.prototype.getRangeHeight = function (data) {
            if (!data.expanded && data.hasChildRecords) {
                return (this.parent.rowHeight - Math.floor((this.parent.rowHeight - this.parent.chartRowsModule.taskBarHeight)));
            }
            return (data.childRecords.length * this.parent.rowHeight) -
                Math.floor((this.parent.rowHeight - this.parent.chartRowsModule.taskBarHeight));
        };
        GanttChart.prototype.renderRange = function (rangeCollection, currentRecord) {
            var topValue = 0;
            var rowIndex = this.parent.currentViewData.indexOf(currentRecord);
            if (!this.parent.allowTaskbarOverlap && this.parent.enableMultiTaskbar) {
                topValue = !currentRecord.expanded ? this.parent.getRowByIndex(rowIndex).offsetTop :
                    this.parent.getRowByIndex(rowIndex).offsetTop + this.parent.rowHeight;
            }
            else {
                topValue = this.getTopValue(currentRecord);
            }
            var sameIDElement = this.rangeViewContainer.querySelector('.' + 'rangeContainer' + currentRecord.ganttProperties.rowUniqueID);
            if (sameIDElement) {
                sameIDElement.remove();
            }
            var parentDiv = ej2_base_1.createElement('div', {
                className: 'rangeContainer' + currentRecord.ganttProperties.rowUniqueID, styles: "top:" + topValue + "px; position: absolute;"
            });
            if (currentRecord.level === 0 && !currentRecord.expanded && ej2_base_2.isNullOrUndefined(currentRecord.parentItem)
                && !this.parent.enableMultiTaskbar) {
                return;
            }
            if (currentRecord.level > 0 && currentRecord.expanded && !this.parent.getRecordByID(currentRecord.parentItem.taskId).expanded) {
                return;
            }
            for (var i = 0; i < rangeCollection.length; i++) {
                var height = void 0;
                var node = this.parent.chartRowsModule.ganttChartTableBody.childNodes;
                if (!this.parent.allowTaskbarOverlap && !currentRecord.expanded && this.parent.enableMultiTaskbar && !this.isCollapseAll) {
                    height = parseInt(node[rowIndex].style.height, 10) -
                        (this.parent.rowHeight - this.parent.chartRowsModule.taskBarHeight);
                }
                else {
                    height = this.getRangeHeight(currentRecord);
                }
                var leftDiv = ej2_base_1.createElement('div', {
                    className: cls.rangeChildContainer + ' ' + 'e-leftarc', styles: (this.parent.enableRtl ? 'right:' : 'left:') +
                        ((this.parent.enableRtl ? rangeCollection[i].left + rangeCollection[i].width - 5 : rangeCollection[i].left) + "px;\n                top: " + Math.floor((this.parent.rowHeight - this.parent.chartRowsModule.taskBarHeight) / 2) + "px;\n                height: " + (height + 1) + "px; border-right: 0px;\n                z-index: " + ((this.parent.viewType === 'ProjectView') ? currentRecord.childRecords.length > 1 ? currentRecord.childRecords.length + 1 : currentRecord.childRecords.length : 6))
                });
                var rightDiv = ej2_base_1.createElement('div', {
                    className: cls.rangeChildContainer + ' ' + 'e-rightarc',
                    styles: (this.parent.enableRtl ? 'right:' : 'left:') + ((this.parent.enableRtl ? rangeCollection[i].left :
                        rangeCollection[i].left + rangeCollection[i].width - 5) + "px;\n                top: " + Math.floor((this.parent.rowHeight - this.parent.chartRowsModule.taskBarHeight) / 2) + "px; height: " + (height + 1) + "px;\n                border-left: 0px;\n                z-index: " + ((this.parent.viewType === 'ProjectView') ? currentRecord.childRecords.length > 1 ? currentRecord.childRecords.length + 1 : currentRecord.childRecords.length : 6))
                });
                parentDiv.appendChild(leftDiv);
                parentDiv.appendChild(rightDiv);
                this.rangeViewContainer.appendChild(parentDiv);
            }
            this.parent.ganttChartModule.chartBodyContent.appendChild(this.rangeViewContainer);
        };
        GanttChart.prototype.renderTimelineContainer = function () {
            this.chartTimelineContainer =
                ej2_base_1.createElement('div', { className: cls.timelineHeaderContainer });
            if (this.parent.enableRtl) {
                this.chartTimelineContainer.style.borderLeftWidth = '1px';
                this.chartTimelineContainer.style.borderRightWidth = '0px';
            }
            this.chartTimelineContainer.setAttribute('role', 'presentation');
            this.chartElement.appendChild(this.chartTimelineContainer);
        };
        GanttChart.prototype.renderBodyContainers = function () {
            this.chartBodyContainer = ej2_base_1.createElement('div', { className: cls.chartBodyContainer });
            this.chartElement.appendChild(this.chartBodyContainer);
            this.scrollElement = ej2_base_1.createElement('div', {
                className: cls.chartScrollElement + ' ' + cls.scrollContent, styles: 'position:relative;'
            });
            this.chartBodyContainer.appendChild(this.scrollElement);
            this.chartBodyContent = ej2_base_1.createElement('div', { className: cls.chartBodyContent, styles: 'position:relative; overflow:hidden ' });
            if (this.parent.virtualScrollModule && this.parent.enableVirtualization || this.parent.enableTimelineVirtualization) {
                this.parent.ganttChartModule.virtualRender.renderWrapper();
            }
            else {
                this.scrollElement.appendChild(this.chartBodyContent);
            }
            this.scrollObject = new chart_scroll_1.ChartScroll(this.parent);
            var toolbarHeight = 0;
            if (!ej2_base_2.isNullOrUndefined(this.parent.toolbarModule) && !ej2_base_2.isNullOrUndefined(this.parent.toolbarModule.element)) {
                toolbarHeight = this.parent.toolbarModule.element.offsetHeight;
            }
            this.scrollObject.
                setHeight(this.parent.ganttHeight - this.chartTimelineContainer.offsetHeight - toolbarHeight);
        };
        GanttChart.prototype.updateWidthAndHeight = function () {
            var emptydivHeight = 36;
            var emptyHeight = this.parent.contentHeight === 0 ? this.parent.flatData.length > 1 ? emptydivHeight : 0 :
                this.parent.contentHeight;
            var contentElement = this.parent.element.getElementsByClassName('e-chart-scroll-container e-content')[0];
            if (emptyHeight >= contentElement['offsetHeight'] || this.parent.height === 'auto' || (contentElement['offsetHeight'] - emptyHeight) < emptydivHeight) {
                this.chartBodyContent.style.height = ej2_base_1.formatUnit(emptyHeight);
            }
            else {
                var scrollHeight = this.parent.element.getElementsByClassName('e-chart-rows-container')[0]['offsetHeight'];
                if (contentElement['offsetHeight'] >= scrollHeight) {
                    this.chartBodyContent.style.height = contentElement['offsetHeight'] - 17 + 'px';
                }
                else {
                    this.chartBodyContent.style.height = contentElement['offsetHeight'] + 'px';
                }
            }
            if (this.parent.timelineModule.isZoomToFit && this.parent.enableTimelineVirtualization) {
                this.chartBodyContent.style.width = (this.parent.enableTimelineVirtualization
                    && (this.parent.timelineModule.totalTimelineWidth > this.parent.element.offsetWidth * 3)) ?
                    ej2_base_1.formatUnit(this.parent.element.offsetWidth * 3)
                    : ej2_base_1.formatUnit(this.parent.timelineModule.totalTimelineWidth - this.parent.timelineModule['clientWidthDifference']);
            }
            else {
                this.chartBodyContent.style.width = (this.parent.enableTimelineVirtualization
                    && (this.parent.timelineModule.totalTimelineWidth > this.parent.element.offsetWidth * 3)) ?
                    ej2_base_1.formatUnit(this.parent.element.offsetWidth * 3)
                    : ej2_base_1.formatUnit(this.parent.timelineModule.totalTimelineWidth);
            }
            if (this.parent.timelineModule.isZoomedToFit && this.parent.enableVirtualization) {
                var clientWidth = Math.abs(this.parent.timelineModule.totalTimelineWidth -
                    this.parent.element.getElementsByClassName('e-chart-scroll-container e-content')[0].clientWidth);
                this.parent.ganttChartModule.chartBodyContent.style.width =
                    ej2_base_1.formatUnit(this.parent.timelineModule.totalTimelineWidth - clientWidth);
            }
            this.setVirtualHeight();
            this.parent.notify('updateHeight', {});
            this.parent.updateGridLineContainerHeight();
            this.updateLastRowBottomWidth();
        };
        GanttChart.prototype.setVirtualHeight = function () {
            if (this.parent.virtualScrollModule && this.parent.enableVirtualization) {
                var wrapper = ej2_base_2.getValue('virtualTrack', this.parent.ganttChartModule.virtualRender);
                wrapper.style.height = this.parent.treeGrid.element.getElementsByClassName('e-virtualtrack')[0].style.height;
                var wrapper1 = ej2_base_2.getValue('wrapper', this.parent.ganttChartModule.virtualRender);
                var treegridVirtualHeight = this.parent.treeGrid.element.getElementsByClassName('e-virtualtable')[0].style.transform;
                var virtualTable = document.getElementsByClassName('e-virtualtable')[1].style.transform;
                if (this.parent.enableTimelineVirtualization) {
                    var translateXValue = void 0;
                    if (virtualTable !== '') {
                        translateXValue = virtualTable.match(/translate.*\((.+)\)/)[1].split(', ')[0];
                    }
                    else {
                        var chartTransform = this.parent.ganttChartModule.scrollElement.getElementsByClassName('e-virtualtable')[0].style.transform;
                        translateXValue = chartTransform.match(/translate.*\((.+)\)/)[1].split(', ')[0];
                    }
                    var translateYValue = treegridVirtualHeight.match(/translate.*\((.+)\)/)[1].split(', ')[1];
                    wrapper1.style.transform = "translate(" + translateXValue + ", " + translateYValue + ")";
                }
                else {
                    wrapper1.style.transform = treegridVirtualHeight;
                }
            }
        };
        GanttChart.prototype.updateLastRowBottomWidth = function () {
            if (this.parent.currentViewData.length > 0 && this.parent.height !== 'auto') {
                var expandedRecords = this.parent.virtualScrollModule && this.parent.enableVirtualization ?
                    this.parent.currentViewData : this.parent.getExpandedRecords(this.parent.currentViewData);
                var lastExpandedRow = expandedRecords[expandedRecords.length - 1];
                var lastExpandedRowIndex = this.parent.currentViewData.indexOf(lastExpandedRow);
                var lastRow = this.parent.getRowByIndex(lastExpandedRowIndex);
                var table = this.parent.chartRowsModule.ganttChartTableBody;
                Eif (table.querySelectorAll('.e-chart-row-cell.e-chart-row-border.e-lastrow')) {
                    ej2_base_2.removeClass(table.querySelectorAll('.e-chart-row-cell.e-chart-row-border.e-lastrow'), 'e-lastrow');
                }
                if (this.chartBodyContent.clientHeight < this.chartBodyContainer.clientHeight) {
                    if (lastRow) {
                        ej2_base_2.addClass(lastRow.querySelectorAll('td'), 'e-lastrow');
                        var emptydivHeight = 36;
                        var emptyHeight = this.parent.contentHeight === 0 ? this.parent.flatData.length > 1 ? emptydivHeight : 0 :
                            this.parent.contentHeight;
                        var contentElement = this.parent.element.getElementsByClassName('e-chart-scroll-container e-content')[0];
                        if (emptyHeight >= contentElement['offsetHeight'] || (contentElement['offsetHeight'] - emptyHeight) < emptydivHeight) {
                            this.chartBodyContent.style.height = ej2_base_1.formatUnit(emptyHeight);
                        }
                        else {
                            var scrollHeight = this.parent.element.getElementsByClassName('e-chart-rows-container')[0]['offsetHeight'];
                            Eif (contentElement['offsetHeight'] >= scrollHeight) {
                                this.chartBodyContent.style.height = contentElement['offsetHeight'] - 17 + 'px';
                            }
                            else {
                                this.chartBodyContent.style.height = contentElement['offsetHeight'] + 'px';
                            }
                        }
                    }
                }
            }
        };
        GanttChart.prototype.removeEventListener = function () {
            Iif (this.parent.isDestroyed) {
                return;
            }
            this.parent.off('renderPanels', this.renderChartContainer);
            this.parent.off('recordsUpdated', this.renderChartElements);
            this.parent.off('dataReady', this.renderInitialContents);
            this.parent.off('tree-grid-created', this.renderChartContents);
            this.parent.off('destroy', this.destroy);
        };
        GanttChart.prototype.ganttChartMouseDown = function (e) {
            var cancel = false;
            Iif (e.type === 'touchstart' && e instanceof TouchEvent && e.touches && e.touches.length === 2) {
                this.initPinchDistance = this.calculatePinchDistance(e.touches[0], e.touches[1]);
                this.isPinching = true;
            }
            if (this.parent.allowTaskbarDragAndDrop && this.parent.editModule &&
                this.parent.editSettings.allowTaskbarEditing && !this.isPinching) {
                var editAction = this.parent.editModule.taskbarEditModule['getTaskBarAction'](e);
                Iif (editAction === 'ChildDrag' || editAction === 'ParentDrag' || editAction === 'MilestoneDrag' || editAction === 'ManualParentDrag') {
                    var args = {
                        cancel: cancel,
                        data: this.getRecordByTaskBar(e.target),
                        target: e.target,
                        chartRow: ej2_base_2.closest(e.target, 'tr')
                    };
                    this.parent.trigger('rowDragStartHelper', args);
                    cancel = args['cancel'];
                }
            }
            Eif (!cancel && !this.isPinching) {
                if (e.which !== 3 && this.parent.editSettings.allowTaskbarEditing) {
                    this.parent.notify('chartMouseDown', e);
                    this.parent.element.tabIndex = 0;
                }
                var isTaskbarEdited = false;
                if (this.parent.editSettings.allowTaskbarEditing && (this.parent.element.querySelector('.e-left-resize-gripper') || this.parent.element.querySelector('.e-left-connectorpoint-outer-div'))) {
                    isTaskbarEdited = true;
                }
                if (!isTaskbarEdited || e.button === 2) {
                    if (this.parent.editSettings.allowEditing && this.parent.treeGrid.element.getElementsByClassName('e-editedbatchcell').length > 0) {
                        this.parent.treeGrid.endEdit();
                    }
                }
            }
        };
        GanttChart.prototype.calculatePinchDistance = function (touch1, touch2) {
            var dx = touch2.clientX - touch1.clientX;
            var dy = touch2.clientY - touch1.clientY;
            return Math.sqrt(dx * dx + dy * dy);
        };
        GanttChart.prototype.ganttChartMouseClick = function (e) {
            if (this.parent.autoFocusTasks) {
                this.scrollToTarget(e);
            }
            this.parent.notify('chartMouseClick', e);
        };
        GanttChart.prototype.ganttChartMouseUp = function (e) {
            if (e.type === 'touchend') {
                this.initPinchDistance = null;
                this.isPinching = false;
                var resizeCheck = this.parent.ganttChartModule.chartBodyContainer.querySelector('.e-taskbar-resize-div');
                if (!ej2_base_2.isNullOrUndefined(resizeCheck)) {
                    resizeCheck.remove();
                }
                var Check = this.parent.ganttChartModule.chartBodyContainer.querySelector('.e-clone-taskbar') || this.parent.chartPane.querySelector('.e-clone-taskbar');
                if (!ej2_base_2.isNullOrUndefined(Check)) {
                    var clonetbody = Check.parentElement;
                    var cloneTable = clonetbody.parentElement;
                    cloneTable.remove();
                }
                var falseline = this.parent.ganttChartModule.chartBodyContainer.querySelector('.e-gantt-false-line');
                if (!ej2_base_2.isNullOrUndefined(falseline)) {
                    this.parent.editModule.taskbarEditModule.removeFalseLine(true);
                }
            }
            if (this.parent.editSettings.allowTaskbarEditing) {
                this.parent.notify('chartMouseUp', e);
            }
            if (!this.parent.editSettings.allowEditing) {
                var isTaskbarEdited = false;
                if (this.parent.editSettings.allowTaskbarEditing &&
                    ej2_base_2.getValue('editModule.taskbarEditModule.isMouseDragged', this.parent) &&
                    ej2_base_2.getValue('editModule.taskbarEditModule.taskBarEditAction', this.parent)) {
                    isTaskbarEdited = true;
                }
                if (!isTaskbarEdited) {
                    var target = e.target;
                    var isOnTaskbarElement = e.target.classList.contains(cls.taskBarMainContainer)
                        || ej2_base_2.closest(e.target, '.' + cls.taskBarMainContainer);
                    if (ej2_base_2.closest(target, '.e-gantt-parent-taskbar') && !this.parent.editSettings.allowEditing) {
                        this.chartExpandCollapseRequest(e);
                    }
                    else if (!isOnTaskbarElement && this.parent.autoFocusTasks) {
                        this.scrollToTarget(e);
                    }
                }
            }
        };
        GanttChart.prototype.scrollToTarget = function (e) {
            var row = ej2_base_2.closest(e.target, 'tr');
            if (row && this.parent.element.contains(row) &&
                (this.parent.element.querySelectorAll('.e-chart-rows-container')[0].contains(e.target) ||
                    this.parent.element.querySelectorAll('.e-gridcontent')[0].contains(e.target)) &&
                this.parent.currentViewData.length > 0) {
                var rowIndex = ej2_base_2.getValue('rowIndex', ej2_base_2.closest(e.target, 'tr'));
                var dateObject = this.parent.currentViewData[rowIndex].ganttProperties.startDate;
                var dateObjLeft = this.parent.currentViewData[rowIndex].ganttProperties.left;
                Eif (!ej2_base_2.isNullOrUndefined(dateObject)) {
                    var left = !this.parent.enableTimelineVirtualization ?
                        this.parent.dataOperation.getTaskLeft(dateObject, false) : {};
                    Eif (this.parent.autoFocusTasks) {
                        Iif (this.parent.enableTimelineVirtualization) {
                            this.updateScrollLeft(dateObjLeft);
                        }
                        else {
                            this.updateScrollLeft(left);
                        }
                    }
                }
            }
        };
        GanttChart.prototype.updateScrollLeft = function (scrollLeft) {
            scrollLeft = scrollLeft > 0 ? scrollLeft : 0;
            scrollLeft = this.scrollElement.scrollWidth <= scrollLeft ? this.scrollElement.scrollWidth : scrollLeft;
            if ((this.scrollElement.offsetWidth + this.parent.ganttChartModule.scrollElement.scrollLeft) < scrollLeft
                || (this.scrollElement.scrollLeft > scrollLeft)) {
                this.scrollObject.setScrollLeft(scrollLeft - 50, this.parent.enableRtl ? -1 : 0);
            }
        };
        GanttChart.prototype.mouseUp = function (e) {
            Iif (e.type === 'touchend') {
                this.initPinchDistance = null;
                this.isPinching = false;
            }
            if (!ej2_base_2.isNullOrUndefined(this.parent.editModule) && !ej2_base_2.isNullOrUndefined(this.parent.editModule.taskbarEditModule)) {
                this.parent.editModule.taskbarEditModule.removeFalseLine(false);
            }
            var resizeCheck = this.parent.element.querySelector('.e-taskbar-resize-div');
            Iif (!ej2_base_2.isNullOrUndefined(resizeCheck)) {
                resizeCheck.remove();
            }
            if (this.parent.allowTaskbarDragAndDrop && this.parent.editModule && this.parent.editModule.taskbarEditModule) {
                this.parent.editModule.taskbarEditModule['previousLeftValue'] = 0;
            }
            if (this.parent.allowRowDragAndDrop) {
                var ganttDragElemet = this.parent.element.querySelector('.e-ganttdrag');
                Iif (ganttDragElemet) {
                    ganttDragElemet.remove();
                }
            }
            if (!this.isGanttElement) {
                this.parent.notify('chartMouseUp', e);
            }
            this.isGanttElement = false;
        };
        GanttChart.prototype.documentMouseUp = function (e) {
            Iif (e.type === 'touchend') {
                this.initPinchDistance = null;
                this.isPinching = false;
                this.previousPinchDistance = 0;
            }
            this.isGanttElement = true;
            Iif (e.target.classList.contains('e-treegridexpand') ||
                e.target.classList.contains('e-treegridcollapse')) {
                if (ej2_base_2.getValue('isEditCollapse', this.parent.treeGrid) === true) {
                    ej2_base_2.setValue('isEditCollapse', false, this.parent.treeGrid);
                }
            }
            if (this.parent.allowRowDragAndDrop) {
                var ganttDragElemet = this.parent.element.querySelector('.e-ganttdrag');
                if (ganttDragElemet) {
                    ganttDragElemet.remove();
                }
            }
            Iif (this.parent.isDestroyed || e.which === 3) {
                return;
            }
            var resizeCheck = this.parent.ganttChartModule.chartBodyContainer.querySelector('.e-taskbar-resize-div');
            if (!ej2_base_2.isNullOrUndefined(resizeCheck)) {
                resizeCheck.remove();
            }
            var Check = this.parent.element.getElementsByClassName('e-clone-taskbar')[0];
            if (!ej2_base_2.isNullOrUndefined(Check)) {
                var clonetbody = Check.parentElement;
                var cloneTable = clonetbody.parentElement;
                cloneTable.remove();
            }
            var isTaskbarEdited = false;
            if (this.parent.editSettings.allowTaskbarEditing &&
                ej2_base_2.getValue('editModule.taskbarEditModule.isMouseDragged', this.parent) &&
                ej2_base_2.getValue('editModule.taskbarEditModule.taskBarEditAction', this.parent)) {
                isTaskbarEdited = true;
            }
            this.parent.notify('chartMouseUp', e);
            Eif (this.parent.showActiveElement) {
                this.parent.showIndicator = true;
                if (!ej2_base_2.isNullOrUndefined(this.parent.loadingIndicator) && this.parent.loadingIndicator.indicatorType === 'Shimmer') {
                    this.parent.hideMaskRow();
                }
                else {
                    this.parent.hideSpinner();
                }
                Iif (this.focusedElement && !e.target.classList.contains('e-split-bar')) {
                    this.focusedElement.tabIndex = this.focusedElement.tabIndex === 0 ? -1 : this.focusedElement.tabIndex;
                    ej2_base_2.removeClass([this.focusedElement], 'e-active-container');
                }
            }
            if (!isTaskbarEdited) {
                var target = e.target;
                var isOnTaskbarElement = e.target.classList.contains(cls.taskBarMainContainer)
                    || ej2_base_2.closest(e.target, '.' + cls.taskBarMainContainer);
                if (ej2_base_2.closest(target, '.e-gantt-parent-taskbar') && !this.parent.editSettings.allowEditing) {
                    this.chartExpandCollapseRequest(e);
                }
                else if (!isOnTaskbarElement && this.parent.autoFocusTasks) {
                    this.scrollToTarget(e);
                }
            }
            if (this.parent.editModule && this.parent.editModule.taskbarEditModule) {
                this.parent.editModule.taskbarEditModule.removeFalseLine(true);
            }
            Iif (!ej2_base_2.isNullOrUndefined(this.parent.onTaskbarClick) && !isTaskbarEdited) {
                var target = e.target;
                var taskbarElement = ej2_base_2.closest(target, '.e-gantt-parent-taskbar,.e-gantt-child-taskbar,.e-gantt-milestone');
                if (taskbarElement) {
                    this.onTaskbarClick(e, target, taskbarElement);
                }
            }
        };
        GanttChart.prototype.onTaskbarClick = function (e, target, taskbarElement) {
            var rowIndex;
            var chartRow = ej2_base_2.closest(target, 'tr');
            Eif (!ej2_base_2.isNullOrUndefined(chartRow)) {
                rowIndex = ej2_base_2.getValue('rowIndex', chartRow);
            }
            var data = this.getRecordByTarget(e);
            var args = {
                data: data,
                taskbarElement: taskbarElement,
                rowIndex: rowIndex,
                target: target
            };
            this.parent.trigger('onTaskbarClick', args);
        };
        GanttChart.prototype.ganttChartLeave = function (e) {
            if (this.parent.editSettings.allowTaskbarEditing) {
                this.parent.notify('chartMouseLeave', e);
            }
        };
        GanttChart.prototype.ganttChartMove = function (e) {
            Iif (e.type === 'touchmove' && this.isPinching === true && e instanceof TouchEvent && e.touches && e.touches.length === 2) {
                var currentPinchDistance = this.calculatePinchDistance(e.touches[0], e.touches[1]);
                if (Math.abs(this.previousPinchDistance - currentPinchDistance) > 15) {
                    if (currentPinchDistance > this.previousPinchDistance) {
                        this.parent.timelineModule.processZooming(true);
                    }
                    else if (currentPinchDistance < this.previousPinchDistance) {
                        this.parent.timelineModule.processZooming(false);
                    }
                    this.previousPinchDistance = currentPinchDistance;
                }
            }
            Eif (this.parent.editSettings.allowTaskbarEditing && this.isPinching === false) {
                Iif (this.parent.element.getElementsByClassName('e-clone-taskbar').length > 0 && !this.parent.enableRtl) {
                    var xValue = void 0;
                    if (e.type === 'touchmove' || e.type === 'touchstart' || e.type === 'touchend') {
                        xValue = e['changedTouches'][0].pageX;
                    }
                    else {
                        xValue = e.pageX;
                    }
                    if (xValue <= this.parent.getOffsetRect(this.parent.ganttChartModule.chartElement).left) {
                        return;
                    }
                }
                this.parent.notify('chartMouseMove', e);
                if (!ej2_base_2.isNullOrUndefined(this.parent.taskFields.dependency) && this.parent.connectorLineEditModule) {
                    this.parent.connectorLineEditModule.updateConnectorLineEditElement(e);
                }
            }
        };
        GanttChart.prototype.contextClick = function (e) {
            if (this.parent.allowFiltering && this.parent.filterModule) {
                this.parent.filterModule.closeFilterOnContextClick(e.srcElement);
            }
            if (this.parent.allowTaskbarDragAndDrop) {
                var Check = this.parent.chartPane.querySelector('.e-clone-taskbar');
                Iif (!ej2_base_2.isNullOrUndefined(Check)) {
                    var clonetbody = Check.parentElement;
                    var cloneTable = clonetbody.parentElement;
                    cloneTable.remove();
                }
            }
        };
        GanttChart.prototype.mouseMoveHandler = function (e) {
            Iif (!ej2_base_2.isNullOrUndefined(this.parent.onMouseMove) &&
                (this.parent.flatData.length ||
                    e.target.classList.contains('e-header-cell-label') ||
                    e.target.classList.contains('e-headercell'))) {
                var target = e.target;
                var args = { originalEvent: e };
                var element = ej2_base_2.closest(target, '.e-chart-row-cell,.e-connector-line-container,' +
                    '.e-event-markers,.e-header-cell-label,.e-rowcell,.e-headercell,.e-indicator-span');
                if (element) {
                    var rowData = void 0;
                    var rowElement = ej2_base_2.closest(target, '.e-rowcell,.e-chart-row-cell');
                    var columnElement = ej2_base_2.closest(target, '.e-rowcell,.e-headercell');
                    if (rowElement) {
                        rowData = this.parent.ganttChartModule.getRecordByTarget(e);
                        args.data = rowData;
                    }
                    if (columnElement) {
                        var cellIndex = ej2_base_2.getValue('cellIndex', columnElement);
                        args.column = this.parent.treeGrid.columns[cellIndex];
                    }
                    if (ej2_base_2.closest(target, '.e-indicator-span')) {
                        var index = 0;
                        var indicators = rowData.ganttProperties.indicators;
                        if (indicators.length > 1) {
                            for (index = 0; index < indicators.length; index++) {
                                if (indicators[index].name === (element.innerText).trim()) {
                                    break;
                                }
                            }
                        }
                        args.indicator = indicators[index];
                    }
                    if (ej2_base_2.closest(target, '.e-connector-line-container')) {
                        var obj = {};
                        obj.target = element;
                        args.predecessor = this.parent.tooltipModule.getPredecessorTooltipData(obj);
                    }
                    if (ej2_base_2.closest(target, '.e-event-markers')) {
                        var obj = {};
                        obj.target = element;
                        args.eventMarkers = this.parent.tooltipModule.getMarkerTooltipData(obj);
                    }
                    if (target.classList.contains('e-header-cell-label')) {
                        args.date = new Date(target.dataset.content);
                    }
                }
                this.parent.trigger('onMouseMove', args);
            }
        };
        GanttChart.prototype.doubleClickHandler = function (e) {
            var target = e.target;
            var row = ej2_base_2.closest(target, 'tr');
            var rowIndex = ej2_base_2.getValue('rowIndex', row);
            var rowData = this.parent.ganttChartModule.getRecordByTarget(e);
            Iif (this.parent.editSettings.allowEditing && this.parent.treeGrid.element.getElementsByClassName('e-editedbatchcell').length > 0) {
                this.parent.treeGrid.endEdit();
            }
            this.parent.notify('chartDblClick', e);
            var args = {
                row: row,
                rowData: rowData,
                rowIndex: rowIndex,
                target: target
            };
            this.recordDoubleClick(args);
        };
        GanttChart.prototype.recordDoubleClick = function (args) {
            this.parent.trigger('recordDoubleClick', args);
        };
        GanttChart.prototype.getRecordByTarget = function (e) {
            var ganttData;
            var row = ej2_base_2.closest(e.target, 'div.' + cls.taskBarMainContainer);
            if (!ej2_base_2.isNullOrUndefined(row)) {
                var id = row.getAttribute('rowUniqueId');
                ganttData = this.parent.getRecordByID(id);
            }
            else {
                row = ej2_base_2.closest(e.target, 'tr');
                Eif (row) {
                    var rowIndex = ej2_base_2.getValue('rowIndex', ej2_base_2.closest(e.target, 'tr'));
                    ganttData = this.parent.currentViewData[rowIndex];
                }
            }
            return ganttData;
        };
        GanttChart.prototype.getChartRows = function () {
            Eif (document.getElementById(this.parent.element.id + 'GanttTaskTableBody') !== null) {
                return document.getElementById(this.parent.element.id + 'GanttTaskTableBody').querySelectorAll('.e-chart-row');
            }
            else {
                return null;
            }
        };
        GanttChart.prototype.chartExpandCollapseRequest = function (e) {
            if (this.parent.enableMultiTaskbar) {
                return;
            }
            var target = e.target;
            var parentElement = ej2_base_2.closest(target, '.e-gantt-parent-taskbar');
            var record = this.getRecordByTarget(e);
            var chartRow = ej2_base_2.closest(target, 'tr');
            var rowIndex = ej2_base_2.getValue('rowIndex', chartRow);
            var gridRow = this.parent.treeGrid.getRows()[rowIndex];
            var args = { data: record, gridRow: gridRow, chartRow: chartRow, cancel: false };
            this.isExpandCollapseFromChart = true;
            if (parentElement.classList.contains('e-row-expand')) {
                this.collapseGanttRow(args);
            }
            else Eif (parentElement.classList.contains('e-row-collapse')) {
                this.expandGanttRow(args);
            }
        };
        GanttChart.prototype.reRenderConnectorLines = function () {
            this.parent.connectorLineModule.dependencyViewContainer.innerHTML = '';
            this.parent.connectorLineIds = [];
            this.parent.updatedConnectorLineCollection = [];
            this.parent.predecessorModule.createConnectorLinesCollection();
            this.parent.connectorLineModule.renderConnectorLines(this.parent.updatedConnectorLineCollection);
            var criticalModule = this.parent.criticalPathModule;
            if (this.parent.enableCriticalPath && criticalModule && criticalModule.criticalPathCollection) {
                criticalModule.criticalConnectorLine(criticalModule.criticalPathCollection, criticalModule.detailPredecessorCollection, true, criticalModule.predecessorCollectionTaskIds);
            }
        };
        GanttChart.prototype.collapseGanttRow = function (args) {
            var _this = this;
            this.parent.trigger('collapsing', args, function (arg) {
                if (_this.isExpandCollapseFromChart && !ej2_base_2.getValue('cancel', arg)) {
                    _this.collapsedGanttRow(arg);
                }
                _this.isExpandCollapseFromChart = false;
            });
        };
        GanttChart.prototype.collapsedGanttRow = function (args) {
            var _this = this;
            if ((ej2_base_2.isNullOrUndefined(args['gridRow']) && this.parent.enableVirtualization) || ej2_base_2.isNullOrUndefined(args['chartRow'])) {
                return;
            }
            var record;
            Iif (this.parent.loadChildOnDemand && this.parent.taskFields.hasChildMapping) {
                record = this.parent.currentViewData.filter(function (item) { return item.ganttProperties[_this.parent.taskFields.id] === args['data'][_this.parent.taskFields.id]; })[0];
            }
            else {
                record = ej2_base_2.getValue('data', args);
            }
            if (this.isExpandCollapseFromChart) {
                this.expandCollapseChartRows('collapse', ej2_base_2.getValue('chartRow', args), record, null);
                var idField_1 = this.parent.taskFields.id;
                Iif (this.parent.loadChildOnDemand && this.parent.taskFields.hasChildMapping) {
                    var gridRec = this.parent.treeGrid.getCurrentViewRecords().filter(function (item) { return item[idField_1] === args['data'][idField_1]; })[0];
                    this.parent.treeGrid.collapseRow(ej2_base_2.getValue('gridRow', args), gridRec);
                }
                else {
                    this.parent.treeGrid.collapseRow(ej2_base_2.getValue('gridRow', args), record);
                }
                this.isExpandCollapseFromChart = false;
            }
            else {
                this.expandCollapseChartRows('collapse', ej2_base_2.getValue('chartRow', args), record, null);
            }
            Eif (this.parent.viewType === 'ResourceView' || this.parent.viewType === 'ProjectView') {
                this.renderMultiTaskbar(record);
            }
            if (!this.parent.enableVirtualization) {
                this.parent.updateContentHeight();
            }
            this.updateWidthAndHeight();
            this.reRenderConnectorLines();
            ej2_base_2.getValue('chartRow', args).setAttribute('aria-expanded', 'false');
        };
        GanttChart.prototype.expandGanttRow = function (args) {
            var _this = this;
            this.parent.trigger('expanding', args, function (arg) {
                if (_this.isExpandCollapseFromChart && !ej2_base_2.getValue('cancel', arg)) {
                    _this.expandedGanttRow(arg);
                }
                _this.isExpandCollapseFromChart = false;
            });
        };
        GanttChart.prototype.expandedGanttRow = function (args) {
            var _this = this;
            Iif ((ej2_base_2.isNullOrUndefined(args['gridRow']) && this.parent.enableVirtualization) || ej2_base_2.isNullOrUndefined(args['chartRow'])) {
                return;
            }
            var record;
            Iif (this.parent.loadChildOnDemand && this.parent.taskFields.hasChildMapping) {
                record = this.parent.currentViewData.filter(function (item) { return item.ganttProperties.taskId === args['data'][_this.parent.taskFields.id]; })[0];
            }
            else {
                record = ej2_base_2.getValue('data', args);
            }
            if (this.isExpandCollapseFromChart) {
                this.expandCollapseChartRows('expand', ej2_base_2.getValue('chartRow', args), record, null);
                var idField_2 = this.parent.taskFields.id;
                Iif (this.parent.loadChildOnDemand && this.parent.taskFields.hasChildMapping) {
                    var gridRec = this.parent.treeGrid.getCurrentViewRecords().filter(function (item) { return item[idField_2] === args['data'][idField_2]; })[0];
                    this.parent.treeGrid.expandRow(ej2_base_2.getValue('gridRow', args), gridRec);
                }
                else {
                    this.parent.treeGrid.expandRow(ej2_base_2.getValue('gridRow', args), record);
                }
                this.isExpandCollapseFromChart = false;
            }
            else {
                Eif (!this.parent.isExpandCollapseLevelMethod) {
                    this.expandCollapseChartRows('expand', ej2_base_2.getValue('chartRow', args), record, null);
                }
                this.parent.isExpandCollapseLevelMethod = false;
            }
            Eif (this.parent.viewType === 'ResourceView' || this.parent.viewType === 'ProjectView') {
                this.renderMultiTaskbar(record);
            }
            Eif (!this.parent.enableVirtualization) {
                this.parent.updateContentHeight();
            }
            this.updateWidthAndHeight();
            this.reRenderConnectorLines();
            ej2_base_2.getValue('chartRow', args).setAttribute('aria-expanded', 'true');
        };
        GanttChart.prototype.renderMultiTaskbar = function (record) {
            if (this.parent.enableMultiTaskbar) {
                this.parent.chartRowsModule.refreshRecords([record], true);
            }
            else if (this.parent.showOverAllocation) {
                this.parent.ganttChartModule.renderRangeContainer(this.parent.currentViewData);
            }
        };
        GanttChart.prototype.expandCollapseChartRows = function (action, rowElement, record, isChild) {
            var displayType;
            if (action === 'expand') {
                displayType = 'table-row';
                if (!isChild) {
                    record.expanded = true;
                }
                var targetElement = rowElement.querySelectorAll('.e-row-collapse');
                for (var t = 0; t < targetElement.length; t++) {
                    ej2_base_2.addClass([targetElement[t]], 'e-row-expand');
                    ej2_base_2.removeClass([targetElement[t]], 'e-row-collapse');
                }
            }
            else Eif (action === 'collapse') {
                displayType = 'none';
                if (!isChild) {
                    record.expanded = false;
                }
                var targetElement = rowElement.querySelectorAll('.e-row-expand');
                for (var t = 0; t < targetElement.length; t++) {
                    ej2_base_2.addClass([targetElement[t]], 'e-row-collapse');
                    ej2_base_2.removeClass([targetElement[t]], 'e-row-expand');
                }
            }
            if (!this.parent.enableVirtualization) {
                var childRecords = record.childRecords;
                var chartRows = this.getChartRows();
                var rows = [];
                for (var i = 0; i < chartRows.length; i++) {
                    if (chartRows[i].classList.contains('gridrowtaskId' +
                        record.ganttProperties.rowUniqueID +
                        'level' +
                        (record.level + 1))) {
                        rows.push(chartRows[i]);
                    }
                }
                for (var i = 0; i < rows.length; i++) {
                    rows[i].style.display = displayType;
                    if (childRecords[i].childRecords &&
                        childRecords[i].childRecords.length &&
                        (action === 'collapse' ||
                            childRecords[i].expanded ||
                            this.isExpandAll)) {
                        this.expandCollapseChartRows(action, rows[i], childRecords[i], true);
                    }
                }
            }
        };
        GanttChart.prototype.expandCollapseAll = function (action) {
            if (action === 'expand') {
                this.isExpandAll = true;
                this.parent.treeGrid.expandAll();
            }
            else {
                this.isCollapseAll = true;
                this.parent.treeGrid.collapseAll();
                if (this.isCollapseAll && !this.parent.allowTaskbarOverlap) {
                    var treeGridContentHeight = this.parent.enableRtl ? this.parent['element'].getElementsByClassName('e-content')[2].children[0]['offsetHeight'] :
                        this.parent['element'].getElementsByClassName('e-content')[0].children[0]['offsetHeight'];
                    this.parent.contentHeight = treeGridContentHeight;
                    document.getElementsByClassName('e-chart-rows-container')[0]['style'].height = this.parent.contentHeight + 'px';
                }
            }
            this.isExpandAll = false;
            this.isCollapseAll = false;
        };
        GanttChart.prototype.expandAtLevel = function (level) {
            this.parent.treeGrid.expandAtLevel(level);
        };
        GanttChart.prototype.collapseAtLevel = function (level) {
            if (this.parent.enableVirtualization) {
                this.parent.isExpandCollapseLevelMethod = true;
            }
            this.parent.treeGrid.collapseAtLevel(level);
        };
        GanttChart.prototype.wireEvents = function () {
            var isIE11Pointer = ej2_base_1.Browser.isPointer;
            var mouseDown = ej2_base_1.Browser.touchStartEvent;
            var mouseUp = ej2_base_1.Browser.touchEndEvent;
            var mouseMove = ej2_base_1.Browser.touchMoveEvent;
            var cancel = isIE11Pointer ? 'pointerleave' : 'mouseleave';
            ej2_base_1.EventHandler.add(this.parent.chartPane, mouseDown, this.ganttChartMouseDown, this);
            ej2_base_1.EventHandler.add(this.parent.chartPane, cancel, this.ganttChartLeave, this);
            ej2_base_1.EventHandler.add(this.parent.chartPane, mouseMove, this.ganttChartMove, this);
            ej2_base_1.EventHandler.add(this.parent.chartPane, 'wheel', this.onWheelZoom, this);
            if (this.parent.isAdaptive) {
                ej2_base_1.EventHandler.add(this.parent.chartPane, ej2_grids_1.click, this.ganttChartMouseClick, this);
                ej2_base_1.EventHandler.add(this.parent.chartPane, mouseUp, this.ganttChartMouseUp, this);
            }
            if (!this.parent.isAdaptive) {
                ej2_base_1.EventHandler.add(this.parent.element, mouseUp, this.documentMouseUp, this);
                ej2_base_1.EventHandler.add(document, mouseUp, this.mouseUp, this);
            }
            ej2_base_1.EventHandler.add(this.parent.element, 'mousemove', this.mouseMoveHandler, this);
            ej2_base_1.EventHandler.add(document.body, 'contextmenu', this.contextClick, this);
            ej2_base_1.EventHandler.add(document, 'mouseup', this.contextClick, this);
            ej2_base_1.EventHandler.add(this.parent.chartRowsModule.ganttChartTableBody, 'dblclick', this.doubleClickHandler, this);
        };
        GanttChart.prototype.unWireEvents = function () {
            var isIE11Pointer = ej2_base_1.Browser.isPointer;
            var mouseDown = ej2_base_1.Browser.touchStartEvent;
            var mouseUp = ej2_base_1.Browser.touchEndEvent;
            var mouseMove = ej2_base_1.Browser.touchMoveEvent;
            var cancel = isIE11Pointer ? 'pointerleave' : 'mouseleave';
            Eif (!ej2_base_2.isNullOrUndefined(this.parent.chartRowsModule.ganttChartTableBody)) {
                ej2_base_1.EventHandler.remove(this.parent.chartRowsModule.ganttChartTableBody, mouseDown, this.ganttChartMouseDown);
            }
            Eif (!ej2_base_2.isNullOrUndefined(this.parent.chartPane)) {
                ej2_base_1.EventHandler.remove(this.parent.chartPane, cancel, this.ganttChartLeave);
                ej2_base_1.EventHandler.remove(this.parent.chartPane, mouseMove, this.ganttChartMove);
                ej2_base_1.EventHandler.remove(this.parent.chartPane, 'wheel', this.onWheelZoom);
                ej2_base_1.EventHandler.remove(this.parent.chartPane, mouseDown, this.ganttChartMouseDown);
            }
            if (this.parent.isAdaptive) {
                Eif (!ej2_base_2.isNullOrUndefined(this.parent.chartPane)) {
                    ej2_base_1.EventHandler.remove(this.parent.chartPane, ej2_grids_1.click, this.ganttChartMouseClick);
                    ej2_base_1.EventHandler.remove(this.parent.chartPane, mouseUp, this.ganttChartMouseUp);
                }
            }
            if (!this.parent.isAdaptive) {
                Eif (!ej2_base_2.isNullOrUndefined(this.parent.element)) {
                    ej2_base_1.EventHandler.remove(this.parent.element, mouseUp, this.documentMouseUp);
                }
                Eif (!ej2_base_2.isNullOrUndefined(document)) {
                    ej2_base_1.EventHandler.remove(document, mouseUp, this.mouseUp);
                }
            }
            Eif (!ej2_base_2.isNullOrUndefined(this.parent.element)) {
                ej2_base_1.EventHandler.remove(this.parent.element, 'mousemove', this.mouseMoveHandler);
            }
            Eif (!ej2_base_2.isNullOrUndefined(document)) {
                ej2_base_1.EventHandler.remove(document, 'mouseup', this.contextClick);
                Eif (!ej2_base_2.isNullOrUndefined(document.body)) {
                    ej2_base_1.EventHandler.remove(document.body, 'contextmenu', this.contextClick);
                }
            }
            Eif (!ej2_base_2.isNullOrUndefined(this.parent.chartRowsModule.ganttChartTableBody)) {
                ej2_base_1.EventHandler.remove(this.parent.chartRowsModule.ganttChartTableBody, 'dblclick', this.doubleClickHandler);
            }
        };
        GanttChart.prototype.onWheelZoom = function (e) {
            if (e.ctrlKey) {
                e.preventDefault();
                var zoomIn1_1 = e.deltaY < 0;
                var isTouchpad_1 = false;
                if (Math.abs(e.deltaY) < 75) {
                    isTouchpad_1 = true;
                }
                if (this.debounceTimeout) {
                    if (((this.debounceTimeoutNext + 20) > this.debounceTimeout)) {
                        clearTimeout(this.debounceTimeout);
                    }
                    if ((this.debounceTimeoutNext + 20) <= this.debounceTimeout || !this.debounceTimeoutNext) {
                        this.debounceTimeoutNext = this.debounceTimeout;
                    }
                }
                this.debounceTimeout = setTimeout(function () {
                    var verticalScrollDelta = Math.abs(e.deltaY);
                    var isValidScrollDelta = isTouchpad_1
                        ? (verticalScrollDelta > 0.5 && verticalScrollDelta < 15)
                        : (verticalScrollDelta > 5 && verticalScrollDelta <= 200);
                    if (isValidScrollDelta) {
                        this.parent.timelineModule.processZooming(zoomIn1_1);
                    }
                }.bind(this), 100);
            }
        };
        GanttChart.prototype.getRecordByTaskBar = function (target) {
            var item;
            Iif (this.parent.enableVirtualization && this.parent.enableMultiTaskbar) {
                item = this.parent.flatData[this.getIndexByTaskBar(target)];
            }
            else {
                item = this.parent.currentViewData[this.getIndexByTaskBar(target)];
            }
            return item;
        };
        GanttChart.prototype.updateElement = function (next, currentColumn, isTab, isInEditedState, row) {
            if (this.parent.ganttColumns[next.getAttribute('data-colindex')].field === this.parent.taskFields.progress) {
                var rowIndex = row.index;
                do {
                    if (row.hasChildRecords) {
                        next = this.getNextElement(next, isTab, isInEditedState);
                    }
                    currentColumn = this.parent.ganttColumns[next.getAttribute('data-colindex')];
                    rowIndex = this.parent.treeGrid.getRows().indexOf(next.parentElement);
                } while (!currentColumn.allowEditing);
                this.parent.treeGrid.saveCell();
                this.parent.treeGrid.editCell(rowIndex, this.parent.ganttColumns[next.getAttribute('data-colindex')].field);
            }
            return next;
        };
        GanttChart.prototype.onTabAction = function (e) {
            this.parent.treeGrid.grid.enableHeaderFocus = this.parent.enableHeaderFocus;
            var toolbarItems = document.getElementsByClassName('e-toolbar-item');
            var isInEditedState = this.parent.editModule && this.parent.editModule.cellEditModule &&
                this.parent.editModule.cellEditModule.isCellEdit;
            Iif (!this.parent.showActiveElement && !isInEditedState) {
                return;
            }
            var $target = isInEditedState ? e.target.closest('.e-rowcell') : e.target;
            if (this.parent.element.querySelectorAll('.e-focused').length > 0) {
                $target = this.parent.element.querySelectorAll('.e-focused')[0];
            }
            Eif ($target && !($target.classList.contains('e-toolbar-item') ||
                $target.classList.contains('e-input') || $target.classList.contains('e-btn'))) {
                this.currentToolbarIndex = -1;
            }
            if ($target.closest('.e-rowcell') || $target.closest('.e-chart-row')) {
                this.parent.focusModule.setActiveElement($target);
            }
            this.focusedRowIndex = $target.closest('.e-rowcell') ? $target.parentElement.rowIndex :
                $target.closest('.e-chart-row') ? $target.closest('.e-chart-row').rowIndex : -1;
            var isTab = (e.action === 'tab') ? true : false;
            var nextElement = this.getNextElement($target, isTab, isInEditedState);
            Iif (nextElement && (nextElement === 'noNextRow' || nextElement.classList.contains('e-rowdragheader'))) {
                (nextElement === 'noNextRow' && this.parent.treeGrid.element.getElementsByClassName('e-editedbatchcell').length > 0) ? this.parent.treeGrid.saveCell() : '';
                nextElement = null;
            }
            if (nextElement && $target.classList.contains('e-headercell')) {
                var colIndex = parseInt(nextElement.getAttribute('data-colindex'), 10);
                if (e.action === 'shiftTab') {
                    while (colIndex !== -1 && !this.parent.treeGrid.columns[colIndex]['visible']) {
                        colIndex = colIndex - 1;
                    }
                    Eif (colIndex !== -1) {
                        colIndex = this.parent.allowRowDragAndDrop ? colIndex + 1 : colIndex;
                        nextElement = document.getElementsByClassName('e-columnheader')[0].childNodes[colIndex];
                    }
                    else {
                        var toolbarItems_1 = document.getElementsByClassName('e-toolbar-item');
                        for (var i = toolbarItems_1.length - 1; i > 0; i--) {
                            if (!document.getElementsByClassName('e-toolbar-item')[i].classList.contains('e-hidden')) {
                                nextElement = document.getElementsByClassName('e-toolbar-item')[i];
                                this.currentToolbarIndex = i;
                                break;
                            }
                        }
                    }
                }
                else {
                    while (!this.parent.treeGrid.columns[colIndex]['visible']) {
                        colIndex = colIndex + 1;
                    }
                    colIndex = this.parent.allowRowDragAndDrop ? colIndex + 1 : colIndex;
                    nextElement = document.getElementsByClassName('e-columnheader')[0].childNodes[colIndex];
                }
            }
            Iif (!nextElement && $target.classList.contains('e-headercell') && e.action === 'tab') {
                nextElement = document.getElementsByClassName('e-timeline-header-container')[0];
            }
            if (!nextElement && ($target.classList.contains('e-headercell') || $target.classList.contains('e-toolbar-item') || $target.classList.contains('e-treegrid') ||
                $target.classList.contains('e-input') || $target.classList.contains('e-btn')) && this.parent.toolbarModule && this.parent.toolbar.length > 0) {
                var itemIndex = this.currentToolbarIndex !== -1 ? (e.action === 'tab' ? this.currentToolbarIndex + 1 :
                    this.currentToolbarIndex - 1) : (e.action === 'shiftTab' ? toolbarItems.length - 1 : 1);
                var isUpdated = false;
                Eif (itemIndex !== -1 && (e.action === 'shiftTab' || (e.action === 'tab' && itemIndex < toolbarItems.length))) {
                    do {
                        Eif (!toolbarItems[itemIndex].classList.contains('e-hidden')) {
                            nextElement = toolbarItems[itemIndex];
                            nextElement.setAttribute('tabindex', '-1');
                            Iif (nextElement.querySelector('.e-btn') === $target) {
                                e.action === 'tab' ? itemIndex++ : itemIndex--;
                                nextElement = toolbarItems[itemIndex];
                            }
                            Eif (nextElement.querySelector('.e-btn')) {
                                (nextElement.querySelector('.e-btn')).setAttribute('tabindex', '0');
                            }
                            isUpdated = true;
                            this.currentToolbarIndex = itemIndex;
                        }
                        else {
                            e.action === 'tab' ? itemIndex++ : itemIndex--;
                        }
                    } while (!isUpdated);
                }
            }
            Iif (e.action === 'tab' && !nextElement && (this.currentToolbarIndex === toolbarItems.length - 1 &&
                ($target.classList.contains('e-toolbar-item') || $target.classList.contains('e-input') ||
                    $target.classList.contains('e-btn')))) {
                for (var i = 0; i < this.parent.treeGrid.columns.length; i++) {
                    if (this.parent.treeGrid.columns[i]['visible']) {
                        nextElement = document.getElementsByClassName('e-columnheader')[0].childNodes[i];
                        break;
                    }
                }
            }
            Iif (e.action === 'shiftTab' && !nextElement && !$target.classList.contains('e-headercell')) {
                nextElement = document.getElementsByClassName('e-timeline-header-container')[0];
            }
            Iif (e.action === 'shiftTab' && $target.classList.contains('e-timeline-header-container')) {
                for (var i = this.parent.treeGrid.columns.length; i > 0; i--) {
                    if (this.parent.treeGrid.columns[i - 1]['visible']) {
                        nextElement = document.getElementsByClassName('e-columnheader')[0].childNodes[i - 1];
                        break;
                    }
                }
            }
            this.tempNextElement = nextElement;
            if (!ej2_base_2.isNullOrUndefined(nextElement) && !ej2_base_2.isNullOrUndefined(nextElement['cellIndex'])) {
                if (this.parent.allowRowDragAndDrop) {
                    this.childrenIndex = nextElement['cellIndex'];
                    this.nextElementIndex = nextElement['cellIndex'] - 1;
                }
                else {
                    this.childrenIndex = nextElement['cellIndex'];
                    this.nextElementIndex = nextElement['cellIndex'];
                }
                if (this.nextElementIndex !== -1 && !this.parent.ganttColumns[this.nextElementIndex]['allowEditing'] &&
                    this.parent.ganttColumns[this.nextElementIndex]['field'] !== this.parent.taskFields.id) {
                    this.isEditableElement = true;
                }
                else {
                    this.isEditableElement = false;
                }
            }
            Iif (nextElement === 'noNextRow') {
                this.manageFocus($target, 'remove', true);
                return;
            }
            Eif (typeof nextElement !== 'string') {
                Eif ($target.classList.contains('e-rowcell') || $target.closest('.e-chart-row-cell') ||
                    $target.classList.contains('e-headercell') || $target.closest('.e-segmented-taskbar') ||
                    $target.classList.contains('e-timeline-header-container')) {
                    e.preventDefault();
                }
                Iif (isTab && $target.classList.contains('e-rowdragdrop')) {
                    this.parent.treeGrid.grid.notify('key-pressed', e);
                    return;
                }
                if ($target.classList.contains('e-rowcell') && (nextElement && nextElement.classList.contains('e-rowcell')) ||
                    $target.classList.contains('e-headercell')) {
                    if (isTab) {
                        if (this.parent.editSettings.allowNextRowEdit) {
                            var rowData = this.parent.currentViewData[this.focusedRowIndex];
                            var columnName = this.parent.ganttColumns[nextElement.getAttribute('data-colindex')].field;
                            Iif (rowData.hasChildRecords) {
                                if (columnName === this.parent.taskFields.endDate || columnName ===
                                    this.parent.taskFields.duration || columnName === this.parent.taskFields.dependency ||
                                    columnName === this.parent.taskFields.progress || columnName === this.parent.taskFields.work ||
                                    columnName === this.parent.taskFields.type || columnName === 'taskType') {
                                    this.parent.treeGrid.grid.endEdit();
                                    this.parent.treeGrid.grid.notify('key-pressed', e);
                                }
                                else if (columnName === this.parent.taskFields.name || columnName === this.parent.taskFields.startDate) {
                                    this.parent.treeGrid.grid.notify('key-pressed', e);
                                }
                                else {
                                    this.parent.treeGrid.grid.notify('key-pressed', e);
                                    if (isInEditedState) {
                                        this.parent.treeGrid.editCell(this.focusedRowIndex, columnName);
                                    }
                                }
                            }
                            else {
                                this.parent.treeGrid.grid.notify('key-pressed', e);
                            }
                        }
                        else {
                            if (!nextElement || (nextElement && !nextElement.classList.contains('e-headercell') && !nextElement.classList.contains('e-timeline-header-container'))) {
                                Iif ($target.classList.contains('e-headercell')) {
                                    this.manageFocus($target, 'remove', false);
                                }
                                var row = this.parent.currentViewData[$target.parentElement.rowIndex];
                                var next = nextElement;
                                Iif (row.hasChildRecords &&
                                    (this.parent.ganttColumns[next.getAttribute('data-colindex')].field === this.parent.taskFields.progress ||
                                        !this.parent.ganttColumns[next.getAttribute('data-colindex')].allowEditing) &&
                                    this.parent.ganttColumns[next.getAttribute('data-colindex')].field !== this.parent.taskFields.id
                                    && $target.classList.contains('e-editedbatchcell')) {
                                    var currentColumn = void 0;
                                    next = this.updateElement(next, currentColumn, isTab, isInEditedState, row);
                                    while (!this.parent.ganttColumns[next.getAttribute('data-colindex')].allowEditing) {
                                        next = this.getNextElement(next, isTab, isInEditedState);
                                    }
                                    next = this.updateElement(next, currentColumn, isTab, isInEditedState, row);
                                }
                                else if (!nextElement || $target.classList.contains('e-editedbatchcell')) {
                                    this.parent.treeGrid.grid.notify('key-pressed', e);
                                }
                            }
                        }
                    }
                    else {
                        if (nextElement && !nextElement.classList.contains('e-headercell') && nextElement.classList.contains('e-rowcell')
                            && !nextElement.classList.contains('e-toolbar-item')) {
                            var row = this.parent.currentViewData[$target.parentElement.rowIndex];
                            var next = nextElement;
                            Iif (row.hasChildRecords &&
                                (this.parent.ganttColumns[next.getAttribute('data-colindex')].field === this.parent.taskFields.progress ||
                                    !this.parent.ganttColumns[next.getAttribute('data-colindex')].allowEditing) &&
                                this.parent.ganttColumns[next.getAttribute('data-colindex')].field !== this.parent.taskFields.id
                                && $target.classList.contains('e-editedbatchcell')) {
                                var currentColumn = void 0;
                                next = this.updateElement(next, currentColumn, isTab, isInEditedState, row);
                                while (!this.parent.ganttColumns[next.getAttribute('data-colindex')].allowEditing) {
                                    next = this.getNextElement(next, isTab, isInEditedState);
                                }
                                next = this.updateElement(next, currentColumn, isTab, isInEditedState, row);
                            }
                            else Iif (parseInt(next.parentElement.getAttribute('data-rowindex'), 10) !== 0 &&
                                parseInt(next.getAttribute('data-colindex'), 10) === 0 &&
                                this.parent.ganttColumns[next.getAttribute('data-colindex')].field === this.parent.taskFields.id &&
                                $target.classList.contains('e-editedbatchcell')) {
                                var rowIndex = $target.parentElement.rowIndex;
                                var rowElement = this.getNextRowElement(rowIndex, isTab, true);
                                next = this.getChildElement(rowElement, isTab);
                                var rowData = this.parent.flatData[parseInt(rowElement.getAttribute('data-rowindex'), 10)];
                                if (rowData.hasChildRecords && (!this.parent.ganttColumns[next.getAttribute('data-colindex')].allowEditing ||
                                    this.parent.ganttColumns[next.getAttribute('data-colindex')].field ===
                                        this.parent.taskFields.progress)) {
                                    var currentColumn = void 0;
                                    next = this.updateElement(next, currentColumn, isTab, isInEditedState, rowData);
                                    while (!this.parent.ganttColumns[next.getAttribute('data-colindex')].allowEditing) {
                                        next = this.getNextElement(next, isTab, isInEditedState);
                                    }
                                    next = this.updateElement(next, currentColumn, isTab, isInEditedState, rowData);
                                }
                                else {
                                    this.parent.treeGrid.grid.notify('key-pressed', e);
                                }
                            }
                            else {
                                this.parent.treeGrid.grid.notify('key-pressed', e);
                            }
                        }
                    }
                }
                if (this.parent.element.querySelectorAll('.e-focused').length > 0) {
                    this.manageFocus(this.parent.element.querySelectorAll('.e-focused')[0], 'remove', false);
                }
                if (!(this.parent.editModule && this.parent.editModule.cellEditModule
                    && !ej2_base_2.isNullOrUndefined(this.parent.editModule.cellEditModule.editedColumn))) {
                    Eif (nextElement) {
                        if ($target.classList.contains('e-rowcell')) {
                            this.manageFocus($target, 'remove', false);
                        }
                        else {
                            this.manageFocus($target, 'remove', true);
                        }
                        if ((nextElement.classList.contains('e-rowcell') && $target.nextElementSibling && !$target.classList.contains('e-timeline-header-container'))
                            || $target.classList.contains('e-right-label-container')) {
                            if (!$target.classList.contains('e-rowcell')) {
                                this.parent.treeGrid.grid.notify('key-pressed', e);
                                var fmodule = ej2_base_2.getValue('focusModule', this.parent.treeGrid.grid);
                                fmodule.currentInfo.element = nextElement;
                                fmodule.currentInfo.elementToFocus = nextElement;
                                fmodule.content.matrix.current = [nextElement.parentElement.rowIndex, nextElement.cellIndex];
                            }
                            this.manageFocus(nextElement, 'add', false);
                        }
                        else {
                            if (nextElement && (nextElement.classList.contains('e-toolbar-item') || nextElement.classList.contains('e-headercell')
                                || nextElement.classList.contains('e-rowcell'))) {
                                this.manageFocus($target, 'remove', false);
                                if (!nextElement.classList.contains('e-toolbar-item')) {
                                    this.manageFocus(nextElement, 'add', false);
                                }
                                Iif ($target.classList.contains('e-treegrid')) {
                                    e.preventDefault();
                                }
                            }
                            else {
                                this.manageFocus(nextElement, 'add', true);
                            }
                        }
                        this.parent.focusModule.setActiveElement(nextElement);
                    }
                }
            }
        };
        GanttChart.prototype.getNextElement = function ($target, isTab, isInEditedState) {
            Iif ($target.classList.contains('e-timeline-header-container') && isTab) {
                var rowElement = this.getNextRowElement(-1, isTab, true);
                return this.getChildElement(rowElement, isTab);
            }
            var nextElement = isTab ? $target.nextElementSibling : $target.previousElementSibling;
            if ($target.parentElement.classList.contains('e-taskbar-main-container')) {
                Iif (this.parent.labelSettings.rightLabel && isTab) {
                    return $target.parentElement.nextElementSibling;
                }
                else Eif (!isTab && this.parent.labelSettings.leftLabel) {
                    return $target.parentElement.previousElementSibling;
                }
            }
            while (nextElement && nextElement.parentElement.classList.contains('e-row')) {
                if (!nextElement.matches('.e-hide') && !nextElement.matches('.e-rowdragdrop')) {
                    return nextElement;
                }
                nextElement = isTab ? nextElement.nextElementSibling : nextElement.previousElementSibling;
            }
            Iif (!ej2_base_2.isNullOrUndefined(nextElement) && (nextElement.classList.contains('e-taskbar-main-container')
                || nextElement.classList.contains('e-right-connectorpoint-outer-div'))) {
                var record = this.parent.currentViewData[this.focusedRowIndex];
                if (!ej2_base_2.isNullOrUndefined(record.ganttProperties.segments) && record.ganttProperties.segments.length > 0) {
                    nextElement = nextElement.classList.contains('e-right-connectorpoint-outer-div')
                        ? nextElement.parentElement.nextElementSibling
                        : nextElement.getElementsByClassName('e-gantt-child-taskbar-inner-div')[0];
                }
            }
            if (this.validateNextElement(nextElement)) {
                return nextElement;
            }
            else {
                var rowIndex = -1;
                var rowElement = null;
                var childElement = void 0;
                if ($target.classList.contains('e-rowcell') && isInEditedState && this.parent.editSettings.allowNextRowEdit) {
                    rowIndex = $target.parentElement.rowIndex;
                    rowElement = this.getNextRowElement(rowIndex, isTab, true);
                    childElement = this.getChildElement(rowElement, isTab);
                    return childElement;
                }
                else if ($target.classList.contains('e-rowcell')) {
                    rowIndex = $target.parentElement.rowIndex;
                    if (isTab) {
                        rowElement = this.parent.getRowByIndex(rowIndex);
                        Iif (this.parent.treeGrid.element.getElementsByClassName('e-editedbatchcell').length > 0) {
                            rowElement = this.getNextRowElement(rowIndex, isTab, true);
                            var childElement_1 = this.getChildElement(rowElement, isTab);
                            return childElement_1;
                        }
                        else {
                            if (this.validateNextElement(rowElement, 'e-left-label-container')) {
                                return rowElement.getElementsByClassName('e-left-label-container')[0];
                            }
                            else Eif (this.validateNextElement(rowElement, 'e-taskbar-main-container')) {
                                return rowElement.getElementsByClassName('e-taskbar-main-container')[0];
                            }
                            else if (this.validateNextElement(rowElement, 'e-right-label-container')) {
                                return rowElement.getElementsByClassName('e-right-label-container')[0];
                            }
                        }
                    }
                    else {
                        rowElement = this.getNextRowElement(rowIndex, isTab, false);
                        Iif (this.validateNextElement(rowElement, 'e-right-label-container')) {
                            return rowElement.getElementsByClassName('e-right-label-container')[0];
                        }
                        else Eif (this.validateNextElement(rowElement, 'e-taskbar-main-container')) {
                            return rowElement.getElementsByClassName('e-taskbar-main-container')[0];
                        }
                        else if (this.validateNextElement(rowElement, 'e-left-label-container')) {
                            return rowElement.getElementsByClassName('e-left-label-container')[0];
                        }
                    }
                }
                else if ($target.parentElement.classList.contains('e-chart-row-cell') ||
                    $target.parentElement.parentElement.classList.contains('e-chart-row-cell')) {
                    rowIndex = ej2_base_2.closest($target, '.e-chart-row').rowIndex;
                    Iif (isTab) {
                        if (!isTab && this.parent.virtualScrollModule && this.parent.enableVirtualization) {
                            var rowRecord = this.parent.currentViewData[rowIndex];
                            rowIndex = this.parent.flatData.indexOf(rowRecord);
                        }
                        rowElement = this.getNextRowElement(rowIndex, isTab, true);
                    }
                    else {
                        rowElement = this.parent.treeGrid.getRows()[rowIndex];
                    }
                    var childElement_2 = this.getChildElement(rowElement, isTab);
                    return childElement_2;
                }
                nextElement = $target;
            }
            return null;
        };
        GanttChart.prototype.getNextRowElement = function (rowIndex, isTab, isChartRow) {
            var expandedRecords = this.parent.getExpandedRecords(this.parent.currentViewData);
            var currentItem = this.parent.currentViewData[rowIndex];
            var expandedRecordIndex = expandedRecords.indexOf(currentItem);
            var nextRecord = isTab ? expandedRecords[expandedRecordIndex + 1] : expandedRecords[expandedRecordIndex - 1];
            var nextRowIndex = this.parent.currentViewData.indexOf(nextRecord);
            Eif (nextRecord) {
                return isChartRow ? this.parent.treeGrid.getRows()[nextRowIndex] : this.parent.getRowByIndex(nextRowIndex);
            }
            else {
                return null;
            }
        };
        GanttChart.prototype.validateNextElement = function ($target, className) {
            Iif ($target && $target.classList.contains('e-rowcell')) {
                return true;
            }
            if ($target && className) {
                var elementByClass = $target.getElementsByClassName(className)[0];
                return (elementByClass && elementByClass.hasChildNodes()) ? true : false;
            }
            else if ($target) {
                return (!ej2_base_2.isNullOrUndefined($target) && $target.hasChildNodes()) ? true : false;
            }
            return false;
        };
        GanttChart.prototype.getChildElement = function (rowElement, isTab) {
            var childElement;
            Eif (rowElement) {
                childElement = isTab ? rowElement.children[0] : rowElement.children[rowElement.children.length - 1];
                while (childElement) {
                    if (!childElement.matches('.e-hide') && !childElement.matches('.e-rowdragdrop')) {
                        return childElement;
                    }
                    childElement = isTab ? childElement.nextElementSibling : childElement.previousElementSibling;
                }
            }
            else {
                return 'noNextRow';
            }
            return childElement;
        };
        GanttChart.prototype.manageFocus = function (element, focus, isChartElement, keyAction) {
            if (isChartElement) {
                var childElement = null;
                if (element.classList.contains('e-left-label-container') ||
                    element.classList.contains('e-right-label-container')) {
                    childElement = element.getElementsByTagName('span')[0];
                }
                else if (element.classList.contains('e-taskbar-main-container')
                    || element.classList.contains('e-gantt-child-taskbar-inner-div')) {
                    var rowIndex = ej2_base_2.closest(element, '.e-chart-row').rowIndex;
                    var data = this.parent.currentViewData[rowIndex];
                    var className = data.hasChildRecords ? data.ganttProperties.isAutoSchedule ? 'e-gantt-parent-taskbar' :
                        'e-manualparent-main-container' :
                        data.ganttProperties.isMilestone ? 'e-gantt-milestone' : !ej2_base_2.isNullOrUndefined(data.ganttProperties.segments)
                            && data.ganttProperties.segments.length > 0 ? 'e-segmented-taskbar' : 'e-gantt-child-taskbar';
                    childElement = element.getElementsByClassName(className)[0];
                    if (ej2_base_2.isNullOrUndefined(childElement)) {
                        childElement = element;
                    }
                }
                Iif (element.classList.contains('e-right-label-temp-container') || element.classList.contains('e-left-label-temp-container') || element.classList.contains('e-indicator-span') || element.classList.contains('e-timeline-header-container')) {
                    if (focus === 'add') {
                        element.setAttribute('tabIndex', '0');
                        ej2_base_2.addClass([element], 'e-active-container');
                        element.focus();
                    }
                    else {
                        if (keyAction !== 'downArrow' && keyAction !== 'upArrow') {
                            ej2_base_2.removeClass([element], 'e-active-container');
                            element.setAttribute('tabIndex', '-1');
                            element.blur();
                        }
                    }
                }
                if (focus === 'add' && !ej2_base_2.isNullOrUndefined(childElement)) {
                    element.setAttribute('tabIndex', '0');
                    ej2_base_2.addClass([childElement], 'e-active-container');
                    element.focus();
                    this.focusedElement = childElement;
                }
                else if (!ej2_base_2.isNullOrUndefined(childElement) && (keyAction !== 'downArrow' && keyAction !== 'upArrow')) {
                    ej2_base_2.removeClass([childElement], 'e-active-container');
                    element.setAttribute('tabIndex', '-1');
                    element.blur();
                }
            }
            else {
                if (focus === 'add') {
                    element.setAttribute('tabIndex', '0');
                    ej2_base_2.addClass([element], ['e-focused', 'e-focus']);
                    element.focus();
                }
                else {
                    element.setAttribute('tabIndex', '-1');
                    ej2_base_2.removeClass([element], ['e-focused', 'e-focus']);
                    element.blur();
                }
            }
        };
        GanttChart.prototype.getIndexByTaskBar = function (target) {
            var row;
            var recordIndex;
            if (!target.classList.contains(cls.taskBarMainContainer)) {
                row = ej2_base_2.closest(target, 'div.' + cls.taskBarMainContainer);
            }
            else {
                row = target;
            }
            if (ej2_base_2.isNullOrUndefined(row)) {
                row = ej2_base_2.closest(target, 'tr.' + cls.chartRow);
                recordIndex = [].slice.call(this.parent.chartRowsModule.ganttChartTableBody.childNodes).indexOf(row);
            }
            else {
                var id = row.getAttribute('rowUniqueId');
                var record = this.parent.getRecordByID(id);
                Iif (this.parent.enableVirtualization && this.parent.enableMultiTaskbar) {
                    recordIndex = this.parent.flatData.indexOf(record);
                }
                else {
                    Iif (this.parent.pdfExportModule && this.parent.pdfExportModule.helper.exportProps
                        && this.parent.pdfExportModule.helper.exportProps.fitToWidthSettings
                        && this.parent.pdfExportModule.helper.exportProps.fitToWidthSettings.isFitToWidth
                        && this.parent.pdfExportModule.isPdfExport) {
                        recordIndex = this.parent.ids.indexOf(record.ganttProperties.taskId.toString());
                    }
                    else {
                        recordIndex = this.parent.currentViewData.indexOf(record);
                    }
                }
            }
            return recordIndex;
        };
        GanttChart.prototype.destroy = function () {
            this.removeEventListener();
            this.unWireEvents();
            this.rangeViewContainer = null;
            this.chartBodyContent = null;
            this.scrollElement = null;
            this.chartTimelineContainer = null;
            this.chartBodyContainer = null;
            Eif (!ej2_base_2.isNullOrUndefined(this.scrollObject)) {
                this.scrollObject.destroy();
                this.scrollObject = null;
            }
        };
        return GanttChart;
    }());
    exports.GanttChart = GanttChart;
});