all files / schedule/actions/ resize.js

68.5% Statements 287/419
53.97% Branches 197/365
82.76% Functions 24/29
68.6% Lines 284/414
11 statements, 6 functions, 9 branches Ignored     
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          1329×   11550× 11550× 19934× 19934×     18×                   18× 18×   18× 18×     18× 18×       18× 18× 18× 18×     18× 18× 18× 18× 18× 18×               18× 18×     18× 18× 18×           18× 18× 18× 18× 18× 18×                       18× 18× 18× 18× 18× 18× 18× 18× 18× 18×   18× 18× 18× 16× 16×   18× 18×     37×     37× 37×   37× 18×   37×     37× 37×     35× 35×   37× 37× 37× 37×               37×     37×   37×   35× 35×           35× 20× 20× 20×     20× 20× 20× 20×     20×   35×                           35× 12× 12× 12×     12× 12× 12× 12×     12×                                                                                                                                     18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18×     18× 13×                 12× 12× 12×   12× 12× 12×     12× 12× 12× 12×       12×   12×   23× 23× 23× 23× 23× 23× 23× 23×             23× 23× 23× 23× 23×   23×   23× 23×                                     23× 23×   23×           23× 23×   23× 23×       23×   23×       15× 12×   15×   15× 15× 15× 15×                                       23×   23×         20×   20×     20×     12× 12× 12×   12×   12×     12× 12× 12×   12×     12×         12×   23× 23× 23×   23× 23× 23×       23× 23× 23× 23× 15× 15× 12× 12× 12×       15×   23×   23×                                 23×   23× 23× 23×         23×         23× 23×       23×                   23×   23×       23× 23× 23×   35× 35× 35× 35× 35× 35×       35× 20×     20×   35×     35× 12×   35×   29727×        
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "@syncfusion/ej2-base", "../actions/action-base", "../event-renderer/month", "../base/util", "../base/constant", "../base/css-constant"], function (require, exports, ej2_base_1, action_base_1, month_1, util, event, cls) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Resize = (function (_super) {
        __extends(Resize, _super);
        function Resize() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Resize.prototype.wireResizeEvent = function (element) {
            var resizeElement = [].slice.call(element.querySelectorAll('.' + cls.EVENT_RESIZE_CLASS));
            for (var _i = 0, resizeElement_1 = resizeElement; _i < resizeElement_1.length; _i++) {
                var element_1 = resizeElement_1[_i];
                ej2_base_1.EventHandler.add(element_1, ej2_base_1.Browser.touchStartEvent, this.resizeStart, this);
            }
        };
        Resize.prototype.resizeHelper = function () {
            Iif (this.parent.activeViewOptions.group.resources.length > 0 && this.parent.activeViewOptions.group.allowGroupEdit) {
                for (var i = 0, len = this.actionObj.originalElement.length; i < len; i++) {
                    var cloneElement = this.createCloneElement(this.actionObj.originalElement[parseInt(i.toString(), 10)]);
                    this.actionObj.cloneElement[parseInt(i.toString(), 10)] = cloneElement;
                    if (this.actionObj.element === this.actionObj.originalElement[parseInt(i.toString(), 10)]) {
                        this.actionObj.clone = cloneElement;
                    }
                }
            }
            else {
                Eif (this.actionObj.element) {
                    this.actionObj.clone = this.createCloneElement(this.actionObj.element);
                }
                this.actionObj.cloneElement = [this.actionObj.clone];
                this.actionObj.originalElement = [this.actionObj.element];
            }
        };
        Resize.prototype.resizeStart = function (e) {
            var _this = this;
            Iif ((e && e.type === 'touchstart' && (!this.parent.uiStateValues.isTapHold ||
                !ej2_base_1.closest(e.target, '.' + cls.APPOINTMENT_BORDER))) || ej2_base_1.closest(e.target, '.' + cls.INLINE_EDIT_CLASS)) {
                return;
            }
            var resizeTarget = ej2_base_1.closest(e.target, '.' + cls.EVENT_RESIZE_CLASS);
            this.actionObj.element = ej2_base_1.closest(resizeTarget, '.' + cls.APPOINTMENT_CLASS);
            this.actionObj.event = this.parent.eventBase.getEventByGuid(this.actionObj.element.getAttribute('data-guid'));
            Iif (ej2_base_1.isNullOrUndefined(this.actionObj.event)) {
                return;
            }
            this.parent.eventBase.removeSelectedAppointmentClass();
            this.actionObj.action = 'resize';
            this.actionObj.slotInterval = this.parent.activeViewOptions.timeScale.interval / this.parent.activeViewOptions.timeScale.slotCount;
            this.actionObj.interval = this.actionObj.slotInterval;
            var eventObj = ej2_base_1.extend({}, this.actionObj.event, null, true);
            var resizeArgs = {
                cancel: false,
                data: eventObj,
                element: this.actionObj.element,
                event: e,
                interval: this.actionObj.interval,
                scroll: { enable: true, scrollBy: 30, timeDelay: 100 }
            };
            this.parent.trigger(event.resizeStart, resizeArgs, function (resizeEventArgs) {
                Iif (resizeEventArgs.cancel) {
                    return;
                }
                _this.actionClass('addClass');
                _this.parent.uiStateValues.action = true;
                _this.resizeEdges = {
                    left: resizeTarget.classList.contains(cls.LEFT_RESIZE_HANDLER),
                    right: resizeTarget.classList.contains(cls.RIGHT_RESIZE_HANDLER),
                    top: resizeTarget.classList.contains(cls.TOP_RESIZE_HANDLER),
                    bottom: resizeTarget.classList.contains(cls.BOTTOM_RESIZE_HANDLER)
                };
                _this.actionObj.groupIndex = _this.parent.uiStateValues.isGroupAdaptive ? _this.parent.uiStateValues.groupIndex : 0;
                var workCell = _this.parent.element.querySelector('.' + cls.WORK_CELLS_CLASS);
                _this.actionObj.cellWidth = _this.parent.getElementWidth(workCell);
                _this.actionObj.cellHeight = _this.parent.getElementHeight(workCell);
                var hRows = _this.parent.activeViewOptions.headerRows.map(function (row) { return row.option; });
                Iif (_this.parent.activeView.isTimelineView() && hRows.length > 0 && ['Date', 'Hour'].indexOf(hRows.slice(-1)[0]) < 0) {
                    var tr = _this.parent.getContentTable().querySelector('tr');
                    var noOfDays = 0;
                    var tdCollections = [].slice.call(tr.children);
                    for (var _i = 0, tdCollections_1 = tdCollections; _i < tdCollections_1.length; _i++) {
                        var td = tdCollections_1[_i];
                        noOfDays += parseInt(td.getAttribute('colspan'), 10);
                    }
                    var trRect = tr.getBoundingClientRect();
                    _this.actionObj.cellWidth = trRect.width / noOfDays;
                    _this.actionObj.cellHeight = trRect.height;
                }
                var pages = _this.parent.eventBase.getPageCoordinates(e);
                _this.actionObj.X = pages.pageX;
                _this.actionObj.Y = pages.pageY;
                _this.actionObj.groupIndex = parseInt(_this.actionObj.element.getAttribute('data-group-index') || '0', 10);
                _this.actionObj.interval = resizeEventArgs.interval;
                _this.actionObj.scroll = resizeEventArgs.scroll;
                _this.actionObj.start = new Date(eventObj[_this.parent.eventFields.startTime].getTime());
                _this.actionObj.end = new Date(eventObj[_this.parent.eventFields.endTime].getTime());
                _this.actionObj.originalElement = _this.getOriginalElement(_this.actionObj.element);
                if (_this.parent.currentView === 'Month') {
                    _this.daysVariation = -1;
                    _this.monthEvent = new month_1.MonthEvent(_this.parent);
                }
                var viewElement = _this.parent.element.querySelector('.' + cls.CONTENT_WRAP_CLASS);
                _this.scrollArgs = { element: viewElement, width: viewElement.scrollWidth, height: viewElement.scrollHeight };
                if (['Month', 'TimelineYear'].indexOf(_this.parent.currentView) < 0) {
                    var scrollWidth = Math.round(_this.scrollArgs.width / _this.actionObj.cellWidth) * _this.actionObj.cellWidth;
                    _this.scrollArgs.width = _this.scrollArgs.width < scrollWidth ? scrollWidth : _this.scrollArgs.width;
                }
                ej2_base_1.EventHandler.add(document, ej2_base_1.Browser.touchMoveEvent, _this.resizing, _this);
                ej2_base_1.EventHandler.add(document, ej2_base_1.Browser.touchEndEvent, _this.resizeStop, _this);
            });
        };
        Resize.prototype.resizing = function (e) {
            Iif (e && e.type === 'touchmove') {
                e.preventDefault();
            }
            Eif (this.parent.quickPopup) {
                this.parent.quickPopup.quickPopupHide();
            }
            if (this.parent.element.querySelectorAll('.' + cls.RESIZE_CLONE_CLASS).length === 0) {
                this.resizeHelper();
            }
            Iif ((!ej2_base_1.isNullOrUndefined(e.target)) && e.target.classList.contains(cls.DISABLE_DATES)) {
                return;
            }
            var pages = this.parent.eventBase.getPageCoordinates(e);
            if (this.parent.currentView === 'Month' || this.parent.currentView === 'TimelineYear') {
                var doc = document.documentElement;
                var left = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
                var top_1 = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
                this.actionObj.pageX = pages.pageX - left;
                this.actionObj.pageY = pages.pageY - top_1;
            }
            else {
                this.actionObj.pageX = pages.pageX;
                this.actionObj.pageY = pages.pageY;
            }
            this.updateScrollPosition(e);
            this.updateResizingDirection(e);
            var eventObj = ej2_base_1.extend({}, this.actionObj.event, null, true);
            var resizeArgs = {
                cancel: false,
                data: eventObj,
                element: this.actionObj.element,
                event: e,
                startTime: this.actionObj.start,
                endTime: this.actionObj.end
            };
            Iif (this.parent.group.resources.length > 0) {
                resizeArgs.groupIndex = this.actionObj.groupIndex;
            }
            this.parent.trigger(event.resizing, resizeArgs);
        };
        Resize.prototype.updateResizingDirection = function (e) {
            if (this.parent.currentView === 'Month' || this.parent.currentView === 'TimelineYear') {
                this.monthResizing();
                return;
            }
            var resizeValidation = this.resizeValidation(e);
            if (this.resizeEdges.left) {
                Eif (resizeValidation) {
                    var leftStyles = this.getLeftRightStyles(e, true);
                    Iif (parseInt(leftStyles.width, 10) < 1) {
                        return;
                    }
                    for (var _i = 0, _a = this.actionObj.cloneElement; _i < _a.length; _i++) {
                        var cloneElement = _a[_i];
                        ej2_base_1.setStyleAttribute(cloneElement, leftStyles);
                        ej2_base_1.addClass([cloneElement], cls.LEFT_RESIZE_HANDLER);
                    }
                }
                this.horizontalResizing(!this.parent.enableRtl);
            }
            if (this.resizeEdges.right) {
                Eif (resizeValidation) {
                    var rightStyles = this.getLeftRightStyles(e, false);
                    Iif (parseInt(rightStyles.width, 10) < 1) {
                        return;
                    }
                    for (var _b = 0, _c = this.actionObj.cloneElement; _b < _c.length; _b++) {
                        var cloneElement = _c[_b];
                        ej2_base_1.setStyleAttribute(cloneElement, rightStyles);
                        ej2_base_1.addClass([cloneElement], cls.RIGHT_RESIZE_HANDLER);
                    }
                }
                this.horizontalResizing(this.parent.enableRtl);
            }
            Iif (this.resizeEdges.top) {
                if (resizeValidation) {
                    var topStyles = this.getTopBottomStyles(e, true);
                    if (parseInt(topStyles.height, 10) < 1) {
                        return;
                    }
                    for (var _d = 0, _e = this.actionObj.cloneElement; _d < _e.length; _d++) {
                        var cloneElement = _e[_d];
                        ej2_base_1.setStyleAttribute(cloneElement, topStyles);
                        ej2_base_1.addClass([cloneElement], cls.TOP_RESIZE_HANDLER);
                    }
                }
                this.verticalResizing(true);
            }
            if (this.resizeEdges.bottom) {
                Eif (resizeValidation) {
                    var bottomStyles = this.getTopBottomStyles(e, false);
                    Iif (parseInt(bottomStyles.height, 10) < 1) {
                        return;
                    }
                    for (var _f = 0, _g = this.actionObj.cloneElement; _f < _g.length; _f++) {
                        var cloneElement = _g[_f];
                        ej2_base_1.setStyleAttribute(cloneElement, bottomStyles);
                        ej2_base_1.addClass([cloneElement], cls.BOTTOM_RESIZE_HANDLER);
                    }
                }
                this.verticalResizing(false);
            }
        };
        Resize.prototype.monthResizing = function () {
            this.removeCloneElement();
            Iif (ej2_base_1.isNullOrUndefined(this.actionObj.pageX) || ej2_base_1.isNullOrUndefined(this.actionObj.pageY)) {
                return;
            }
            var td = document.elementFromPoint(this.actionObj.pageX, this.actionObj.pageY);
            Iif (ej2_base_1.isNullOrUndefined(td)) {
                return;
            }
            var resizeTime = this.parent.getDateFromElement(td);
            var isSameCell = this.parent.activeViewOptions.group.resources.length > 0 ?
                parseInt(td.getAttribute('data-group-index'), 10) === this.actionObj.groupIndex : true;
            var startTime = new Date(this.actionObj.event[this.parent.eventFields.startTime].getTime());
            var endTime = new Date(this.actionObj.event[this.parent.eventFields.endTime].getTime());
            Iif ((!this.parent.enableRtl && this.resizeEdges.left) || (this.parent.enableRtl && this.resizeEdges.right)
                || this.resizeEdges.top) {
                startTime = resizeTime;
            }
            else Eif ((!this.parent.enableRtl && this.resizeEdges.right) || (this.parent.enableRtl && this.resizeEdges.left)
                || this.resizeEdges.bottom) {
                endTime = util.addDays(resizeTime, 1);
            }
            Eif (isSameCell && startTime < endTime) {
                this.actionObj.start = startTime;
                this.actionObj.end = endTime;
                var event_1 = this.getUpdatedEvent(this.actionObj.start, this.actionObj.end, this.actionObj.event);
                Iif (this.parent.currentView === 'TimelineYear') {
                    this.yearEventsRendering(event_1);
                }
                else {
                    this.dynamicEventsRendering(event_1);
                }
                this.updateOriginalElement(this.actionObj.clone);
            }
        };
        Resize.prototype.yearEventsRendering = function (event) {
            var eventWrappers = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CLONE_ELEMENT_CLASS));
            for (var _i = 0, eventWrappers_1 = eventWrappers; _i < eventWrappers_1.length; _i++) {
                var wrapper = eventWrappers_1[_i];
                ej2_base_1.remove(wrapper);
            }
            var endDate = new Date(event[this.parent.eventFields.endTime]);
            var monthDiff = 0;
            if (this.parent.activeViewOptions.group.resources.length === 0) {
                monthDiff = this.getMonthDiff(event[this.parent.eventFields.startTime], util.addDays(endDate, -1));
            }
            for (var i = 0; i <= monthDiff; i++) {
                var eventObj = void 0;
                if (this.parent.activeViewOptions.group.resources.length === 0) {
                    eventObj = this.getEventCount(event, this.actionObj.start.getMonth() + i);
                }
                else {
                    eventObj = ej2_base_1.extend({}, event, null, true);
                    endDate = this.resizeEdges.left || this.resizeEdges.right ? util.addDays(endDate, -1) : endDate;
                    eventObj.count = this.getMonthDiff(event[this.parent.eventFields.startTime], endDate) + 1;
                }
                this.dynamicYearlyEventsRendering(eventObj, true);
            }
        };
        Resize.prototype.getMonthDiff = function (startDate, endDate) {
            var months;
            months = (endDate.getFullYear() - startDate.getFullYear()) * 12;
            months -= startDate.getMonth();
            months += endDate.getMonth();
            return months <= 0 ? 0 : months;
        };
        Resize.prototype.getEventCount = function (eventObj, month) {
            var eventData = ej2_base_1.extend({}, eventObj, null, true);
            var eventStart = eventData[this.parent.eventFields.startTime];
            var eventEnd = eventData[this.parent.eventFields.endTime];
            var monthStart = new Date(this.parent.selectedDate.getFullYear(), month, 1);
            var monthEnd = util.addDays(new Date(this.parent.selectedDate.getFullYear(), month + 1, 0), 1);
            var count = 1;
            if (eventStart.getTime() < monthStart.getTime()) {
                eventData[this.parent.eventFields.startTime] = monthStart;
            }
            if (eventEnd.getTime() > monthEnd.getTime()) {
                eventData[this.parent.eventFields.endTime] = monthEnd;
            }
            if (this.parent.activeViewOptions.group.resources.length === 0) {
                count = Math.ceil((eventData[this.parent.eventFields.endTime].getTime() -
                    eventData[this.parent.eventFields.startTime].getTime()) / util.MS_PER_DAY);
            }
            eventData.count = count;
            return eventData;
        };
        Resize.prototype.resizeStop = function (e) {
            var _this = this;
            ej2_base_1.EventHandler.remove(document, ej2_base_1.Browser.touchMoveEvent, this.resizing);
            ej2_base_1.EventHandler.remove(document, ej2_base_1.Browser.touchEndEvent, this.resizeStop);
            clearInterval(this.actionObj.scrollInterval);
            this.actionObj.scrollInterval = null;
            this.actionObj.action = null;
            this.removeCloneElementClasses();
            this.removeCloneElement();
            this.actionClass('removeClass');
            this.parent.uiStateValues.action = this.parent.uiStateValues.isTapHold = false;
            var resizeArgs = { cancel: false, data: this.getChangedData(), element: this.actionObj.element, event: e };
            this.parent.trigger(event.resizeStop, resizeArgs, function (resizeEventArgs) {
                Iif (resizeEventArgs.cancel) {
                    return;
                }
                if (_this.parent.eventBase.checkOverlap(resizeEventArgs.data)) {
                    return;
                }
                Iif (_this.parent.isSpecificResourceEvents()) {
                    _this.parent.crudModule.crudObj.sourceEvent =
                        [_this.parent.resourceBase.lastResourceLevel[parseInt(resizeEventArgs.element.getAttribute('data-group-index'), 10)]];
                    _this.parent.crudModule.crudObj.targetEvent = _this.parent.crudModule.crudObj.sourceEvent;
                    _this.parent.crudModule.crudObj.isCrudAction = true;
                }
                _this.saveChangedData(resizeEventArgs);
            });
        };
        Resize.prototype.verticalResizing = function (isTop) {
            var offsetValue = this.actionObj.clone.offsetTop;
            Eif (!isTop) {
                offsetValue += this.actionObj.clone.offsetHeight;
            }
            var minutes = (offsetValue / Math.round(this.actionObj.cellHeight)) * this.actionObj.slotInterval;
            var element = this.actionObj.clone.offsetParent;
            Iif (ej2_base_1.isNullOrUndefined(element)) {
                return;
            }
            var resizeTime = util.resetTime(this.parent.getDateFromElement(element));
            resizeTime.setHours(this.parent.activeView.getStartHour().getHours());
            resizeTime.setMinutes(minutes + this.parent.activeView.getStartHour().getMinutes());
            Iif (isTop) {
                this.actionObj.start = this.calculateIntervalTime(resizeTime);
            }
            else {
                this.actionObj.end = this.calculateIntervalTime(resizeTime);
            }
            this.updateTimePosition(resizeTime);
        };
        Resize.prototype.horizontalResizing = function (isLeft) {
            var eventStart = new Date(this.actionObj.event[this.parent.eventFields.startTime].getTime());
            var eventEnd = new Date(this.actionObj.event[this.parent.eventFields.endTime].getTime());
            var resizeTime;
            var headerName = this.parent.currentView;
            var isTimelineMonth = this.parent.currentView === 'TimelineMonth';
            Eif (this.parent.activeView.isTimelineView()) {
                var tr = this.parent.getContentTable().querySelector('tr');
                Iif (this.parent.activeViewOptions.headerRows.length > 0) {
                    var rows = this.parent.activeViewOptions.headerRows.map(function (row) { return row.option; });
                    headerName = rows.slice(-1)[0];
                    if (isTimelineMonth && headerName === 'Hour') {
                        headerName = rows.slice(-2)[0] || 'Month';
                    }
                }
                resizeTime = isLeft ? eventStart : eventEnd;
                var cellIndex = 0;
                var tdCollections = [].slice.call(tr.children);
                var isLastCell = false;
                var pixelsPerMinute = this.actionObj.cellWidth / (this.parent.activeViewOptions.timeScale.interval /
                    this.parent.activeViewOptions.timeScale.slotCount);
                var offset = parseFloat(this.parent.enableRtl ? this.actionObj.clone.style.right :
                    this.actionObj.clone.style.left);
                offset = Math.round(offset / pixelsPerMinute) * pixelsPerMinute;
                Iif (['Year', 'Month', 'Week', 'Date'].indexOf(headerName) !== -1) {
                    var noOfDays = 0;
                    for (var _i = 0, tdCollections_2 = tdCollections; _i < tdCollections_2.length; _i++) {
                        var td = tdCollections_2[_i];
                        noOfDays += parseInt(td.getAttribute('colspan'), 10);
                    }
                    var offsetValue = this.parent.enableRtl ? parseInt(this.actionObj.clone.style.right, 10) :
                        parseInt(this.actionObj.clone.style.left, 10);
                    offsetValue = Math.round(offsetValue / this.actionObj.cellWidth) * this.actionObj.cellWidth;
                    if (!isLeft) {
                        offsetValue += (this.parent.getElementWidth(this.actionObj.clone) - this.actionObj.cellWidth);
                    }
                    cellIndex = !isTimelineMonth ? Math.round(offsetValue / (this.parent.getElementWidth(tr) / noOfDays)) :
                        Math.floor(offsetValue / Math.floor(this.parent.getElementWidth(tr) / noOfDays));
                    cellIndex = isLeft ? cellIndex : isTimelineMonth ? cellIndex + 1 : cellIndex;
                    isLastCell = cellIndex === tdCollections.length;
                    cellIndex = (cellIndex < 0) ? 0 : (cellIndex >= noOfDays) ? noOfDays - 1 : cellIndex;
                }
                else {
                    var cellWidth = this.actionObj.cellWidth;
                    cellIndex = isLeft ? Math.round(offset / this.actionObj.cellWidth) :
                        Math.ceil((offset + (this.parent.getElementWidth(this.actionObj.clone) - cellWidth)) / this.actionObj.cellWidth);
                    Iif (this.parent.enableRtl) {
                        var offsetWidth = (Math.round(offset / this.actionObj.cellWidth) *
                            this.actionObj.cellWidth) + (isLeft ? 0 : (this.parent.getElementWidth(this.actionObj.clone) -
                            this.actionObj.cellWidth));
                        cellIndex = Math.floor(offsetWidth / this.actionObj.cellWidth);
                    }
                    isLastCell = cellIndex === tdCollections.length;
                    cellIndex = this.getIndex(cellIndex);
                }
                var resizeDate = void 0;
                Iif (['Year', 'Month', 'Week', 'Date'].indexOf(headerName) !== -1) {
                    resizeDate = new Date(this.parent.activeView.renderDates[parseInt(cellIndex.toString(), 10)].getTime());
                }
                else {
                    resizeDate = this.parent.getDateFromElement(tr.children[parseInt(cellIndex.toString(), 10)]);
                }
                if (['TimelineMonth', 'Year', 'Month', 'Week', 'Date'].indexOf(headerName) !== -1 ||
                    !this.parent.activeViewOptions.timeScale.enable) {
                    resizeTime = new Date(resizeDate.setHours(resizeTime.getHours(), resizeTime.getMinutes(), resizeTime.getSeconds()));
                }
                else {
                    if (!isLeft) {
                        offset += this.parent.getElementWidth(this.actionObj.clone);
                    }
                    var spanMinutes = Math.floor((this.actionObj.slotInterval / this.actionObj.cellWidth) *
                        (offset - Math.floor(offset / this.actionObj.cellWidth) * this.actionObj.cellWidth));
                    spanMinutes = (isLastCell || (!isLeft && spanMinutes === 0)) ? this.actionObj.slotInterval : spanMinutes;
                    resizeTime = new Date(resizeDate.getTime());
                    resizeTime = new Date(resizeDate.getTime() + (spanMinutes * util.MS_PER_MINUTE));
                    this.updateTimePosition(resizeTime);
                }
            }
            else {
                var cloneIndex = ej2_base_1.closest(this.actionObj.clone, 'td').cellIndex;
                var originalWidth = Math.ceil((isLeft ? this.parent.getElementWidth(this.actionObj.element) : 0) /
                    this.actionObj.cellWidth) * this.actionObj.cellWidth;
                var noOfDays = Math.ceil((this.parent.getElementWidth(this.actionObj.clone) - originalWidth) /
                    this.actionObj.cellWidth);
                var tr = ej2_base_1.closest(this.actionObj.clone, 'tr');
                var dayIndex = isLeft ? cloneIndex - noOfDays : cloneIndex + noOfDays - 1;
                dayIndex = this.getIndex(dayIndex);
                resizeTime = this.parent.getDateFromElement(tr.children[parseInt(dayIndex.toString(), 10)]);
                if (isLeft) {
                    resizeTime.setHours(eventStart.getHours(), eventStart.getMinutes(), eventStart.getSeconds());
                }
                else {
                    resizeTime.setHours(eventEnd.getHours(), eventEnd.getMinutes(), eventEnd.getSeconds());
                }
            }
            var isNotHourSlot = ['TimelineMonth', 'Year', 'Month', 'Week', 'WorkWeek', 'Date', 'Day'].indexOf(headerName) !== -1 ||
                !this.parent.activeViewOptions.timeScale.enable;
            if (isLeft) {
                Iif ((eventEnd.getTime() - resizeTime.getTime()) <= 0) {
                    resizeTime = isNotHourSlot ? util.resetTime(eventEnd) : eventStart;
                }
                this.actionObj.start = !isNotHourSlot ? this.calculateIntervalTime(resizeTime) : resizeTime;
            }
            else {
                var resizeEnd = (isNotHourSlot && resizeTime.getHours() === 0 && resizeTime.getMinutes() === 0) ?
                    util.addDays(resizeTime, 1) : resizeTime;
                Iif (isNotHourSlot && (resizeEnd.getTime() - eventStart.getTime()) <= 0) {
                    resizeEnd = util.addDays(util.resetTime(eventStart), 1);
                }
                this.actionObj.end = !isNotHourSlot ? this.calculateIntervalTime(resizeEnd) : resizeEnd;
            }
        };
        Resize.prototype.getTopBottomStyles = function (e, isTop) {
            var viewElement = this.parent.element.querySelector('.' + cls.CONTENT_WRAP_CLASS);
            var slotInterval = (this.actionObj.cellHeight / this.actionObj.slotInterval) * this.actionObj.interval;
            var clnHeight = isTop ? this.actionObj.element.offsetHeight + (this.actionObj.Y - this.actionObj.pageY) :
                this.actionObj.element.offsetHeight + (this.actionObj.pageY - this.actionObj.Y);
            var clnTop = isTop ? this.actionObj.element.offsetTop -
                (this.actionObj.Y - this.actionObj.pageY) : this.actionObj.clone.offsetTop;
            clnHeight = (clnTop < 0) ? this.actionObj.clone.offsetHeight :
                (this.actionObj.clone.offsetTop + this.actionObj.clone.offsetHeight) > this.scrollArgs.height ?
                    this.actionObj.clone.offsetHeight : clnHeight;
            clnTop = (clnTop < 0) ? 0 : clnTop;
            clnTop = isTop ? Math.floor(clnTop / slotInterval) * slotInterval : clnTop;
            clnHeight = clnTop + clnHeight >= viewElement.scrollHeight ? viewElement.scrollHeight - clnTop :
                Math.ceil(clnHeight / slotInterval) * slotInterval;
            Iif (!isTop && this.actionObj.clone.offsetTop + clnHeight >= this.parent.getContentTable().offsetHeight) {
                clnHeight = this.parent.getContentTable().offsetHeight - this.actionObj.clone.offsetTop;
            }
            var styles = {
                height: ej2_base_1.formatUnit(clnHeight < this.actionObj.cellHeight ? Math.floor(clnHeight / slotInterval) * slotInterval : clnHeight),
                top: ej2_base_1.formatUnit((clnHeight < this.actionObj.cellHeight && isTop) ? Math.ceil(clnTop / slotInterval) * slotInterval : clnTop),
                left: '0px', right: '0px', width: '100%'
            };
            return styles;
        };
        Resize.prototype.getLeftRightStyles = function (e, isLeft) {
            var styles = {};
            var isTimelineView = this.parent.activeView.isTimelineView();
            var isTimeViews = ['TimelineDay', 'TimelineWeek', 'TimelineWorkWeek'].indexOf(this.parent.currentView) > -1 &&
                this.parent.activeViewOptions.timeScale.enable;
            var slotInterval = (this.actionObj.cellWidth / this.actionObj.slotInterval) * this.actionObj.interval;
            var pageWidth = isLeft ? (this.actionObj.X - this.actionObj.pageX) : (this.actionObj.pageX - this.actionObj.X);
            var targetWidth = isTimelineView ?
                Math.round(this.parent.getElementWidth(this.actionObj.element) / this.actionObj.cellWidth) * this.actionObj.cellWidth :
                this.parent.currentView === 'Month' ? this.parent.getElementWidth(this.actionObj.element) :
                    Math.ceil(this.parent.getElementWidth(this.actionObj.element) / this.actionObj.cellWidth) * this.actionObj.cellWidth;
            var offsetWidth = targetWidth + (Math.ceil(pageWidth / this.actionObj.cellWidth) * this.actionObj.cellWidth);
            var left = (this.parent.enableRtl) ? parseInt(this.actionObj.element.style.right, 10) : this.actionObj.clone.offsetLeft;
            left = Math.round(left / slotInterval) * slotInterval;
            if (isTimeViews) {
                offsetWidth = targetWidth + (Math.ceil(pageWidth / slotInterval) * slotInterval);
                if (!isLeft) {
                    var roundedLeft = (+parseFloat(this.actionObj.element.style[this.parent.enableRtl ? 'right' : 'left'])).toFixed(1);
                    var roundedWidth = Math.round(targetWidth / slotInterval) * slotInterval;
                    Iif (roundedLeft !== left.toFixed(1) || roundedWidth !== targetWidth) {
                        offsetWidth = (Math.round((left + offsetWidth) / slotInterval) * slotInterval) - left;
                    }
                }
                this.actionObj.event[this.parent.eventFields.isAllDay] = false;
            }
            var width = !isLeft && (Math.floor(offsetWidth + this.actionObj.clone.offsetLeft) > this.scrollArgs.width) ?
                this.parent.getElementWidth(this.actionObj.clone) : (offsetWidth < this.actionObj.cellWidth) ? offsetWidth : offsetWidth;
            Iif (this.parent.enableRtl) {
                var rightValue = isTimelineView ? parseInt(this.actionObj.element.style.right, 10) :
                    -(offsetWidth - this.actionObj.cellWidth);
                rightValue = isTimelineView ? rightValue : isLeft ? 0 : rightValue > 0 ? 0 : rightValue;
                if (isTimelineView && !isLeft) {
                    rightValue = Math.round(rightValue / slotInterval) * slotInterval;
                    rightValue = rightValue - (Math.ceil((this.actionObj.pageX - this.actionObj.X) / slotInterval) * slotInterval);
                    if (rightValue < 0) {
                        rightValue = parseInt(this.actionObj.clone.style.right, 10);
                        width = parseInt(this.actionObj.clone.style.width, 10);
                    }
                }
                rightValue = rightValue >= this.scrollArgs.width ? this.scrollArgs.width - this.actionObj.cellWidth : rightValue;
                styles.right = ej2_base_1.formatUnit(rightValue);
                width = width + rightValue > this.scrollArgs.width ? this.parent.getElementWidth(this.actionObj.clone) : width;
            }
            else {
                var offsetLeft = isLeft ? this.actionObj.element.offsetLeft - (this.actionObj.X - this.actionObj.pageX) :
                    this.parent.enableRtl ? this.actionObj.element.offsetLeft : 0;
                Eif (isTimelineView) {
                    offsetLeft = isLeft ? offsetLeft : parseInt(this.actionObj.clone.style.left, 10);
                    Iif (this.parent.enableRtl) {
                        offsetLeft = !isLeft ? (this.actionObj.pageX < this.actionObj.X - this.parent.getElementWidth(this.actionObj.clone))
                            ? parseInt(this.actionObj.clone.style.right, 10) : offsetLeft : offsetLeft;
                    }
                    else {
                        offsetLeft = isLeft ? (this.actionObj.pageX > this.actionObj.X + this.parent.getElementWidth(this.actionObj.clone) &&
                            this.parent.getElementWidth(this.actionObj.clone) === this.actionObj.cellWidth) ?
                            parseInt(this.actionObj.clone.style.left, 10) : offsetLeft : offsetLeft;
                    }
                }
                var leftValue = offsetLeft;
                offsetLeft = isTimelineView ? isTimeViews ? isLeft ? this.actionObj.element.offsetLeft -
                    (Math.ceil((this.actionObj.element.offsetLeft - offsetLeft) / slotInterval) * slotInterval) : offsetLeft :
                    Math.floor(offsetLeft / this.actionObj.cellWidth) * this.actionObj.cellWidth :
                    Math.ceil(Math.abs(offsetLeft) / this.actionObj.cellWidth) * this.actionObj.cellWidth;
                Iif (offsetLeft < 0) {
                    if (isTimelineView && isLeft && (offsetLeft % slotInterval)) {
                        offsetLeft = parseInt(this.actionObj.clone.style.left, 10);
                        width = parseInt(this.actionObj.clone.style.width, 10);
                    }
                    else {
                        offsetLeft = 0;
                        width = this.parent.getElementWidth(this.actionObj.clone);
                    }
                }
                var cloneWidth = Math.ceil(this.parent.getElementWidth(this.actionObj.clone) / this.actionObj.cellWidth) *
                    this.actionObj.cellWidth;
                if (isLeft) {
                    styles.left = ej2_base_1.formatUnit(isTimelineView ? offsetLeft : isLeft ? leftValue < 0 ? -offsetLeft :
                        (Math.ceil((targetWidth - cloneWidth) / this.actionObj.cellWidth) * this.actionObj.cellWidth) : offsetLeft);
                }
            }
            width = Math.floor(width);
            styles.width = ej2_base_1.formatUnit(width);
            return styles;
        };
        Resize.prototype.resizeValidation = function (e) {
            var pages = this.parent.eventBase.getPageCoordinates(e);
            var viewDimension = this.getContentAreaDimension();
            var isTimeScale = this.parent.activeView.isTimelineView() && this.parent.activeViewOptions.timeScale.enable;
            var cellWidth = this.actionObj.cellWidth;
            var resizeValidation = false;
            if (this.resizeEdges.left) {
                Iif (pages.pageX < viewDimension.leftOffset && pages.pageX >= viewDimension.left && isTimeScale) {
                    cellWidth = 0;
                }
                resizeValidation = (pages.pageX - cellWidth) >= viewDimension.left;
            }
            if (this.resizeEdges.right) {
                Iif (pages.pageX > viewDimension.rightOffset && pages.pageX <= viewDimension.right && isTimeScale) {
                    cellWidth = 0;
                }
                resizeValidation = (pages.pageX + cellWidth) <= viewDimension.right;
            }
            Iif (this.resizeEdges.top) {
                resizeValidation = this.actionObj.clone.offsetTop >= viewDimension.top;
            }
            if (this.resizeEdges.bottom) {
                resizeValidation = (this.actionObj.clone.offsetTop + this.actionObj.clone.offsetHeight) <= this.scrollArgs.height;
            }
            return resizeValidation;
        };
        Resize.prototype.getModuleName = function () {
            return 'resize';
        };
        return Resize;
    }(action_base_1.ActionBase));
    exports.Resize = Resize;
});