all files / actions/ selection.js

92.4% Statements 304/329
87.3% Branches 220/252
95.35% Functions 41/43
92.38% Lines 303/328
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   1088× 1088× 1088× 1088× 1088× 1088× 1088× 1088× 1088× 1088× 1088× 1088× 1088×   27959×   1088× 1088×         1088×     1344× 287× 287×     1088× 1088× 1088× 1088× 1088× 1088× 1088× 1088×   914× 152× 152×   762× 762× 762× 762× 742×   762×   762× 762×     755× 755×   755× 755× 755× 755×     755× 755× 12×   755× 54×       746×     755× 755× 735×   755× 755× 650×   755×   522× 522× 522×   519× 519× 519×       519× 10×                 515×     519× 519× 519× 519×     519× 456×   519×       519× 519× 519× 519× 519×   12× 12× 12×   12×   12× 12×     10×   10× 10×         516× 516×       9028× 516× 516× 63×   453× 36× 36×   36×     417×   453× 25×   453× 428×   453×   453× 453×       24345×   2953×   6092×                               6092×     10× 10× 10×   10×     96× 96× 96× 96× 96× 96× 88×   96×   41× 41× 41× 41× 41× 41× 38× 38× 38× 38× 36×     36×   36× 36×                         52×         1428× 17×   1428× 1428× 1433× 24144×   1433× 1370× 1370× 1370× 1370×       1370×     74×   1296× 574×   722× 722×   1370×           1428× 1428× 1433×     796× 796×   574× 574×                         56× 56× 56×   56×                     53×     56× 56×     155× 155× 155× 155×   152× 55×     155× 155×   155× 125× 125×       155× 56× 56×       56× 56× 41× 38×   38× 38×       41×             15×       21544× 21544× 57×     1087× 978×   109× 109×     107×          
define(["require", "exports", "@syncfusion/ej2-grids", "@syncfusion/ej2-grids", "@syncfusion/ej2-base", "@syncfusion/ej2-data"], function (require, exports, ej2_grids_1, ej2_grids_2, ej2_base_1, ej2_data_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Selection = (function () {
        function Selection(gantt) {
            this.isSelectionFromChart = false;
            this.isFromChart = false;
            this.multipleIndexes = [];
            this.selectedRowIndexes = [];
            this.enableSelectMultiTouch = false;
            this.openPopup = false;
            this.parent = gantt;
            this.bindEvents();
            this.parent.treeGrid.selectedRowIndex = this.parent.selectedRowIndex;
            this.parent.treeGrid.allowSelection = this.parent.allowSelection;
            this.parent.treeGrid.grid.selectionSettings.enableToggle = this.parent.selectionSettings.enableToggle;
            this.parent.treeGrid.selectionSettings = ej2_grids_1.getActualProperties(this.parent.selectionSettings);
            this.wireEvents();
        }
        Selection.prototype.getModuleName = function () {
            return 'selection';
        };
        Selection.prototype.wireEvents = function () {
            this.parent.on('selectRowByIndex', this.selectRowByIndex, this);
            Iif (this.parent.isAdaptive) {
                this.parent.on('chartMouseClick', this.mouseUpHandler, this);
                this.parent.on('treeGridClick', this.popUpClickHandler, this);
            }
            else {
                this.parent.on('chartMouseUp', this.mouseUpHandler, this);
            }
        };
        Selection.prototype.selectRowByIndex = function () {
            if ((this.parent.selectedRowIndex !== -1 || this.parent.staticSelectedRowIndex !== -1)) {
                this.selectRow(this.parent.staticSelectedRowIndex !== -1 ? this.parent.staticSelectedRowIndex : this.parent.selectedRowIndex);
                this.parent.staticSelectedRowIndex = -1;
            }
        };
        Selection.prototype.bindEvents = function () {
            this.parent.treeGrid.rowSelecting = this.rowSelecting.bind(this);
            this.parent.treeGrid.rowSelected = this.rowSelected.bind(this);
            this.parent.treeGrid.rowDeselecting = this.rowDeselecting.bind(this);
            this.parent.treeGrid.rowDeselected = this.rowDeselected.bind(this);
            this.parent.treeGrid.cellSelecting = this.cellSelecting.bind(this);
            this.parent.treeGrid.cellSelected = this.cellSelected.bind(this);
            this.parent.treeGrid.cellDeselecting = this.cellDeselecting.bind(this);
            this.parent.treeGrid.cellDeselected = this.cellDeselected.bind(this);
        };
        Selection.prototype.rowSelecting = function (args) {
            if (!this.parent.isGanttChartRendered) {
                args.cancel = true;
                return;
            }
            args.isCtrlPressed = this.isMultiCtrlRequest || args.isCtrlPressed;
            args.isShiftPressed = this.isMultiShiftRequest || args.isShiftPressed;
            args.target = this.actualTarget;
            if (!ej2_base_1.isNullOrUndefined(args.foreignKeyData) && Object.keys(args.foreignKeyData).length === 0) {
                delete args.foreignKeyData;
            }
            if (this.parent.selectionSettings && this.parent.selectionSettings.persistSelection) {
                this.parent.treeGrid.grid.selectionModule['checkSelectAllClicked'] = true;
            }
            this.parent.trigger('rowSelecting', args);
            if (this.isMultiShiftRequest || this.isMultiCtrlRequest) {
                this.isMultiShiftRequest = this.isMultiCtrlRequest = false;
            }
        };
        Selection.prototype.rowSelected = function (args) {
            var rowIndexes = 'rowIndexes';
            var index = (this.parent.selectionSettings.type === 'Multiple' && !ej2_base_1.isNullOrUndefined(args[rowIndexes])) ?
                args[rowIndexes] : [args.rowIndex];
            this.addRemoveClass(index, args['name']);
            this.selectedRowIndexes = ej2_base_1.extend([], this.getSelectedRowIndexes(), [], true);
            this.parent.setProperties({ selectedRowIndex: this.parent.treeGrid.grid.selectedRowIndex }, true);
            Iif (this.isMultiShiftRequest) {
                this.selectedRowIndexes = index;
            }
            Eif (this.parent.autoFocusTasks) {
                if (this.parent.enableTimelineVirtualization) {
                    this.parent['isRowSelected'] = true;
                }
                if (args.data && !ej2_base_1.isNullOrUndefined(args.data['length'])) {
                    for (var i = 0; i < args.data['length']; i++) {
                        this.parent.ganttChartModule.updateScrollLeft(args.data[i].ganttProperties.left);
                    }
                }
                else {
                    this.parent.ganttChartModule.updateScrollLeft(ej2_base_1.getValue('data.ganttProperties.left', args));
                }
            }
            args.target = this.actualTarget;
            if (!ej2_base_1.isNullOrUndefined(args.foreignKeyData) && Object.keys(args.foreignKeyData).length === 0) {
                delete args.foreignKeyData;
            }
            this.prevRowIndex = args.rowIndex;
            if (!ej2_base_1.isNullOrUndefined(this.parent.toolbarModule)) {
                this.parent.toolbarModule.refreshToolbarItems(args);
            }
            this.parent.trigger('rowSelected', args);
        };
        Selection.prototype.rowDeselecting = function (args) {
            args.target = this.actualTarget;
            args.isInteracted = this.isInteracted;
            this.parent.trigger('rowDeselecting', args);
        };
        Selection.prototype.rowDeselected = function (args) {
            var index;
            var isContains;
            Iif (this.multipleIndexes.length !== 0) {
                index = this.multipleIndexes;
            }
            else {
                if (!ej2_base_1.isNullOrUndefined(args.rowIndexes)) {
                    for (var i = 0; i < args.rowIndexes.length; i++) {
                        if (args.rowIndexes[i] === args.rowIndex) {
                            isContains = true;
                        }
                    }
                    Eif (isContains) {
                        index = args.rowIndexes;
                    }
                    else {
                        index = [args.rowIndex];
                    }
                }
                else {
                    index = [args.rowIndex];
                }
            }
            this.addRemoveClass(index);
            this.selectedRowIndexes = ej2_base_1.extend([], this.getSelectedRowIndexes(), [], true);
            this.parent.setProperties({ selectedRowIndex: -1 }, true);
            Iif (this.selectedRowIndexes.length === 1) {
                this.parent.setProperties({ selectedRowIndex: this.selectedRowIndexes[0] }, true);
            }
            if (!ej2_base_1.isNullOrUndefined(this.parent.toolbarModule)) {
                this.parent.toolbarModule.refreshToolbarItems();
            }
            Iif (this.parent.selectionSettings.type === 'Multiple' && this.parent.isAdaptive
                && this.selectedRowIndexes.length === 0) {
                this.hidePopUp();
            }
            args.target = this.actualTarget;
            args.isInteracted = this.isInteracted;
            this.parent.trigger('rowDeselected', args);
            this.isInteracted = false;
            this.multipleIndexes = [];
        };
        Selection.prototype.cellSelecting = function (args) {
            var callBackPromise = new ej2_data_1.Deferred();
            this.parent.trigger('cellSelecting', args, function (cellselectingArgs) {
                callBackPromise.resolve(cellselectingArgs);
            });
            return callBackPromise;
        };
        Selection.prototype.cellSelected = function (args) {
            this.parent.trigger('cellSelected', args);
            if (!ej2_base_1.isNullOrUndefined(this.parent.toolbarModule)) {
                this.parent.toolbarModule.refreshToolbarItems();
            }
        };
        Selection.prototype.cellDeselecting = function (args) {
            this.parent.trigger('cellDeselecting', args);
        };
        Selection.prototype.cellDeselected = function (args) {
            this.parent.trigger('cellDeselected', args);
            if (!ej2_base_1.isNullOrUndefined(this.parent.toolbarModule)) {
                this.parent.toolbarModule.refreshToolbarItems();
            }
        };
        Selection.prototype.selectCell = function (cellIndex, isToggle) {
            this.parent.treeGrid.selectCell(cellIndex, isToggle);
        };
        Selection.prototype.selectCells = function (rowCellIndexes) {
            this.parent.treeGrid.grid.selectCells(rowCellIndexes);
        };
        Selection.prototype.selectRow = function (index, isToggle, isPreventFocus) {
            var ganttRow = [].slice.call(this.parent.ganttChartModule.chartBodyContent.querySelector('tbody').children);
            if (this.parent.enableVirtualization && (this.parent.treeGridModule.addedRecord ||
                (this.parent.editModule && this.parent.editModule.isAdded))) {
                index = this.parent.getExpandedRecords(this.parent.flatData).indexOf(this.parent.flatData[index]);
                this.parent.treeGridModule.addedRecord = false;
                Eif (this.parent.editModule) {
                    this.parent.editModule.isAdded = false;
                }
            }
            var selectedRow = ganttRow.filter(function (e) { return parseInt(e.getAttribute('data-rowindex'), 10) === index; })[0];
            var condition;
            if (index === -1 || (ej2_base_1.isNullOrUndefined(selectedRow) && !this.parent.enableVirtualization) || this.parent.selectionSettings.mode === 'Cell') {
                return;
            }
            if (this.parent.showActiveElement && !ej2_base_1.isNullOrUndefined(isPreventFocus) && !isPreventFocus || this.isFromChart) {
                Eif (this.isFromChart) {
                    this.isFromChart = false;
                }
                this.parent.treeGrid.grid.selectionModule.preventFocus = true;
            }
            else {
                this.parent.treeGrid.grid.selectionModule.preventFocus = false;
            }
            if ((!ej2_base_1.isNullOrUndefined(this.selectedClass) && (this.selectedClass === selectedRow) && (!isToggle))) {
                condition = true;
            }
            if (condition !== true) {
                this.parent.treeGrid.selectRow(index, isToggle);
            }
            this.parent.treeGrid.grid.selectionModule.preventFocus = this.parent.treeGrid.grid.selectionModule.preventFocus === true ?
                false : this.parent.treeGrid.grid.selectionModule.preventFocus;
            this.prevRowIndex = index;
            this.selectedClass = selectedRow;
        };
        Selection.prototype.selectRows = function (records) {
            Eif (!ej2_base_1.isNullOrUndefined(records) && records.length > 0) {
                this.parent.treeGrid.selectRows(records);
            }
        };
        Selection.prototype.getSelectedRowIndexes = function () {
            return this.parent.treeGrid.getSelectedRowIndexes();
        };
        Selection.prototype.getSelectedRowCellIndexes = function () {
            return this.parent.treeGrid.getSelectedRowCellIndexes();
        };
        Selection.prototype.getSelectedRecords = function () {
            Iif (this.parent.loadChildOnDemand && this.parent.taskFields.hasChildMapping) {
                var selectedRows = [];
                var selectedIndexes_1 = this.parent.selectionModule.getSelectedRowIndexes();
                var _loop_1 = function (i) {
                    var rec = this_1.parent.currentViewData.filter(function (data) {
                        return data.index === selectedIndexes_1[i];
                    })[0];
                    selectedRows.push(rec);
                };
                var this_1 = this;
                for (var i = 0; i < selectedIndexes_1.length; i++) {
                    _loop_1(i);
                }
                return selectedRows;
            }
            else {
                return this.parent.treeGrid.getSelectedRecords();
            }
        };
        Selection.prototype.getCellSelectedRecords = function () {
            var cellDetails = this.parent.selectionModule.getSelectedRowCellIndexes();
            var cellSelectedRecords = [];
            for (var i = 0; i < cellDetails.length; i++) {
                cellSelectedRecords.push(this.parent.currentViewData[cellDetails[i].rowIndex]);
            }
            return cellSelectedRecords;
        };
        Selection.prototype.getSelectedRows = function () {
            return this.parent.treeGrid.getSelectedRows();
        };
        Selection.prototype.clearSelection = function () {
            this.addRemoveClass(this.selectedRowIndexes);
            this.parent.treeGrid.clearSelection();
            this.parent.selectedRowIndex = -1;
            this.selectedRowIndexes = [];
            this.selectedClass = null;
            if (!ej2_base_1.isNullOrUndefined(this.parent.toolbarModule)) {
                this.parent.toolbarModule.refreshToolbarItems();
            }
            this.isInteracted = false;
        };
        Selection.prototype.highlightSelectedRows = function (e, fromChart) {
            this.isMultiCtrlRequest = e.ctrlKey || this.enableSelectMultiTouch;
            this.isMultiShiftRequest = e.shiftKey;
            this.actualTarget = e.target;
            this.isInteracted = true;
            this.isSelectionFromChart = fromChart;
            if (fromChart) {
                var selectedRow = ej2_base_1.closest(e.target, 'tr.e-chart-row');
                var rIndex = parseInt(selectedRow.getAttribute('data-rowindex'), 10);
                var isToggle = this.parent.selectionSettings.enableToggle;
                if (this.parent.selectionSettings.type === 'Single' || (!this.isMultiCtrlRequest && !this.isMultiShiftRequest)) {
                    Iif (this.parent.selectionSettings.persistSelection) {
                        this.addRemoveClass(this.selectedRowIndexes, e['name']);
                    }
                    Eif (!this.parent.allowTaskbarDragAndDrop || (this.parent.allowTaskbarDragAndDrop && (this.parent.rowDragAndDropModule &&
                        !this.parent.rowDragAndDropModule['draggedRecord']))) {
                        this.isFromChart = true;
                        this.selectRow(rIndex, isToggle);
                    }
                }
                else {
                    Iif (this.isMultiShiftRequest) {
                        this.selectRowsByRange(ej2_base_1.isNullOrUndefined(this.prevRowIndex) ? rIndex : this.prevRowIndex, rIndex);
                    }
                    else {
                        ej2_base_1.setValue('isMultiCtrlRequest', true, this.parent.treeGrid.grid.selectionModule);
                        this.parent.treeGrid.grid.selectionModule.addRowsToSelection([rIndex]);
                        var isUnSelected = this.selectedRowIndexes.indexOf(rIndex) > -1;
                        if (isUnSelected) {
                            this.addRemoveClass([rIndex], e['name']);
                        }
                    }
                }
            }
        };
        Selection.prototype.getselectedrowsIndex = function (startIndex, endIndex) {
            var indexes = [];
            var _a = (startIndex < endIndex) ?
                { i: startIndex, max: endIndex } : { i: endIndex, max: startIndex }, i = _a.i, max = _a.max;
            for (; i <= max; i++) {
                indexes.push(i);
            }
            if (startIndex > endIndex) {
                indexes.reverse();
            }
            this.selectedRowIndexes = indexes;
        };
        Selection.prototype.selectRowsByRange = function (startIndex, endIndex) {
            this.isSelectionFromChart = true;
            this.getselectedrowsIndex(startIndex, endIndex);
            this.selectRows(this.selectedRowIndexes);
        };
        Selection.prototype.addRemoveClass = function (records, request) {
            if (typeof (records) == 'number') {
                records = [records];
            }
            var ganttRow = [].slice.call(this.parent.ganttChartModule.chartBodyContent.querySelector('tbody').children);
            var _loop_2 = function (i) {
                var selectedRow = ganttRow.filter(function (e) {
                    return parseInt(e.getAttribute('data-rowindex'), 10) === records[parseInt(i.toString(), 10)];
                })[0];
                if (!ej2_base_1.isNullOrUndefined(selectedRow)) {
                    var persist = false;
                    var index = this_2.getSelectedRowIndexes().indexOf(records[parseInt(i.toString(), 10)]);
                    var selectedRecordLen = this_2.getSelectedRecords().length;
                    if (this_2.parent.selectionSettings.persistSelection && this_2.parent.selectionSettings.enableToggle &&
                        !ej2_base_1.isNullOrUndefined(request) && this_2.parent.selectionSettings.type !== 'Multiple' &&
                        selectedRecordLen > 0) {
                        persist = true;
                    }
                    if (this_2.parent.selectionSettings.enableToggle && this_2.parent.selectionSettings.persistSelection &&
                        (index > -1 && this_2.parent.selectionSettings.type === 'Single' && persist) ||
                        (index > -1 && ((!ej2_base_1.isNullOrUndefined(request) && this_2.parent.selectionSettings.type === 'Multiple')))) {
                        this_2.addClass(selectedRow);
                    }
                    else if (ej2_base_1.isNullOrUndefined(request)) {
                        this_2.removeClass(selectedRow);
                    }
                    else Eif (index > -1) {
                        this_2.addClass(selectedRow);
                    }
                    Iif ((this_2.parent.selectionSettings.type === 'Single' || (!this_2.isMultiCtrlRequest && !this_2.isMultiShiftRequest)) && index > -1 && this_2.parent.selectionSettings.persistSelection &&
                        request === 'chartMouseUp' && this_2.isSelectionFromChart) {
                        this_2.removeClass(selectedRow);
                    }
                }
            };
            var this_2 = this;
            for (var i = 0; i < records.length; i++) {
                _loop_2(i);
            }
        };
        Selection.prototype.addClass = function (selectedRow) {
            ej2_base_1.addClass([selectedRow], 'e-active');
            selectedRow.setAttribute('aria-selected', 'true');
        };
        Selection.prototype.removeClass = function (selectedRow) {
            ej2_base_1.removeClass([selectedRow], 'e-active');
            selectedRow.removeAttribute('aria-selected');
        };
        Selection.prototype.showPopup = function (e) {
            Eif (this.isSelectionFromChart) {
                ej2_grids_2.setCssInGridPopUp(this.parent.element.querySelector('.e-ganttpopup'), e, 'e-rowselect e-icons e-icon-rowselect' +
                    ((this.enableSelectMultiTouch &&
                        (this.getSelectedRecords().length > 1 || this.getSelectedRowCellIndexes().length > 1)) ? ' e-spanclicked' : ''));
                document.getElementsByClassName('e-gridpopup')[0].style.display = 'none';
                this.openPopup = true;
            }
            else if (this.selectedRowIndexes.length === 0) {
                this.hidePopUp();
            }
        };
        Selection.prototype.hidePopUp = function () {
            if (this.openPopup) {
                document.getElementsByClassName('e-ganttpopup')[0].style.display = 'none';
                this.openPopup = false;
            }
            else {
                document.getElementsByClassName('e-gridpopup')[0].style.display = 'none';
            }
        };
        Selection.prototype.popUpClickHandler = function (e) {
            var target = e.target;
            var grid = this.parent.treeGrid.grid;
            var $popUpElemet = ej2_base_1.closest(target, '.e-ganttpopup') ?
                ej2_base_1.closest(target, '.e-ganttpopup') : ej2_base_1.closest(target, '.e-gridpopup');
            if ($popUpElemet) {
                var spanElement = $popUpElemet.querySelector('.' + 'e-rowselect');
                if (ej2_base_1.closest(target, '.e-ganttpopup') &&
                    !spanElement.classList.contains('e-spanclicked')) {
                    this.enableSelectMultiTouch = true;
                    spanElement.classList.add('e-spanclicked');
                }
                else Iif (ej2_base_1.closest(target, '.e-gridpopup') &&
                    spanElement.classList.contains('e-spanclicked')) {
                    this.openPopup = true;
                    this.enableSelectMultiTouch = true;
                }
                else {
                    this.hidePopUp();
                    this.enableSelectMultiTouch = false;
                    Eif (ej2_base_1.closest(target, '.e-ganttpopup')) {
                        spanElement.classList.remove('e-spanclicked');
                    }
                }
            }
            else if (this.parent.selectionSettings.type === 'Multiple' && this.parent.isAdaptive) {
                var $tr = ej2_base_1.closest(target, '.e-rowcell');
                if ($tr && this.selectedRowIndexes.length === 0) {
                    this.hidePopUp();
                }
            }
            Eif (grid) {
                ej2_base_1.setValue('enableSelectMultiTouch', this.enableSelectMultiTouch, grid.selectionModule);
            }
        };
        Selection.prototype.mouseUpHandler = function (e) {
            var isTaskbarEdited = false;
            var elements = document.querySelectorAll('.e-drag-item');
            var targetElement = null;
            if (e.target.closest('.e-rowcell')) {
                targetElement = e.target;
            }
            else if (e.target.closest('.e-chart-row')) {
                targetElement = e.target.closest('.e-left-label-container') ||
                    e.target.closest('.e-taskbar-main-container') || e.target.closest('.e-right-label-container');
            }
            Eif (this.parent.focusModule) {
                this.parent.focusModule.setActiveElement(targetElement);
            }
            if (this.parent.editModule && this.parent.editSettings.allowTaskbarEditing && this.parent.editModule.taskbarEditModule) {
                var taskbarEdit = this.parent.editModule.taskbarEditModule;
                Iif (taskbarEdit.isMouseDragged || taskbarEdit.tapPointOnFocus) {
                    isTaskbarEdited = true;
                }
            }
            if (!isTaskbarEdited && this.parent.element.contains(e.target) && !(elements.length === 1)) {
                var parent_1 = ej2_grids_1.parentsUntil(e.target, 'e-chart-row');
                var isSelected = e.target.classList.contains('e-rowcell') ||
                    e.target.classList.contains('e-row') ||
                    e.target.classList.contains('e-treegridexpand') ||
                    e.target.classList.contains('e-treegridcollapse') || !ej2_base_1.isNullOrUndefined(parent_1);
                this.popUpClickHandler(e);
                if (this.parent.selectionSettings.mode !== 'Cell' && isSelected) {
                    if (ej2_base_1.closest(e.target, 'tr.e-chart-row')) {
                        if (this.parent.enableVirtualization) {
                            this.parent.treeGrid.grid.selectionModule.isInteracted = true;
                        }
                        this.parent.treeGrid['isFromChartSide'] = true;
                        this.highlightSelectedRows(e, true);
                    }
                    else {
                        this.parent.treeGrid['isFromChartSide'] = false;
                        this.highlightSelectedRows(e, false);
                    }
                    if (this.parent.selectionSettings.type === 'Multiple' && this.parent.isAdaptive) {
                        if (this.selectedRowIndexes.length > 0) {
                            this.showPopup(e);
                        }
                        else {
                            this.hidePopUp();
                        }
                    }
                }
                else {
                    this.isSelectionFromChart = false;
                }
            }
        };
        Selection.prototype.maintainSelectedRecords = function (i) {
            var index = this.parent.selectionModule.getSelectedRowIndexes().indexOf(i);
            if (index > -1) {
                this.addRemoveClass([i]);
            }
        };
        Selection.prototype.destroy = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.parent.off('selectRowByIndex', this.selectRowByIndex);
            if (this.parent.isAdaptive) {
                this.parent.off('chartMouseClick', this.mouseUpHandler);
                this.parent.off('treeGridClick', this.popUpClickHandler);
            }
            else {
                this.parent.off('chartMouseUp', this.mouseUpHandler);
            }
        };
        return Selection;
    }());
    exports.Selection = Selection;
});