all files / renderer/ event-marker.js

100% Statements 57/57
100% Branches 28/28
100% Functions 7/7
100% Lines 57/57
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   529× 529×   634× 191× 152×     152× 152×   191× 191×     443×     447×     191× 191× 191× 191× 191× 191× 248× 245× 245×   245× 245×     239×   245×       245× 234×     234× 234× 234× 233×   234×     228×   234× 234×     234×   245× 171×   245× 245×         245×     191×   648× 202×          
define(["require", "exports", "@syncfusion/ej2-base", "../base/css-constants"], function (require, exports, ej2_base_1, cls) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var EventMarker = (function () {
        function EventMarker(gantt) {
            this.parent = gantt;
            this.eventMarkersContainer = null;
        }
        EventMarker.prototype.renderEventMarkers = function () {
            if (this.parent.eventMarkers && this.parent.eventMarkers.length > 0) {
                if (!this.parent.ganttChartModule.chartBodyContent.contains(this.eventMarkersContainer)) {
                    this.eventMarkersContainer = ej2_base_1.createElement('div', {
                        className: cls.eventMarkersContainer
                    });
                    this.eventMarkersContainer.setAttribute('role', 'term');
                    this.parent.ganttChartModule.chartBodyContent.appendChild(this.eventMarkersContainer);
                }
                this.eventMarkersContainer.innerHTML = '';
                this.getEventMarkersElements(this.eventMarkersContainer);
            }
            else {
                this.removeContainer();
            }
        };
        EventMarker.prototype.removeContainer = function () {
            if (this.eventMarkersContainer) {
                ej2_base_1.remove(this.eventMarkersContainer);
                this.eventMarkersContainer = null;
            }
        };
        EventMarker.prototype.getEventMarkersElements = function (container) {
            var left;
            var eventMarkerElement;
            var spanElement;
            var rightArrow;
            var eventMarkerCollection = [];
            for (var i = 0; i < this.parent.eventMarkers.length; i++) {
                if (!ej2_base_1.isNullOrUndefined(this.parent.eventMarkers[i].day)) {
                    left = this.parent.dataOperation.getTaskLeft(this.parent.dateValidationModule.getDateFromFormat(this.parent.eventMarkers[i].day, true), false, true);
                    eventMarkerCollection.push({ id: i, left: left, label: this.parent.eventMarkers[i].label,
                        date: this.parent.dateValidationModule.getDateFromFormat(this.parent.eventMarkers[i].day, true) });
                    var align = void 0;
                    if (this.parent.enableRtl) {
                        align = "right:" + left + "px;";
                    }
                    else {
                        align = "left:" + left + "px;";
                    }
                    eventMarkerElement = ej2_base_1.createElement('div', {
                        className: cls.eventMarkersChild, styles: align + "  height:100%;",
                        id: 'stripline' + i
                    });
                    if (this.parent.eventMarkers[i].label) {
                        spanElement = ej2_base_1.createElement('div', {
                            className: cls.eventMarkersSpan
                        });
                        var property = this.parent.disableHtmlEncode ? 'textContent' : 'innerHTML';
                        spanElement[property] = this.parent.eventMarkers[i].label;
                        if (this.parent.enableHtmlSanitizer && typeof (spanElement[property]) === 'string') {
                            spanElement[property] = ej2_base_1.SanitizeHtmlHelper.sanitize(spanElement[property]);
                        }
                        if (this.parent.enableRtl) {
                            spanElement.style.right = '5px';
                        }
                        else {
                            spanElement.style.left = '5px';
                        }
                        eventMarkerElement.appendChild(spanElement);
                        rightArrow = ej2_base_1.createElement('div', {
                            className: 'e-gantt-right-arrow'
                        });
                        eventMarkerElement.appendChild(rightArrow);
                    }
                    if (this.parent.eventMarkers[i].cssClass) {
                        eventMarkerElement.classList.add(this.parent.eventMarkers[i].cssClass);
                    }
                    eventMarkerElement.setAttribute('tabindex', '-1');
                    eventMarkerElement.setAttribute('aria-label', this.parent.localeObj.getConstant('eventMarkers') + ' '
                        + (typeof this.parent.eventMarkers[i].day === 'string' ?
                            this.parent.eventMarkers[i].day :
                            this.parent.getFormatedDate(this.parent.eventMarkers[i].day))
                        + ' ' + this.parent.eventMarkers[i].label);
                    container.appendChild(eventMarkerElement);
                }
            }
            this.parent.eventMarkerColloction = eventMarkerCollection;
        };
        EventMarker.prototype.updateContainerHeight = function () {
            if (this.eventMarkersContainer) {
                this.eventMarkersContainer.style.height = ej2_base_1.formatUnit(this.parent.getContentHeight());
            }
        };
        return EventMarker;
    }());
    exports.EventMarker = EventMarker;
});