all files / renderer/ edit-tooltip.js

94.69% Statements 107/113
85.56% Branches 77/90
100% Functions 10/10
94.69% Lines 107/113
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   747× 747×   148× 148×                 148× 148×         148×   148× 148×   148× 148×   148× 148× 148× 148× 148× 148× 148×     148× 148×     323× 148× 148× 148× 148×   146×       146×     175× 146× 146×     310× 310×   310×   310×   310× 293×       291× 291×         291×   291× 47×     45×     244×   62×     60×     182× 18×       18×     164× 10×   154× 150×         293× 293× 293× 293×   26×   293×       287× 287× 287× 287× 287×       287× 287×       287× 287×       287×     12×   12×   12×       47×   47×         62×   62×             164× 164× 164× 164×   164× 164×   164× 164×                     293×        
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-popups", "../base/css-constants"], function (require, exports, ej2_base_1, ej2_popups_1, cls) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var EditTooltip = (function () {
        function EditTooltip(gantt, taskbarEdit) {
            this.parent = gantt;
            this.taskbarEdit = taskbarEdit;
        }
        EditTooltip.prototype.createTooltip = function (opensOn, mouseTrail, target) {
            var _this = this;
            this.toolTipObj = new ej2_popups_1.Tooltip({
                opensOn: opensOn,
                position: 'TopRight',
                enableRtl: this.parent.enableRtl,
                mouseTrail: mouseTrail,
                cssClass: cls.ganttTooltip,
                target: target ? target : null,
                animation: { open: { effect: 'None' }, close: { effect: 'None' } }
            });
            this.toolTipObj.beforeRender = function (args) {
                var argsData = {
                    data: _this.taskbarEdit.taskBarEditRecord,
                    args: args,
                    content: _this.toolTipObj.content
                };
                _this.parent.trigger('beforeTooltipRender', argsData);
            };
            this.toolTipObj.afterOpen = function (args) {
                _this.updateTooltipPosition(args);
            };
            this.toolTipObj.isStringTemplate = true;
            this.toolTipObj.appendTo(this.parent.chartPane);
        };
        EditTooltip.prototype.updateTooltipPosition = function (args) {
            args.element.style.visibility = 'visible';
            var parentWithZoomStyle = this.parent.element.closest('[style*="zoom"]');
            Eif (ej2_base_1.isNullOrUndefined(parentWithZoomStyle)) {
                var containerPosition = this.parent.getOffsetRect(this.parent.chartPane);
                var leftEnd = containerPosition.left + this.parent.chartPane.offsetWidth;
                var tooltipPositionX = args.element.offsetLeft;
                Iif (leftEnd < (tooltipPositionX + args.element.offsetWidth)) {
                    tooltipPositionX += leftEnd - (tooltipPositionX + args.element.offsetWidth);
                }
                args.element.style.left = tooltipPositionX + 'px';
                args.element.style.visibility = 'visible';
            }
        };
        EditTooltip.prototype.showHideTaskbarEditTooltip = function (bool, segmentIndex) {
            if (bool && this.parent.tooltipSettings.showTooltip) {
                this.createTooltip('Custom', false);
                this.parent.tooltipModule.toolTipObj.close();
                this.updateTooltip(segmentIndex);
                if (this.taskbarEdit.connectorSecondAction === 'ConnectorPointLeftDrag') {
                    this.toolTipObj.open(this.taskbarEdit.connectorSecondElement.querySelector('.' + cls.connectorPointLeft));
                }
                else Iif (this.taskbarEdit.connectorSecondAction === 'ConnectorPointRightDrag') {
                    this.toolTipObj.open(this.taskbarEdit.connectorSecondElement.querySelector('.' + cls.connectorPointRight));
                }
                else {
                    this.toolTipObj.open(this.taskbarEdit.taskBarEditElement);
                }
            }
            else if (!ej2_base_1.isNullOrUndefined(this.toolTipObj)) {
                this.toolTipObj.destroy();
                this.toolTipObj = null;
            }
        };
        EditTooltip.prototype.updateTooltip = function (segmentIndex) {
            var ganttProp = this.taskbarEdit.taskBarEditRecord.ganttProperties;
            var taskWidth = (ej2_base_1.isNullOrUndefined(segmentIndex) || segmentIndex === -1) ? ganttProp.width :
                ganttProp.segments[segmentIndex].width;
            var progressWidth = (ej2_base_1.isNullOrUndefined(segmentIndex) || segmentIndex === -1) ? ganttProp.progressWidth :
                ganttProp.segments[segmentIndex].progressWidth;
            var left = (ej2_base_1.isNullOrUndefined(segmentIndex) || segmentIndex === -1) ? ganttProp.left : ganttProp.left +
                ganttProp.segments[segmentIndex].left;
            if (!ej2_base_1.isNullOrUndefined(this.toolTipObj)) {
                if (this.taskbarEdit.taskBarEditAction === 'ConnectorPointLeftDrag' ||
                    this.taskbarEdit.taskBarEditAction === 'ConnectorPointRightDrag') {
                    this.toolTipObj.content = this.getTooltipText(segmentIndex);
                    this.toolTipObj.offsetY = -3;
                }
                else {
                    this.toolTipObj.content = this.getTooltipText(segmentIndex);
                    Iif (ganttProp.segments && ganttProp.segments.length > 0 && this.taskbarEdit['mainElement'] && this.taskbarEdit.taskBarEditAction === 'ProgressResizing') {
                        var segments = this.taskbarEdit['mainElement'].querySelectorAll('.e-segmented-taskbar');
                        this.toolTipObj.refresh(segments[segmentIndex]);
                    }
                    else {
                        this.toolTipObj.refresh(this.taskbarEdit.taskBarEditElement);
                    }
                    if (this.taskbarEdit.taskBarEditAction === 'LeftResizing') {
                        if (this.parent.enableRtl) {
                            this.toolTipObj.offsetX = 0;
                        }
                        else {
                            this.toolTipObj.offsetX = -taskWidth;
                        }
                    }
                    else if (this.taskbarEdit.taskBarEditAction === 'RightResizing' ||
                        this.taskbarEdit.taskBarEditAction === 'ParentResizing') {
                        if (this.parent.enableRtl) {
                            this.toolTipObj.offsetX = -taskWidth;
                        }
                        else {
                            this.toolTipObj.offsetX = 0;
                        }
                    }
                    else if (this.taskbarEdit.taskBarEditAction === 'ProgressResizing') {
                        Iif (this.parent.enableRtl) {
                            this.toolTipObj.offsetX = -(progressWidth);
                        }
                        else {
                            this.toolTipObj.offsetX = -(taskWidth - progressWidth);
                        }
                    }
                    else if (this.taskbarEdit.taskBarEditAction === 'MilestoneDrag') {
                        this.toolTipObj.offsetX = -(this.parent.chartRowsModule.milestoneHeight / 2);
                    }
                    else if (taskWidth > 5) {
                        this.toolTipObj.offsetX = -(taskWidth + left - this.taskbarEdit.tooltipPositionX);
                    }
                }
            }
        };
        EditTooltip.prototype.getTooltipText = function (segmentIndex) {
            var tooltipString = '';
            var instance = this.parent.globalize;
            var editRecord = this.taskbarEdit.taskBarEditRecord.ganttProperties;
            if (!ej2_base_1.isNullOrUndefined(editRecord.segments) && editRecord.segments.length > 0 && segmentIndex !== -1
                && this.taskbarEdit.taskBarEditAction !== 'ProgressResizing') {
                editRecord = editRecord.segments[segmentIndex];
            }
            if (this.parent.tooltipSettings.editing) {
                var templateNode = this.parent.tooltipModule.templateCompiler(this.parent.tooltipSettings.editing, this.parent, this.taskbarEdit.taskBarEditRecord, 'TooltipEditingTemplate');
                if (ej2_base_1.getValue('tooltipEle', this.toolTipObj)) {
                    this.parent.renderTemplates();
                }
                tooltipString = templateNode[0];
            }
            else {
                var startDate = void 0;
                var endDate = void 0;
                var duration = void 0;
                Eif (!ej2_base_1.isNullOrUndefined(editRecord.startDate)) {
                    startDate = '<tr><td class = "e-gantt-tooltip-label">' + this.parent.localeObj.getConstant('startDate') +
                        '</td><td style="padding: 2px;">:</td><td class = "e-gantt-tooltip-value">' +
                        instance.formatDate(editRecord.startDate, { format: this.parent.getDateFormat() }) + '</td></tr>';
                }
                Eif (!ej2_base_1.isNullOrUndefined(editRecord.endDate)) {
                    endDate = '<tr><td class = "e-gantt-tooltip-label">' + this.parent.localeObj.getConstant('endDate') +
                        '</td><td style="padding: 2px;">:</td><td class = "e-gantt-tooltip-value">' +
                        instance.formatDate(editRecord.endDate, { format: this.parent.getDateFormat() }) + '</td></tr>';
                }
                Eif (!ej2_base_1.isNullOrUndefined(editRecord.duration)) {
                    duration = '<tr><td class = "e-gantt-tooltip-label">' + this.parent.localeObj.getConstant('duration') +
                        '</td><td style="padding: 2px;">:</td><td class = "e-gantt-tooltip-value">' +
                        this.parent.getDurationString(editRecord.duration, editRecord.durationUnit) + '</td></tr>';
                }
                switch (this.taskbarEdit.taskBarEditAction) {
                    case 'ProgressResizing':
                        {
                            var progress = '<tr><td class = "e-gantt-tooltip-label">' + this.parent.localeObj.getConstant('progress') +
                                '</td><td style="padding: 2px;">:</td><td class = "e-gantt-tooltip-value">' + editRecord.progress + '</td></tr>';
                            tooltipString = '<table class = "e-gantt-tooltiptable"><tbody>' +
                                progress + '</tbody></table>';
                            break;
                        }
                    case 'LeftResizing':
                        {
                            tooltipString = '<table class = "e-gantt-tooltiptable"><tbody>' +
                                startDate + duration + '</tbody></table>';
                            break;
                        }
                    case 'RightResizing':
                    case 'ParentResizing':
                        {
                            tooltipString = '<table class = "e-gantt-tooltiptable"><tbody>' +
                                endDate + duration + '</tbody></table>';
                            break;
                        }
                    case 'ChildDrag':
                    case 'ParentDrag':
                    case 'MilestoneDrag':
                    case 'ManualParentDrag':
                        {
                            var sDate = '';
                            var eDate = '';
                            Eif (!ej2_base_1.isNullOrUndefined(this.taskbarEdit.taskBarEditRecord.ganttProperties.startDate)) {
                                sDate = startDate;
                            }
                            Eif (!ej2_base_1.isNullOrUndefined(this.taskbarEdit.taskBarEditRecord.ganttProperties.endDate)) {
                                eDate = endDate;
                            }
                            tooltipString = '<table class = "e-gantt-tooltiptable"><tbody>' + sDate + eDate + '</tbody></table>';
                            break;
                        }
                    case 'ConnectorPointLeftDrag':
                    case 'ConnectorPointRightDrag':
                        {
                            tooltipString = this.parent.connectorLineModule.tooltipTable;
                            Iif (ej2_base_1.isNullOrUndefined(this.toolTipObj)) {
                                this.parent.connectorLineModule.tooltipTable.innerHTML =
                                    this.parent.connectorLineModule.getConnectorLineTooltipInnerTd(this.parent.editModule.taskbarEditModule.taskBarEditRecord.ganttProperties.taskName, this.parent.editModule.taskbarEditModule.fromPredecessorText, '', '');
                            }
                            break;
                        }
                }
            }
            return tooltipString;
        };
        return EditTooltip;
    }());
    exports.EditTooltip = EditTooltip;
});