jsgantt-improved 2.8.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.cjs +5 -0
- package/.travis.yml +0 -2
- package/Documentation.md +1 -1
- package/dist/draw_columns.js +171 -0
- package/dist/draw_dependencies.js +97 -0
- package/dist/e2e/app.e2e-spec.js +3 -3
- package/dist/e2e/app.e2e-spec.js.map +1 -1
- package/dist/e2e/app.po.js +5 -5
- package/dist/e2e/app.po.js.map +1 -1
- package/dist/jsgantt.js +580 -473
- package/dist/json.js +200 -0
- package/dist/lang.js +1635 -0
- package/dist/options.js +219 -0
- package/dist/playwright.config.js +33 -0
- package/dist/playwright.config.js.map +1 -0
- package/dist/src/draw.js +149 -148
- package/dist/src/draw.js.map +1 -1
- package/dist/src/draw_columns.js +66 -63
- package/dist/src/draw_columns.js.map +1 -1
- package/dist/src/draw_dependencies.js +4 -2
- package/dist/src/draw_dependencies.js.map +1 -1
- package/dist/src/events.js +72 -54
- package/dist/src/events.js.map +1 -1
- package/dist/src/json.js +10 -7
- package/dist/src/json.js.map +1 -1
- package/dist/src/lang.js +1 -1
- package/dist/src/lang.js.map +1 -1
- package/dist/src/options.js +14 -13
- package/dist/src/options.js.map +1 -1
- package/dist/src/task.js +61 -49
- package/dist/src/task.js.map +1 -1
- package/dist/src/utils/date_utils.js +46 -15
- package/dist/src/utils/date_utils.js.map +1 -1
- package/dist/src/utils/draw_utils.js +24 -18
- package/dist/src/utils/draw_utils.js.map +1 -1
- package/dist/src/utils/general_utils.js +59 -36
- package/dist/src/utils/general_utils.js.map +1 -1
- package/dist/src/utils.js +498 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/xml.js +74 -67
- package/dist/src/xml.js.map +1 -1
- package/dist/test/e2e/gantt.page.js +150 -0
- package/dist/test/e2e/gantt.page.js.map +1 -0
- package/dist/test/e2e/issue172-row-alignment.spec.js +198 -0
- package/dist/test/e2e/issue172-row-alignment.spec.js.map +1 -0
- package/dist/test/e2e/issue207-bar-axis-alignment.spec.js +329 -0
- package/dist/test/e2e/issue207-bar-axis-alignment.spec.js.map +1 -0
- package/dist/test/e2e/issue255-show-weekends.spec.js +102 -0
- package/dist/test/e2e/issue255-show-weekends.spec.js.map +1 -0
- package/dist/test/e2e/issue349-taskname-click-event.spec.js +270 -0
- package/dist/test/e2e/issue349-taskname-click-event.spec.js.map +1 -0
- package/dist/test/e2e/issue48-dependency-lines.spec.js +204 -0
- package/dist/test/e2e/issue48-dependency-lines.spec.js.map +1 -0
- package/dist/test/e2e/issue54-month-today.spec.js +181 -0
- package/dist/test/e2e/issue54-month-today.spec.js.map +1 -0
- package/dist/test/e2e/issue68-working-days.spec.js +243 -0
- package/dist/test/e2e/issue68-working-days.spec.js.map +1 -0
- package/dist/test/e2e/zoom-alignment.spec.js +133 -0
- package/dist/test/e2e/zoom-alignment.spec.js.map +1 -0
- package/dist/test/index.js +3 -8
- package/dist/test/index.js.map +1 -1
- package/dist/test/unit/date-utils.spec.js +180 -0
- package/dist/test/unit/date-utils.spec.js.map +1 -0
- package/dist/test/unit/draw-cols-chart.spec.js +105 -0
- package/dist/test/unit/draw-cols-chart.spec.js.map +1 -0
- package/dist/test/unit/gantt-chart-constructor.spec.js +85 -0
- package/dist/test/unit/gantt-chart-constructor.spec.js.map +1 -0
- package/dist/test/unit/helpers.js +67 -0
- package/dist/test/unit/helpers.js.map +1 -0
- package/dist/test/unit/task-item.spec.js +46 -0
- package/dist/test/unit/task-item.spec.js.map +1 -0
- package/dist/test/unit/task-management.spec.js +141 -0
- package/dist/test/unit/task-management.spec.js.map +1 -0
- package/dist/test/unit/working-days.spec.js +109 -0
- package/dist/test/unit/working-days.spec.js.map +1 -0
- package/dist/utils/draw_utils.js +169 -0
- package/dist/utils/general_utils.js +498 -0
- package/dist/xml.js +345 -0
- package/dist-e2e/gantt.page.js +79 -0
- package/dist-e2e/gantt.page.js.map +1 -0
- package/dist-e2e/issue-setMinDate-setMaxDate.spec.js +96 -0
- package/dist-e2e/issue172-row-alignment.spec.js +90 -0
- package/dist-e2e/issue172-row-alignment.spec.js.map +1 -0
- package/dist-e2e/issue207-bar-axis-alignment.spec.js +161 -0
- package/dist-e2e/issue207-bar-axis-alignment.spec.js.map +1 -0
- package/dist-e2e/issue349-taskname-click-event.spec.js +170 -0
- package/dist-e2e/issue349-taskname-click-event.spec.js.map +1 -0
- package/dist-e2e/issue375-column-visibility.spec.js +129 -0
- package/dist-e2e/issue375-column-visibility.spec.js.map +1 -0
- package/dist-e2e/issue54-month-today.spec.js +84 -0
- package/dist-e2e/issue54-month-today.spec.js.map +1 -0
- package/dist-e2e/issue68-working-days.spec.js +105 -0
- package/dist-e2e/issue68-working-days.spec.js.map +1 -0
- package/docs/index.js +5 -2
- package/docs/jsgantt.js +5749 -0
- package/jsgantt.js +5749 -0
- package/package.json +10 -18
- package/pw-e2e.config.js +13 -0
- package/test-results/.last-run.json +4 -0
- package/protractor.conf.js +0 -29
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printChart = exports.calculateStartEndFromDepend = exports.makeRequestOldBrowsers = exports.makeRequest = exports.moveToolTip = exports.updateFlyingObj = exports.isParentElementOrSelf = exports.criticalPath = exports.hashKey = exports.hashString = exports.fadeToolTip = exports.hideToolTip = exports.isIE = exports.getOffset = exports.calculateCurrentDateOffset = exports.getScrollbarWidth = exports.getScrollPositions = exports.benchMark = exports.getZoomFactor = exports.delayedHide = exports.stripUnwanted = exports.stripIds = exports.changeFormat = exports.findObj = exports.internalPropertiesLang = exports.internalProperties = void 0;
|
|
4
|
+
exports.internalProperties = ['pID', 'pName', 'pStart', 'pEnd', 'pClass', 'pLink', 'pMile', 'pRes', 'pComp', 'pGroup', 'pParent',
|
|
5
|
+
'pOpen', 'pDepend', 'pCaption', 'pNotes', 'pGantt', 'pCost', 'pPlanStart', 'pPlanEnd', 'pPlanClass'];
|
|
6
|
+
exports.internalPropertiesLang = {
|
|
7
|
+
'pID': 'id',
|
|
8
|
+
'pName': 'name',
|
|
9
|
+
'pStart': 'startdate',
|
|
10
|
+
'pEnd': 'enddate',
|
|
11
|
+
'pLink': 'link',
|
|
12
|
+
'pMile': 'mile',
|
|
13
|
+
'pRes': 'res',
|
|
14
|
+
'pDuration': 'dur',
|
|
15
|
+
'pComp': 'comp',
|
|
16
|
+
'pGroup': 'group',
|
|
17
|
+
'pParent': 'parent',
|
|
18
|
+
'pOpen': 'open',
|
|
19
|
+
'pDepend': 'depend',
|
|
20
|
+
'pCaption': 'caption',
|
|
21
|
+
'pNotes': 'notes',
|
|
22
|
+
'pCost': 'cost',
|
|
23
|
+
'pPlanStart': 'planstartdate',
|
|
24
|
+
'pPlanEnd': 'planenddate',
|
|
25
|
+
'pPlanClass': 'planclass'
|
|
26
|
+
};
|
|
27
|
+
var findObj = function (theObj, theDoc) {
|
|
28
|
+
if (theDoc === void 0) { theDoc = null; }
|
|
29
|
+
var p, i, foundObj;
|
|
30
|
+
if (!theDoc)
|
|
31
|
+
theDoc = document;
|
|
32
|
+
if (document.getElementById)
|
|
33
|
+
foundObj = document.getElementById(theObj);
|
|
34
|
+
return foundObj;
|
|
35
|
+
};
|
|
36
|
+
exports.findObj = findObj;
|
|
37
|
+
var changeFormat = function (pFormat, ganttObj) {
|
|
38
|
+
if (ganttObj)
|
|
39
|
+
ganttObj.setFormat(pFormat);
|
|
40
|
+
else
|
|
41
|
+
alert('Chart undefined');
|
|
42
|
+
};
|
|
43
|
+
exports.changeFormat = changeFormat;
|
|
44
|
+
var stripIds = function (pNode) {
|
|
45
|
+
for (var i = 0; i < pNode.childNodes.length; i++) {
|
|
46
|
+
if ('removeAttribute' in pNode.childNodes[i])
|
|
47
|
+
pNode.childNodes[i].removeAttribute('id');
|
|
48
|
+
if (pNode.childNodes[i].hasChildNodes())
|
|
49
|
+
(0, exports.stripIds)(pNode.childNodes[i]);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.stripIds = stripIds;
|
|
53
|
+
var stripUnwanted = function (pNode) {
|
|
54
|
+
var vAllowedTags = new Array('#text', 'p', 'br', 'ul', 'ol', 'li', 'div', 'span', 'img');
|
|
55
|
+
for (var i = 0; i < pNode.childNodes.length; i++) {
|
|
56
|
+
/* versions of IE<9 don't support indexOf on arrays so add trailing comma to the joined array and lookup value to stop substring matches */
|
|
57
|
+
if ((vAllowedTags.join().toLowerCase() + ',').indexOf(pNode.childNodes[i].nodeName.toLowerCase() + ',') == -1) {
|
|
58
|
+
pNode.replaceChild(document.createTextNode(pNode.childNodes[i].outerHTML), pNode.childNodes[i]);
|
|
59
|
+
}
|
|
60
|
+
if (pNode.childNodes[i].hasChildNodes())
|
|
61
|
+
(0, exports.stripUnwanted)(pNode.childNodes[i]);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.stripUnwanted = stripUnwanted;
|
|
65
|
+
var delayedHide = function (pGanttChartObj, pTool, pTimer) {
|
|
66
|
+
var vDelay = pGanttChartObj.getTooltipDelay() || 1500;
|
|
67
|
+
if (pTool)
|
|
68
|
+
pTool.delayTimeout = setTimeout(function () { (0, exports.hideToolTip)(pGanttChartObj, pTool, pTimer); }, vDelay);
|
|
69
|
+
};
|
|
70
|
+
exports.delayedHide = delayedHide;
|
|
71
|
+
var getZoomFactor = function () {
|
|
72
|
+
var vFactor = 1;
|
|
73
|
+
if (document.body.getBoundingClientRect) {
|
|
74
|
+
// rect is only in physical pixel size in IE before version 8
|
|
75
|
+
var vRect = document.body.getBoundingClientRect();
|
|
76
|
+
var vPhysicalW = vRect.right - vRect.left;
|
|
77
|
+
var vLogicalW = document.body.offsetWidth;
|
|
78
|
+
// the zoom level is always an integer percent value
|
|
79
|
+
vFactor = Math.round((vPhysicalW / vLogicalW) * 100) / 100;
|
|
80
|
+
}
|
|
81
|
+
return vFactor;
|
|
82
|
+
};
|
|
83
|
+
exports.getZoomFactor = getZoomFactor;
|
|
84
|
+
var benchMark = function (pItem) {
|
|
85
|
+
var vEndTime = new Date().getTime();
|
|
86
|
+
alert(pItem + ': Elapsed time: ' + ((vEndTime - this.vBenchTime) / 1000) + ' seconds.');
|
|
87
|
+
this.vBenchTime = new Date().getTime();
|
|
88
|
+
};
|
|
89
|
+
exports.benchMark = benchMark;
|
|
90
|
+
var getScrollPositions = function () {
|
|
91
|
+
var vScrollLeft = window.pageXOffset;
|
|
92
|
+
var vScrollTop = window.pageYOffset;
|
|
93
|
+
if (!('pageXOffset' in window)) // Internet Explorer before version 9
|
|
94
|
+
{
|
|
95
|
+
var vZoomFactor = (0, exports.getZoomFactor)();
|
|
96
|
+
vScrollLeft = Math.round(document.documentElement.scrollLeft / vZoomFactor);
|
|
97
|
+
vScrollTop = Math.round(document.documentElement.scrollTop / vZoomFactor);
|
|
98
|
+
}
|
|
99
|
+
return { x: vScrollLeft, y: vScrollTop };
|
|
100
|
+
};
|
|
101
|
+
exports.getScrollPositions = getScrollPositions;
|
|
102
|
+
var scrollbarWidth = undefined;
|
|
103
|
+
var getScrollbarWidth = function () {
|
|
104
|
+
if (scrollbarWidth)
|
|
105
|
+
return scrollbarWidth;
|
|
106
|
+
var outer = document.createElement('div');
|
|
107
|
+
outer.className = 'gscrollbar-calculation-container';
|
|
108
|
+
document.body.appendChild(outer);
|
|
109
|
+
// Creating inner element and placing it in the container
|
|
110
|
+
var inner = document.createElement('div');
|
|
111
|
+
outer.appendChild(inner);
|
|
112
|
+
// Calculating difference between container's full width and the child width
|
|
113
|
+
scrollbarWidth = (outer.offsetWidth - inner.offsetWidth);
|
|
114
|
+
// Removing temporary elements from the DOM
|
|
115
|
+
outer.parentNode.removeChild(outer);
|
|
116
|
+
return scrollbarWidth;
|
|
117
|
+
};
|
|
118
|
+
exports.getScrollbarWidth = getScrollbarWidth;
|
|
119
|
+
var calculateCurrentDateOffset = function (curTaskStart, curTaskEnd) {
|
|
120
|
+
var tmpTaskStart = Date.UTC(curTaskStart.getFullYear(), curTaskStart.getMonth(), curTaskStart.getDate(), curTaskStart.getHours(), 0, 0);
|
|
121
|
+
var tmpTaskEnd = Date.UTC(curTaskEnd.getFullYear(), curTaskEnd.getMonth(), curTaskEnd.getDate(), curTaskEnd.getHours(), 0, 0);
|
|
122
|
+
return (tmpTaskEnd - tmpTaskStart);
|
|
123
|
+
};
|
|
124
|
+
exports.calculateCurrentDateOffset = calculateCurrentDateOffset;
|
|
125
|
+
var getOffset = function (pStartDate, pEndDate, pColWidth, pFormat, pShowWeekends, pFirstDayOfWeek) {
|
|
126
|
+
if (pFirstDayOfWeek === void 0) { pFirstDayOfWeek = 1; }
|
|
127
|
+
var DAY_CELL_MARGIN_WIDTH = 3; // Cell margin for 'day' format
|
|
128
|
+
var WEEK_CELL_MARGIN_WIDTH = 3; // Cell margin for 'week' format
|
|
129
|
+
var MONTH_CELL_MARGIN_WIDTH = 3; // Cell margin for 'month' format
|
|
130
|
+
var QUARTER_CELL_MARGIN_WIDTH = 3; // Cell margin for 'quarter' format
|
|
131
|
+
var HOUR_CELL_MARGIN_WIDTH = 3; // Cell margin for 'hour' format
|
|
132
|
+
var vMonthDaysArr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
|
|
133
|
+
var curTaskStart = new Date(pStartDate.getTime());
|
|
134
|
+
var curTaskEnd = new Date(pEndDate.getTime());
|
|
135
|
+
var vTaskRightPx = 0;
|
|
136
|
+
// Length of task in hours
|
|
137
|
+
var oneHour = 3600000;
|
|
138
|
+
var vTaskRight = (0, exports.calculateCurrentDateOffset)(curTaskStart, curTaskEnd) / oneHour;
|
|
139
|
+
var vPosTmpDate;
|
|
140
|
+
if (pFormat == 'day') {
|
|
141
|
+
if (!pShowWeekends) {
|
|
142
|
+
var start = curTaskStart;
|
|
143
|
+
var end = curTaskEnd;
|
|
144
|
+
var countWeekends = 0;
|
|
145
|
+
while (start < end) {
|
|
146
|
+
var day = start.getDay();
|
|
147
|
+
var vLastDay = (pFirstDayOfWeek + 6) % 7;
|
|
148
|
+
var vPenultDay = (pFirstDayOfWeek + 5) % 7;
|
|
149
|
+
if (day === vLastDay || day === vPenultDay) {
|
|
150
|
+
countWeekends++;
|
|
151
|
+
}
|
|
152
|
+
start = new Date(start.getTime() + 24 * oneHour);
|
|
153
|
+
}
|
|
154
|
+
vTaskRight -= countWeekends * 24;
|
|
155
|
+
}
|
|
156
|
+
vTaskRightPx = Math.ceil((vTaskRight / 24) * (pColWidth + DAY_CELL_MARGIN_WIDTH) - 1);
|
|
157
|
+
}
|
|
158
|
+
else if (pFormat == 'week') {
|
|
159
|
+
vTaskRightPx = Math.ceil((vTaskRight / (24 * 7)) * (pColWidth + WEEK_CELL_MARGIN_WIDTH) - 1);
|
|
160
|
+
}
|
|
161
|
+
else if (pFormat == 'month') {
|
|
162
|
+
var vMonthsDiff = (12 * (curTaskEnd.getFullYear() - curTaskStart.getFullYear())) + (curTaskEnd.getMonth() - curTaskStart.getMonth());
|
|
163
|
+
vPosTmpDate = new Date(curTaskEnd.getTime());
|
|
164
|
+
vPosTmpDate.setDate(curTaskStart.getDate());
|
|
165
|
+
var vDaysCrctn = (curTaskEnd.getTime() - vPosTmpDate.getTime()) / (86400000);
|
|
166
|
+
vTaskRightPx = Math.ceil((vMonthsDiff * (pColWidth + MONTH_CELL_MARGIN_WIDTH)) + (vDaysCrctn * (pColWidth / vMonthDaysArr[curTaskEnd.getMonth()])) - 1);
|
|
167
|
+
}
|
|
168
|
+
else if (pFormat == 'quarter') {
|
|
169
|
+
var vMonthsDiff = (12 * (curTaskEnd.getFullYear() - curTaskStart.getFullYear())) + (curTaskEnd.getMonth() - curTaskStart.getMonth());
|
|
170
|
+
vPosTmpDate = new Date(curTaskEnd.getTime());
|
|
171
|
+
vPosTmpDate.setDate(curTaskStart.getDate());
|
|
172
|
+
var vDaysCrctn = (curTaskEnd.getTime() - vPosTmpDate.getTime()) / (86400000);
|
|
173
|
+
vTaskRightPx = Math.ceil((vMonthsDiff * ((pColWidth + QUARTER_CELL_MARGIN_WIDTH) / 3)) + (vDaysCrctn * (pColWidth / 90)) - 1);
|
|
174
|
+
}
|
|
175
|
+
else if (pFormat == 'hour') {
|
|
176
|
+
// can't just calculate sum because of daylight savings changes
|
|
177
|
+
vPosTmpDate = new Date(curTaskEnd.getTime());
|
|
178
|
+
vPosTmpDate.setMinutes(curTaskStart.getMinutes(), 0);
|
|
179
|
+
var vMinsCrctn = (curTaskEnd.getTime() - vPosTmpDate.getTime()) / (3600000);
|
|
180
|
+
vTaskRightPx = Math.ceil((vTaskRight * (pColWidth + HOUR_CELL_MARGIN_WIDTH)) + (vMinsCrctn * (pColWidth)));
|
|
181
|
+
}
|
|
182
|
+
return vTaskRightPx;
|
|
183
|
+
};
|
|
184
|
+
exports.getOffset = getOffset;
|
|
185
|
+
var isIE = function () {
|
|
186
|
+
if (typeof document.all != 'undefined') {
|
|
187
|
+
if ('pageXOffset' in window)
|
|
188
|
+
return false; // give IE9 and above the benefit of the doubt!
|
|
189
|
+
else
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
else
|
|
193
|
+
return false;
|
|
194
|
+
};
|
|
195
|
+
exports.isIE = isIE;
|
|
196
|
+
var hideToolTip = function (pGanttChartObj, pTool, pTimer) {
|
|
197
|
+
if (pGanttChartObj.getUseFade()) {
|
|
198
|
+
clearInterval(pTool.fadeInterval);
|
|
199
|
+
pTool.fadeInterval = setInterval(function () { (0, exports.fadeToolTip)(-1, pTool, 0); }, pTimer);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
pTool.style.opacity = 0;
|
|
203
|
+
pTool.style.filter = 'alpha(opacity=0)';
|
|
204
|
+
pTool.style.visibility = 'hidden';
|
|
205
|
+
pTool.vToolCont.setAttribute("showing", null);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
exports.hideToolTip = hideToolTip;
|
|
209
|
+
var fadeToolTip = function (pDirection, pTool, pMaxAlpha) {
|
|
210
|
+
var vIncrement = parseInt(pTool.getAttribute('fadeIncrement'));
|
|
211
|
+
var vAlpha = pTool.getAttribute('currentOpacity');
|
|
212
|
+
var vCurAlpha = parseInt(vAlpha);
|
|
213
|
+
if ((vCurAlpha != pMaxAlpha && pDirection == 1) || (vCurAlpha != 0 && pDirection == -1)) {
|
|
214
|
+
var i = vIncrement;
|
|
215
|
+
if (pMaxAlpha - vCurAlpha < vIncrement && pDirection == 1) {
|
|
216
|
+
i = pMaxAlpha - vCurAlpha;
|
|
217
|
+
}
|
|
218
|
+
else if (vAlpha < vIncrement && pDirection == -1) {
|
|
219
|
+
i = vCurAlpha;
|
|
220
|
+
}
|
|
221
|
+
vAlpha = vCurAlpha + (i * pDirection);
|
|
222
|
+
pTool.style.opacity = vAlpha * 0.01;
|
|
223
|
+
pTool.style.filter = 'alpha(opacity=' + vAlpha + ')';
|
|
224
|
+
pTool.setAttribute('currentOpacity', vAlpha);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
clearInterval(pTool.fadeInterval);
|
|
228
|
+
if (pDirection == -1) {
|
|
229
|
+
pTool.style.opacity = 0;
|
|
230
|
+
pTool.style.filter = 'alpha(opacity=0)';
|
|
231
|
+
pTool.style.visibility = 'hidden';
|
|
232
|
+
pTool.vToolCont.setAttribute("showing", null);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
exports.fadeToolTip = fadeToolTip;
|
|
237
|
+
var hashString = function (key) {
|
|
238
|
+
if (!key) {
|
|
239
|
+
key = 'default';
|
|
240
|
+
}
|
|
241
|
+
key += '';
|
|
242
|
+
var hash = 5381;
|
|
243
|
+
for (var i = 0; i < key.length; i++) {
|
|
244
|
+
if (key.charCodeAt) {
|
|
245
|
+
// tslint:disable-next-line:no-bitwise
|
|
246
|
+
hash = (hash << 5) + hash + key.charCodeAt(i);
|
|
247
|
+
}
|
|
248
|
+
// tslint:disable-next-line:no-bitwise
|
|
249
|
+
hash = hash & hash;
|
|
250
|
+
}
|
|
251
|
+
// tslint:disable-next-line:no-bitwise
|
|
252
|
+
return hash >>> 0;
|
|
253
|
+
};
|
|
254
|
+
exports.hashString = hashString;
|
|
255
|
+
var hashKey = function (key) {
|
|
256
|
+
return (0, exports.hashString)(key);
|
|
257
|
+
};
|
|
258
|
+
exports.hashKey = hashKey;
|
|
259
|
+
var criticalPath = function (tasks) {
|
|
260
|
+
var path = {};
|
|
261
|
+
// calculate duration
|
|
262
|
+
tasks.forEach(function (task) {
|
|
263
|
+
task.duration = new Date(task.pEnd).getTime() - new Date(task.pStart).getTime();
|
|
264
|
+
});
|
|
265
|
+
tasks.forEach(function (task) {
|
|
266
|
+
if (!path[task.pID]) {
|
|
267
|
+
path[task.pID] = task;
|
|
268
|
+
}
|
|
269
|
+
if (!path[task.pParent]) {
|
|
270
|
+
path[task.pParent] = {
|
|
271
|
+
childrens: []
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
if (!path[task.pID].childrens) {
|
|
275
|
+
path[task.pID].childrens = [];
|
|
276
|
+
}
|
|
277
|
+
path[task.pParent].childrens.push(task);
|
|
278
|
+
var max = path[task.pParent].childrens[0].duration;
|
|
279
|
+
path[task.pParent].childrens.forEach(function (t) {
|
|
280
|
+
if (t.duration > max) {
|
|
281
|
+
max = t.duration;
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
path[task.pParent].duration = max;
|
|
285
|
+
});
|
|
286
|
+
var finalNodes = { 0: path[0] };
|
|
287
|
+
var node = path[0];
|
|
288
|
+
var _loop_1 = function () {
|
|
289
|
+
if (node.childrens.length > 0) {
|
|
290
|
+
var found_1 = node.childrens[0];
|
|
291
|
+
var max_1 = found_1.duration;
|
|
292
|
+
node.childrens.forEach(function (c) {
|
|
293
|
+
if (c.duration > max_1) {
|
|
294
|
+
found_1 = c;
|
|
295
|
+
max_1 = c.duration;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
finalNodes[found_1.pID] = found_1;
|
|
299
|
+
node = found_1;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
node = null;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
while (node) {
|
|
306
|
+
_loop_1();
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
exports.criticalPath = criticalPath;
|
|
310
|
+
function isParentElementOrSelf(child, parent) {
|
|
311
|
+
while (child) {
|
|
312
|
+
if (child === parent)
|
|
313
|
+
return true;
|
|
314
|
+
child = child.parentElement;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
exports.isParentElementOrSelf = isParentElementOrSelf;
|
|
318
|
+
var updateFlyingObj = function (e, pGanttChartObj, pTimer) {
|
|
319
|
+
var documentElement = document.documentElement;
|
|
320
|
+
var bodyElement = document.getElementsByTagName('body')[0];
|
|
321
|
+
var vCurTopBuf = 3;
|
|
322
|
+
var vCurLeftBuf = 5;
|
|
323
|
+
var vCurBotBuf = 3;
|
|
324
|
+
var vCurRightBuf = 15;
|
|
325
|
+
var vMouseX = (e) ? e.clientX : window.event.clientX;
|
|
326
|
+
var vMouseY = (e) ? e.clientY : window.event.clientY;
|
|
327
|
+
var vViewportX = (documentElement === null || documentElement === void 0 ? void 0 : documentElement.clientWidth) || (bodyElement === null || bodyElement === void 0 ? void 0 : bodyElement.clientWidth);
|
|
328
|
+
var vViewportY = (documentElement === null || documentElement === void 0 ? void 0 : documentElement.clientHeight) || (bodyElement === null || bodyElement === void 0 ? void 0 : bodyElement.clientHeight);
|
|
329
|
+
var vNewX = vMouseX;
|
|
330
|
+
var vNewY = vMouseY;
|
|
331
|
+
var screenX = screen.availWidth || window.innerWidth;
|
|
332
|
+
var screenY = screen.availHeight || window.innerHeight;
|
|
333
|
+
var vOldX = parseInt(pGanttChartObj.vTool.style.left);
|
|
334
|
+
var vOldY = parseInt(pGanttChartObj.vTool.style.top);
|
|
335
|
+
if (navigator.appName.toLowerCase() == 'microsoft internet explorer') {
|
|
336
|
+
// the clientX and clientY properties include the left and top borders of the client area
|
|
337
|
+
vMouseX -= documentElement === null || documentElement === void 0 ? void 0 : documentElement.clientLeft;
|
|
338
|
+
vMouseY -= documentElement === null || documentElement === void 0 ? void 0 : documentElement.clientTop;
|
|
339
|
+
var vZoomFactor = (0, exports.getZoomFactor)();
|
|
340
|
+
if (vZoomFactor != 1) { // IE 7 at non-default zoom level
|
|
341
|
+
vMouseX = Math.round(vMouseX / vZoomFactor);
|
|
342
|
+
vMouseY = Math.round(vMouseY / vZoomFactor);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
var vScrollPos = (0, exports.getScrollPositions)();
|
|
346
|
+
/* Code for positioned right of the mouse by default*/
|
|
347
|
+
/*
|
|
348
|
+
if (vMouseX+vCurRightBuf+pGanttChartObj.vTool.offsetWidth>vViewportX)
|
|
349
|
+
{
|
|
350
|
+
if (vMouseX-vCurLeftBuf-pGanttChartObj.vTool.offsetWidth<0) vNewX=vScrollPos.x;
|
|
351
|
+
else vNewX=vMouseX+vScrollPos.x-vCurLeftBuf-pGanttChartObj.vTool.offsetWidth;
|
|
352
|
+
}
|
|
353
|
+
else vNewX=vMouseX+vScrollPos.x+vCurRightBuf;
|
|
354
|
+
*/
|
|
355
|
+
/* Code for positioned left of the mouse by default */
|
|
356
|
+
if (vMouseX - vCurLeftBuf - pGanttChartObj.vTool.offsetWidth < 0) {
|
|
357
|
+
if (vMouseX + vCurRightBuf + pGanttChartObj.vTool.offsetWidth > vViewportX)
|
|
358
|
+
vNewX = vScrollPos.x;
|
|
359
|
+
else
|
|
360
|
+
vNewX = vMouseX + vScrollPos.x + vCurRightBuf;
|
|
361
|
+
}
|
|
362
|
+
else
|
|
363
|
+
vNewX = vMouseX + vScrollPos.x - vCurLeftBuf - pGanttChartObj.vTool.offsetWidth;
|
|
364
|
+
/* Code for positioned below the mouse by default */
|
|
365
|
+
if (vMouseY + vCurBotBuf + pGanttChartObj.vTool.offsetHeight > vViewportY) {
|
|
366
|
+
if (vMouseY - vCurTopBuf - pGanttChartObj.vTool.offsetHeight < 0)
|
|
367
|
+
vNewY = vScrollPos.y;
|
|
368
|
+
else
|
|
369
|
+
vNewY = vMouseY + vScrollPos.y - vCurTopBuf - pGanttChartObj.vTool.offsetHeight;
|
|
370
|
+
}
|
|
371
|
+
else
|
|
372
|
+
vNewY = vMouseY + vScrollPos.y + vCurBotBuf;
|
|
373
|
+
/* Code for positioned above the mouse by default */
|
|
374
|
+
/*
|
|
375
|
+
if (vMouseY-vCurTopBuf-pGanttChartObj.vTool.offsetHeight<0)
|
|
376
|
+
{
|
|
377
|
+
if (vMouseY+vCurBotBuf+pGanttChartObj.vTool.offsetHeight>vViewportY) vNewY=vScrollPos.y;
|
|
378
|
+
else vNewY=vMouseY+vScrollPos.y+vCurBotBuf;
|
|
379
|
+
}
|
|
380
|
+
else vNewY=vMouseY+vScrollPos.y-vCurTopBuf-pGanttChartObj.vTool.offsetHeight;
|
|
381
|
+
*/
|
|
382
|
+
var outViewport = Math.abs(vOldX - vNewX) > screenX || Math.abs(vOldY - vNewY) > screenY;
|
|
383
|
+
if (pGanttChartObj.getUseMove() && !outViewport) {
|
|
384
|
+
clearInterval(pGanttChartObj.vTool.moveInterval);
|
|
385
|
+
pGanttChartObj.vTool.moveInterval = setInterval(function () { (0, exports.moveToolTip)(vNewX, vNewY, pGanttChartObj.vTool, pTimer); }, pTimer);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
pGanttChartObj.vTool.style.left = vNewX + 'px';
|
|
389
|
+
pGanttChartObj.vTool.style.top = vNewY + 'px';
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
exports.updateFlyingObj = updateFlyingObj;
|
|
393
|
+
var moveToolTip = function (pNewX, pNewY, pTool, timer) {
|
|
394
|
+
var vSpeed = parseInt(pTool.getAttribute('moveSpeed'));
|
|
395
|
+
var vOldX = parseInt(pTool.style.left);
|
|
396
|
+
var vOldY = parseInt(pTool.style.top);
|
|
397
|
+
if (pTool.style.visibility != 'visible') {
|
|
398
|
+
pTool.style.left = pNewX + 'px';
|
|
399
|
+
pTool.style.top = pNewY + 'px';
|
|
400
|
+
clearInterval(pTool.moveInterval);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
if (pNewX != vOldX && pNewY != vOldY) {
|
|
404
|
+
vOldX += Math.ceil((pNewX - vOldX) / vSpeed);
|
|
405
|
+
vOldY += Math.ceil((pNewY - vOldY) / vSpeed);
|
|
406
|
+
pTool.style.left = vOldX + 'px';
|
|
407
|
+
pTool.style.top = vOldY + 'px';
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
clearInterval(pTool.moveInterval);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
exports.moveToolTip = moveToolTip;
|
|
415
|
+
var makeRequest = function (pFile, json, vDebug) {
|
|
416
|
+
if (json === void 0) { json = true; }
|
|
417
|
+
if (vDebug === void 0) { vDebug = false; }
|
|
418
|
+
if (window.fetch) {
|
|
419
|
+
var f = fetch(pFile);
|
|
420
|
+
if (json) {
|
|
421
|
+
return f.then(function (res) { return res.json(); });
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
return f;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
return (0, exports.makeRequestOldBrowsers)(pFile, vDebug)
|
|
429
|
+
.then(function (xhttp) {
|
|
430
|
+
if (json) {
|
|
431
|
+
var jsonObj = JSON.parse(xhttp.response);
|
|
432
|
+
return jsonObj;
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
var xmlDoc = xhttp.responseXML;
|
|
436
|
+
return xmlDoc;
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
exports.makeRequest = makeRequest;
|
|
442
|
+
var makeRequestOldBrowsers = function (pFile, vDebug) {
|
|
443
|
+
if (vDebug === void 0) { vDebug = false; }
|
|
444
|
+
return new Promise(function (resolve, reject) {
|
|
445
|
+
var bd;
|
|
446
|
+
if (vDebug) {
|
|
447
|
+
bd = new Date();
|
|
448
|
+
console.info('before jsonparse', bd);
|
|
449
|
+
}
|
|
450
|
+
var xhttp;
|
|
451
|
+
if (window.XMLHttpRequest) {
|
|
452
|
+
xhttp = new XMLHttpRequest();
|
|
453
|
+
}
|
|
454
|
+
else { // IE 5/6
|
|
455
|
+
xhttp = new window.ActiveXObject('Microsoft.XMLHTTP');
|
|
456
|
+
}
|
|
457
|
+
xhttp.open('GET', pFile, true);
|
|
458
|
+
xhttp.send(null);
|
|
459
|
+
xhttp.onload = function (e) {
|
|
460
|
+
if (xhttp.readyState === 4) {
|
|
461
|
+
if (xhttp.status === 200) {
|
|
462
|
+
// resolve(xhttp.responseText);
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
console.error(xhttp.statusText);
|
|
466
|
+
}
|
|
467
|
+
if (vDebug) {
|
|
468
|
+
bd = new Date();
|
|
469
|
+
console.info('before jsonparse', bd);
|
|
470
|
+
}
|
|
471
|
+
resolve(xhttp);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
xhttp.onerror = function (e) {
|
|
475
|
+
reject(xhttp.statusText);
|
|
476
|
+
};
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
exports.makeRequestOldBrowsers = makeRequestOldBrowsers;
|
|
480
|
+
var calculateStartEndFromDepend = function (tasksList) {
|
|
481
|
+
};
|
|
482
|
+
exports.calculateStartEndFromDepend = calculateStartEndFromDepend;
|
|
483
|
+
var printChart = function (width, height, css) {
|
|
484
|
+
if (css === void 0) { css = undefined; }
|
|
485
|
+
if (css === undefined) {
|
|
486
|
+
css = // Default injected CSS
|
|
487
|
+
"@media print {\n @page {\n size: ".concat(width, "mm ").concat(height, "mm;\n }\n /* set gantt container to the same width as the page */\n .gchartcontainer {\n width: ").concat(width, "mm;\n }\n };");
|
|
488
|
+
}
|
|
489
|
+
var $container = document.querySelector('.gchartcontainer');
|
|
490
|
+
$container.insertAdjacentHTML('afterbegin', "<style>".concat(css, "</style>"));
|
|
491
|
+
// Remove the print CSS when the print dialog is closed
|
|
492
|
+
window.addEventListener('afterprint', function () {
|
|
493
|
+
$container.removeChild($container.children[0]);
|
|
494
|
+
}, { 'once': true });
|
|
495
|
+
// Trigger the print
|
|
496
|
+
window.print();
|
|
497
|
+
};
|
|
498
|
+
exports.printChart = printChart;
|