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 | 1×
1×
1×
1×
1×
1×
1×
1118×
1118×
1118×
1118×
1118×
1118×
1118×
1118×
1×
1×
5×
5×
5×
5×
5×
5×
5×
5×
1×
1×
5×
5×
1×
1×
2×
2×
1×
1×
4671×
4671×
4671×
1×
1×
822×
822×
822×
1×
1×
1031×
1×
1×
6199×
1×
1×
508×
508×
508×
508×
1×
1×
12×
1×
1×
83885×
83885×
83885×
83885×
83885×
1×
1×
2778521×
1×
1×
1843200×
1843200×
1843200×
1843200×
1×
1×
2084×
1×
1×
206162×
206162×
1×
1×
3330×
3330×
3330×
3330×
3330×
3330×
1×
1×
6×
6×
6×
6×
6×
6×
1×
1×
59212×
59212×
59212×
59212×
59212×
59212×
57213×
1999×
1999×
1999×
59212×
1×
1×
3339×
1×
1×
2119×
2119×
2119×
1×
1×
112×
1×
1×
1×
1×
3524×
3522×
2×
1×
2×
2×
2×
2×
2×
2×
2×
2×
1×
1×
6×
6×
1×
1×
1×
1×
11964×
42588×
11950×
49×
49×
49×
49×
49×
11901×
14×
1×
1×
3237×
3237×
1×
1×
5049×
5049×
5855×
5855×
1×
1×
89744×
89744×
89744×
1×
1×
101828×
101828×
101828×
101828×
101828×
101828×
101828×
101828×
1×
1×
6×
1×
1×
907×
1×
1×
68518×
37036×
58621×
58621×
18142×
18142×
58621×
68518×
1×
1×
6493×
1×
1×
6151×
1×
1×
3×
1×
| define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WEEK_LENGTH = 7;
exports.DEFAULT_WEEKS = 6;
exports.MS_PER_DAY = 86400000;
exports.MS_PER_MINUTE = 60000;
function getElementHeightFromClass(container, elementClass, isTransformed) {
var height = 0;
var el = ej2_base_1.createElement('div', { className: elementClass }).cloneNode();
el.style.visibility = 'hidden';
el.style.position = 'absolute';
container.appendChild(el);
height = getElementHeight(el, isTransformed);
ej2_base_1.remove(el);
return height;
}
exports.getElementHeightFromClass = getElementHeightFromClass;
function getElementWidthFromClass(container, elementClass, isTransformed) {
var width = 0;
var el = ej2_base_1.createElement('div', { className: elementClass }).cloneNode();
el.style.visibility = 'hidden';
el.style.position = 'absolute';
container.appendChild(el);
width = getElementWidth(el, isTransformed);
ej2_base_1.remove(el);
return width;
}
exports.getElementWidthFromClass = getElementWidthFromClass;
function getTranslateY(element) {
var style = getComputedStyle(element);
return window.WebKitCSSMatrix ?
new WebKitCSSMatrix(style.webkitTransform).m42 : 0;
}
exports.getTranslateY = getTranslateY;
function getTranslateX(element) {
var style = getComputedStyle(element);
return window.WebKitCSSMatrix ?
new WebKitCSSMatrix(style.webkitTransform).m41 : 0;
}
exports.getTranslateX = getTranslateX;
function getWeekFirstDate(date, firstDayOfWeek) {
var date1 = new Date(date.getTime());
firstDayOfWeek = (firstDayOfWeek - date1.getDay() + 7 * (-1)) % 7;
return new Date(date1.setDate(date1.getDate() + (isNaN(firstDayOfWeek) ? 0 : firstDayOfWeek)));
}
exports.getWeekFirstDate = getWeekFirstDate;
function getWeekLastDate(date, firstDayOfWeek) {
var weekFirst = getWeekFirstDate(date, firstDayOfWeek);
var weekLast = new Date(weekFirst.getFullYear(), weekFirst.getMonth(), weekFirst.getDate() + 6);
return new Date(weekLast.getTime());
}
exports.getWeekLastDate = getWeekLastDate;
function firstDateOfMonth(date) {
return new Date(date.getFullYear(), date.getMonth(), 1);
}
exports.firstDateOfMonth = firstDateOfMonth;
function lastDateOfMonth(date) {
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
}
exports.lastDateOfMonth = lastDateOfMonth;
function getWeekNumber(date) {
var date1 = new Date(date.getFullYear(), 0, 1).valueOf();
var currentDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()).valueOf();
var dayOfYear = ((currentDate - date1 + exports.MS_PER_DAY) / exports.MS_PER_DAY);
return Math.ceil(dayOfYear / 7);
}
exports.getWeekNumber = getWeekNumber;
function getWeekMiddleDate(weekFirst, weekLast) {
return new Date(weekLast.valueOf() - ((weekLast.valueOf() - weekFirst.valueOf()) / 2));
}
exports.getWeekMiddleDate = getWeekMiddleDate;
function setTime(date, time) {
var tzOffsetBefore = date.getTimezoneOffset();
var d = new Date(date.getTime() + time);
var tzOffsetDiff = d.getTimezoneOffset() - tzOffsetBefore;
date.setTime(d.getTime() + tzOffsetDiff * exports.MS_PER_MINUTE);
return date;
}
exports.setTime = setTime;
function resetTime(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
exports.resetTime = resetTime;
function getDateInMs(date) {
var localOffset = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0).getTimezoneOffset();
var dateOffset = date.getTimezoneOffset();
var timezoneOffset = dateOffset - localOffset;
return ((date.getTime() - new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0).getTime())
- (timezoneOffset * 60 * 1000));
}
exports.getDateInMs = getDateInMs;
function getDateCount(startDate, endDate) {
return Math.ceil((endDate.getTime() - startDate.getTime()) / exports.MS_PER_DAY);
}
exports.getDateCount = getDateCount;
function addDays(date, noOfDays) {
date = new Date('' + date);
return new Date(date.setDate(date.getDate() + noOfDays));
}
exports.addDays = addDays;
function addMonths(date, noOfMonths) {
date = new Date('' + date);
var day = date.getDate();
date.setDate(1);
date.setMonth(date.getMonth() + noOfMonths);
date.setDate(Math.min(day, getMaxDays(date)));
return date;
}
exports.addMonths = addMonths;
function addYears(date, noOfYears) {
date = new Date('' + date);
var day = date.getDate();
date.setDate(1);
date.setFullYear(date.getFullYear() + noOfYears);
date.setDate(Math.min(day, getMaxDays(date)));
return date;
}
exports.addYears = addYears;
function getStartEndHours(date, startHour, endHour) {
var date1 = new Date(date.getTime());
date1.setHours(startHour.getHours());
date1.setMinutes(startHour.getMinutes());
date1.setSeconds(startHour.getSeconds());
var date2 = new Date(date.getTime());
if (endHour.getHours() === 0) {
date2 = addDays(date2, 1);
}
else {
date2.setHours(endHour.getHours());
date2.setMinutes(endHour.getMinutes());
date2.setSeconds(endHour.getSeconds());
}
return { startHour: date1, endHour: date2 };
}
exports.getStartEndHours = getStartEndHours;
function getMaxDays(date) {
return lastDateOfMonth(date).getDate();
}
exports.getMaxDays = getMaxDays;
function getDaysCount(startDate, endDate) {
var strTime = resetTime(new Date(startDate));
var endTime = resetTime(new Date(endDate));
return Math.round((endTime.getTime() - strTime.getTime()) / exports.MS_PER_DAY);
}
exports.getDaysCount = getDaysCount;
function getDateFromString(date) {
return date.indexOf('Date') !== -1 ? new Date(parseInt(date.match(/\d+/g).toString(), 10)) :
date.indexOf('T') !== -1 ? new Date(date) : new Date(date.replace(/-/g, '/'));
}
exports.getDateFromString = getDateFromString;
var scrollWidth = null;
var pixelRatio = null;
function getScrollBarWidth() {
if (scrollWidth !== null) {
return scrollWidth;
}
if (pixelRatio === null) {
pixelRatio = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth;
}
var divNode = ej2_base_1.createElement('div');
var value = 0;
divNode.style.cssText = 'width:100px;height: 100px;overflow: scroll;position: absolute;top: -9999px;';
document.body.appendChild(divNode);
var ratio = (devicePixelRatio) ? (devicePixelRatio.toFixed(2) === '1.10' || devicePixelRatio <= 1) ?
Math.ceil(devicePixelRatio % 1) : Math.floor(devicePixelRatio % 1) : 0;
value = (divNode.offsetWidth - divNode.clientWidth - ratio) | 0;
document.body.removeChild(divNode);
return scrollWidth = value;
}
exports.getScrollBarWidth = getScrollBarWidth;
function resetScrollbarWidth() {
var zoomPixelRatio = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth;
if (pixelRatio && pixelRatio !== zoomPixelRatio) {
scrollWidth = null;
pixelRatio = zoomPixelRatio;
}
}
exports.resetScrollbarWidth = resetScrollbarWidth;
function findIndexInData(data, field, value, event, resourceCollection) {
for (var i = 0, length_1 = data.length; i < length_1; i++) {
if (data[parseInt(i.toString(), 10)]["" + field] === value) {
if (event) {
var field_1 = resourceCollection.slice(-2)[0].field;
var res = (event["" + field_1] instanceof Array ? event["" + field_1] : [event["" + field_1]]);
var resData = res.join(',');
Eif (resData.includes(data[parseInt(i.toString(), 10)][resourceCollection.slice(-1)[0].groupIDField])) {
return i;
}
}
else {
return i;
}
}
}
return -1;
}
exports.findIndexInData = findIndexInData;
function getOuterHeight(element) {
var style = getComputedStyle(element);
return element.offsetHeight + (parseInt(style.marginTop, 10) || 0) + (parseInt(style.marginBottom, 10) || 0);
}
exports.getOuterHeight = getOuterHeight;
function removeChildren(element) {
var elementChildren = [].slice.call(element.children);
for (var _i = 0, elementChildren_1 = elementChildren; _i < elementChildren_1.length; _i++) {
var elementChild = elementChildren_1[_i];
element.removeChild(elementChild);
}
}
exports.removeChildren = removeChildren;
function isDaylightSavingTime(date) {
var jan = new Date(date.getFullYear(), 0, 1);
var jul = new Date(date.getFullYear(), 6, 1);
return date.getTimezoneOffset() < Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
}
exports.isDaylightSavingTime = isDaylightSavingTime;
function getUniversalTime(date) {
var year = date.getFullYear();
var month = date.getMonth();
var day = date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var milliseconds = date.getMilliseconds();
return Date.UTC(year, month, day, hours, minutes, seconds, milliseconds);
}
exports.getUniversalTime = getUniversalTime;
function isMobile() {
return window.navigator.userAgent.toLowerCase().indexOf('mobi') > -1;
}
exports.isMobile = isMobile;
function isIPadDevice() {
return window.navigator.userAgent.toLowerCase().indexOf('ipad') > -1;
}
exports.isIPadDevice = isIPadDevice;
function capitalizeFirstWord(inputString, type) {
if (type === 'multiple') {
inputString = inputString.split(' ').map(function (e) { return e.charAt(0).toLocaleUpperCase() + e.substring(1); }).join(' ');
}
else Eif (type === 'single') {
if (inputString[0] >= '0' && inputString[0] <= '9') {
var array = inputString.match(/[a-zA-Z]/);
inputString = ej2_base_1.isNullOrUndefined(array) ? inputString :
inputString.slice(0, array.index) + inputString[array.index].toLocaleUpperCase() + inputString.slice(array.index + 1);
}
inputString = inputString[0].toLocaleUpperCase() + inputString.slice(1);
}
return inputString;
}
exports.capitalizeFirstWord = capitalizeFirstWord;
function getElementWidth(element, isTransformed) {
return isTransformed ? element.offsetWidth : element.getBoundingClientRect().width;
}
exports.getElementWidth = getElementWidth;
function getElementHeight(element, isTransformed) {
return isTransformed ? element.offsetHeight : element.getBoundingClientRect().height;
}
exports.getElementHeight = getElementHeight;
function getElementTop(element, isTransformed) {
return isTransformed ? element.offsetTop : element.getBoundingClientRect().top;
}
exports.getElementTop = getElementTop;
});
|