all files / schedule/actions/ action-base.js

47.04% Statements 151/321
29.73% Branches 77/259
59.38% Functions 19/32
46.84% Lines 148/316
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   2475× 2475× 2475×         2475× 2475× 2475×   13× 13× 13× 13× 13×     13×                   13×   11× 11× 11× 11× 11× 11×     11× 11× 11×   11×         11×                       11×   11×     11×     17× 17× 17×   11× 11× 11×       11× 11× 11×               11×   17× 17× 17×           17×     17×     17×   20× 20× 20× 20× 20× 20× 20× 20×       20×     20×   20×   20×                                                                               15× 15× 15× 15× 15×   15× 15× 15× 15×   15× 15× 15×     15× 15×   15× 15×     15×   15× 15× 15×       15× 15× 15× 15×     15× 15× 15×                                                                                   26× 13×     13×     24× 24× 24× 13×                                                   13× 13× 13× 13×                                                                                                                                                                                                                                           1945× 1894×   51× 51× 51× 51×        
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../base/css-constant", "../base/util"], function (require, exports, ej2_base_1, ej2_base_2, cls, util) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ActionBase = (function () {
        function ActionBase(parent) {
            this.daysVariation = 0;
            this.parent = parent;
            this.actionObj = {
                X: 0, Y: 0, groupIndex: 0, cellWidth: 0, cellHeight: 0, slotInterval: 0, interval: 0, actionIndex: 0,
                cloneElement: [], originalElement: [], action: null, isAllDay: null, excludeSelectors: null,
                index: 0, navigationInterval: null, scrollInterval: null
            };
            this.scrollArgs = { element: null, width: 0, height: 0 };
            this.resizeEdges = { left: false, right: false, top: false, bottom: false };
            this.scrollEdges = { left: false, right: false, top: false, bottom: false };
        }
        ActionBase.prototype.getChangedData = function (multiData) {
            var _this = this;
            var eventObj = ej2_base_1.extend({}, this.actionObj.event, null, true);
            eventObj[this.parent.eventFields.startTime] = this.actionObj.start;
            eventObj[this.parent.eventFields.endTime] = this.actionObj.end;
            Iif (!ej2_base_1.isNullOrUndefined(this.actionObj.isAllDay)) {
                eventObj[this.parent.eventFields.isAllDay] = this.actionObj.isAllDay;
            }
            if (this.parent.activeViewOptions.group.resources.length > 0) {
                var originalElement = this.getOriginalElement(this.actionObj.element);
                Eif (originalElement) {
                    var indexCol_1 = originalElement.map(function (element) { return parseInt(element.getAttribute('data-group-index'), 10); });
                    Eif (indexCol_1.indexOf(this.actionObj.groupIndex) === -1 || (!ej2_base_1.isNullOrUndefined(multiData) && multiData.length > 0)) {
                        var cloneIndex_1 = parseInt(this.actionObj.clone.getAttribute('data-group-index'), 10);
                        indexCol_1 = indexCol_1.filter(function (index) { return index !== cloneIndex_1; });
                        indexCol_1.push(this.actionObj.groupIndex);
                        Iif (multiData && multiData.length > 0) {
                            multiData.forEach(function (data) {
                                _this.parent.resourceBase.getResourceData(data, _this.actionObj.groupIndex, indexCol_1);
                            });
                        }
                        else {
                            this.parent.resourceBase.getResourceData(eventObj, this.actionObj.groupIndex, indexCol_1);
                        }
                    }
                }
            }
            return eventObj;
        };
        ActionBase.prototype.saveChangedData = function (eventArgs, isMultiSelect) {
            if (isMultiSelect === void 0) { isMultiSelect = false; }
            this.parent.activeEventData.event = this.actionObj.event;
            this.parent.currentAction = 'Save';
            var currentAction;
            var eventsCollection = [eventArgs.data];
            Iif (isMultiSelect) {
                eventsCollection = eventArgs.selectedData;
            }
            for (var _i = 0, eventsCollection_1 = eventsCollection; _i < eventsCollection_1.length; _i++) {
                var eventObj = eventsCollection_1[_i];
                var isSameResource = (this.parent.activeViewOptions.group.resources.length > 0) ?
                    parseInt(this.actionObj.element.getAttribute('data-group-index'), 10) === this.actionObj.groupIndex : true;
                Iif (+eventObj[this.parent.eventFields.startTime] === +this.actionObj.event[this.parent.eventFields.startTime] &&
                    +eventObj[this.parent.eventFields.endTime] === +this.actionObj.event[this.parent.eventFields.endTime] && isSameResource) {
                    this.parent.crudModule.crudObj.isCrudAction = false;
                    return;
                }
                Iif (eventObj[this.parent.eventFields.recurrenceRule]) {
                    var eveId = (eventObj[this.parent.eventFields.recurrenceID] || eventObj[this.parent.eventFields.id]);
                    if (eventObj[this.parent.eventFields.id] === eventObj[this.parent.eventFields.recurrenceID]) {
                        eventObj[this.parent.eventFields.id] = this.parent.eventBase.getEventMaxID();
                        currentAction = 'EditOccurrence';
                    }
                    if (this.parent.enableRecurrenceValidation
                        && this.parent.eventWindow.editOccurrenceValidation(eveId, eventObj, this.actionObj.event)) {
                        return;
                    }
                }
                else {
                    currentAction = null;
                }
                Iif (eventObj[this.parent.eventFields.startTimezone] || eventObj[this.parent.eventFields.endTimezone]) {
                    this.parent.eventBase.timezoneConvert(eventObj);
                }
                this.parent.crudModule.saveEvent(eventObj, currentAction);
            }
        };
        ActionBase.prototype.calculateIntervalTime = function (date) {
            var intervalTime = new Date(+date);
            intervalTime.setMinutes(Math.floor(intervalTime.getMinutes() / this.actionObj.interval) * this.actionObj.interval);
            return intervalTime;
        };
        ActionBase.prototype.getContentAreaDimension = function () {
            var viewElement = this.parent.element.querySelector('.' + cls.CONTENT_WRAP_CLASS);
            var trElement = [].slice.call(viewElement.querySelector('tr').children);
            Iif (!this.parent.activeView.isTimelineView() && this.parent.activeViewOptions.group.resources.length > 0 &&
                !this.parent.isAdaptive && !this.parent.enableAdaptiveUI && !this.parent.virtualScrollModule) {
                trElement = this.getResourceElements(trElement);
            }
            var leftOffset = trElement[0].getBoundingClientRect();
            var rightOffset = trElement.slice(-1)[0].getBoundingClientRect();
            var viewDimension = {
                bottom: viewElement.scrollHeight - 5,
                left: this.parent.enableRtl ? rightOffset.left : leftOffset.left,
                right: this.parent.enableRtl ? leftOffset.right : rightOffset.right,
                top: 0,
                leftOffset: this.parent.enableRtl ? rightOffset.right : leftOffset.right,
                rightOffset: this.parent.enableRtl ? leftOffset.left : rightOffset.left
            };
            return viewDimension;
        };
        ActionBase.prototype.getIndex = function (index) {
            var contentElements = [].slice.call(this.parent.getContentTable().querySelector('tr').children);
            var indexes = { minIndex: 0, maxIndex: contentElements.length - 1 };
            Iif (this.actionObj.action === 'resize' && this.parent.activeViewOptions.group.resources.length > 0 &&
                !this.parent.uiStateValues.isGroupAdaptive && !this.parent.activeView.isTimelineView()) {
                var groupElements = this.getResourceElements(contentElements);
                indexes.minIndex = groupElements[0].cellIndex;
                indexes.maxIndex = groupElements.slice(-1)[0].cellIndex;
            }
            Iif (index < indexes.minIndex) {
                index = indexes.minIndex;
            }
            Iif (index > indexes.maxIndex) {
                index = indexes.maxIndex;
            }
            return index;
        };
        ActionBase.prototype.updateTimePosition = function (date, multiData) {
            var index = 0;
            for (var _i = 0, _a = this.actionObj.cloneElement; _i < _a.length; _i++) {
                var cloneElement = _a[_i];
                var timeElement = cloneElement.querySelector('.' + cls.APPOINTMENT_TIME);
                Eif (timeElement) {
                    var startTime = this.actionObj.start;
                    var endTime = this.actionObj.end;
                    Iif (multiData && multiData.length > 0) {
                        startTime = multiData[parseInt(index.toString(), 10)][this.parent.eventFields.startTime];
                        endTime = multiData[parseInt(index.toString(), 10)][this.parent.eventFields.endTime];
                    }
                    timeElement.innerHTML = this.parent.getTimeString(startTime) + ' - ' +
                        this.parent.getTimeString(endTime);
                }
                index++;
            }
            Eif (!this.parent.activeViewOptions.timeScale.enable || !this.parent.isAdaptive || this.parent.currentView === 'Month' ||
                this.parent.currentView === 'TimelineMonth') {
                return;
            }
            var timeIndicator = this.parent.element.querySelector('.' + cls.CLONE_TIME_INDICATOR_CLASS);
            if (!timeIndicator) {
                timeIndicator = ej2_base_1.createElement('div', { className: cls.CLONE_TIME_INDICATOR_CLASS });
                var wrapperClass = this.parent.activeView.isTimelineView() ? cls.DATE_HEADER_WRAP_CLASS : cls.TIME_CELLS_WRAP_CLASS;
                this.parent.element.querySelector('.' + wrapperClass).appendChild(timeIndicator);
            }
            timeIndicator.innerHTML = this.parent.getTimeString(date);
            var offsetValue = 0;
            if (this.parent.activeView.isTimelineView()) {
                if (this.parent.enableRtl) {
                    var rightValue = parseInt(this.actionObj.clone.style.right, 10);
                    offsetValue = this.actionObj.action === 'drag' || this.resizeEdges.left ?
                        rightValue + this.actionObj.clone.offsetWidth : rightValue;
                    timeIndicator.style.right = ej2_base_2.formatUnit(offsetValue);
                }
                else {
                    var leftValue = parseInt(this.actionObj.clone.style.left, 10);
                    offsetValue = this.actionObj.action === 'drag' || this.resizeEdges.left ?
                        leftValue : leftValue + this.actionObj.clone.offsetWidth;
                    timeIndicator.style.left = ej2_base_2.formatUnit(offsetValue);
                }
            }
            else {
                offsetValue = this.actionObj.action === 'drag' || this.resizeEdges.top ? this.actionObj.clone.offsetTop :
                    this.actionObj.clone.offsetTop + this.actionObj.clone.offsetHeight;
                timeIndicator.style.top = ej2_base_2.formatUnit(offsetValue);
            }
        };
        ActionBase.prototype.getResourceElements = function (table) {
            var _this = this;
            return table.filter(function (element) {
                return parseInt(element.getAttribute('data-group-index'), 10) === _this.actionObj.groupIndex;
            });
        };
        ActionBase.prototype.getOriginalElement = function (element) {
            var originalElement;
            var guid = element.getAttribute('data-guid');
            var isMorePopup = element.offsetParent && element.offsetParent.classList.contains(cls.MORE_EVENT_POPUP_CLASS);
            if (isMorePopup || this.parent.activeView.isTimelineView() || (this.actionObj.action !== 'resize' && this.parent.virtualScrollModule)) {
                originalElement = [].slice.call(this.parent.element.querySelectorAll('[data-guid="' + guid + '"]'));
            }
            else {
                var tr = ej2_base_1.closest(element, 'tr');
                Eif (tr) {
                    originalElement = [].slice.call(tr.querySelectorAll('[data-guid="' + guid + '"]'));
                }
            }
            return originalElement;
        };
        ActionBase.prototype.createCloneElement = function (element) {
            var cloneWrapper = ej2_base_1.createElement('div', { innerHTML: element.outerHTML });
            var cloneElement = cloneWrapper.children[0];
            var cloneClassLists = [cls.CLONE_ELEMENT_CLASS];
            cloneClassLists.push((this.actionObj.action === 'drag') ? cls.DRAG_CLONE_CLASS : cls.RESIZE_CLONE_CLASS);
            if (this.parent.currentView === 'Month' || this.parent.currentView === 'TimelineMonth') {
                cloneClassLists.push(cls.MONTH_CLONE_ELEMENT_CLASS);
            }
            ej2_base_1.addClass([cloneElement], cloneClassLists);
            ej2_base_1.addClass([element], cls.EVENT_ACTION_CLASS);
            Eif (!ej2_base_1.isNullOrUndefined(element.parentElement)) {
                element.parentElement.appendChild(cloneElement);
            }
            cloneElement.style.width = ej2_base_2.formatUnit(cloneElement.offsetWidth - 2);
            var dragElement = document.querySelector(this.parent.eventDragArea);
            Iif (this.parent.eventDragArea && this.actionObj.action === 'drag' && dragElement) {
                dragElement.appendChild(cloneElement);
            }
            ej2_base_1.setStyleAttribute(cloneElement, { border: '0px' });
            return cloneElement;
        };
        ActionBase.prototype.removeCloneElementClasses = function () {
            var elements = this.actionObj.originalElement;
            if (this.parent.currentView === 'Month' || this.parent.currentView === 'TimelineYear' ||
                this.parent.currentView === 'Day' || this.parent.currentView === 'Week' || this.parent.currentView === 'WorkWeek') {
                elements = [].slice.call(this.parent.element.querySelectorAll('.' + cls.EVENT_ACTION_CLASS));
            }
            ej2_base_2.removeClass(elements, cls.EVENT_ACTION_CLASS);
        };
        ActionBase.prototype.removeCloneElement = function () {
            this.actionObj.originalElement = [];
            var dynamicEle = [].slice.call(this.parent.element.querySelectorAll('.e-dynamic-clone'));
            for (var _i = 0, dynamicEle_1 = dynamicEle; _i < dynamicEle_1.length; _i++) {
                var cloneEle = dynamicEle_1[_i];
                ej2_base_2.remove(cloneEle);
            }
            for (var _a = 0, _b = this.actionObj.cloneElement; _a < _b.length; _a++) {
                var cloneElement = _b[_a];
                Eif (!ej2_base_1.isNullOrUndefined(cloneElement.parentNode)) {
                    ej2_base_2.remove(cloneElement);
                }
            }
            this.actionObj.cloneElement = [];
            var timeIndicator = this.parent.element.querySelector('.' + cls.CLONE_TIME_INDICATOR_CLASS);
            Iif (timeIndicator) {
                ej2_base_2.remove(timeIndicator);
            }
        };
        ActionBase.prototype.getCursorElement = function (e) {
            var pages = this.parent.eventBase.getPageCoordinates(e);
            return document.elementFromPoint(pages.clientX, pages.clientY);
        };
        ActionBase.prototype.autoScroll = function () {
            var parent = this.parent.element.querySelector('.' + cls.CONTENT_WRAP_CLASS);
            var yIsScrollable = parent.offsetHeight <= parent.scrollHeight;
            var xIsScrollable = parent.offsetWidth <= parent.scrollWidth;
            var yInBounds = yIsScrollable && parent.scrollTop >= 0 && parent.scrollTop + parent.offsetHeight <= parent.scrollHeight;
            var xInBounds = xIsScrollable && parent.scrollLeft >= 0 && parent.scrollLeft + parent.offsetWidth <= parent.scrollWidth;
            if (this.actionObj.action === 'resize' && this.scrollEdges.right && (parent.scrollLeft + parent.offsetWidth) > parent.scrollWidth) {
                var tdCollections = ([].slice.call(this.parent.getContentTable().querySelector('tr').children)).length - 1;
                var cellIndex = Math.ceil((this.actionObj.clone.offsetLeft + (this.actionObj.clone.offsetWidth)) /
                    this.actionObj.cellWidth);
                xInBounds = cellIndex === tdCollections;
            }
            if (yInBounds && (this.scrollEdges.top || this.scrollEdges.bottom)) {
                parent.scrollTop += this.scrollEdges.top ? -this.actionObj.scroll.scrollBy : this.actionObj.scroll.scrollBy;
                if (this.actionObj.action === 'resize') {
                    if (parent.scrollHeight !== parent.offsetHeight + parent.scrollTop && parent.scrollTop > 0) {
                        this.actionObj.Y += this.scrollEdges.top ? this.actionObj.scroll.scrollBy : -this.actionObj.scroll.scrollBy;
                    }
                }
            }
            if (xInBounds && (this.scrollEdges.left || this.scrollEdges.right)) {
                parent.scrollLeft += this.scrollEdges.left ? -this.actionObj.scroll.scrollBy : this.actionObj.scroll.scrollBy;
                if (this.actionObj.action === 'resize') {
                    if (parent.scrollWidth !== parent.offsetWidth + parent.scrollLeft && parent.scrollLeft > 0) {
                        this.actionObj.X += this.scrollEdges.left ? this.actionObj.scroll.scrollBy : -this.actionObj.scroll.scrollBy;
                    }
                }
            }
        };
        ActionBase.prototype.autoScrollValidation = function () {
            if (!this.actionObj.scroll.enable) {
                return false;
            }
            var res = this.parent.boundaryValidation(this.actionObj.pageY, this.actionObj.pageX);
            this.scrollEdges = res;
            return res.bottom || res.top || res.left || res.right;
        };
        ActionBase.prototype.actionClass = function (type) {
            if (type === 'addClass') {
                ej2_base_1.addClass([this.parent.element], cls.EVENT_ACTION_CLASS);
            }
            else {
                ej2_base_2.removeClass([this.parent.element], cls.EVENT_ACTION_CLASS);
            }
        };
        ActionBase.prototype.updateScrollPosition = function (e) {
            var _this = this;
            this.scrollEventArgs = e;
            if (this.actionObj.scroll.enable && ej2_base_1.isNullOrUndefined(this.actionObj.scrollInterval)) {
                this.actionObj.scrollInterval = window.setInterval(function () {
                    if (_this.autoScrollValidation() && !_this.actionObj.clone.classList.contains(cls.ALLDAY_APPOINTMENT_CLASS)) {
                        if (_this.parent.activeView.isTimelineView() && _this.parent.activeViewOptions.group.resources.length > 0
                            && _this.actionObj.groupIndex < 0) {
                            return;
                        }
                        _this.autoScroll();
                        if (_this.actionObj.action === 'drag') {
                            _this.parent.dragAndDropModule.updateDraggingDateTime(_this.scrollEventArgs);
                        }
                        else {
                            _this.parent.resizeModule.updateResizingDirection(_this.scrollEventArgs);
                        }
                    }
                }, this.actionObj.scroll.timeDelay);
            }
        };
        ActionBase.prototype.updateOriginalElement = function (cloneElement) {
            var query = '[data-id="' + cloneElement.getAttribute('data-id') + '"]';
            if (this.parent.activeViewOptions.group.resources.length > 0) {
                query = query.concat('[data-group-index = "' + cloneElement.getAttribute('data-group-index') + '"]');
            }
            var elements = [].slice.call(this.parent.element.querySelectorAll(query));
            ej2_base_1.addClass(elements, cls.EVENT_ACTION_CLASS);
            var eventWrappers = [].slice.call(this.parent.element.querySelectorAll('.' + cls.CLONE_ELEMENT_CLASS));
            ej2_base_2.removeClass(eventWrappers, cls.EVENT_ACTION_CLASS);
        };
        ActionBase.prototype.getUpdatedEvent = function (startTime, endTime, eventObj) {
            var event = JSON.parse(JSON.stringify(eventObj));
            event[this.parent.eventFields.startTime] = startTime;
            event[this.parent.eventFields.endTime] = endTime;
            return event;
        };
        ActionBase.prototype.dynamicYearlyEventsRendering = function (event, isResize) {
            if (isResize === void 0) { isResize = false; }
            if (!ej2_base_1.isNullOrUndefined(this.parent.eventDragArea)) {
                return;
            }
            var appWidth = this.actionObj.cellWidth - 7;
            if (isResize && (this.resizeEdges.left || this.resizeEdges.right)) {
                appWidth = this.actionObj.cellWidth * event.count;
            }
            if (!isResize && (this.parent.activeViewOptions.orientation === 'Horizontal' && this.parent.activeViewOptions.group.resources.length === 0)) {
                var eventObj = this.yearEvent.isSpannedEvent(event, event[this.parent.eventFields.startTime]);
                if (eventObj[this.parent.eventFields.startTime].getTime() ===
                    eventObj[this.parent.eventFields.endTime].getTime()) {
                    eventObj.isSpanned.count = 1;
                }
                appWidth = eventObj.isSpanned.count * this.actionObj.cellWidth;
            }
            if (!isResize && this.parent.activeViewOptions.orientation === 'Vertical' && this.parent.activeViewOptions.group.resources.length !== 0) {
                var eventObj = this.yearEvent.isSpannedEvent(event, event[this.parent.eventFields.startTime]);
                appWidth = eventObj.isSpanned.count * this.actionObj.cellWidth;
            }
            var appointmentElement = this.createAppointmentElement(this.actionObj.groupIndex, event[this.parent.eventFields.subject]);
            appointmentElement.setAttribute('drag', 'true');
            ej2_base_1.addClass([appointmentElement], cls.CLONE_ELEMENT_CLASS);
            ej2_base_1.setStyleAttribute(appointmentElement, {
                'width': appWidth + 'px', 'border': '0px', 'pointer-events': 'none',
                'position': 'absolute', 'overflow': 'hidden', 'padding': '3px'
            });
            if (this.actionObj.clone.style.backgroundColor !== '') {
                ej2_base_1.setStyleAttribute(appointmentElement, { 'backgroundColor': this.actionObj.clone.style.backgroundColor });
            }
            var date = util.resetTime(event[this.parent.eventFields.startTime]).getTime();
            var query = '.' + cls.WORK_CELLS_CLASS + '[data-date="' + date + '"]';
            if (this.parent.activeViewOptions.group.resources.length > 0 && !this.parent.uiStateValues.isGroupAdaptive) {
                query = '.' + cls.WORK_CELLS_CLASS + '[data-date="' + date + '"][data-group-index="' + this.actionObj.groupIndex + '"]';
            }
            var cellTd = this.parent.element.querySelector(query);
            if (ej2_base_1.isNullOrUndefined(cellTd)) {
                return;
            }
            if (isResize) {
                var dateHeader = cellTd.querySelector('.' + cls.DATE_HEADER_CLASS);
                var appHeight = this.actionObj.cellHeight * event.count -
                    (dateHeader ? dateHeader.offsetHeight : 0) - 7;
                if (this.resizeEdges.right || this.resizeEdges.left) {
                    appHeight = parseInt(this.actionObj.clone.style.height, 10);
                }
                ej2_base_1.setStyleAttribute(appointmentElement, { 'height': appHeight + 'px' });
            }
            this.renderDynamicElement(cellTd, appointmentElement, true);
            this.actionObj.cloneElement.push(appointmentElement);
        };
        ActionBase.prototype.renderDynamicElement = function (cellTd, element, isAppointment) {
            if (isAppointment === void 0) { isAppointment = false; }
            if (cellTd.querySelector('.' + cls.APPOINTMENT_WRAPPER_CLASS)) {
                cellTd.querySelector('.' + cls.APPOINTMENT_WRAPPER_CLASS).appendChild(element);
            }
            else {
                var wrapper = ej2_base_1.createElement('div', { className: cls.APPOINTMENT_WRAPPER_CLASS });
                wrapper.appendChild(element);
                cellTd.appendChild(wrapper);
            }
        };
        ActionBase.prototype.createAppointmentElement = function (resIndex, innerText) {
            var appointmentWrapper = ej2_base_1.createElement('div', {
                className: cls.APPOINTMENT_CLASS,
                innerHTML: innerText
            });
            if (this.parent.activeViewOptions.group.resources.length > 0) {
                appointmentWrapper.setAttribute('data-group-index', resIndex.toString());
            }
            return appointmentWrapper;
        };
        ActionBase.prototype.dynamicEventsRendering = function (event) {
            var _this = this;
            if (!ej2_base_1.isNullOrUndefined(this.parent.eventDragArea)) {
                return;
            }
            var dateRender = this.parent.activeView.renderDates;
            var workCells = [].slice.call(this.parent.element.querySelectorAll('.' + cls.WORK_CELLS_CLASS));
            var workDays = this.parent.activeViewOptions.workDays;
            var groupOrder;
            if (this.parent.activeViewOptions.group.resources.length > 0) {
                var renderedResource = this.parent.virtualScrollModule && this.parent.virtualScrollModule.isHorizontalScroll ?
                    this.parent.resourceBase.renderedResources : this.parent.resourceBase.lastResourceLevel;
                var resources = renderedResource.
                    filter(function (res) { return res.groupIndex === _this.actionObj.groupIndex; });
                dateRender = resources[0].renderDates;
                var elementSelector = "." + cls.WORK_CELLS_CLASS + "[data-group-index=\"" + this.actionObj.groupIndex + "\"]";
                workCells = [].slice.call(this.parent.element.querySelectorAll(elementSelector));
                workDays = resources[0].workDays;
                groupOrder = resources[0].groupOrder;
            }
            this.monthEvent.dateRender = dateRender;
            this.monthEvent.getSlotDates(workDays);
            if (this.resizeEdges.left || this.resizeEdges.right) {
                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_2.remove(wrapper);
                }
            }
            var spannedEvents = this.monthEvent.splitEvent(event, dateRender);
            for (var _a = 0, spannedEvents_1 = spannedEvents; _a < spannedEvents_1.length; _a++) {
                var event_1 = spannedEvents_1[_a];
                var day = this.parent.getIndexOfDate(dateRender, util.resetTime(event_1[this.monthEvent.fields.startTime]));
                var diffInDays = event_1.data.count;
                var appWidth = (diffInDays * this.actionObj.cellWidth) - 7;
                var appointmentElement = this.monthEvent.createAppointmentElement(event_1, this.actionObj.groupIndex, true);
                appointmentElement.setAttribute('drag', 'true');
                ej2_base_1.addClass([appointmentElement], cls.CLONE_ELEMENT_CLASS);
                this.monthEvent.applyResourceColor(appointmentElement, event_1, 'backgroundColor', groupOrder);
                ej2_base_1.setStyleAttribute(appointmentElement, { 'width': appWidth + 'px', 'border': '0px', 'pointer-events': 'none' });
                var cellTd = workCells[parseInt(day.toString(), 10)];
                if (cellTd) {
                    this.monthEvent.renderElement(cellTd, appointmentElement, true);
                    this.actionObj.cloneElement.push(appointmentElement);
                }
            }
        };
        ActionBase.prototype.destroy = function () {
            if (!this.parent || this.parent && this.parent.isDestroyed) {
                return;
            }
            this.actionObj = {};
            this.scrollArgs = {};
            this.resizeEdges = { left: false, right: false, top: false, bottom: false };
            this.scrollEdges = { left: false, right: false, top: false, bottom: false };
        };
        return ActionBase;
    }());
    exports.ActionBase = ActionBase;
});