all files / spreadsheet/services/ overlay.js

76.38% Statements 262/343
69.32% Branches 174/251
93.33% Functions 14/15
76.38% Lines 262/343
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   885× 885× 885× 885× 885× 885× 885× 885× 885× 885×   173×         173× 173× 173× 24× 24×   173×   173× 173× 173× 173× 173× 173×           173×         173× 173× 16× 16× 16×   15×     16× 12×   10×           157×   173× 173× 173× 167× 167× 167×         173× 173× 173×   19× 19× 19× 19× 19× 16×   16×               19× 12× 12×   19× 12× 12×     167× 167× 167× 167× 167× 167×   119× 119×                                                                                                                     612× 604×                                                                                                                                             10617×       10614× 10614× 10614× 63× 63× 63× 63×       10617×   14×   13× 13× 13× 13×     13× 13×                         13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 10×   13× 13×   13×     13× 13× 13×   167× 167× 167× 167× 668×   668× 668×     885× 885× 50× 90× 90×     885× 885× 885×   885× 885×   885× 885× 885× 885× 885×     885× 885× 885×   885× 885×   885× 885×   885× 885×   885×   885×     885×        
define(["require", "exports", "../index", "../common/index", "../common/index", "../common/index", "../../workbook/index", "../../workbook/index", "@syncfusion/ej2-base"], function (require, exports, index_1, index_2, index_3, index_4, index_5, index_6, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Overlay = (function () {
        function Overlay(parent) {
            this.minHeight = '300px';
            this.minWidth = '400px';
            this.isOverlayClicked = false;
            this.isResizerClicked = false;
            this.currentWidth = 400;
            this.currenHeight = 300;
            this.parent = parent;
            this.parent.on(index_3.selectionStatus, this.isOverlaySelected, this);
            this.parent.on(index_2.refreshOverlayElem, this.refreshOverlayElem, this);
            this.parent.on(index_4.spreadsheetDestroyed, this.destroy, this);
        }
        Overlay.prototype.insertOverlayElement = function (id, range, sheetIndex) {
            var div = this.parent.createElement('div', {
                id: id,
                attrs: { 'class': 'e-ss-overlay' },
                styles: 'width: ' + this.minWidth + ';  height: ' + this.minHeight
            });
            Eif (this.parent.allowEditing) {
                var actOverlayElem = this.parent.element.getElementsByClassName('e-ss-overlay-active')[0];
                if (actOverlayElem) {
                    ej2_base_1.removeClass([actOverlayElem], 'e-ss-overlay-active');
                    this.parent.notify(index_1.removeDesignChart, {});
                }
                div.classList.add('e-ss-overlay-active');
            }
            var indexes = index_5.getRangeIndexes(range);
            var sheet = this.parent.sheets[sheetIndex];
            var frozenRow = this.parent.frozenRowCount(sheet);
            var frozenCol = this.parent.frozenColCount(sheet);
            var pos = index_2.getCellPosition(sheet, indexes, frozenRow, frozenCol, this.parent.viewport.beforeFreezeHeight, this.parent.viewport.beforeFreezeWidth, this.parent.sheetModule.colGroupWidth, true);
            if (indexes[0] >= frozenRow && indexes[1] < frozenCol) {
                var mainPanel = this.parent.sheetModule.contentPanel;
                Iif (mainPanel.scrollTop) {
                    pos.top -= mainPanel.scrollTop;
                    pos.top +=
                        this.parent.getColumnHeaderContent().parentElement.getBoundingClientRect().height;
                }
            }
            if (indexes[1] >= frozenCol && indexes[0] < frozenRow) {
                var scrollPanel = this.parent.getScrollElement();
                Iif (scrollPanel.scrollLeft) {
                    pos.left -= scrollPanel.scrollLeft;
                    pos.left += this.parent.sheetModule.getRowHeaderWidth(sheet);
                }
            }
            var parent;
            if (indexes[0] < frozenRow || indexes[1] < frozenCol) {
                parent = this.parent.element.querySelector('#' + this.parent.element.id + '_sheet');
                Eif (frozenRow) {
                    if (indexes[0] >= frozenRow) {
                        pos.top += (sheet.showHeaders ? 31 : 0) + index_5.getRowsHeight(sheet, index_5.getCellIndexes(sheet.topLeftCell)[0], frozenRow - 1);
                    }
                    else if (!frozenCol) {
                        pos.left += this.parent.sheetModule.getRowHeaderWidth(sheet, true);
                    }
                }
                if (frozenCol) {
                    if (indexes[1] >= frozenCol) {
                        pos.left += this.parent.sheetModule.getRowHeaderWidth(sheet);
                    }
                    else Iif (!frozenRow) {
                        pos.left += (sheet.showHeaders ? 31 : 0);
                    }
                }
            }
            else {
                parent = this.parent.getMainContent();
            }
            div.style.top = Number(index_4.addDPRValue(pos.top).toFixed(2)) + 'px';
            div.style.left = Number(index_4.addDPRValue(pos.left).toFixed(2)) + 'px';
            if (sheetIndex === this.parent.activeSheetIndex) {
                parent.appendChild(div);
                this.renderResizeHandler(div);
                this.addEventListener(div);
            }
            else Iif (this.parent.isPrintingProcessing) {
                div.style.visibility = 'hidden';
                document.body.append(div);
            }
            this.originalWidth = parseFloat(getComputedStyle(div, null).getPropertyValue('width').replace('px', ''));
            this.originalHeight = parseFloat(getComputedStyle(div, null).getPropertyValue('height').replace('px', ''));
            return { element: div, top: pos.top, left: pos.left };
        };
        Overlay.prototype.adjustFreezePaneSize = function (model, element, range) {
            var indexes = index_5.getRangeIndexes(range);
            var sheet = this.parent.getActiveSheet();
            var frozenRow = this.parent.frozenRowCount(sheet);
            var frozenCol = this.parent.frozenColCount(sheet);
            if (indexes[0] < frozenRow || indexes[1] < frozenCol) {
                if (!ej2_base_1.isNullOrUndefined(model.top)) {
                    element.style.top = model.top + (sheet.showHeaders ? 31 : 0) - this.parent.viewport.beforeFreezeHeight + 'px';
                }
                if (!ej2_base_1.isNullOrUndefined(model.left)) {
                    element.style.left = model.left + this.parent.sheetModule.getRowHeaderWidth(sheet, true) -
                        this.parent.viewport.beforeFreezeWidth + 'px';
                }
            }
            else {
                if (!ej2_base_1.isNullOrUndefined(model.top)) {
                    element.style.top = model.top - this.parent.viewport.beforeFreezeHeight - (frozenRow ? index_5.getRowsHeight(sheet, index_5.getCellIndexes(sheet.topLeftCell)[0], frozenRow - 1) : 0) + 'px';
                }
                if (!ej2_base_1.isNullOrUndefined(model.left)) {
                    element.style.left = model.left - this.parent.viewport.beforeFreezeWidth - (frozenCol ? index_6.getColumnsWidth(sheet, index_5.getCellIndexes(sheet.topLeftCell)[1], frozenCol - 1) : 0) + 'px';
                }
            }
            if (ej2_base_1.isNullOrUndefined(model.top)) {
                var startTop = index_5.getCellIndexes(sheet.topLeftCell)[0];
                model.top = this.parent.viewport.beforeFreezeHeight + (frozenRow && startTop === indexes[0] ? 0 : index_5.getRowsHeight(sheet, frozenRow ? startTop : 0, indexes[0] - 1));
            }
            if (ej2_base_1.isNullOrUndefined(model.left)) {
                var startLeft = index_5.getCellIndexes(sheet.topLeftCell)[1];
                model.left = this.parent.viewport.beforeFreezeWidth + (frozenCol && startLeft === indexes[1] ? 0 : index_6.getColumnsWidth(sheet, frozenCol ? startLeft : 0, indexes[1] - 1));
            }
        };
        Overlay.prototype.addEventListener = function (div) {
            var overlayElem = div;
            ej2_base_1.EventHandler.add(overlayElem, index_3.getStartEvent(), this.overlayClickHandler, this);
            ej2_base_1.EventHandler.add(overlayElem, index_3.getMoveEvent(), this.overlayMouseMoveHandler, this);
            ej2_base_1.EventHandler.add(this.parent.element.querySelector('#' + this.parent.element.id + '_sheet'), index_3.getMoveEvent(), this.overlayMouseMoveHandler, this);
            ej2_base_1.EventHandler.add(document, index_4.getEndEvent(), this.overlayMouseUpHandler, this);
            this.parent.on(index_3.overlayEleSize, this.setOriginalSize, this);
        };
        Overlay.prototype.setOriginalSize = function (args) {
            this.originalHeight = args.height;
            this.originalWidth = args.width;
        };
        Overlay.prototype.overlayMouseMoveHandler = function (e) {
            var target = e.target;
            var overlayElem = document.getElementsByClassName('e-ss-overlay-active')[0];
            var sheet = this.parent.getActiveSheet();
            var checkOffset = sheet.frozenRows || sheet.frozenColumns ? [29, this.parent.sheetModule.getRowHeaderWidth(sheet, true)] : [-1, -1];
            var height1;
            var top;
            var width1;
            var height2;
            var width2;
            var left;
            if (this.isOverlayClicked && this.isResizerClicked) {
                Iif (index_4.isTouchMove(e)) {
                    e.preventDefault();
                }
                switch (this.resizer) {
                    case 'e-ss-overlay-t':
                        height1 = Math.max(this.originalMouseY - index_4.getClientY(e) + this.originalHeight, 20);
                        top = index_4.getClientY(e) - (this.originalMouseY - this.originalResizeTop);
                        if (height1 > 20 && top > checkOffset[0]) {
                            overlayElem.style.height = height1 + 'px';
                            overlayElem.style.top = top + 'px';
                            this.resizedReorderTop = top;
                            this.currenHeight = height1;
                            this.parent.notify(index_5.refreshChartSize, {
                                height: overlayElem.style.height, width: overlayElem.style.width, overlayEle: overlayElem
                            });
                        }
                        break;
                    case 'e-ss-overlay-r':
                        width1 = this.originalWidth + (index_4.getPageX(e) - this.originalMouseX);
                        if (width1 > 20) {
                            overlayElem.style.width = width1 + 'px';
                            this.currentWidth = width1;
                            this.parent.notify(index_5.refreshChartSize, {
                                height: overlayElem.style.height, width: overlayElem.style.width, overlayEle: overlayElem
                            });
                        }
                        break;
                    case 'e-ss-overlay-b':
                        height2 = this.originalHeight + (index_4.getPageY(e) - this.originalMouseY);
                        Eif (height2 > 20) {
                            overlayElem.style.height = height2 + 'px';
                            this.currenHeight = height2;
                            this.parent.notify(index_5.refreshChartSize, {
                                height: overlayElem.style.height, width: overlayElem.style.width, overlayEle: overlayElem
                            });
                        }
                        break;
                    case 'e-ss-overlay-l':
                        width2 = Math.max(this.originalMouseX - index_4.getClientX(e) + this.originalWidth, 20);
                        left = index_4.getClientX(e) - (this.originalMouseX - this.originalResizeLeft);
                        if (width2 > 20 && left > checkOffset[1]) {
                            overlayElem.style.width = width2 + 'px';
                            overlayElem.style.left = left + 'px';
                            this.resizedReorderLeft = left;
                            this.currentWidth = width2;
                            this.parent.notify(index_5.refreshChartSize, {
                                height: overlayElem.style.height, width: overlayElem.style.width, overlayEle: overlayElem
                            });
                        }
                        break;
                }
            }
            else Eif (this.isOverlayClicked) {
                Iif (index_4.isTouchMove(e)) {
                    e.preventDefault();
                }
                Eif ((ej2_base_1.closest(target, '.e-sheet') && !target.classList.contains('e-sheet-content')) ||
                    target.classList.contains('e-cell')) {
                    Iif (!overlayElem) {
                        return;
                    }
                    var aX = index_4.getClientX(e) - this.diffX;
                    var aY = index_4.getClientY(e) - this.diffY;
                    Eif (aX > checkOffset[1]) {
                        overlayElem.style.left = aX + 'px';
                    }
                    Eif (aY > checkOffset[0]) {
                        overlayElem.style.top = aY + 'px';
                    }
                    this.resizedReorderLeft = aX < 0 ? 0 : aX;
                    this.resizedReorderTop = aY < 0 ? 0 : aY;
                }
                else {
                    this.overlayMouseUpHandler(e, true);
                }
            }
        };
        Overlay.prototype.overlayMouseUpHandler = function (e, isMouseUp) {
            if (!this.parent || this.parent.getActiveSheet().isProtected || !this.parent.allowEditing) {
                return;
            }
            this.isResizerClicked = false;
            var elem = e.target;
            var overlayElems = document.getElementsByClassName('e-datavisualization-chart e-ss-overlay-active');
            if (!elem.classList.contains('e-ss-overlay')) {
                elem = ej2_base_1.closest(e.target, '.e-datavisualization-chart') ?
                    ej2_base_1.closest(e.target, '.e-datavisualization-chart') : elem;
            }
            var sheet = this.parent.getActiveSheet();
            var eventArgs = {
                prevTop: sheet.frozenRows || sheet.frozenColumns ? this.prevY : this.originalReorderTop,
                prevLeft: sheet.frozenRows || sheet.frozenColumns ? this.prevX : this.originalReorderLeft,
                currentTop: this.resizedReorderTop >= 0 ? parseInt(this.resizedReorderTop.toString(), 10) : this.originalReorderTop,
                currentLeft: this.resizedReorderLeft >= 0 ? parseInt(this.resizedReorderLeft.toString(), 10) : this.originalReorderLeft,
                id: elem.id, currentHeight: this.currenHeight, currentWidth: this.currentWidth,
                requestType: 'imageRefresh', prevHeight: this.originalHeight, prevWidth: this.originalWidth
            };
            if (this.isOverlayClicked || isMouseUp) {
                var currRowIdx = void 0;
                var currColIdx = void 0;
                var prevRowIdx = { clientY: eventArgs.prevTop, isImage: true };
                var prevColIdx = { clientX: eventArgs.prevLeft, isImage: true };
                var overlayEle = this.parent.element.getElementsByClassName('e-ss-overlay-active')[0];
                Iif (sheet.frozenRows || sheet.frozenColumns) {
                    if (!overlayEle) {
                        return;
                    }
                    prevRowIdx.isImage = false;
                    prevColIdx.isImage = false;
                    prevRowIdx.target = overlayEle;
                    prevColIdx.target = overlayEle;
                    if (eventArgs.prevTop < this.parent.getColumnHeaderContent().getBoundingClientRect().bottom) {
                        prevRowIdx.target = this.parent.getColumnHeaderContent();
                    }
                    if (eventArgs.prevLeft < this.parent.getRowHeaderContent().getBoundingClientRect().right) {
                        prevColIdx.target = this.parent.getRowHeaderTable();
                    }
                    var clientRect = overlayEle.getBoundingClientRect();
                    currRowIdx = { clientY: clientRect.top };
                    currColIdx = { clientX: clientRect.left };
                    if (clientRect.top < this.parent.getColumnHeaderContent().getBoundingClientRect().bottom) {
                        currRowIdx.target = this.parent.getColumnHeaderContent();
                    }
                    if (clientRect.left < this.parent.getRowHeaderContent().getBoundingClientRect().right) {
                        currColIdx.target = this.parent.getRowHeaderTable();
                    }
                }
                else {
                    currRowIdx = { clientY: eventArgs.currentTop, isImage: true };
                    currColIdx = { clientX: eventArgs.currentLeft, isImage: true };
                }
                this.parent.notify(index_3.getRowIdxFromClientY, prevRowIdx);
                this.parent.notify(index_3.getRowIdxFromClientY, currRowIdx);
                this.parent.notify(index_3.getColIdxFromClientX, prevColIdx);
                this.parent.notify(index_3.getColIdxFromClientX, currColIdx);
                Iif (currRowIdx.size) {
                    eventArgs.currentTop = currRowIdx.size;
                }
                Iif (currColIdx.size) {
                    eventArgs.currentLeft = currColIdx.size;
                }
                eventArgs.prevRowIdx = prevRowIdx.clientY;
                eventArgs.prevColIdx = prevColIdx.clientX;
                eventArgs.currentRowIdx = currRowIdx.clientY;
                eventArgs.currentColIdx = currColIdx.clientX;
                Iif ((sheet.frozenColumns || sheet.frozenRows) && !ej2_base_1.closest(overlayEle, '.e-sheet-content')) {
                    var frozenCol = this.parent.frozenColCount(sheet);
                    var frozenRow = this.parent.frozenRowCount(sheet);
                    if (eventArgs.currentRowIdx >= frozenRow && eventArgs.currentColIdx >= frozenCol) {
                        var top_1 = parseInt(overlayEle.style.top, 10);
                        var left = parseInt(overlayEle.style.left, 10);
                        var mainPanel = this.parent.sheetModule.contentPanel;
                        top_1 += mainPanel.scrollTop;
                        top_1 -= this.parent.getColumnHeaderContent().parentElement.getBoundingClientRect().height;
                        var scrollPanel = this.parent.getScrollElement();
                        left += scrollPanel.scrollLeft;
                        left -= this.parent.sheetModule.getRowHeaderWidth(sheet);
                        overlayEle.style.top = top_1 + 'px';
                        overlayEle.style.left = left + 'px';
                        this.parent.getMainContent().appendChild(overlayEle);
                    }
                }
                if (overlayElems && overlayElems[0]) {
                    Eif (overlayElems[0].querySelector('.e-control')) {
                        eventArgs.id = overlayElems[0].id;
                    }
                }
                if (this.originalReorderTop !== this.resizedReorderTop || this.originalReorderLeft !== this.resizedReorderLeft) {
                    eventArgs.id = overlayEle.id;
                    if (overlayElems && overlayElems[0]) {
                        eventArgs.requestType = 'chartRefresh';
                        this.parent.notify(index_2.refreshChartCellObj, eventArgs);
                    }
                    else {
                        this.parent.notify(index_2.refreshImgCellObj, eventArgs);
                    }
                    this.resizedReorderTop = this.originalReorderTop;
                    this.resizedReorderLeft = this.originalReorderLeft;
                }
                else if (this.currenHeight !== this.originalHeight || this.originalWidth !== this.currentWidth) {
                    eventArgs.id = elem.id.indexOf('overlay') > 0 ? elem.id : elem.parentElement &&
                        elem.parentElement.classList.contains('e-ss-overlay') ? elem.parentElement.id : overlayEle.id;
                    if (overlayElems && overlayElems[0]) {
                        eventArgs.requestType = 'chartRefresh';
                        this.parent.notify(index_2.refreshChartCellObj, eventArgs);
                    }
                    else {
                        this.parent.notify(index_2.refreshImgCellObj, eventArgs);
                    }
                    this.originalHeight = this.currenHeight;
                    this.originalWidth = this.currentWidth;
                }
            }
            this.isOverlayClicked = false;
        };
        Overlay.prototype.isOverlaySelected = function (args) {
            args.isOverlayClicked = this.isOverlayClicked;
        };
        Overlay.prototype.refreshOverlayElem = function (args) {
            if (args) {
                var selector = '.e-ss-overlay-active' + ((args && args.selector) || '');
                var overlayElem = this.parent.element.querySelector(selector);
                Eif (overlayElem) {
                    ej2_base_1.removeClass([overlayElem], 'e-ss-overlay-active');
                    this.parent.notify(index_1.removeDesignChart, {});
                }
            }
            else {
                var selector = 'e-ss-overlay-active';
                var overlayElems = Array.from(this.parent.element.getElementsByClassName(selector));
                for (var i = 0; i < overlayElems.length; i++) {
                    var element = overlayElems[i];
                    Eif (element) {
                        ej2_base_1.removeClass([element], 'e-ss-overlay-active');
                        this.parent.notify(index_1.removeDesignChart, {});
                    }
                }
            }
            this.parent.notify(index_1.clearChartBorder, null);
        };
        Overlay.prototype.overlayClickHandler = function (e) {
            if (this.parent.getActiveSheet().isProtected || !this.parent.allowEditing) {
                return;
            }
            this.isOverlayClicked = true;
            var target = e.target;
            var overlayElem = e.target;
            if (!target.classList.contains('e-ss-overlay')) {
                overlayElem = target.parentElement;
                if (ej2_base_1.closest(e.target, '.e-datavisualization-chart')) {
                    overlayElem = ej2_base_1.closest(e.target, '.e-datavisualization-chart');
                }
            }
            var sheet = this.parent.getActiveSheet();
            Iif ((sheet.frozenColumns || sheet.frozenRows) && ej2_base_1.closest(overlayElem, '.e-sheet-content')) {
                var top_2 = parseInt(overlayElem.style.top, 10);
                var left = parseInt(overlayElem.style.left, 10);
                var mainPanel = this.parent.sheetModule.contentPanel;
                top_2 -= mainPanel.scrollTop;
                top_2 += this.parent.getColumnHeaderContent().parentElement.getBoundingClientRect().height;
                var scrollPanel = this.parent.getScrollElement();
                left -= scrollPanel.scrollLeft;
                left += this.parent.sheetModule.getRowHeaderWidth(sheet);
                overlayElem.style.top = top_2 + 'px';
                overlayElem.style.left = left + 'px';
                this.parent.element.querySelector('#' + this.parent.element.id + '_sheet').appendChild(overlayElem);
            }
            this.originalWidth = this.currentWidth = parseFloat(overlayElem.style.width);
            this.originalHeight = this.currenHeight = parseFloat(overlayElem.style.height);
            this.originalReorderLeft = parseFloat(overlayElem.style.left);
            this.originalReorderTop = parseFloat(overlayElem.style.top);
            this.resizedReorderLeft = parseFloat(overlayElem.style.left);
            this.resizedReorderTop = parseFloat(overlayElem.style.top);
            this.originalResizeTop = this.originalReorderTop;
            this.originalResizeLeft = this.originalReorderLeft;
            this.originalMouseX = index_4.getClientX(e);
            this.originalMouseY = index_4.getClientY(e);
            this.diffX = this.originalMouseX - this.originalReorderLeft;
            this.diffY = this.originalMouseY - this.originalReorderTop;
            var actOverlayElem = document.getElementsByClassName('e-ss-overlay-active')[0];
            if (actOverlayElem) {
                ej2_base_1.removeClass([actOverlayElem], 'e-ss-overlay-active');
            }
            this.parent.element.querySelector('#' + overlayElem.id).classList.add('e-ss-overlay-active');
            if (target.classList.contains('e-ss-resizer')) {
                this.resizer = target.classList[0];
                this.isResizerClicked = true;
            }
            if (overlayElem.classList.contains('e-datavisualization-chart')) {
                this.parent.notify(index_5.focusChartBorder, { id: overlayElem.id });
                if (!actOverlayElem) {
                    this.parent.notify(index_2.insertDesignChart, { id: overlayElem.id });
                }
            }
            var clientRect = overlayElem.getBoundingClientRect();
            this.prevX = clientRect.left;
            this.prevY = clientRect.top;
        };
        Overlay.prototype.renderResizeHandler = function (overlay) {
            var handles = ['e-ss-overlay-t', 'e-ss-overlay-r', 'e-ss-overlay-b', 'e-ss-overlay-l'];
            var idx = 0;
            var handleElem;
            while (idx < handles.length) {
                handleElem = this.parent.createElement('div', { className: handles[idx] + ' ' + 'e-ss-resizer' + (ej2_base_1.Browser.isDevice ? ' e-ss-resizer-touch' : ''),
                    styles: 'width: 8px; height: 8px; border-radius: 4px;' });
                overlay.appendChild(handleElem);
                idx++;
            }
        };
        Overlay.prototype.removeEventListener = function () {
            var overlays = this.parent.element.querySelectorAll('.e-ss-overlay');
            if (overlays.length) {
                for (var idx = 0; idx < overlays.length; idx++) {
                    ej2_base_1.EventHandler.remove(overlays[idx], index_3.getStartEvent(), this.overlayClickHandler);
                    ej2_base_1.EventHandler.remove(overlays[idx], index_3.getMoveEvent(), this.overlayMouseMoveHandler);
                }
            }
            var ele = this.parent.element.querySelector('#' + this.parent.element.id + '_sheet');
            Eif (ele) {
                ej2_base_1.EventHandler.remove(ele, index_3.getMoveEvent(), this.overlayMouseMoveHandler);
            }
            Eif (document) {
                ej2_base_1.EventHandler.remove(document, index_4.getEndEvent(), this.overlayMouseUpHandler);
            }
            Eif (!this.parent.isDestroyed) {
                this.parent.off(index_3.overlayEleSize, this.setOriginalSize);
                this.parent.off(index_3.selectionStatus, this.isOverlaySelected);
                this.parent.off(index_2.refreshOverlayElem, this.refreshOverlayElem);
                this.parent.off(index_4.spreadsheetDestroyed, this.destroy);
            }
        };
        Overlay.prototype.destroy = function () {
            this.removeEventListener();
            Eif (this.currentWidth) {
                this.currentWidth = null;
            }
            Eif (this.currenHeight) {
                this.currenHeight = null;
            }
            Eif (this.minHeight) {
                this.minHeight = null;
            }
            Eif (this.minWidth) {
                this.minWidth = null;
            }
            if (this.isOverlayClicked) {
                this.isOverlayClicked = null;
            }
            Iif (this.isResizerClicked) {
                this.isResizerClicked = null;
            }
            this.parent = null;
        };
        return Overlay;
    }());
    exports.Overlay = Overlay;
});