histropediajs 1.6.0 → 1.6.2
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/README.md +1 -0
- package/dist/histropedia.esm.js +1913 -1895
- package/dist/histropedia.umd.js +1921 -1903
- package/dist/histropedia.umd.min.js +2 -2
- package/index.d.ts +9 -1
- package/package.json +3 -3
package/dist/histropedia.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
HistropediaJS v1.6.
|
|
2
|
+
HistropediaJS v1.6.2 | Histropedia Ltd. (c) 2026 | https://js.histropedia.com
|
|
3
3
|
Use of this software is subject to our End User Licence Agreement: https://js.histropedia.com/licence.html
|
|
4
4
|
*/
|
|
5
5
|
(function(global, factory) {
|
|
@@ -87,1791 +87,42 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
__name(tween, "tween");
|
|
90
|
-
const
|
|
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
|
-
_withPrefixedArgs(argsArray) {
|
|
128
|
-
if (!this._prefix) {
|
|
129
|
-
return argsArray;
|
|
130
|
-
}
|
|
131
|
-
if (argsArray && argsArray.length > 0 && typeof argsArray[0] === "string") {
|
|
132
|
-
const cloned = argsArray.slice();
|
|
133
|
-
cloned[0] = `${this._prefix} ${cloned[0]}`;
|
|
134
|
-
return cloned;
|
|
135
|
-
}
|
|
136
|
-
return [this._prefix, ...argsArray];
|
|
137
|
-
}
|
|
138
|
-
_log(method, args) {
|
|
139
|
-
if (!this._enabled) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const fn = this._fns[method] || this._fns.log;
|
|
143
|
-
fn(...this._withPrefixedArgs(args));
|
|
144
|
-
}
|
|
145
|
-
log(...args) {
|
|
146
|
-
this._log("log", args);
|
|
147
|
-
}
|
|
148
|
-
warn(...args) {
|
|
149
|
-
this._log("warn", args);
|
|
150
|
-
}
|
|
151
|
-
error(...args) {
|
|
152
|
-
this._log("error", args);
|
|
153
|
-
}
|
|
154
|
-
info(...args) {
|
|
155
|
-
this._log("info", args);
|
|
156
|
-
}
|
|
157
|
-
debug(...args) {
|
|
158
|
-
this._log("debug", args);
|
|
159
|
-
}
|
|
160
|
-
group(...args) {
|
|
161
|
-
if (!this._enabled) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
this._fns.group(...this._withPrefixedArgs(args));
|
|
165
|
-
}
|
|
166
|
-
groupCollapsed(...args) {
|
|
167
|
-
if (!this._enabled) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
this._fns.groupCollapsed(...this._withPrefixedArgs(args));
|
|
171
|
-
}
|
|
172
|
-
groupEnd() {
|
|
173
|
-
if (!this._enabled) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
this._fns.groupEnd();
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
__name(_LoggerImpl, "LoggerImpl");
|
|
180
|
-
let LoggerImpl = _LoggerImpl;
|
|
181
|
-
const Logger = new LoggerImpl();
|
|
182
|
-
const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
183
|
-
const MONTH_NAMES = [
|
|
184
|
-
"Jan",
|
|
185
|
-
"Feb",
|
|
186
|
-
"Mar",
|
|
187
|
-
"Apr",
|
|
188
|
-
"May",
|
|
189
|
-
"Jun",
|
|
190
|
-
"Jul",
|
|
191
|
-
"Aug",
|
|
192
|
-
"Sep",
|
|
193
|
-
"Oct",
|
|
194
|
-
"Nov",
|
|
195
|
-
"Dec"
|
|
196
|
-
];
|
|
197
|
-
const LEGACY_PRECISIONS = {
|
|
198
|
-
1: "billion-years",
|
|
199
|
-
3: "million-years",
|
|
200
|
-
6: "millennium",
|
|
201
|
-
7: "century",
|
|
202
|
-
8: "decade",
|
|
203
|
-
9: "year",
|
|
204
|
-
10: "month",
|
|
205
|
-
11: "day",
|
|
206
|
-
12: "hour",
|
|
207
|
-
13: "minute",
|
|
208
|
-
14: "second",
|
|
209
|
-
15: "millisecond"
|
|
210
|
-
};
|
|
211
|
-
const DMY_STRING_PATTERN = /^(-?\d+)(?:-(\d{1,2}))?(?:-(\d{1,2}))?(?:[T ](\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?$/;
|
|
212
|
-
const MILLISECONDS_PER_SECOND = 1e3;
|
|
213
|
-
const MILLISECONDS_PER_MINUTE = 60 * MILLISECONDS_PER_SECOND;
|
|
214
|
-
const MILLISECONDS_PER_HOUR = 60 * MILLISECONDS_PER_MINUTE;
|
|
215
|
-
const MILLISECONDS_PER_DAY = 24 * MILLISECONDS_PER_HOUR;
|
|
216
|
-
function normalizePrecision(precision) {
|
|
217
|
-
return Object.prototype.hasOwnProperty.call(LEGACY_PRECISIONS, precision) ? LEGACY_PRECISIONS[precision] : precision || "day";
|
|
218
|
-
}
|
|
219
|
-
__name(normalizePrecision, "normalizePrecision");
|
|
220
|
-
function getHistoricalPeriodBounds(year, size) {
|
|
221
|
-
const endYear = Math.ceil(year / size) * size;
|
|
222
|
-
return {
|
|
223
|
-
startYear: endYear - size + 1,
|
|
224
|
-
endYear
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
__name(getHistoricalPeriodBounds, "getHistoricalPeriodBounds");
|
|
228
|
-
function clampInteger(value, fallback, minimum, maximum) {
|
|
229
|
-
const parsed = Number(value);
|
|
230
|
-
if (!Number.isFinite(parsed)) {
|
|
231
|
-
return fallback;
|
|
232
|
-
}
|
|
233
|
-
return Math.min(maximum, Math.max(minimum, Math.trunc(parsed)));
|
|
234
|
-
}
|
|
235
|
-
__name(clampInteger, "clampInteger");
|
|
236
|
-
function setTimeParts(target, hour, minute, second, millisecond) {
|
|
237
|
-
const values = {
|
|
238
|
-
hour: clampInteger(hour, 0, 0, 23),
|
|
239
|
-
minute: clampInteger(minute, 0, 0, 59),
|
|
240
|
-
second: clampInteger(second, 0, 0, 59),
|
|
241
|
-
millisecond: clampInteger(millisecond, 0, 0, 999)
|
|
242
|
-
};
|
|
243
|
-
for (const [key, value] of Object.entries(values)) {
|
|
244
|
-
Object.defineProperty(target, key, {
|
|
245
|
-
value,
|
|
246
|
-
enumerable: value !== 0,
|
|
247
|
-
configurable: true,
|
|
248
|
-
writable: true
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
__name(setTimeParts, "setTimeParts");
|
|
253
|
-
function setPrecision(target, precision) {
|
|
254
|
-
if (precision === void 0) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
Object.defineProperty(target, "precision", {
|
|
258
|
-
value: precision,
|
|
259
|
-
enumerable: false,
|
|
260
|
-
configurable: true,
|
|
261
|
-
writable: true
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
__name(setPrecision, "setPrecision");
|
|
265
|
-
function createAdjustedDmy(source, values) {
|
|
266
|
-
return new Dmy(__spreadProps(__spreadValues({}, values), { precision: source.precision }));
|
|
267
|
-
}
|
|
268
|
-
__name(createAdjustedDmy, "createAdjustedDmy");
|
|
269
|
-
function Dmy(year, month, day, hour, minute, second, millisecond) {
|
|
270
|
-
if (typeof year === "object") {
|
|
271
|
-
const options = year;
|
|
272
|
-
this.year = options.year;
|
|
273
|
-
this.month = options.month;
|
|
274
|
-
this.day = getCorrectDay(options.year, options.month, options.day);
|
|
275
|
-
setTimeParts(this, options.hour, options.minute, options.second, options.millisecond);
|
|
276
|
-
setPrecision(this, options.precision);
|
|
277
|
-
} else {
|
|
278
|
-
this.year = year;
|
|
279
|
-
this.month = month;
|
|
280
|
-
this.day = getCorrectDay(year, month, day);
|
|
281
|
-
setTimeParts(this, hour, minute, second, millisecond);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
__name(Dmy, "Dmy");
|
|
285
|
-
function getCorrectDay(year, month, day) {
|
|
286
|
-
return day > 28 ? Math.min(day, daysInMonth(year, month)) : day;
|
|
287
|
-
}
|
|
288
|
-
__name(getCorrectDay, "getCorrectDay");
|
|
289
|
-
function daysInMonth(year, month) {
|
|
290
|
-
if (month === 2) {
|
|
291
|
-
if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
|
|
292
|
-
return 29;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return DAYS_IN_MONTH[month - 1];
|
|
296
|
-
}
|
|
297
|
-
__name(daysInMonth, "daysInMonth");
|
|
298
|
-
function digitGroupedNumber(number, separator) {
|
|
299
|
-
number = number.toString();
|
|
300
|
-
separator = typeof separator === "string" ? separator : ",";
|
|
301
|
-
if (number.length <= 4) {
|
|
302
|
-
return number;
|
|
303
|
-
}
|
|
304
|
-
return number.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
|
|
305
|
-
}
|
|
306
|
-
__name(digitGroupedNumber, "digitGroupedNumber");
|
|
307
|
-
Dmy.prototype.getDaysTo = function(other) {
|
|
308
|
-
const dayDifference = other.getDaysSinceYearZero() - this.getDaysSinceYearZero();
|
|
309
|
-
const timeDifference = other.getMillisecondsOfDay() - this.getMillisecondsOfDay();
|
|
310
|
-
return dayDifference + timeDifference / MILLISECONDS_PER_DAY;
|
|
311
|
-
};
|
|
312
|
-
Dmy.prototype.getMillisecondsOfDay = function() {
|
|
313
|
-
return this.hour * MILLISECONDS_PER_HOUR + this.minute * MILLISECONDS_PER_MINUTE + this.second * MILLISECONDS_PER_SECOND + this.millisecond;
|
|
314
|
-
};
|
|
315
|
-
Dmy.prototype.getMonthsTo = function(other) {
|
|
316
|
-
return this.getYearsTo(other) * 12;
|
|
317
|
-
};
|
|
318
|
-
Dmy.prototype.getYearsTo = function(other) {
|
|
319
|
-
let yearDiff = other.year - this.year;
|
|
320
|
-
yearDiff += (other.month - this.month) / 12 + (other.day - this.day) / 365.2422 + (other.getMillisecondsOfDay() - this.getMillisecondsOfDay()) / (MILLISECONDS_PER_DAY * 365.2422);
|
|
321
|
-
return yearDiff;
|
|
322
|
-
};
|
|
323
|
-
Dmy.prototype.getLeapYearsSinceYearZero = function() {
|
|
324
|
-
let year = this.year;
|
|
325
|
-
if (this.month < 3) {
|
|
326
|
-
year--;
|
|
327
|
-
}
|
|
328
|
-
return Math.floor(year / 4) - Math.floor(year / 100) + Math.floor(year / 400);
|
|
329
|
-
};
|
|
330
|
-
Dmy.prototype.getDaysSinceYearZero = function() {
|
|
331
|
-
const year = this.year;
|
|
332
|
-
let days = year * 365 + this.day;
|
|
333
|
-
for (let i = 0; i < this.month - 1; i++) {
|
|
334
|
-
days += DAYS_IN_MONTH[i];
|
|
335
|
-
}
|
|
336
|
-
days += this.getLeapYearsSinceYearZero();
|
|
337
|
-
return days;
|
|
338
|
-
};
|
|
339
|
-
Dmy.prototype.getDayOfYear = function() {
|
|
340
|
-
let dayOfYear = this.day;
|
|
341
|
-
for (let m = 1; m < this.month; m++) {
|
|
342
|
-
dayOfYear += daysInMonth(this.year, m);
|
|
343
|
-
}
|
|
344
|
-
return dayOfYear;
|
|
345
|
-
};
|
|
346
|
-
Dmy.getByDayOfYear = function(year, dayOfYear) {
|
|
347
|
-
const dmy = new Dmy(year, 1, 1);
|
|
348
|
-
let dim = DAYS_IN_MONTH[0];
|
|
349
|
-
for (let i = 0; i < dayOfYear - 1; i++) {
|
|
350
|
-
dmy.day++;
|
|
351
|
-
if (dmy.day > dim) {
|
|
352
|
-
dmy.day = 1;
|
|
353
|
-
dmy.month++;
|
|
354
|
-
if (dmy.month > 12) {
|
|
355
|
-
dmy.month = 1;
|
|
356
|
-
dmy.year++;
|
|
357
|
-
}
|
|
358
|
-
dim = dmy.month === 2 ? daysInMonth(dmy.year, dmy.month) : DAYS_IN_MONTH[dmy.month - 1];
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return dmy;
|
|
362
|
-
};
|
|
363
|
-
Dmy.prototype.getNextDay = function() {
|
|
364
|
-
return this.addDays(1);
|
|
365
|
-
};
|
|
366
|
-
Dmy.prototype.addDays = function(amount) {
|
|
367
|
-
let day = this.day;
|
|
368
|
-
let month = this.month;
|
|
369
|
-
let year = this.year;
|
|
370
|
-
const direction = amount < 0 ? -1 : 1;
|
|
371
|
-
let remaining = Math.abs(Math.trunc(amount));
|
|
372
|
-
while (remaining > 0) {
|
|
373
|
-
if (direction > 0) {
|
|
374
|
-
day++;
|
|
375
|
-
if (day > daysInMonth(year, month)) {
|
|
376
|
-
day = 1;
|
|
377
|
-
month++;
|
|
378
|
-
if (month > 12) {
|
|
379
|
-
month = 1;
|
|
380
|
-
year++;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
} else {
|
|
384
|
-
day--;
|
|
385
|
-
if (day < 1) {
|
|
386
|
-
month--;
|
|
387
|
-
if (month < 1) {
|
|
388
|
-
month = 12;
|
|
389
|
-
year--;
|
|
390
|
-
}
|
|
391
|
-
day = daysInMonth(year, month);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
remaining--;
|
|
395
|
-
}
|
|
396
|
-
return createAdjustedDmy(this, {
|
|
397
|
-
year,
|
|
398
|
-
month,
|
|
399
|
-
day,
|
|
400
|
-
hour: this.hour,
|
|
401
|
-
minute: this.minute,
|
|
402
|
-
second: this.second,
|
|
403
|
-
millisecond: this.millisecond
|
|
404
|
-
});
|
|
405
|
-
};
|
|
406
|
-
Dmy.prototype.addMilliseconds = function(amount) {
|
|
407
|
-
let date = this;
|
|
408
|
-
let milliseconds = this.getMillisecondsOfDay() + Math.trunc(amount);
|
|
409
|
-
while (milliseconds < 0) {
|
|
410
|
-
date = date.addDays(-1);
|
|
411
|
-
milliseconds += MILLISECONDS_PER_DAY;
|
|
412
|
-
}
|
|
413
|
-
while (milliseconds >= MILLISECONDS_PER_DAY) {
|
|
414
|
-
date = date.addDays(1);
|
|
415
|
-
milliseconds -= MILLISECONDS_PER_DAY;
|
|
416
|
-
}
|
|
417
|
-
const hour = Math.floor(milliseconds / MILLISECONDS_PER_HOUR);
|
|
418
|
-
milliseconds -= hour * MILLISECONDS_PER_HOUR;
|
|
419
|
-
const minute = Math.floor(milliseconds / MILLISECONDS_PER_MINUTE);
|
|
420
|
-
milliseconds -= minute * MILLISECONDS_PER_MINUTE;
|
|
421
|
-
const second = Math.floor(milliseconds / MILLISECONDS_PER_SECOND);
|
|
422
|
-
const millisecond = milliseconds - second * MILLISECONDS_PER_SECOND;
|
|
423
|
-
return createAdjustedDmy(this, {
|
|
424
|
-
year: date.year,
|
|
425
|
-
month: date.month,
|
|
426
|
-
day: date.day,
|
|
427
|
-
hour,
|
|
428
|
-
minute,
|
|
429
|
-
second,
|
|
430
|
-
millisecond
|
|
431
|
-
});
|
|
432
|
-
};
|
|
433
|
-
Dmy.prototype.addSeconds = function(amount) {
|
|
434
|
-
return this.addMilliseconds(amount * MILLISECONDS_PER_SECOND);
|
|
435
|
-
};
|
|
436
|
-
Dmy.prototype.addMinutes = function(amount) {
|
|
437
|
-
return this.addMilliseconds(amount * MILLISECONDS_PER_MINUTE);
|
|
438
|
-
};
|
|
439
|
-
Dmy.prototype.addHours = function(amount) {
|
|
440
|
-
return this.addMilliseconds(amount * MILLISECONDS_PER_HOUR);
|
|
441
|
-
};
|
|
442
|
-
Dmy.prototype.addMonths = function(amount) {
|
|
443
|
-
let month = this.month;
|
|
444
|
-
let year = this.year;
|
|
445
|
-
for (let i = 0; i < amount; i++) {
|
|
446
|
-
month++;
|
|
447
|
-
if (month > 12) {
|
|
448
|
-
month = 1;
|
|
449
|
-
year++;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return createAdjustedDmy(this, { year, month, day: 1 });
|
|
453
|
-
};
|
|
454
|
-
Dmy.prototype.getPreviousDay = function() {
|
|
455
|
-
return this.addDays(-1);
|
|
456
|
-
};
|
|
457
|
-
Dmy.prototype.getNextMonth = function() {
|
|
458
|
-
let month = this.month;
|
|
459
|
-
let year = this.year;
|
|
460
|
-
month++;
|
|
461
|
-
if (month > 12) {
|
|
462
|
-
month = 1;
|
|
463
|
-
year++;
|
|
464
|
-
}
|
|
465
|
-
return createAdjustedDmy(this, { year, month, day: 1 });
|
|
466
|
-
};
|
|
467
|
-
Dmy.prototype.getPreviousMonth = function() {
|
|
468
|
-
let month = this.month;
|
|
469
|
-
let year = this.year;
|
|
470
|
-
month--;
|
|
471
|
-
if (month < 1) {
|
|
472
|
-
month = 12;
|
|
473
|
-
year--;
|
|
474
|
-
}
|
|
475
|
-
return createAdjustedDmy(this, { year, month, day: 1 });
|
|
476
|
-
};
|
|
477
|
-
Dmy.prototype.addYears = function(amount) {
|
|
478
|
-
return createAdjustedDmy(this, { year: this.year + amount, month: 1, day: 1 });
|
|
479
|
-
};
|
|
480
|
-
function pad(value, length) {
|
|
481
|
-
return String(value).padStart(length, "0");
|
|
482
|
-
}
|
|
483
|
-
__name(pad, "pad");
|
|
484
|
-
Dmy.prototype.format = function(format, options) {
|
|
485
|
-
options = options || {};
|
|
486
|
-
format = format || "D MMM YYYY";
|
|
487
|
-
const prefixSettings = options.yearPrefix;
|
|
488
|
-
const bceText = typeof options.bceText === "string" ? options.bceText : " ʙᴄᴇ";
|
|
489
|
-
const isBc = this.year <= 0;
|
|
490
|
-
const is1Bc = this.year === 0;
|
|
491
|
-
const thousandsSeparator = options.thousandsSeparator;
|
|
492
|
-
if (prefixSettings && !is1Bc) {
|
|
493
|
-
const prefixValue = prefixSettings.value || 1;
|
|
494
|
-
const prefixLabel = prefixSettings.label || "";
|
|
495
|
-
let formattedYear;
|
|
496
|
-
if (isBc) {
|
|
497
|
-
formattedYear = digitGroupedNumber((-this.year + 1) / prefixValue, thousandsSeparator) + prefixLabel + bceText;
|
|
498
|
-
} else {
|
|
499
|
-
formattedYear = digitGroupedNumber(this.year / prefixValue, thousandsSeparator) + prefixLabel;
|
|
500
|
-
}
|
|
501
|
-
return formattedYear;
|
|
502
|
-
}
|
|
503
|
-
return format.replace(
|
|
504
|
-
"YYYY",
|
|
505
|
-
isBc ? digitGroupedNumber(-this.year + 1, thousandsSeparator) + bceText : digitGroupedNumber(this.year, thousandsSeparator)
|
|
506
|
-
).replace("D", this.day).replace("MMM", MONTH_NAMES[this.month - 1]).replace("HH", pad(this.hour, 2)).replace("mm", pad(this.minute, 2)).replace("ss", pad(this.second, 2)).replace("SSS", pad(this.millisecond, 3));
|
|
507
|
-
};
|
|
508
|
-
Dmy.prototype.isSame = function(other) {
|
|
509
|
-
return other.year === this.year && other.month === this.month && other.day === this.day && (other.hour || 0) === this.hour && (other.minute || 0) === this.minute && (other.second || 0) === this.second && (other.millisecond || 0) === this.millisecond;
|
|
510
|
-
};
|
|
511
|
-
Dmy.prototype.toKeyString = function() {
|
|
512
|
-
const dateKey = `${this.year}|${this.month}|${this.day}`;
|
|
513
|
-
if (this.getMillisecondsOfDay() === 0) {
|
|
514
|
-
return dateKey;
|
|
515
|
-
}
|
|
516
|
-
return `${dateKey}|${this.hour}|${this.minute}|${this.second}|${this.millisecond}`;
|
|
517
|
-
};
|
|
518
|
-
Dmy.prototype.isAfter = function(other) {
|
|
519
|
-
const fields = ["year", "month", "day", "hour", "minute", "second", "millisecond"];
|
|
520
|
-
for (let i = 0; i < fields.length; i++) {
|
|
521
|
-
const field = fields[i];
|
|
522
|
-
const thisValue = this[field] || 0;
|
|
523
|
-
const otherValue = other[field] || 0;
|
|
524
|
-
if (thisValue !== otherValue) {
|
|
525
|
-
return thisValue > otherValue;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
return false;
|
|
529
|
-
};
|
|
530
|
-
Dmy.prototype.isBetween = function(from, to) {
|
|
531
|
-
return this.isAfter(from) && to.isAfter(this);
|
|
532
|
-
};
|
|
533
|
-
Dmy.prototype.compare = function(other) {
|
|
534
|
-
if (this.isSame(other)) {
|
|
535
|
-
return 0;
|
|
536
|
-
}
|
|
537
|
-
if (this.isAfter(other)) {
|
|
538
|
-
return 1;
|
|
539
|
-
}
|
|
540
|
-
return -1;
|
|
541
|
-
};
|
|
542
|
-
Dmy.prototype.asFloat = function() {
|
|
543
|
-
const m = this.month - 1;
|
|
544
|
-
const d = this.day - 1;
|
|
545
|
-
const dayFraction = this.getMillisecondsOfDay() / MILLISECONDS_PER_DAY;
|
|
546
|
-
if (m === 0 && d === 0 && dayFraction === 0) {
|
|
547
|
-
return this.year;
|
|
548
|
-
}
|
|
549
|
-
return Math.round((this.year + (m * 31 + d + dayFraction) / 371) * 100) / 100;
|
|
550
|
-
};
|
|
551
|
-
Dmy.prototype.isInFuture = function() {
|
|
552
|
-
const date = /* @__PURE__ */ new Date();
|
|
553
|
-
const now = new Dmy(
|
|
554
|
-
date.getFullYear(),
|
|
555
|
-
date.getMonth() + 1,
|
|
556
|
-
date.getDate(),
|
|
557
|
-
date.getHours(),
|
|
558
|
-
date.getMinutes(),
|
|
559
|
-
date.getSeconds(),
|
|
560
|
-
date.getMilliseconds()
|
|
561
|
-
);
|
|
562
|
-
return this.isAfter(now);
|
|
563
|
-
};
|
|
564
|
-
Dmy.prototype.convertToIso = function() {
|
|
565
|
-
if (this.year < 0) {
|
|
566
|
-
this.year += 1;
|
|
567
|
-
}
|
|
568
|
-
return this;
|
|
569
|
-
};
|
|
570
|
-
Dmy.CreateAsStartOfPeriod = function(isoDmy, precision) {
|
|
571
|
-
const isoYear = isoDmy.year;
|
|
572
|
-
const month = isoDmy.month || 1;
|
|
573
|
-
const day = isoDmy.day || 1;
|
|
574
|
-
precision = normalizePrecision(precision);
|
|
575
|
-
if (precision === "millisecond") {
|
|
576
|
-
return new Dmy(isoDmy);
|
|
577
|
-
}
|
|
578
|
-
if (precision === "second") {
|
|
579
|
-
return new Dmy(isoYear, month, day, isoDmy.hour, isoDmy.minute, isoDmy.second, 0);
|
|
580
|
-
}
|
|
581
|
-
if (precision === "minute") {
|
|
582
|
-
return new Dmy(isoYear, month, day, isoDmy.hour, isoDmy.minute, 0, 0);
|
|
583
|
-
}
|
|
584
|
-
if (precision === "hour") {
|
|
585
|
-
return new Dmy(isoYear, month, day, isoDmy.hour, 0, 0, 0);
|
|
586
|
-
}
|
|
587
|
-
if (precision === "day") {
|
|
588
|
-
return new Dmy(isoYear, month, day);
|
|
589
|
-
}
|
|
590
|
-
if (precision === "month") {
|
|
591
|
-
return new Dmy(isoYear, month, 1);
|
|
592
|
-
}
|
|
593
|
-
if (precision === "year" || precision === "million-years" || precision === "billion-years") {
|
|
594
|
-
return new Dmy(isoYear, 1, 1);
|
|
595
|
-
}
|
|
596
|
-
if (precision === "decade") {
|
|
597
|
-
return new Dmy(Math.floor(isoYear / 10) * 10, 1, 1);
|
|
598
|
-
}
|
|
599
|
-
if (precision === "century") {
|
|
600
|
-
return new Dmy(getHistoricalPeriodBounds(isoYear, 100).startYear, 1, 1);
|
|
601
|
-
}
|
|
602
|
-
if (precision === "millennium") {
|
|
603
|
-
return new Dmy(getHistoricalPeriodBounds(isoYear, 1e3).startYear, 1, 1);
|
|
604
|
-
}
|
|
605
|
-
return new Dmy(isoYear, month, day);
|
|
606
|
-
};
|
|
607
|
-
Dmy.CreateAsEndOfPeriod = function(isoDmy, precision) {
|
|
608
|
-
const isoYear = isoDmy.year;
|
|
609
|
-
const month = isoDmy.month || 1;
|
|
610
|
-
const day = isoDmy.day || 1;
|
|
611
|
-
precision = normalizePrecision(precision);
|
|
612
|
-
if (precision === "millisecond") {
|
|
613
|
-
return new Dmy(isoDmy);
|
|
614
|
-
}
|
|
615
|
-
if (precision === "second") {
|
|
616
|
-
return new Dmy(isoYear, month, day, isoDmy.hour, isoDmy.minute, isoDmy.second, 999);
|
|
617
|
-
}
|
|
618
|
-
if (precision === "minute") {
|
|
619
|
-
return new Dmy(isoYear, month, day, isoDmy.hour, isoDmy.minute, 59, 999);
|
|
620
|
-
}
|
|
621
|
-
if (precision === "hour") {
|
|
622
|
-
return new Dmy(isoYear, month, day, isoDmy.hour, 59, 59, 999);
|
|
623
|
-
}
|
|
624
|
-
if (precision === "day") {
|
|
625
|
-
return new Dmy(isoYear, month, day);
|
|
626
|
-
}
|
|
627
|
-
if (precision === "month") {
|
|
628
|
-
return new Dmy(isoYear, month, daysInMonth(isoYear, month));
|
|
629
|
-
}
|
|
630
|
-
if (precision === "year") {
|
|
631
|
-
return new Dmy(isoYear, 12, 31);
|
|
632
|
-
}
|
|
633
|
-
if (precision === "decade") {
|
|
634
|
-
return new Dmy(Math.floor(isoYear / 10) * 10 + 9, 12, 31);
|
|
635
|
-
}
|
|
636
|
-
if (precision === "century") {
|
|
637
|
-
return new Dmy(getHistoricalPeriodBounds(isoYear, 100).endYear, 12, 31);
|
|
638
|
-
}
|
|
639
|
-
if (precision === "millennium") {
|
|
640
|
-
return new Dmy(getHistoricalPeriodBounds(isoYear, 1e3).endYear, 12, 31);
|
|
641
|
-
}
|
|
642
|
-
if (precision === "million-years") {
|
|
643
|
-
return new Dmy(isoYear + 999999, 12, 31);
|
|
644
|
-
}
|
|
645
|
-
if (precision === "billion-years") {
|
|
646
|
-
return new Dmy(isoYear + 999999999, 12, 31);
|
|
647
|
-
}
|
|
648
|
-
Logger.error("precision is not implemented");
|
|
649
|
-
return new Dmy(isoYear, month, day);
|
|
650
|
-
};
|
|
651
|
-
Dmy.CreateAsExclusiveEndOfPeriod = function(isoDmy, precision) {
|
|
652
|
-
precision = normalizePrecision(precision);
|
|
653
|
-
const start = Dmy.CreateAsStartOfPeriod(isoDmy, precision);
|
|
654
|
-
if (precision === "millisecond") {
|
|
655
|
-
return start.addMilliseconds(1);
|
|
656
|
-
}
|
|
657
|
-
if (precision === "second") {
|
|
658
|
-
return start.addSeconds(1);
|
|
659
|
-
}
|
|
660
|
-
if (precision === "minute") {
|
|
661
|
-
return start.addMinutes(1);
|
|
662
|
-
}
|
|
663
|
-
if (precision === "hour") {
|
|
664
|
-
return start.addHours(1);
|
|
665
|
-
}
|
|
666
|
-
if (precision === "day") {
|
|
667
|
-
return start.addDays(1);
|
|
668
|
-
}
|
|
669
|
-
return Dmy.CreateAsEndOfPeriod(isoDmy, precision).addDays(1);
|
|
670
|
-
};
|
|
671
|
-
Dmy.now = function() {
|
|
672
|
-
const now = /* @__PURE__ */ new Date();
|
|
673
|
-
return new Dmy({
|
|
674
|
-
year: now.getYear() + 1900,
|
|
675
|
-
month: now.getMonth() + 1,
|
|
676
|
-
day: now.getDate()
|
|
677
|
-
});
|
|
678
|
-
};
|
|
679
|
-
function parseDmyString(dateString) {
|
|
680
|
-
const match = String(dateString).match(DMY_STRING_PATTERN);
|
|
681
|
-
if (!match) {
|
|
682
|
-
return null;
|
|
683
|
-
}
|
|
684
|
-
const year = parseInt(match[1], 10);
|
|
685
|
-
const month = match[2] == null ? 1 : parseInt(match[2], 10);
|
|
686
|
-
const day = match[3] == null ? 1 : parseInt(match[3], 10);
|
|
687
|
-
const hour = match[4] == null ? 0 : parseInt(match[4], 10);
|
|
688
|
-
const minute = match[5] == null ? 0 : parseInt(match[5], 10);
|
|
689
|
-
const second = match[6] == null ? 0 : parseInt(match[6], 10);
|
|
690
|
-
const millisecond = match[7] ? parseInt(match[7].padEnd(3, "0"), 10) : 0;
|
|
691
|
-
return {
|
|
692
|
-
date: new Dmy({
|
|
693
|
-
year,
|
|
694
|
-
month,
|
|
695
|
-
day,
|
|
696
|
-
hour,
|
|
697
|
-
minute,
|
|
698
|
-
second,
|
|
699
|
-
millisecond
|
|
700
|
-
}),
|
|
701
|
-
hasMonth: match[2] != null,
|
|
702
|
-
hasDay: match[3] != null,
|
|
703
|
-
hasTime: match[4] != null
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
__name(parseDmyString, "parseDmyString");
|
|
707
|
-
Dmy.fromString = function(dateString) {
|
|
708
|
-
const parsed = parseDmyString(dateString);
|
|
709
|
-
return parsed ? parsed.date : new Dmy(NaN, 1, 1);
|
|
710
|
-
};
|
|
711
|
-
function merge(target, ...sources) {
|
|
712
|
-
return Object.assign(target, ...sources);
|
|
713
|
-
}
|
|
714
|
-
__name(merge, "merge");
|
|
715
|
-
function deepMerge(target, ...sources) {
|
|
716
|
-
const ensureSafeProto = /* @__PURE__ */ __name((obj) => {
|
|
717
|
-
if (obj && typeof obj === "object" && !Object.prototype.hasOwnProperty.call(obj, "__proto__")) {
|
|
718
|
-
try {
|
|
719
|
-
Object.defineProperty(obj, "__proto__", {
|
|
720
|
-
value: void 0,
|
|
721
|
-
writable: true,
|
|
722
|
-
enumerable: false,
|
|
723
|
-
configurable: true
|
|
724
|
-
});
|
|
725
|
-
} catch (e) {
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
}, "ensureSafeProto");
|
|
729
|
-
ensureSafeProto(target);
|
|
730
|
-
const isUnsafeKey = /* @__PURE__ */ __name((key) => key === "__proto__" || key === "constructor" || key === "prototype", "isUnsafeKey");
|
|
731
|
-
const isPlainObject = /* @__PURE__ */ __name((obj) => {
|
|
732
|
-
if (obj === null || typeof obj !== "object") {
|
|
733
|
-
return false;
|
|
734
|
-
}
|
|
735
|
-
const proto = Object.getPrototypeOf(obj);
|
|
736
|
-
return proto === Object.prototype || proto === null;
|
|
737
|
-
}, "isPlainObject");
|
|
738
|
-
for (const src of sources) {
|
|
739
|
-
if (!src || typeof src !== "object") {
|
|
740
|
-
continue;
|
|
741
|
-
}
|
|
742
|
-
for (const k of Object.keys(src)) {
|
|
743
|
-
if (isUnsafeKey(k)) {
|
|
744
|
-
continue;
|
|
745
|
-
}
|
|
746
|
-
const v = src[k];
|
|
747
|
-
if (Array.isArray(v)) {
|
|
748
|
-
target[k] = v.slice();
|
|
749
|
-
continue;
|
|
750
|
-
}
|
|
751
|
-
if (isPlainObject(v)) {
|
|
752
|
-
const base = isPlainObject(target[k]) ? target[k] : {};
|
|
753
|
-
ensureSafeProto(base);
|
|
754
|
-
target[k] = deepMerge(base, v);
|
|
755
|
-
continue;
|
|
756
|
-
}
|
|
757
|
-
target[k] = v;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
ensureSafeProto(target);
|
|
761
|
-
return target;
|
|
762
|
-
}
|
|
763
|
-
__name(deepMerge, "deepMerge");
|
|
764
|
-
function buildObjectFromPath(path, value) {
|
|
765
|
-
const pathParts = path.split(".");
|
|
766
|
-
const pathEnd = pathParts[pathParts.length - 1];
|
|
767
|
-
let obj = {};
|
|
768
|
-
obj[pathEnd] = value;
|
|
769
|
-
for (let i = pathParts.length - 2; i >= 0; i--) {
|
|
770
|
-
const previousPathPart = pathParts[i];
|
|
771
|
-
const objClone = deepMerge({}, obj);
|
|
772
|
-
obj = {};
|
|
773
|
-
obj[previousPathPart] = objClone;
|
|
774
|
-
}
|
|
775
|
-
return obj;
|
|
776
|
-
}
|
|
777
|
-
__name(buildObjectFromPath, "buildObjectFromPath");
|
|
778
|
-
function defineValueOrFunctionProperty(obj, propName) {
|
|
779
|
-
const privatePropertyName = `_${propName}`;
|
|
780
|
-
obj[privatePropertyName] = void 0;
|
|
781
|
-
Object.defineProperty(obj, propName, {
|
|
782
|
-
get() {
|
|
783
|
-
const value = this[privatePropertyName];
|
|
784
|
-
if (typeof value === "function") {
|
|
785
|
-
return value(this);
|
|
786
|
-
}
|
|
787
|
-
return value;
|
|
788
|
-
},
|
|
789
|
-
set(value) {
|
|
790
|
-
this[privatePropertyName] = value;
|
|
791
|
-
},
|
|
792
|
-
enumerable: true,
|
|
793
|
-
configurable: false
|
|
794
|
-
});
|
|
795
|
-
}
|
|
796
|
-
__name(defineValueOrFunctionProperty, "defineValueOrFunctionProperty");
|
|
797
|
-
function isUndefined(value) {
|
|
798
|
-
return typeof value === "undefined";
|
|
799
|
-
}
|
|
800
|
-
__name(isUndefined, "isUndefined");
|
|
801
|
-
const propertyAbbreviations = {
|
|
802
|
-
id: "i",
|
|
803
|
-
title: "t",
|
|
804
|
-
rank: "r",
|
|
805
|
-
subtitle: "s",
|
|
806
|
-
"from.year": "fy",
|
|
807
|
-
"from.month": "fm",
|
|
808
|
-
"from.day": "fd",
|
|
809
|
-
"from.hour": "fhr",
|
|
810
|
-
"from.minute": "fmi",
|
|
811
|
-
"from.second": "fs",
|
|
812
|
-
"from.millisecond": "fms",
|
|
813
|
-
"from.precision": "fp",
|
|
814
|
-
"to.year": "ty",
|
|
815
|
-
"to.month": "tm",
|
|
816
|
-
"to.day": "td",
|
|
817
|
-
"to.hour": "thr",
|
|
818
|
-
"to.minute": "tmi",
|
|
819
|
-
"to.second": "ts",
|
|
820
|
-
"to.millisecond": "tms",
|
|
821
|
-
"to.precision": "tp",
|
|
822
|
-
isToPresent: "p",
|
|
823
|
-
isStarred: "v",
|
|
824
|
-
"offset.left": "ol",
|
|
825
|
-
"offset.top": "ot",
|
|
826
|
-
imageUrl: "m",
|
|
827
|
-
lane: "ln",
|
|
828
|
-
style: "st",
|
|
829
|
-
activeStyle: "ast",
|
|
830
|
-
hiddenByFilter: "h",
|
|
831
|
-
hidePeriodLine: "hp"
|
|
832
|
-
};
|
|
833
|
-
function extractProperty(data, property) {
|
|
834
|
-
return Object.prototype.hasOwnProperty.call(data, property) ? data[property] : data[propertyAbbreviations[property]];
|
|
835
|
-
}
|
|
836
|
-
__name(extractProperty, "extractProperty");
|
|
837
|
-
function extractPropertyFromPath(data, path) {
|
|
838
|
-
const pathParts = path.split(".");
|
|
839
|
-
const value = pathParts.reduce((curr, next) => curr ? curr[next] : void 0, data);
|
|
840
|
-
return isUndefined(value) ? data[propertyAbbreviations[path]] : value;
|
|
841
|
-
}
|
|
842
|
-
__name(extractPropertyFromPath, "extractPropertyFromPath");
|
|
843
|
-
function isPath(property) {
|
|
844
|
-
return property.indexOf(".") > -1;
|
|
845
|
-
}
|
|
846
|
-
__name(isPath, "isPath");
|
|
847
|
-
function getPropertyFromData(data, property) {
|
|
848
|
-
if (isPath(property)) {
|
|
849
|
-
return extractPropertyFromPath(data, property);
|
|
850
|
-
}
|
|
851
|
-
return extractProperty(data, property);
|
|
852
|
-
}
|
|
853
|
-
__name(getPropertyFromData, "getPropertyFromData");
|
|
854
|
-
function existsInData(data, property) {
|
|
855
|
-
if (isPath(property)) {
|
|
856
|
-
return !isUndefined(extractPropertyFromPath(data, property));
|
|
857
|
-
}
|
|
858
|
-
return !isUndefined(extractProperty(data, property));
|
|
859
|
-
}
|
|
860
|
-
__name(existsInData, "existsInData");
|
|
861
|
-
defineValueOrFunctionProperty(Article.prototype, "hidePeriodLine");
|
|
862
|
-
defineValueOrFunctionProperty(Article.prototype, "hiddenByFilter");
|
|
863
|
-
function Article(owner, id) {
|
|
864
|
-
this.id = id;
|
|
865
|
-
this.owner = owner;
|
|
866
|
-
this.isDataLoaded = false;
|
|
867
|
-
this.imageLoaded = false;
|
|
868
|
-
this.stacking = 0;
|
|
869
|
-
this.groupIndex = 0;
|
|
870
|
-
this.isActive = false;
|
|
871
|
-
this.isVisible = false;
|
|
872
|
-
this.isVisibleInLane = true;
|
|
873
|
-
this.isInRange = false;
|
|
874
|
-
this.isInView = false;
|
|
875
|
-
this.isVisibleInGroup = false;
|
|
876
|
-
this.isVisibleInRows = true;
|
|
877
|
-
this.isStarred = false;
|
|
878
|
-
this.isMouseOverStar = false;
|
|
879
|
-
this.isMouseover = false;
|
|
880
|
-
this.isDragging = false;
|
|
881
|
-
this.registeredPosition = { left: 0, top: 0 };
|
|
882
|
-
this.position = { left: 0, top: 0 };
|
|
883
|
-
this.dragStartOffset = { left: 0, top: 0 };
|
|
884
|
-
this.indicator = { fromX: 0, toX: 0 };
|
|
885
|
-
this.offset = { left: 0, top: 0 };
|
|
886
|
-
this.finalOffset = { left: 0, top: 0 };
|
|
887
|
-
this.isVisibleAfterFade = false;
|
|
888
|
-
this.opacity = 0;
|
|
889
|
-
this.fadeAnimation = {
|
|
890
|
-
finalOpacity: 0,
|
|
891
|
-
dummyElement: null
|
|
892
|
-
};
|
|
893
|
-
this.moveAnimation = {
|
|
894
|
-
finalOffset: { left: 0, top: 0 },
|
|
895
|
-
dummyElement: void 0
|
|
896
|
-
};
|
|
897
|
-
this.row = 0;
|
|
898
|
-
this.laneId = null;
|
|
899
|
-
this.laneOrder = 0;
|
|
900
|
-
this.isFading = false;
|
|
901
|
-
this.isMoving = false;
|
|
902
|
-
this._cachedHeight = 0;
|
|
903
|
-
this._cachedWidth = 0;
|
|
904
|
-
this._sizeValid = false;
|
|
905
|
-
this._sizeCacheKey = null;
|
|
906
|
-
this._layoutCaches = null;
|
|
907
|
-
this._resolvedDefaultCardLayout = null;
|
|
908
|
-
this._resolvedCardLayoutName = null;
|
|
909
|
-
}
|
|
910
|
-
__name(Article, "Article");
|
|
911
|
-
Article.prototype.setupByReceivedData = function(receivedData) {
|
|
912
|
-
this.owner._assignArticleToLane(this, this.owner._resolveLaneIdFromArticleData(receivedData));
|
|
913
|
-
const articleDefaultData = this.owner._getResolvedArticleOptions(this).defaultData;
|
|
914
|
-
const data = deepMerge({}, articleDefaultData, receivedData);
|
|
915
|
-
if (!existsInData(receivedData, "to")) {
|
|
916
|
-
delete data.to;
|
|
917
|
-
}
|
|
918
|
-
this.data = deepMerge({}, receivedData);
|
|
919
|
-
this.title = getPropertyFromData(data, "title") || "";
|
|
920
|
-
this.rank = getPropertyFromData(data, "rank") || 0;
|
|
921
|
-
this.subtitle = getPropertyFromData(data, "subtitle") || "";
|
|
922
|
-
this._setupArticlePeriod(data);
|
|
923
|
-
this.offset.left = this.finalOffset.left = this.moveAnimation.finalOffset.left = data.offsetLeft || 0;
|
|
924
|
-
this.offset.top = this.finalOffset.top = this.moveAnimation.finalOffset.top = data.offsetTop || 0;
|
|
925
|
-
this.isStarred = !!data.starred;
|
|
926
|
-
this.cardLayout = getPropertyFromData(data, "cardLayout") || null;
|
|
927
|
-
this.initialiseStyles(data);
|
|
928
|
-
this.hiddenByFilter = getPropertyFromData(data, "hiddenByFilter");
|
|
929
|
-
this.hidePeriodLine = existsInData(data, "hidePeriodLine") ? getPropertyFromData(data, "hidePeriodLine") : this.owner.options.article.periodLine.defaultHide;
|
|
930
|
-
this.isDataLoaded = true;
|
|
931
|
-
this.isImageInfoLoaded = false;
|
|
932
|
-
};
|
|
933
|
-
Article.prototype._setupArticlePeriod = function(data) {
|
|
934
|
-
let fromDmy = new Dmy(
|
|
935
|
-
parseInt(getPropertyFromData(data, "from.year")),
|
|
936
|
-
parseInt(getPropertyFromData(data, "from.month")),
|
|
937
|
-
parseInt(getPropertyFromData(data, "from.day")),
|
|
938
|
-
parseInt(getPropertyFromData(data, "from.hour")),
|
|
939
|
-
parseInt(getPropertyFromData(data, "from.minute")),
|
|
940
|
-
parseInt(getPropertyFromData(data, "from.second")),
|
|
941
|
-
parseInt(getPropertyFromData(data, "from.millisecond"))
|
|
942
|
-
);
|
|
943
|
-
fromDmy = this.owner.getDmyFromInput(fromDmy);
|
|
944
|
-
const fromPrecision = getPropertyFromData(data, "from.precision");
|
|
945
|
-
const isToPresentProp = getPropertyFromData(data, "isToPresent");
|
|
946
|
-
const isToPresent = isToPresentProp === true || isToPresentProp === 1;
|
|
947
|
-
let toDmy, toPrecision;
|
|
948
|
-
if (isToPresent) {
|
|
949
|
-
toDmy = Dmy.now();
|
|
950
|
-
} else if (existsInData(data, "to")) {
|
|
951
|
-
toDmy = new Dmy(
|
|
952
|
-
parseInt(getPropertyFromData(data, "to.year")),
|
|
953
|
-
parseInt(getPropertyFromData(data, "to.month")),
|
|
954
|
-
parseInt(getPropertyFromData(data, "to.day")),
|
|
955
|
-
parseInt(getPropertyFromData(data, "to.hour")),
|
|
956
|
-
parseInt(getPropertyFromData(data, "to.minute")),
|
|
957
|
-
parseInt(getPropertyFromData(data, "to.second")),
|
|
958
|
-
parseInt(getPropertyFromData(data, "to.millisecond"))
|
|
959
|
-
);
|
|
960
|
-
toDmy = this.owner.getDmyFromInput(toDmy);
|
|
961
|
-
toPrecision = getPropertyFromData(data, "to.precision");
|
|
962
|
-
} else {
|
|
963
|
-
toDmy = fromDmy;
|
|
964
|
-
toPrecision = fromPrecision;
|
|
965
|
-
}
|
|
966
|
-
const from = Dmy.CreateAsStartOfPeriod(fromDmy, fromPrecision);
|
|
967
|
-
const to = Dmy.CreateAsExclusiveEndOfPeriod(toDmy, toPrecision);
|
|
968
|
-
this.period = { from, to, isToPresent };
|
|
969
|
-
this.period.years = this.period.to.asFloat() - this.period.from.asFloat();
|
|
970
|
-
};
|
|
971
|
-
Article.prototype.setImage = function() {
|
|
972
|
-
this.isImageInfoLoaded = true;
|
|
973
|
-
if (getPropertyFromData(this.data, "imageUrl")) {
|
|
974
|
-
this.owner.enqueueImageLoad(this);
|
|
975
|
-
} else {
|
|
976
|
-
this._releaseImageResource();
|
|
977
|
-
this.image = null;
|
|
978
|
-
this.imageLoaded = false;
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
Article.prototype._releaseImageResource = function(options = {}) {
|
|
982
|
-
const releaser = typeof this._closeImage === "function" ? this._closeImage : null;
|
|
983
|
-
if (releaser) {
|
|
984
|
-
this._closeImage = null;
|
|
985
|
-
try {
|
|
986
|
-
releaser(options);
|
|
987
|
-
} catch (e) {
|
|
988
|
-
}
|
|
989
|
-
return;
|
|
990
|
-
}
|
|
991
|
-
if (!options.keepState) {
|
|
992
|
-
this.image = null;
|
|
993
|
-
this.imageLoaded = false;
|
|
994
|
-
this._loadedImageKey = null;
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
Article.prototype.registerPosition = function(pos) {
|
|
998
|
-
this.registeredPosition = this.position = pos;
|
|
999
|
-
};
|
|
1000
|
-
Article.prototype.overlaps = function(other) {
|
|
1001
|
-
return other.period.from.isSame(this.period.from) && other.period.to.isSame(this.period.to) || other.period.from.isBetween(this.period.from, this.period.to) || other.period.to.isBetween(this.period.from, this.period.to) || this.period.from.isBetween(other.period.from, other.period.to) || this.period.to.isBetween(other.period.from, other.period.to);
|
|
1002
|
-
};
|
|
1003
|
-
Article.prototype.overlapsInclusiveWithDates = function(from, to) {
|
|
1004
|
-
return !(this.period.from.isAfter(to) || from.isAfter(this.period.to));
|
|
1005
|
-
};
|
|
1006
|
-
Article.prototype.overlapsInclusive = function(other) {
|
|
1007
|
-
return this.overlapsInclusiveWithDates(other.period.from, other.period.to);
|
|
1008
|
-
};
|
|
1009
|
-
Article.prototype.isInside = function(pos) {
|
|
1010
|
-
if (!this.isVisible) {
|
|
1011
|
-
return false;
|
|
1012
|
-
}
|
|
1013
|
-
this._ensureSizeCache();
|
|
1014
|
-
const left = this.position.left;
|
|
1015
|
-
const top = this.position.top;
|
|
1016
|
-
const width = this._cachedWidth;
|
|
1017
|
-
const height = this._cachedHeight;
|
|
1018
|
-
return pos.left >= left && pos.left <= left + width && pos.top >= top && pos.top <= top + height;
|
|
1019
|
-
};
|
|
1020
|
-
Article.prototype.pointerEnter = function(event) {
|
|
1021
|
-
this.isMouseover = true;
|
|
1022
|
-
this.owner.trigger("article-pointerenter", this, event);
|
|
1023
|
-
};
|
|
1024
|
-
Article.prototype.pointerLeave = function(event) {
|
|
1025
|
-
this.isMouseover = false;
|
|
1026
|
-
this.owner.trigger("article-pointerleave", this, event);
|
|
1027
|
-
};
|
|
1028
|
-
Article.prototype.updateIsMouseOverStar = function(pos) {
|
|
1029
|
-
const star = this.getIconBox();
|
|
1030
|
-
if (!star) {
|
|
1031
|
-
return false;
|
|
1032
|
-
}
|
|
1033
|
-
const oldState = this.isMouseOverStar;
|
|
1034
|
-
this.isMouseOverStar = pos.left >= star.left && pos.left <= star.left + star.width && pos.top >= star.top && pos.top <= star.top + star.height;
|
|
1035
|
-
if (this.isMouseOverStar !== oldState && !this.owner.isAnimating) {
|
|
1036
|
-
this.owner.redraw();
|
|
1037
|
-
}
|
|
1038
|
-
return this.isMouseOverStar;
|
|
1039
|
-
};
|
|
1040
|
-
Article.prototype.getCursor = function(pos) {
|
|
1041
|
-
const cursor = this.owner.options.style.cursor;
|
|
1042
|
-
if (this.isDragging) {
|
|
1043
|
-
return cursor.article.dragging;
|
|
1044
|
-
}
|
|
1045
|
-
this.updateIsMouseOverStar(pos);
|
|
1046
|
-
if (!this.owner.options.article.draggable) {
|
|
1047
|
-
return cursor.clickable;
|
|
1048
|
-
}
|
|
1049
|
-
if (this.isActive) {
|
|
1050
|
-
return this.isMouseOverStar ? cursor.clickable : cursor.article.hoverDraggable;
|
|
1051
|
-
}
|
|
1052
|
-
return cursor.clickable;
|
|
1053
|
-
};
|
|
1054
|
-
Article.prototype.clicked = function(pos) {
|
|
1055
|
-
this.updateIsMouseOverStar(pos);
|
|
1056
|
-
if (this.isMouseOverStar) {
|
|
1057
|
-
this.isStarred = !this.isStarred;
|
|
1058
|
-
return true;
|
|
1059
|
-
}
|
|
1060
|
-
return false;
|
|
1061
|
-
};
|
|
1062
|
-
Article.prototype.getStatusForSave = function() {
|
|
1063
|
-
const state = { i: this.id };
|
|
1064
|
-
if (this.offset.left !== 0) {
|
|
1065
|
-
state.l = this.offset.left;
|
|
1066
|
-
}
|
|
1067
|
-
if (this.offset.top !== 0) {
|
|
1068
|
-
state.t = this.offset.top;
|
|
1069
|
-
}
|
|
1070
|
-
if (this.isStarred) {
|
|
1071
|
-
state.v = true;
|
|
1072
|
-
}
|
|
1073
|
-
return state;
|
|
1074
|
-
};
|
|
1075
|
-
Article.prototype.headerOverlapsWith = function(other) {
|
|
1076
|
-
const thisLeft = this.registeredPosition.left;
|
|
1077
|
-
const otherLeft = other.registeredPosition.left;
|
|
1078
|
-
const thisRight = thisLeft + this.getWidth();
|
|
1079
|
-
const otherRight = otherLeft + other.getWidth();
|
|
1080
|
-
return otherRight >= thisLeft && thisRight >= otherLeft;
|
|
1081
|
-
};
|
|
1082
|
-
Article.prototype._getWidth = function() {
|
|
1083
|
-
return this.getCurrentStyle().width;
|
|
1084
|
-
};
|
|
1085
|
-
Article.prototype.getWidth = function() {
|
|
1086
|
-
this._ensureSizeCache();
|
|
1087
|
-
return this._cachedWidth;
|
|
1088
|
-
};
|
|
1089
|
-
Article.prototype.getHeight = function() {
|
|
1090
|
-
this._ensureSizeCache();
|
|
1091
|
-
return this._cachedHeight;
|
|
1092
|
-
};
|
|
1093
|
-
Article.prototype.setOption = function(option, value) {
|
|
1094
|
-
let needsDefaultRedraw = false;
|
|
1095
|
-
if (typeof option === "string") {
|
|
1096
|
-
if (typeof value === "undefined") {
|
|
1097
|
-
const selectedOption = getPropertyFromData(this.data, option);
|
|
1098
|
-
return selectedOption;
|
|
1099
|
-
}
|
|
1100
|
-
option = buildObjectFromPath(option, value);
|
|
1101
|
-
}
|
|
1102
|
-
deepMerge(this.data, option);
|
|
1103
|
-
if (existsInData(option, "id")) {
|
|
1104
|
-
this.id = option.id;
|
|
1105
|
-
}
|
|
1106
|
-
if (existsInData(option, "title")) {
|
|
1107
|
-
this.title = option.title;
|
|
1108
|
-
this.titleLines = void 0;
|
|
1109
|
-
}
|
|
1110
|
-
if (existsInData(option, "subtitle")) {
|
|
1111
|
-
this.subtitle = option.subtitle;
|
|
1112
|
-
this.summarisedSubtitle = void 0;
|
|
1113
|
-
}
|
|
1114
|
-
if (existsInData(option, "from") || existsInData(option, "to") || existsInData(option, "isToPresent")) {
|
|
1115
|
-
this._setupArticlePeriod(this.data);
|
|
1116
|
-
needsDefaultRedraw = true;
|
|
1117
|
-
}
|
|
1118
|
-
if (existsInData(option, "imageUrl")) {
|
|
1119
|
-
this.setImage();
|
|
1120
|
-
}
|
|
1121
|
-
if (existsInData(option, "rank")) {
|
|
1122
|
-
this.rank = option.rank;
|
|
1123
|
-
needsDefaultRedraw = true;
|
|
1124
|
-
}
|
|
1125
|
-
if (existsInData(option, "starred")) {
|
|
1126
|
-
this.isStarred = option.starred;
|
|
1127
|
-
}
|
|
1128
|
-
if (existsInData(option, "hiddenByFilter")) {
|
|
1129
|
-
this.hiddenByFilter = option.hiddenByFilter;
|
|
1130
|
-
}
|
|
1131
|
-
if (existsInData(option, "hidePeriodLine")) {
|
|
1132
|
-
this.hidePeriodLine = option.hidePeriodLine;
|
|
1133
|
-
}
|
|
1134
|
-
const laneChanged = existsInData(option, "lane");
|
|
1135
|
-
if (laneChanged) {
|
|
1136
|
-
this.owner._assignArticleToLane(this, option.lane);
|
|
1137
|
-
this.initialiseStyles(this.data);
|
|
1138
|
-
this.invalidateCaches();
|
|
1139
|
-
needsDefaultRedraw = true;
|
|
1140
|
-
}
|
|
1141
|
-
const styleChanged = existsInData(option, "style");
|
|
1142
|
-
const activeStyleChanged = existsInData(option, "activeStyle");
|
|
1143
|
-
const hoverStyleChanged = existsInData(option, "hoverStyle");
|
|
1144
|
-
if (styleChanged || hoverStyleChanged || activeStyleChanged) {
|
|
1145
|
-
this.initialiseStyles(this.data);
|
|
1146
|
-
}
|
|
1147
|
-
this.invalidateCaches();
|
|
1148
|
-
const cardLayoutChanged = existsInData(option, "cardLayout");
|
|
1149
|
-
if (cardLayoutChanged) {
|
|
1150
|
-
this.setCardLayout(option.cardLayout);
|
|
1151
|
-
}
|
|
1152
|
-
if (laneChanged) {
|
|
1153
|
-
this.owner.updateArticlesGroupIndex();
|
|
1154
|
-
}
|
|
1155
|
-
if (needsDefaultRedraw) {
|
|
1156
|
-
this.owner.requestRedraw();
|
|
1157
|
-
} else {
|
|
1158
|
-
this.owner.requestRedraw(this.redraw);
|
|
1159
|
-
}
|
|
1160
|
-
};
|
|
1161
|
-
Article.prototype.initialiseStyles = function(data = this.data) {
|
|
1162
|
-
const resolvedDefaultCardLayout = this.owner._resolveDefaultCardLayoutName(this);
|
|
1163
|
-
const explicitCardLayout = this.owner._getExplicitArticleCardLayout(this);
|
|
1164
|
-
const cardLayout = explicitCardLayout || resolvedDefaultCardLayout;
|
|
1165
|
-
this._resolvedDefaultCardLayout = resolvedDefaultCardLayout;
|
|
1166
|
-
this._resolvedCardLayoutName = cardLayout;
|
|
1167
|
-
const styleOverrides = this.owner._getResolvedArticleStyleOverrides(this, cardLayout);
|
|
1168
|
-
const style = deepMerge({}, styleOverrides.style, getPropertyFromData(data, "style") || {});
|
|
1169
|
-
const activeStyle = deepMerge(
|
|
1170
|
-
{},
|
|
1171
|
-
styleOverrides.activeStyle,
|
|
1172
|
-
getPropertyFromData(data, "activeStyle") || {}
|
|
1173
|
-
);
|
|
1174
|
-
const hoverStyle = deepMerge(
|
|
1175
|
-
{},
|
|
1176
|
-
styleOverrides.hoverStyle,
|
|
1177
|
-
getPropertyFromData(data, "hoverStyle") || {}
|
|
1178
|
-
);
|
|
1179
|
-
this.style = style;
|
|
1180
|
-
this.activeStyle = deepMerge({}, style, activeStyle);
|
|
1181
|
-
this.hoverStyle = deepMerge({}, style, hoverStyle);
|
|
1182
|
-
this.activeHoverStyle = deepMerge({}, style, hoverStyle, activeStyle);
|
|
1183
|
-
};
|
|
1184
|
-
Article.prototype.setStyle = function(option, value) {
|
|
1185
|
-
if (typeof option === "string") {
|
|
1186
|
-
if (typeof value === "undefined") {
|
|
1187
|
-
return getPropertyFromData(this.style, option);
|
|
1188
|
-
}
|
|
1189
|
-
option = buildObjectFromPath(option, value);
|
|
1190
|
-
}
|
|
1191
|
-
this.data.style = deepMerge(this.data.style || {}, option);
|
|
1192
|
-
this.initialiseStyles(this.data);
|
|
1193
|
-
this.invalidateCaches();
|
|
1194
|
-
this.owner.requestRedraw();
|
|
1195
|
-
};
|
|
1196
|
-
Article.prototype.setHoverStyle = function(option, value) {
|
|
1197
|
-
if (typeof option === "string") {
|
|
1198
|
-
if (typeof value === "undefined") {
|
|
1199
|
-
return getPropertyFromData(this.activeStyle, option);
|
|
1200
|
-
}
|
|
1201
|
-
option = buildObjectFromPath(option, value);
|
|
1202
|
-
}
|
|
1203
|
-
this.data.hoverStyle = deepMerge(this.data.hoverStyle || {}, option);
|
|
1204
|
-
this.initialiseStyles(this.data);
|
|
1205
|
-
this.owner.requestRedraw();
|
|
1206
|
-
};
|
|
1207
|
-
Article.prototype.setActiveStyle = function(option, value) {
|
|
1208
|
-
if (typeof option === "string") {
|
|
1209
|
-
if (typeof value === "undefined") {
|
|
1210
|
-
return getPropertyFromData(this.activeStyle, option);
|
|
1211
|
-
}
|
|
1212
|
-
option = buildObjectFromPath(option, value);
|
|
1213
|
-
}
|
|
1214
|
-
this.data.activeStyle = deepMerge(this.data.activeStyle || {}, option);
|
|
1215
|
-
this.initialiseStyles(this.data);
|
|
1216
|
-
this.owner.requestRedraw();
|
|
1217
|
-
};
|
|
1218
|
-
Article.prototype.activated = function() {
|
|
1219
|
-
Logger.warn(
|
|
1220
|
-
'DEPRECATION WARNING: article.activated() was deprecated in v1.3.0. Use timeline.select(article.id) and handle selection with options.on["article-select"] instead.'
|
|
1221
|
-
);
|
|
1222
|
-
this.owner.trigger("article-click", this);
|
|
1223
|
-
};
|
|
1224
|
-
Article.prototype.updateVisibility = function() {
|
|
1225
|
-
const oldVisibility = this.isVisibleAfterFade;
|
|
1226
|
-
const newVisibility = this.isInRange && this.isVisibleInLane && this.isVisibleInGroup && this.isVisibleInRows && !this.isHiddenByFilter;
|
|
1227
|
-
if (!this.isVisibleInLane) {
|
|
1228
|
-
this.setVisibility(false);
|
|
1229
|
-
return;
|
|
1230
|
-
}
|
|
1231
|
-
if (oldVisibility === newVisibility) {
|
|
1232
|
-
return;
|
|
1233
|
-
}
|
|
1234
|
-
if (newVisibility && !this.isImageInfoLoaded) {
|
|
1235
|
-
this.setImage();
|
|
1236
|
-
}
|
|
1237
|
-
if (!this.owner.options.article.animation.fade.active) {
|
|
1238
|
-
this.setVisibility(newVisibility);
|
|
1239
|
-
return;
|
|
1240
|
-
}
|
|
1241
|
-
this.setVisibilityWithFade(newVisibility);
|
|
1242
|
-
};
|
|
1243
|
-
Article.prototype.setVisibility = function(visibility) {
|
|
1244
|
-
var _a, _b, _c, _d;
|
|
1245
|
-
if (this.isFading && ((_b = (_a = this.fadeAnimation) == null ? void 0 : _a.dummyElement) == null ? void 0 : _b.stop)) {
|
|
1246
|
-
this.fadeAnimation.dummyElement.stop();
|
|
1247
|
-
this.isFading = false;
|
|
1248
|
-
if (((_d = (_c = this.owner) == null ? void 0 : _c.lastAnimatingArticle) == null ? void 0 : _d.id) === this.id && this.owner.lastAnimatingArticle.animationType === "fade") {
|
|
1249
|
-
this.owner.isAnimatingArticles = false;
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
this.isVisible = visibility;
|
|
1253
|
-
this.isVisibleAfterFade = visibility;
|
|
1254
|
-
this.opacity = visibility ? 1 : 0;
|
|
1255
|
-
if (!visibility) {
|
|
1256
|
-
this._releaseImageResource({ skipRedraw: true });
|
|
1257
|
-
}
|
|
1258
|
-
};
|
|
1259
|
-
Article.prototype.setVisibilityWithFade = function(visibility) {
|
|
1260
|
-
var _a, _b, _c, _d;
|
|
1261
|
-
const me = this;
|
|
1262
|
-
if (visibility === me.isVisibleAfterFade) {
|
|
1263
|
-
return;
|
|
1264
|
-
}
|
|
1265
|
-
if (me.isFading && ((_b = (_a = me.fadeAnimation) == null ? void 0 : _a.dummyElement) == null ? void 0 : _b.stop)) {
|
|
1266
|
-
me.fadeAnimation.dummyElement.stop();
|
|
1267
|
-
}
|
|
1268
|
-
me.isFading = true;
|
|
1269
|
-
me.isVisibleAfterFade = visibility;
|
|
1270
|
-
me.fadeAnimation = me.fadeAnimation || {};
|
|
1271
|
-
me.fadeAnimation.finalOpacity = visibility;
|
|
1272
|
-
if (visibility) {
|
|
1273
|
-
me.isVisible = true;
|
|
1274
|
-
}
|
|
1275
|
-
me.owner.notifyArticleAnimating("fade", me.id);
|
|
1276
|
-
const settings = me.owner.options.article.animation.fade;
|
|
1277
|
-
const duration = (_c = settings.duration) != null ? _c : 400;
|
|
1278
|
-
const easingName = (_d = settings.easing) != null ? _d : "swing";
|
|
1279
|
-
const easingFn = EASINGS[easingName] || EASINGS.swing;
|
|
1280
|
-
const startOpacity = me.opacity;
|
|
1281
|
-
const endOpacity = visibility ? 1 : 0;
|
|
1282
|
-
const fadeTween = tween({
|
|
1283
|
-
from: startOpacity,
|
|
1284
|
-
to: endOpacity,
|
|
1285
|
-
duration,
|
|
1286
|
-
easing: easingFn,
|
|
1287
|
-
/** Fired every animation frame */
|
|
1288
|
-
onUpdate(value) {
|
|
1289
|
-
me.opacity = value;
|
|
1290
|
-
me.owner.requestRedraw();
|
|
1291
|
-
},
|
|
1292
|
-
/** Finalise */
|
|
1293
|
-
onComplete() {
|
|
1294
|
-
me.isFading = false;
|
|
1295
|
-
if (!visibility) {
|
|
1296
|
-
me.isVisible = false;
|
|
1297
|
-
me._releaseImageResource({ skipRedraw: true });
|
|
1298
|
-
}
|
|
1299
|
-
const last = me.owner.lastAnimatingArticle;
|
|
1300
|
-
if (me.id === last.id && last.animationType === "fade") {
|
|
1301
|
-
me.owner.isAnimatingArticles = false;
|
|
1302
|
-
}
|
|
1303
|
-
if (typeof settings.complete === "function") {
|
|
1304
|
-
settings.complete.call(me);
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
});
|
|
1308
|
-
me.fadeAnimation.dummyElement = fadeTween;
|
|
1309
|
-
};
|
|
1310
|
-
Article.prototype.moveToOffset = function(destination) {
|
|
1311
|
-
this.finalOffset.top = this.offset.top = destination.top || this.offset.top;
|
|
1312
|
-
this.finalOffset.left = this.offset.left = destination.left || this.offset.left;
|
|
1313
|
-
this.position.top = this.registeredPosition.top + this.offset.top;
|
|
1314
|
-
this.position.left = this.registeredPosition.left + this.offset.left;
|
|
1315
|
-
};
|
|
1316
|
-
Article.prototype.moveTo = function(destination) {
|
|
1317
|
-
const finalOffset = {
|
|
1318
|
-
left: destination.left - this.registeredPosition.left,
|
|
1319
|
-
top: destination.top - this.registeredPosition.top
|
|
1320
|
-
};
|
|
1321
|
-
this.moveToOffset(finalOffset);
|
|
1322
|
-
};
|
|
1323
|
-
Article.prototype.moveToWithAnim = function(destination) {
|
|
1324
|
-
const finalOffset = {
|
|
1325
|
-
left: destination.left - this.registeredPosition.left,
|
|
1326
|
-
top: destination.top - this.registeredPosition.top
|
|
1327
|
-
};
|
|
1328
|
-
this.moveToOffsetWithAnim(finalOffset);
|
|
1329
|
-
};
|
|
1330
|
-
Article.prototype.moveToOffsetWithAnim = function(destination) {
|
|
1331
|
-
var _a, _b, _c;
|
|
1332
|
-
const me = this;
|
|
1333
|
-
const moveAnimation = me.moveAnimation;
|
|
1334
|
-
if (destination.top === moveAnimation.finalOffset.top && destination.left === moveAnimation.finalOffset.left) {
|
|
1335
|
-
return;
|
|
1336
|
-
}
|
|
1337
|
-
if (me.isMoving && ((_a = moveAnimation == null ? void 0 : moveAnimation.dummyElement) == null ? void 0 : _a.stop)) {
|
|
1338
|
-
moveAnimation.dummyElement.stop();
|
|
1339
|
-
}
|
|
1340
|
-
moveAnimation.finalOffset = this.finalOffset = {
|
|
1341
|
-
left: destination.left,
|
|
1342
|
-
top: destination.top
|
|
1343
|
-
};
|
|
1344
|
-
me.isMoving = true;
|
|
1345
|
-
me.owner.notifyArticleAnimating("move", me.id);
|
|
1346
|
-
const settings = me.owner.options.article.animation.move;
|
|
1347
|
-
const duration = (_b = settings.duration) != null ? _b : 400;
|
|
1348
|
-
const easingName = (_c = settings.easing) != null ? _c : "swing";
|
|
1349
|
-
const easingFn = EASINGS[easingName] || EASINGS.swing;
|
|
1350
|
-
const startTop = me.offset.top;
|
|
1351
|
-
const startLeft = me.offset.left;
|
|
1352
|
-
const deltaTop = destination.top - startTop;
|
|
1353
|
-
const deltaLeft = destination.left - startLeft;
|
|
1354
|
-
const moveTween = tween({
|
|
1355
|
-
from: 0,
|
|
1356
|
-
to: 1,
|
|
1357
|
-
duration,
|
|
1358
|
-
easing: easingFn,
|
|
1359
|
-
onUpdate(progress) {
|
|
1360
|
-
me.offset.top = startTop + deltaTop * progress;
|
|
1361
|
-
me.offset.left = startLeft + deltaLeft * progress;
|
|
1362
|
-
me.position.top = me.registeredPosition.top + me.offset.top;
|
|
1363
|
-
me.position.left = me.registeredPosition.left + me.offset.left;
|
|
1364
|
-
me.owner.requestRedraw();
|
|
1365
|
-
},
|
|
1366
|
-
onComplete() {
|
|
1367
|
-
me.offset.top = destination.top;
|
|
1368
|
-
me.offset.left = destination.left;
|
|
1369
|
-
me.position.top = me.registeredPosition.top + destination.top;
|
|
1370
|
-
me.position.left = me.registeredPosition.left + destination.left;
|
|
1371
|
-
me.isMoving = false;
|
|
1372
|
-
const last = me.owner.lastAnimatingArticle;
|
|
1373
|
-
if (me.id === last.id && last.animationType === "move") {
|
|
1374
|
-
me.owner.isAnimatingArticles = false;
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
});
|
|
1378
|
-
moveAnimation.dummyElement = moveTween;
|
|
1379
|
-
};
|
|
1380
|
-
function roundPixel(value) {
|
|
1381
|
-
return Math.round(value);
|
|
1382
|
-
}
|
|
1383
|
-
__name(roundPixel, "roundPixel");
|
|
1384
|
-
function snapPixel(value, dpr = 1) {
|
|
1385
|
-
const ratio = typeof dpr === "number" && isFinite(dpr) && dpr > 0 ? dpr : 1;
|
|
1386
|
-
return Math.round(value * ratio) / ratio;
|
|
1387
|
-
}
|
|
1388
|
-
__name(snapPixel, "snapPixel");
|
|
1389
|
-
function retainPixel(value) {
|
|
1390
|
-
return value;
|
|
1391
|
-
}
|
|
1392
|
-
__name(retainPixel, "retainPixel");
|
|
1393
|
-
function createPixelSnap(dpr = 1, mode = "device") {
|
|
1394
|
-
if (mode === false || mode === "none") {
|
|
1395
|
-
return retainPixel;
|
|
1396
|
-
}
|
|
1397
|
-
if (mode === "css") {
|
|
1398
|
-
return roundPixel;
|
|
1399
|
-
}
|
|
1400
|
-
return /* @__PURE__ */ __name(function snapToDevicePixel(value) {
|
|
1401
|
-
return snapPixel(value, dpr);
|
|
1402
|
-
}, "snapToDevicePixel");
|
|
1403
|
-
}
|
|
1404
|
-
__name(createPixelSnap, "createPixelSnap");
|
|
1405
|
-
function createStrokePixelSnap(dpr = 1, mode = "device", lineWidth = 1) {
|
|
1406
|
-
if (mode === false || mode === "none") {
|
|
1407
|
-
return retainPixel;
|
|
1408
|
-
}
|
|
1409
|
-
const deviceRatio = typeof dpr === "number" && isFinite(dpr) && dpr > 0 ? dpr : 1;
|
|
1410
|
-
const ratio = mode === "css" ? 1 : deviceRatio;
|
|
1411
|
-
const width = typeof lineWidth === "number" && isFinite(lineWidth) && lineWidth > 0 ? lineWidth : 1;
|
|
1412
|
-
const halfPhysicalWidth = width * ratio / 2;
|
|
1413
|
-
return /* @__PURE__ */ __name(function snapStrokeCentre(value) {
|
|
1414
|
-
return (Math.round(value * ratio - halfPhysicalWidth) + halfPhysicalWidth) / ratio;
|
|
1415
|
-
}, "snapStrokeCentre");
|
|
1416
|
-
}
|
|
1417
|
-
__name(createStrokePixelSnap, "createStrokePixelSnap");
|
|
1418
|
-
function createInnerSpace(outerSpace, borderWidth, snap) {
|
|
1419
|
-
if (!snap) {
|
|
1420
|
-
snap = roundPixel;
|
|
1421
|
-
}
|
|
1422
|
-
const halfBorder = borderWidth / 2;
|
|
1423
|
-
return {
|
|
1424
|
-
left: snap(outerSpace.left + halfBorder),
|
|
1425
|
-
top: snap(outerSpace.top + halfBorder),
|
|
1426
|
-
width: snap(outerSpace.width - borderWidth),
|
|
1427
|
-
height: snap(outerSpace.height - borderWidth)
|
|
1428
|
-
};
|
|
1429
|
-
}
|
|
1430
|
-
__name(createInnerSpace, "createInnerSpace");
|
|
1431
|
-
Article.prototype.draw = function(ctx) {
|
|
1432
|
-
if (!this.isDataLoaded || isNaN(this.position.left)) {
|
|
1433
|
-
return;
|
|
1434
|
-
}
|
|
1435
|
-
this._ensureSizeCache();
|
|
1436
|
-
ctx.globalAlpha = this.opacity;
|
|
1437
|
-
const cardLayout = this._getCurrentCardLayout();
|
|
1438
|
-
cardLayout.draw.call(this, ctx);
|
|
1439
|
-
};
|
|
1440
|
-
Article.prototype.getCurrentStyle = function() {
|
|
1441
|
-
if (this.isActive) {
|
|
1442
|
-
return this.isMouseover ? this.activeHoverStyle : this.activeStyle;
|
|
1443
|
-
}
|
|
1444
|
-
return this.isMouseover ? this.hoverStyle : this.style;
|
|
1445
|
-
};
|
|
1446
|
-
Article.prototype._getCurrentStyle = function() {
|
|
1447
|
-
return this.getCurrentStyle();
|
|
1448
|
-
};
|
|
1449
|
-
Article.prototype._getPeriodLineRenderGeometry = function(axisY) {
|
|
1450
|
-
const resolvedArticleOptions = this.owner._getResolvedArticleOptions(this);
|
|
1451
|
-
const periodLineOptions = resolvedArticleOptions.periodLine || {};
|
|
1452
|
-
const globalPeriodLineOptions = this.owner.options.article.periodLine || {};
|
|
1453
|
-
const position = globalPeriodLineOptions.position || "axis";
|
|
1454
|
-
const baselineGap = Number.isFinite(periodLineOptions.baselineGap) ? periodLineOptions.baselineGap : 0;
|
|
1455
|
-
const spacing = this.hidePeriodLine ? 0 : periodLineOptions.spacing || 0;
|
|
1456
|
-
const thickness = this.hidePeriodLine ? 0 : periodLineOptions.thickness || 0;
|
|
1457
|
-
const offset = (spacing + thickness) * this.stacking;
|
|
1458
|
-
let anchorY = axisY;
|
|
1459
|
-
let anchorOffset = this.owner.options.style.mainLine.size / 2;
|
|
1460
|
-
if (position === "lane" && this.owner._isLaneLayoutActive()) {
|
|
1461
|
-
const lane = this.owner.getLaneById(this.laneId);
|
|
1462
|
-
if (lane && lane.geometry) {
|
|
1463
|
-
anchorY = Math.floor(lane.geometry.bottom);
|
|
1464
|
-
anchorOffset = 0;
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
const y = anchorY - baselineGap - offset - anchorOffset - thickness / 2;
|
|
1468
|
-
return {
|
|
1469
|
-
position,
|
|
1470
|
-
baselineGap,
|
|
1471
|
-
spacing,
|
|
1472
|
-
thickness,
|
|
1473
|
-
anchorY,
|
|
1474
|
-
anchorOffset,
|
|
1475
|
-
y
|
|
1476
|
-
};
|
|
1477
|
-
};
|
|
1478
|
-
Article.prototype.drawPeriodLinesAndConnectors = function(ctx, axisY) {
|
|
1479
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1480
|
-
ctx.globalAlpha = this.opacity;
|
|
1481
|
-
const style = this.getCurrentStyle();
|
|
1482
|
-
const geometry = this._getPeriodLineRenderGeometry(axisY);
|
|
1483
|
-
const y = geometry.y;
|
|
1484
|
-
if (!this.hidePeriodLine) {
|
|
1485
|
-
const fromX = this.indicator.fromX, toX = this.indicator.toX;
|
|
1486
|
-
ctx.beginPath();
|
|
1487
|
-
ctx.lineWidth = geometry.thickness;
|
|
1488
|
-
ctx.moveTo(fromX, y);
|
|
1489
|
-
ctx.lineTo(toX, y);
|
|
1490
|
-
if (this.period.isToPresent) {
|
|
1491
|
-
const periodLength = toX - fromX, maxFadeLength = 15, fadeStartColorStop = Math.max(1 - maxFadeLength / periodLength, 0.7), grad = ctx.createLinearGradient(fromX, y, toX, y);
|
|
1492
|
-
grad.addColorStop(0, style.color);
|
|
1493
|
-
grad.addColorStop(fadeStartColorStop, style.color);
|
|
1494
|
-
grad.addColorStop(1, "rgba(255,255,255,0)");
|
|
1495
|
-
ctx.strokeStyle = grad;
|
|
1496
|
-
} else {
|
|
1497
|
-
ctx.strokeStyle = style.color;
|
|
1498
|
-
}
|
|
1499
|
-
ctx.stroke();
|
|
1500
|
-
}
|
|
1501
|
-
if (!style.connectorLine.visible) {
|
|
1502
|
-
return;
|
|
1503
|
-
}
|
|
1504
|
-
const cardLayout = this._getCurrentCardLayout();
|
|
1505
|
-
const connectorEnd = typeof cardLayout.getConnectorEnd === "function" ? cardLayout.getConnectorEnd.call(this) : {
|
|
1506
|
-
left: this.position.left + style.connectorLine.offsetX,
|
|
1507
|
-
top: this.position.top + this.getHeight() + style.connectorLine.offsetY
|
|
1508
|
-
};
|
|
1509
|
-
const x1 = Math.max(0, this.indicator.fromX);
|
|
1510
|
-
const y1 = y;
|
|
1511
|
-
const x2 = connectorEnd.left;
|
|
1512
|
-
const y2 = connectorEnd.top;
|
|
1513
|
-
const isVertical = Math.abs(x1 - x2) < Number.EPSILON;
|
|
1514
|
-
const pixelSnapMode = (_d = (_c = (_b = (_a = this.owner) == null ? void 0 : _a.options) == null ? void 0 : _b.article) == null ? void 0 : _c.rendering) == null ? void 0 : _d.pixelSnap;
|
|
1515
|
-
const snapStroke = createStrokePixelSnap(
|
|
1516
|
-
((_f = (_e = this.owner) == null ? void 0 : _e.getCanvasDpr) == null ? void 0 : _f.call(_e)) || 1,
|
|
1517
|
-
pixelSnapMode,
|
|
1518
|
-
style.connectorLine.thickness
|
|
1519
|
-
);
|
|
1520
|
-
const connectorX = isVertical ? snapStroke(x2) : null;
|
|
1521
|
-
const drawX1 = connectorX != null ? connectorX : x1;
|
|
1522
|
-
const drawX2 = connectorX != null ? connectorX : x2;
|
|
1523
|
-
ctx.strokeStyle = ctx.fillStyle = style.color;
|
|
1524
|
-
ctx.lineWidth = style.connectorLine.thickness;
|
|
1525
|
-
ctx.beginPath();
|
|
1526
|
-
ctx.moveTo(drawX1, y1);
|
|
1527
|
-
ctx.lineTo(drawX2, y2);
|
|
1528
|
-
ctx.stroke();
|
|
1529
|
-
const radians = Math.atan((y2 - y1) / (drawX2 - drawX1)) + (drawX2 >= drawX1 ? -90 : 90) * Math.PI / 180;
|
|
1530
|
-
ctx.save();
|
|
1531
|
-
ctx.beginPath();
|
|
1532
|
-
ctx.translate(drawX2, y2);
|
|
1533
|
-
ctx.rotate(radians);
|
|
1534
|
-
ctx.moveTo(-style.connectorLine.arrow.width, 0);
|
|
1535
|
-
ctx.lineTo(style.connectorLine.arrow.width, 0);
|
|
1536
|
-
ctx.lineTo(0, -style.connectorLine.arrow.height);
|
|
1537
|
-
ctx.closePath();
|
|
1538
|
-
ctx.restore();
|
|
1539
|
-
ctx.fill();
|
|
1540
|
-
};
|
|
1541
|
-
Article.prototype.getIconBox = function() {
|
|
1542
|
-
const cardLayout = this._getCurrentCardLayout();
|
|
1543
|
-
return cardLayout.getIconBox.call(this);
|
|
1544
|
-
};
|
|
1545
|
-
Article.prototype.startDragging = function(pos, evt) {
|
|
1546
|
-
if (this.isMoving) {
|
|
1547
|
-
this.moveAnimation.dummyElement.stop();
|
|
1548
|
-
}
|
|
1549
|
-
this.isDragging = true;
|
|
1550
|
-
this.dragInitialPosition = { left: this.position.left, top: this.position.top };
|
|
1551
|
-
this.lastDragPosition = { left: this.position.left, top: this.position.top };
|
|
1552
|
-
this.dragStartOffset = {
|
|
1553
|
-
left: pos.left - this.position.left,
|
|
1554
|
-
top: pos.top - this.position.top
|
|
1555
|
-
};
|
|
1556
|
-
this.owner.startAnimation();
|
|
1557
|
-
if (this.owner && typeof this.owner.trigger === "function") {
|
|
1558
|
-
this.owner.trigger("article-drag-start", this, evt);
|
|
1559
|
-
}
|
|
1560
|
-
};
|
|
1561
|
-
Article.prototype.stopDragging = function(evt) {
|
|
1562
|
-
var _a, _b;
|
|
1563
|
-
this.offset = this.finalOffset = this.moveAnimation.finalOffset = {
|
|
1564
|
-
left: this.position.left - this.registeredPosition.left,
|
|
1565
|
-
top: this.position.top - this.registeredPosition.top
|
|
1566
|
-
};
|
|
1567
|
-
this.isDragging = false;
|
|
1568
|
-
(_b = (_a = this.owner) == null ? void 0 : _a._markTimelineStateChanged) == null ? void 0 : _b.call(_a);
|
|
1569
|
-
if (this.owner && typeof this.owner.trigger === "function") {
|
|
1570
|
-
this.owner.trigger("article-drag-end", this, evt);
|
|
1571
|
-
}
|
|
1572
|
-
};
|
|
1573
|
-
Article.prototype.dragging = function(pos, evt) {
|
|
1574
|
-
const newPosition = {
|
|
1575
|
-
left: pos.left - this.dragStartOffset.left,
|
|
1576
|
-
top: pos.top - this.dragStartOffset.top
|
|
1577
|
-
};
|
|
1578
|
-
const previousPosition = this.lastDragPosition || {
|
|
1579
|
-
left: this.position.left,
|
|
1580
|
-
top: this.position.top
|
|
1581
|
-
};
|
|
1582
|
-
const initialPosition = this.dragInitialPosition || previousPosition;
|
|
1583
|
-
const dx = newPosition.left - previousPosition.left;
|
|
1584
|
-
const dy = newPosition.top - previousPosition.top;
|
|
1585
|
-
const totalDx = newPosition.left - initialPosition.left;
|
|
1586
|
-
const totalDy = newPosition.top - initialPosition.top;
|
|
1587
|
-
this.position = newPosition;
|
|
1588
|
-
this.lastDragPosition = newPosition;
|
|
1589
|
-
if (this.owner && typeof this.owner.trigger === "function") {
|
|
1590
|
-
this.owner.trigger("article-drag", this, { dx, dy, totalDx, totalDy }, evt);
|
|
1591
|
-
}
|
|
1592
|
-
};
|
|
1593
|
-
Article.prototype._cacheBucket = function() {
|
|
1594
|
-
const name = this._getCurrentCardLayoutName();
|
|
1595
|
-
if (!this._layoutCaches) {
|
|
1596
|
-
this._layoutCaches = /* @__PURE__ */ Object.create(null);
|
|
1597
|
-
}
|
|
1598
|
-
return this._layoutCaches[name] || (this._layoutCaches[name] = /* @__PURE__ */ Object.create(null));
|
|
1599
|
-
};
|
|
1600
|
-
Article.prototype.memo = function(key, factory) {
|
|
1601
|
-
const bucket = this._cacheBucket();
|
|
1602
|
-
return key in bucket ? bucket[key] : bucket[key] = factory.call(this);
|
|
1603
|
-
};
|
|
1604
|
-
Article.prototype._getSizeCacheKey = function() {
|
|
1605
|
-
var _a, _b;
|
|
1606
|
-
const style = typeof this.getCurrentStyle === "function" ? this.getCurrentStyle() : null;
|
|
1607
|
-
const imageStyle = style && style.image || {};
|
|
1608
|
-
const header = style && style.header || {};
|
|
1609
|
-
const subheader = style && style.subheader || {};
|
|
1610
|
-
const border = style && style.border || {};
|
|
1611
|
-
const layout = typeof this._getCurrentCardLayoutName === "function" ? this._getCurrentCardLayoutName() : "";
|
|
1612
|
-
const hasImage = this.imageLoaded && this.image;
|
|
1613
|
-
const keyParts = [
|
|
1614
|
-
layout,
|
|
1615
|
-
style && style.width,
|
|
1616
|
-
style && style.height,
|
|
1617
|
-
header.height,
|
|
1618
|
-
subheader.height,
|
|
1619
|
-
border.width,
|
|
1620
|
-
(_a = imageStyle.margin) != null ? _a : 0,
|
|
1621
|
-
imageStyle.shape || "",
|
|
1622
|
-
(_b = imageStyle.maxHeight) != null ? _b : "",
|
|
1623
|
-
style && style.maxImageHeight !== void 0 ? style.maxImageHeight : "",
|
|
1624
|
-
hasImage ? this.image.width : "noimg",
|
|
1625
|
-
hasImage ? this.image.height : ""
|
|
1626
|
-
];
|
|
1627
|
-
return keyParts.join("|");
|
|
1628
|
-
};
|
|
1629
|
-
Article.prototype.updateCachedSize = function() {
|
|
1630
|
-
const cardLayout = this._getCurrentCardLayout();
|
|
1631
|
-
this._cachedWidth = cardLayout.getWidth.call(this);
|
|
1632
|
-
this._cachedHeight = cardLayout.getHeight.call(this);
|
|
1633
|
-
this.height = this._cachedHeight;
|
|
1634
|
-
this._sizeValid = true;
|
|
1635
|
-
this._sizeCacheKey = this._getSizeCacheKey();
|
|
1636
|
-
};
|
|
1637
|
-
Article.prototype._ensureSizeCache = function() {
|
|
1638
|
-
const cacheKey = this._getSizeCacheKey();
|
|
1639
|
-
if (!this._sizeValid || cacheKey !== this._sizeCacheKey) {
|
|
1640
|
-
this.updateCachedSize();
|
|
1641
|
-
}
|
|
1642
|
-
};
|
|
1643
|
-
Article.prototype.invalidateCaches = function() {
|
|
1644
|
-
this._sizeValid = false;
|
|
1645
|
-
this._sizeCacheKey = null;
|
|
1646
|
-
if (this._layoutCaches) {
|
|
1647
|
-
const buckets = this._layoutCaches;
|
|
1648
|
-
for (const layoutName in buckets) {
|
|
1649
|
-
const bucket = buckets[layoutName];
|
|
1650
|
-
if (!bucket) {
|
|
1651
|
-
continue;
|
|
1652
|
-
}
|
|
1653
|
-
for (const k in bucket) {
|
|
1654
|
-
const v = bucket[k];
|
|
1655
|
-
if (v && typeof v.close === "function") {
|
|
1656
|
-
try {
|
|
1657
|
-
v.close();
|
|
1658
|
-
} catch (e) {
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
this._layoutCaches = null;
|
|
1665
|
-
};
|
|
1666
|
-
Article.prototype._getCurrentCardLayoutName = function() {
|
|
1667
|
-
return this._resolvedCardLayoutName || this.cardLayout || this._resolvedDefaultCardLayout || this.owner._resolveArticleCardLayoutName(this);
|
|
1668
|
-
};
|
|
1669
|
-
Article.prototype._getCurrentCardLayout = function() {
|
|
1670
|
-
return this.owner.getCardLayout(this._getCurrentCardLayoutName());
|
|
1671
|
-
};
|
|
1672
|
-
Article.prototype.setCardLayout = function(cardLayout) {
|
|
1673
|
-
const layout = this.owner.getCardLayout(cardLayout);
|
|
1674
|
-
if (!layout) {
|
|
1675
|
-
throw new Error(`Card layout "${cardLayout}" not found`);
|
|
1676
|
-
}
|
|
1677
|
-
this.cardLayout = cardLayout;
|
|
1678
|
-
this._resolvedCardLayoutName = cardLayout;
|
|
1679
|
-
this.initialiseStyles();
|
|
1680
|
-
this.invalidateCaches();
|
|
1681
|
-
this.owner.requestRedraw(this.redraw);
|
|
1682
|
-
};
|
|
1683
|
-
function compareArticleIds(idA, idB) {
|
|
1684
|
-
const numA = Number(idA);
|
|
1685
|
-
const numB = Number(idB);
|
|
1686
|
-
const idsAreNumeric = Number.isFinite(numA) && Number.isFinite(numB);
|
|
1687
|
-
if (idsAreNumeric) {
|
|
1688
|
-
return numA - numB;
|
|
1689
|
-
}
|
|
1690
|
-
const strA = String(idA);
|
|
1691
|
-
const strB = String(idB);
|
|
1692
|
-
if (strA === strB) {
|
|
1693
|
-
return 0;
|
|
1694
|
-
}
|
|
1695
|
-
return strA < strB ? -1 : 1;
|
|
1696
|
-
}
|
|
1697
|
-
__name(compareArticleIds, "compareArticleIds");
|
|
1698
|
-
function ARTICLE_DURATION_SORTER(articleA, articleB) {
|
|
1699
|
-
const a = articleA.period.from.getDaysTo(articleA.period.to);
|
|
1700
|
-
const b = articleB.period.from.getDaysTo(articleB.period.to);
|
|
1701
|
-
if (a < b) {
|
|
1702
|
-
return 1;
|
|
1703
|
-
}
|
|
1704
|
-
if (a > b) {
|
|
1705
|
-
return -1;
|
|
1706
|
-
}
|
|
1707
|
-
return compareArticleIds(articleA.id, articleB.id);
|
|
1708
|
-
}
|
|
1709
|
-
__name(ARTICLE_DURATION_SORTER, "ARTICLE_DURATION_SORTER");
|
|
1710
|
-
function ARTICLE_DURATION_YEARS_SORTER(articleA, articleB) {
|
|
1711
|
-
const a = articleA.period.years;
|
|
1712
|
-
const b = articleB.period.years;
|
|
1713
|
-
if (a < b) {
|
|
1714
|
-
return 1;
|
|
1715
|
-
}
|
|
1716
|
-
if (a > b) {
|
|
1717
|
-
return -1;
|
|
1718
|
-
}
|
|
1719
|
-
return compareArticleIds(articleA.id, articleB.id);
|
|
1720
|
-
}
|
|
1721
|
-
__name(ARTICLE_DURATION_YEARS_SORTER, "ARTICLE_DURATION_YEARS_SORTER");
|
|
1722
|
-
function ARTICLE_IMAGE_QUEUE_SORTER(articleA, articleB) {
|
|
1723
|
-
const a = articleA.isInView && articleA.isVisible;
|
|
1724
|
-
const b = articleB.isInView && articleB.isVisible;
|
|
1725
|
-
if (!a && b) {
|
|
1726
|
-
return -1;
|
|
1727
|
-
}
|
|
1728
|
-
if (a && !b) {
|
|
1729
|
-
return 1;
|
|
1730
|
-
}
|
|
1731
|
-
return articleA.position.top - articleB.position.top;
|
|
1732
|
-
}
|
|
1733
|
-
__name(ARTICLE_IMAGE_QUEUE_SORTER, "ARTICLE_IMAGE_QUEUE_SORTER");
|
|
1734
|
-
function ARTICLE_FROM_SORTER(articleA, articleB) {
|
|
1735
|
-
const a = articleA.period.from;
|
|
1736
|
-
const b = articleB.period.from;
|
|
1737
|
-
let result = a.compare(b);
|
|
1738
|
-
if (result === 0) {
|
|
1739
|
-
result = compareArticleIds(articleB.id, articleA.id);
|
|
1740
|
-
}
|
|
1741
|
-
return result;
|
|
1742
|
-
}
|
|
1743
|
-
__name(ARTICLE_FROM_SORTER, "ARTICLE_FROM_SORTER");
|
|
1744
|
-
function ARTICLE_TO_SORTER(articleA, articleB) {
|
|
1745
|
-
const a = articleA.period.to;
|
|
1746
|
-
const b = articleB.period.to;
|
|
1747
|
-
let result = b.compare(a);
|
|
1748
|
-
if (result === 0) {
|
|
1749
|
-
result = compareArticleIds(articleB.id, articleA.id);
|
|
1750
|
-
}
|
|
1751
|
-
return result;
|
|
1752
|
-
}
|
|
1753
|
-
__name(ARTICLE_TO_SORTER, "ARTICLE_TO_SORTER");
|
|
1754
|
-
function ARTICLE_TOP_SORTER(articleA, articleB) {
|
|
1755
|
-
const a = articleA.position.top;
|
|
1756
|
-
const b = articleB.position.top;
|
|
1757
|
-
if (a < b) {
|
|
1758
|
-
return -1;
|
|
1759
|
-
}
|
|
1760
|
-
if (a > b) {
|
|
1761
|
-
return 1;
|
|
1762
|
-
}
|
|
1763
|
-
return compareArticleIds(articleB.id, articleA.id);
|
|
1764
|
-
}
|
|
1765
|
-
__name(ARTICLE_TOP_SORTER, "ARTICLE_TOP_SORTER");
|
|
1766
|
-
function ARTICLE_ROW_SORTER(articleA, articleB) {
|
|
1767
|
-
const laneOrderA = articleA.laneOrder || 0;
|
|
1768
|
-
const laneOrderB = articleB.laneOrder || 0;
|
|
1769
|
-
if (laneOrderA > laneOrderB) {
|
|
1770
|
-
return -1;
|
|
1771
|
-
}
|
|
1772
|
-
if (laneOrderA < laneOrderB) {
|
|
1773
|
-
return 1;
|
|
1774
|
-
}
|
|
1775
|
-
const a = articleA.row;
|
|
1776
|
-
const b = articleB.row;
|
|
1777
|
-
if (a < b) {
|
|
1778
|
-
return 1;
|
|
1779
|
-
}
|
|
1780
|
-
if (a > b) {
|
|
1781
|
-
return -1;
|
|
1782
|
-
}
|
|
1783
|
-
return compareArticleIds(articleB.id, articleA.id);
|
|
1784
|
-
}
|
|
1785
|
-
__name(ARTICLE_ROW_SORTER, "ARTICLE_ROW_SORTER");
|
|
1786
|
-
function ARTICLE_RANK_SORTER(articleA, articleB) {
|
|
1787
|
-
const a = articleA.rank;
|
|
1788
|
-
const b = articleB.rank;
|
|
1789
|
-
if (a < b) {
|
|
1790
|
-
return 1;
|
|
1791
|
-
}
|
|
1792
|
-
if (a > b) {
|
|
1793
|
-
return -1;
|
|
1794
|
-
}
|
|
1795
|
-
return compareArticleIds(articleB.id, articleA.id);
|
|
1796
|
-
}
|
|
1797
|
-
__name(ARTICLE_RANK_SORTER, "ARTICLE_RANK_SORTER");
|
|
1798
|
-
function ARTICLE_EFFECTIVE_RANK_SORTER(articleA, articleB) {
|
|
1799
|
-
const a = articleA.effectiveRank;
|
|
1800
|
-
const b = articleB.effectiveRank;
|
|
1801
|
-
if (a < b) {
|
|
1802
|
-
return 1;
|
|
1803
|
-
}
|
|
1804
|
-
if (a > b) {
|
|
1805
|
-
return -1;
|
|
1806
|
-
}
|
|
1807
|
-
return compareArticleIds(articleB.id, articleA.id);
|
|
1808
|
-
}
|
|
1809
|
-
__name(ARTICLE_EFFECTIVE_RANK_SORTER, "ARTICLE_EFFECTIVE_RANK_SORTER");
|
|
1810
|
-
function ARTICLE_POSITION_SORTER(articleA, articleB) {
|
|
1811
|
-
const a = articleA.position.left;
|
|
1812
|
-
const b = articleB.position.left;
|
|
1813
|
-
let result = a < b ? 1 : a > b ? -1 : 0;
|
|
1814
|
-
if (result === 0) {
|
|
1815
|
-
result = articleA.position.top - articleB.position.top;
|
|
1816
|
-
if (result === 0) {
|
|
1817
|
-
result = articleA.period.from.compare(articleB.period.from);
|
|
1818
|
-
if (result === 0) {
|
|
1819
|
-
result = compareArticleIds(articleA.id, articleB.id);
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
return result;
|
|
1824
|
-
}
|
|
1825
|
-
__name(ARTICLE_POSITION_SORTER, "ARTICLE_POSITION_SORTER");
|
|
1826
|
-
const sorters = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1827
|
-
__proto__: null,
|
|
1828
|
-
ARTICLE_DURATION_SORTER,
|
|
1829
|
-
ARTICLE_DURATION_YEARS_SORTER,
|
|
1830
|
-
ARTICLE_EFFECTIVE_RANK_SORTER,
|
|
1831
|
-
ARTICLE_FROM_SORTER,
|
|
1832
|
-
ARTICLE_IMAGE_QUEUE_SORTER,
|
|
1833
|
-
ARTICLE_POSITION_SORTER,
|
|
1834
|
-
ARTICLE_RANK_SORTER,
|
|
1835
|
-
ARTICLE_ROW_SORTER,
|
|
1836
|
-
ARTICLE_TOP_SORTER,
|
|
1837
|
-
ARTICLE_TO_SORTER
|
|
1838
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
1839
|
-
const MINOR_MARKER = 0;
|
|
1840
|
-
const MAJOR_MARKER = 1;
|
|
1841
|
-
const ERA_MARKER = 2;
|
|
1842
|
-
const ZOOM_MILLISECOND = -4;
|
|
1843
|
-
const ZOOM_SECOND = -3;
|
|
1844
|
-
const ZOOM_MINUTE = -2;
|
|
1845
|
-
const ZOOM_HOUR = -1;
|
|
1846
|
-
const ZOOM_DAY = 0;
|
|
1847
|
-
const ZOOM_MONTH = 1;
|
|
1848
|
-
const ZOOM_YEAR = 2;
|
|
1849
|
-
const ZOOM_DECADE = 3;
|
|
1850
|
-
const ZOOM_CENTURY = 4;
|
|
1851
|
-
const ZOOM_MILLENNIUM = 5;
|
|
1852
|
-
const ZOOM_10_THOUSAND_YEARS = 6;
|
|
1853
|
-
const ZOOM_100_THOUSAND_YEARS = 7;
|
|
1854
|
-
const ZOOM_MILLION_YEARS = 8;
|
|
1855
|
-
const ZOOM_10_MILLION_YEARS = 9;
|
|
1856
|
-
const ZOOM_100_MILLION_YEARS = 10;
|
|
1857
|
-
const ZOOM_BILLION_YEARS = 11;
|
|
1858
|
-
const PRECISION_MILLISECOND = "millisecond";
|
|
1859
|
-
const PRECISION_SECOND = "second";
|
|
1860
|
-
const PRECISION_MINUTE = "minute";
|
|
1861
|
-
const PRECISION_HOUR = "hour";
|
|
1862
|
-
const PRECISION_DAY = "day";
|
|
1863
|
-
const PRECISION_MONTH = "month";
|
|
1864
|
-
const PRECISION_YEAR = "year";
|
|
1865
|
-
const PRECISION_DECADE = "decade";
|
|
1866
|
-
const PRECISION_CENTURY = "century";
|
|
1867
|
-
const PRECISION_MILLENNIUM = "millennium";
|
|
1868
|
-
const PRECISION_MILLION_YEARS = "million-years";
|
|
1869
|
-
const PRECISION_BILLION_YEARS = "billion-years";
|
|
1870
|
-
const YEAR_PREFIXES = {
|
|
1871
|
-
//uses power of ten of prefix as key to access it's settings
|
|
1872
|
-
3: { label: " ka", value: 1e3 },
|
|
1873
|
-
6: { label: " Ma", value: 1e6 },
|
|
1874
|
-
9: { label: " Ga", value: 1e9 }
|
|
90
|
+
const MINOR_MARKER = 0;
|
|
91
|
+
const MAJOR_MARKER = 1;
|
|
92
|
+
const ERA_MARKER = 2;
|
|
93
|
+
const ZOOM_MILLISECOND = -4;
|
|
94
|
+
const ZOOM_SECOND = -3;
|
|
95
|
+
const ZOOM_MINUTE = -2;
|
|
96
|
+
const ZOOM_HOUR = -1;
|
|
97
|
+
const ZOOM_DAY = 0;
|
|
98
|
+
const ZOOM_MONTH = 1;
|
|
99
|
+
const ZOOM_YEAR = 2;
|
|
100
|
+
const ZOOM_DECADE = 3;
|
|
101
|
+
const ZOOM_CENTURY = 4;
|
|
102
|
+
const ZOOM_MILLENNIUM = 5;
|
|
103
|
+
const ZOOM_10_THOUSAND_YEARS = 6;
|
|
104
|
+
const ZOOM_100_THOUSAND_YEARS = 7;
|
|
105
|
+
const ZOOM_MILLION_YEARS = 8;
|
|
106
|
+
const ZOOM_10_MILLION_YEARS = 9;
|
|
107
|
+
const ZOOM_100_MILLION_YEARS = 10;
|
|
108
|
+
const ZOOM_BILLION_YEARS = 11;
|
|
109
|
+
const PRECISION_MILLISECOND = "millisecond";
|
|
110
|
+
const PRECISION_SECOND = "second";
|
|
111
|
+
const PRECISION_MINUTE = "minute";
|
|
112
|
+
const PRECISION_HOUR = "hour";
|
|
113
|
+
const PRECISION_DAY = "day";
|
|
114
|
+
const PRECISION_MONTH = "month";
|
|
115
|
+
const PRECISION_YEAR = "year";
|
|
116
|
+
const PRECISION_DECADE = "decade";
|
|
117
|
+
const PRECISION_CENTURY = "century";
|
|
118
|
+
const PRECISION_MILLENNIUM = "millennium";
|
|
119
|
+
const PRECISION_MILLION_YEARS = "million-years";
|
|
120
|
+
const PRECISION_BILLION_YEARS = "billion-years";
|
|
121
|
+
const YEAR_PREFIXES = {
|
|
122
|
+
//uses power of ten of prefix as key to access it's settings
|
|
123
|
+
3: { label: " ka", value: 1e3 },
|
|
124
|
+
6: { label: " Ma", value: 1e6 },
|
|
125
|
+
9: { label: " Ga", value: 1e9 }
|
|
1875
126
|
};
|
|
1876
127
|
const DENSITY_LOW = "low";
|
|
1877
128
|
const DENSITY_MEDIUM = "medium";
|
|
@@ -2483,48 +734,1835 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
2483
734
|
all: 25,
|
|
2484
735
|
step: { months: 0, days: 549755813888 }
|
|
2485
736
|
}
|
|
2486
|
-
];
|
|
2487
|
-
const constants = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
737
|
+
];
|
|
738
|
+
const constants = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
739
|
+
__proto__: null,
|
|
740
|
+
DENSITY_ALL,
|
|
741
|
+
DENSITY_HIGH,
|
|
742
|
+
DENSITY_LOW,
|
|
743
|
+
DENSITY_MEDIUM,
|
|
744
|
+
DENSITY_SETTINGS,
|
|
745
|
+
ERA_MARKER,
|
|
746
|
+
MAJOR_MARKER,
|
|
747
|
+
MINOR_MARKER,
|
|
748
|
+
PRECISION_BILLION_YEARS,
|
|
749
|
+
PRECISION_CENTURY,
|
|
750
|
+
PRECISION_DAY,
|
|
751
|
+
PRECISION_DECADE,
|
|
752
|
+
PRECISION_HOUR,
|
|
753
|
+
PRECISION_MILLENNIUM,
|
|
754
|
+
PRECISION_MILLION_YEARS,
|
|
755
|
+
PRECISION_MILLISECOND,
|
|
756
|
+
PRECISION_MINUTE,
|
|
757
|
+
PRECISION_MONTH,
|
|
758
|
+
PRECISION_SECOND,
|
|
759
|
+
PRECISION_YEAR,
|
|
760
|
+
RANGE_ALL,
|
|
761
|
+
RANGE_SCREEN,
|
|
762
|
+
YEAR_PREFIXES,
|
|
763
|
+
ZOOM_100_MILLION_YEARS,
|
|
764
|
+
ZOOM_100_THOUSAND_YEARS,
|
|
765
|
+
ZOOM_10_MILLION_YEARS,
|
|
766
|
+
ZOOM_10_THOUSAND_YEARS,
|
|
767
|
+
ZOOM_BILLION_YEARS,
|
|
768
|
+
ZOOM_CENTURY,
|
|
769
|
+
ZOOM_DAY,
|
|
770
|
+
ZOOM_DECADE,
|
|
771
|
+
ZOOM_HOUR,
|
|
772
|
+
ZOOM_MILLENNIUM,
|
|
773
|
+
ZOOM_MILLION_YEARS,
|
|
774
|
+
ZOOM_MILLISECOND,
|
|
775
|
+
ZOOM_MINUTE,
|
|
776
|
+
ZOOM_MONTH,
|
|
777
|
+
ZOOM_SECOND,
|
|
778
|
+
ZOOM_YEAR
|
|
779
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
780
|
+
const _LoggerImpl = class _LoggerImpl {
|
|
781
|
+
constructor() {
|
|
782
|
+
this._enabled = false;
|
|
783
|
+
this._prefix = "[Histropedia]";
|
|
784
|
+
const c = typeof console !== "undefined" ? console : null;
|
|
785
|
+
this._console = c;
|
|
786
|
+
this._fns = {
|
|
787
|
+
log: c && c.log ? c.log.bind(c) : () => {
|
|
788
|
+
},
|
|
789
|
+
warn: c && c.warn ? c.warn.bind(c) : () => {
|
|
790
|
+
},
|
|
791
|
+
error: c && c.error ? c.error.bind(c) : () => {
|
|
792
|
+
},
|
|
793
|
+
info: c && c.info ? c.info.bind(c) : () => {
|
|
794
|
+
},
|
|
795
|
+
debug: c && c.debug ? c.debug.bind(c) : c && c.log ? c.log.bind(c) : () => {
|
|
796
|
+
},
|
|
797
|
+
group: c && c.group ? c.group.bind(c) : c && c.log ? c.log.bind(c) : () => {
|
|
798
|
+
},
|
|
799
|
+
groupCollapsed: c && c.groupCollapsed ? c.groupCollapsed.bind(c) : c && c.group ? c.group.bind(c) : c && c.log ? c.log.bind(c) : () => {
|
|
800
|
+
},
|
|
801
|
+
groupEnd: c && c.groupEnd ? c.groupEnd.bind(c) : () => {
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
setEnabled(enabled) {
|
|
806
|
+
this._enabled = !!enabled;
|
|
807
|
+
}
|
|
808
|
+
isEnabled() {
|
|
809
|
+
return !!this._enabled;
|
|
810
|
+
}
|
|
811
|
+
setPrefix(prefix) {
|
|
812
|
+
this._prefix = String(prefix || "");
|
|
813
|
+
}
|
|
814
|
+
getPrefix() {
|
|
815
|
+
return this._prefix;
|
|
816
|
+
}
|
|
817
|
+
_withPrefixedArgs(argsArray) {
|
|
818
|
+
if (!this._prefix) {
|
|
819
|
+
return argsArray;
|
|
820
|
+
}
|
|
821
|
+
if (argsArray && argsArray.length > 0 && typeof argsArray[0] === "string") {
|
|
822
|
+
const cloned = argsArray.slice();
|
|
823
|
+
cloned[0] = `${this._prefix} ${cloned[0]}`;
|
|
824
|
+
return cloned;
|
|
825
|
+
}
|
|
826
|
+
return [this._prefix, ...argsArray];
|
|
827
|
+
}
|
|
828
|
+
_log(method, args) {
|
|
829
|
+
if (!this._enabled) {
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
const fn = this._fns[method] || this._fns.log;
|
|
833
|
+
fn(...this._withPrefixedArgs(args));
|
|
834
|
+
}
|
|
835
|
+
log(...args) {
|
|
836
|
+
this._log("log", args);
|
|
837
|
+
}
|
|
838
|
+
warn(...args) {
|
|
839
|
+
this._log("warn", args);
|
|
840
|
+
}
|
|
841
|
+
error(...args) {
|
|
842
|
+
this._log("error", args);
|
|
843
|
+
}
|
|
844
|
+
info(...args) {
|
|
845
|
+
this._log("info", args);
|
|
846
|
+
}
|
|
847
|
+
debug(...args) {
|
|
848
|
+
this._log("debug", args);
|
|
849
|
+
}
|
|
850
|
+
group(...args) {
|
|
851
|
+
if (!this._enabled) {
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
this._fns.group(...this._withPrefixedArgs(args));
|
|
855
|
+
}
|
|
856
|
+
groupCollapsed(...args) {
|
|
857
|
+
if (!this._enabled) {
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
this._fns.groupCollapsed(...this._withPrefixedArgs(args));
|
|
861
|
+
}
|
|
862
|
+
groupEnd() {
|
|
863
|
+
if (!this._enabled) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
this._fns.groupEnd();
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
__name(_LoggerImpl, "LoggerImpl");
|
|
870
|
+
let LoggerImpl = _LoggerImpl;
|
|
871
|
+
const Logger = new LoggerImpl();
|
|
872
|
+
const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
873
|
+
const MONTH_NAMES = [
|
|
874
|
+
"Jan",
|
|
875
|
+
"Feb",
|
|
876
|
+
"Mar",
|
|
877
|
+
"Apr",
|
|
878
|
+
"May",
|
|
879
|
+
"Jun",
|
|
880
|
+
"Jul",
|
|
881
|
+
"Aug",
|
|
882
|
+
"Sep",
|
|
883
|
+
"Oct",
|
|
884
|
+
"Nov",
|
|
885
|
+
"Dec"
|
|
886
|
+
];
|
|
887
|
+
const LEGACY_PRECISIONS = {
|
|
888
|
+
1: "billion-years",
|
|
889
|
+
3: "million-years",
|
|
890
|
+
6: "millennium",
|
|
891
|
+
7: "century",
|
|
892
|
+
8: "decade",
|
|
893
|
+
9: "year",
|
|
894
|
+
10: "month",
|
|
895
|
+
11: "day",
|
|
896
|
+
12: "hour",
|
|
897
|
+
13: "minute",
|
|
898
|
+
14: "second",
|
|
899
|
+
15: "millisecond"
|
|
900
|
+
};
|
|
901
|
+
const DMY_STRING_PATTERN = /^(-?\d+)(?:-(\d{1,2}))?(?:-(\d{1,2}))?(?:[T ](\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?$/;
|
|
902
|
+
const MILLISECONDS_PER_SECOND = 1e3;
|
|
903
|
+
const MILLISECONDS_PER_MINUTE = 60 * MILLISECONDS_PER_SECOND;
|
|
904
|
+
const MILLISECONDS_PER_HOUR = 60 * MILLISECONDS_PER_MINUTE;
|
|
905
|
+
const MILLISECONDS_PER_DAY = 24 * MILLISECONDS_PER_HOUR;
|
|
906
|
+
function normalizePrecision(precision) {
|
|
907
|
+
return Object.prototype.hasOwnProperty.call(LEGACY_PRECISIONS, precision) ? LEGACY_PRECISIONS[precision] : precision || "day";
|
|
908
|
+
}
|
|
909
|
+
__name(normalizePrecision, "normalizePrecision");
|
|
910
|
+
function getDatePrecision(parts) {
|
|
911
|
+
if (parts.precision !== void 0) {
|
|
912
|
+
return parts.precision;
|
|
913
|
+
}
|
|
914
|
+
if (!(parts instanceof Dmy)) {
|
|
915
|
+
for (const component of [
|
|
916
|
+
PRECISION_MILLISECOND,
|
|
917
|
+
PRECISION_SECOND,
|
|
918
|
+
PRECISION_MINUTE,
|
|
919
|
+
PRECISION_HOUR
|
|
920
|
+
]) {
|
|
921
|
+
if (parts[component] !== void 0) {
|
|
922
|
+
return component;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
return PRECISION_DAY;
|
|
927
|
+
}
|
|
928
|
+
__name(getDatePrecision, "getDatePrecision");
|
|
929
|
+
function getHistoricalPeriodBounds(year, size) {
|
|
930
|
+
if (year <= 0) {
|
|
931
|
+
const historicalYear = 1 - year;
|
|
932
|
+
const oldestYear = Math.ceil(historicalYear / size) * size;
|
|
933
|
+
return { startYear: 1 - oldestYear, endYear: size - oldestYear };
|
|
934
|
+
}
|
|
935
|
+
const endYear = Math.ceil(year / size) * size;
|
|
936
|
+
return {
|
|
937
|
+
startYear: endYear - size + 1,
|
|
938
|
+
endYear
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
__name(getHistoricalPeriodBounds, "getHistoricalPeriodBounds");
|
|
942
|
+
function getDecadeBounds(year) {
|
|
943
|
+
if (year <= 0) {
|
|
944
|
+
const decade = Math.floor((1 - year) / 10) * 10;
|
|
945
|
+
return { startYear: 1 - (decade + 9), endYear: 1 - Math.max(1, decade) };
|
|
946
|
+
}
|
|
947
|
+
const startYear = Math.floor(year / 10) * 10;
|
|
948
|
+
return { startYear: Math.max(1, startYear), endYear: startYear + 9 };
|
|
949
|
+
}
|
|
950
|
+
__name(getDecadeBounds, "getDecadeBounds");
|
|
951
|
+
function clampInteger(value, fallback, minimum, maximum) {
|
|
952
|
+
const parsed = Number(value);
|
|
953
|
+
if (!Number.isFinite(parsed)) {
|
|
954
|
+
return fallback;
|
|
955
|
+
}
|
|
956
|
+
return Math.min(maximum, Math.max(minimum, Math.trunc(parsed)));
|
|
957
|
+
}
|
|
958
|
+
__name(clampInteger, "clampInteger");
|
|
959
|
+
function setTimeParts(target, hour, minute, second, millisecond) {
|
|
960
|
+
const values = {
|
|
961
|
+
hour: clampInteger(hour, 0, 0, 23),
|
|
962
|
+
minute: clampInteger(minute, 0, 0, 59),
|
|
963
|
+
second: clampInteger(second, 0, 0, 59),
|
|
964
|
+
millisecond: clampInteger(millisecond, 0, 0, 999)
|
|
965
|
+
};
|
|
966
|
+
for (const [key, value] of Object.entries(values)) {
|
|
967
|
+
Object.defineProperty(target, key, {
|
|
968
|
+
value,
|
|
969
|
+
enumerable: value !== 0,
|
|
970
|
+
configurable: true,
|
|
971
|
+
writable: true
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
__name(setTimeParts, "setTimeParts");
|
|
976
|
+
function setPrecision(target, precision) {
|
|
977
|
+
if (precision === void 0) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
Object.defineProperty(target, "precision", {
|
|
981
|
+
value: precision,
|
|
982
|
+
enumerable: false,
|
|
983
|
+
configurable: true,
|
|
984
|
+
writable: true
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
__name(setPrecision, "setPrecision");
|
|
988
|
+
function createAdjustedDmy(source, values) {
|
|
989
|
+
return new Dmy(__spreadProps(__spreadValues({}, values), { precision: getDatePrecision(source) }));
|
|
990
|
+
}
|
|
991
|
+
__name(createAdjustedDmy, "createAdjustedDmy");
|
|
992
|
+
function Dmy(year, month, day, hour, minute, second, millisecond) {
|
|
993
|
+
if (typeof year === "object") {
|
|
994
|
+
const options = year;
|
|
995
|
+
this.year = options.year;
|
|
996
|
+
this.month = options.month;
|
|
997
|
+
this.day = getCorrectDay(options.year, options.month, options.day);
|
|
998
|
+
setTimeParts(this, options.hour, options.minute, options.second, options.millisecond);
|
|
999
|
+
setPrecision(this, getDatePrecision(options));
|
|
1000
|
+
} else {
|
|
1001
|
+
this.year = year;
|
|
1002
|
+
this.month = month;
|
|
1003
|
+
this.day = getCorrectDay(year, month, day);
|
|
1004
|
+
setTimeParts(this, hour, minute, second, millisecond);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
__name(Dmy, "Dmy");
|
|
1008
|
+
function getCorrectDay(year, month, day) {
|
|
1009
|
+
return day > 28 ? Math.min(day, daysInMonth(year, month)) : day;
|
|
1010
|
+
}
|
|
1011
|
+
__name(getCorrectDay, "getCorrectDay");
|
|
1012
|
+
function daysInMonth(year, month) {
|
|
1013
|
+
if (month === 2) {
|
|
1014
|
+
if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
|
|
1015
|
+
return 29;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return DAYS_IN_MONTH[month - 1];
|
|
1019
|
+
}
|
|
1020
|
+
__name(daysInMonth, "daysInMonth");
|
|
1021
|
+
function digitGroupedNumber(number, separator) {
|
|
1022
|
+
number = number.toString();
|
|
1023
|
+
separator = typeof separator === "string" ? separator : ",";
|
|
1024
|
+
if (number.length <= 4) {
|
|
1025
|
+
return number;
|
|
1026
|
+
}
|
|
1027
|
+
return number.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
|
|
1028
|
+
}
|
|
1029
|
+
__name(digitGroupedNumber, "digitGroupedNumber");
|
|
1030
|
+
Dmy.prototype.getDaysTo = function(other) {
|
|
1031
|
+
const dayDifference = other.getDaysSinceYearZero() - this.getDaysSinceYearZero();
|
|
1032
|
+
const timeDifference = other.getMillisecondsOfDay() - this.getMillisecondsOfDay();
|
|
1033
|
+
return dayDifference + timeDifference / MILLISECONDS_PER_DAY;
|
|
1034
|
+
};
|
|
1035
|
+
Dmy.prototype.getMillisecondsOfDay = function() {
|
|
1036
|
+
return this.hour * MILLISECONDS_PER_HOUR + this.minute * MILLISECONDS_PER_MINUTE + this.second * MILLISECONDS_PER_SECOND + this.millisecond;
|
|
1037
|
+
};
|
|
1038
|
+
Dmy.prototype.getMonthsTo = function(other) {
|
|
1039
|
+
return this.getYearsTo(other) * 12;
|
|
1040
|
+
};
|
|
1041
|
+
Dmy.prototype.getYearsTo = function(other) {
|
|
1042
|
+
let yearDiff = other.year - this.year;
|
|
1043
|
+
yearDiff += (other.month - this.month) / 12 + (other.day - this.day) / 365.2422 + (other.getMillisecondsOfDay() - this.getMillisecondsOfDay()) / (MILLISECONDS_PER_DAY * 365.2422);
|
|
1044
|
+
return yearDiff;
|
|
1045
|
+
};
|
|
1046
|
+
Dmy.prototype.getLeapYearsSinceYearZero = function() {
|
|
1047
|
+
let year = this.year;
|
|
1048
|
+
if (this.month < 3) {
|
|
1049
|
+
year--;
|
|
1050
|
+
}
|
|
1051
|
+
return Math.floor(year / 4) - Math.floor(year / 100) + Math.floor(year / 400);
|
|
1052
|
+
};
|
|
1053
|
+
Dmy.prototype.getDaysSinceYearZero = function() {
|
|
1054
|
+
const year = this.year;
|
|
1055
|
+
let days = year * 365 + this.day;
|
|
1056
|
+
for (let i = 0; i < this.month - 1; i++) {
|
|
1057
|
+
days += DAYS_IN_MONTH[i];
|
|
1058
|
+
}
|
|
1059
|
+
days += this.getLeapYearsSinceYearZero();
|
|
1060
|
+
return days;
|
|
1061
|
+
};
|
|
1062
|
+
Dmy.prototype.getDayOfYear = function() {
|
|
1063
|
+
let dayOfYear = this.day;
|
|
1064
|
+
for (let m = 1; m < this.month; m++) {
|
|
1065
|
+
dayOfYear += daysInMonth(this.year, m);
|
|
1066
|
+
}
|
|
1067
|
+
return dayOfYear;
|
|
1068
|
+
};
|
|
1069
|
+
Dmy.getByDayOfYear = function(year, dayOfYear) {
|
|
1070
|
+
const dmy = new Dmy(year, 1, 1);
|
|
1071
|
+
let dim = DAYS_IN_MONTH[0];
|
|
1072
|
+
for (let i = 0; i < dayOfYear - 1; i++) {
|
|
1073
|
+
dmy.day++;
|
|
1074
|
+
if (dmy.day > dim) {
|
|
1075
|
+
dmy.day = 1;
|
|
1076
|
+
dmy.month++;
|
|
1077
|
+
if (dmy.month > 12) {
|
|
1078
|
+
dmy.month = 1;
|
|
1079
|
+
dmy.year++;
|
|
1080
|
+
}
|
|
1081
|
+
dim = dmy.month === 2 ? daysInMonth(dmy.year, dmy.month) : DAYS_IN_MONTH[dmy.month - 1];
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return dmy;
|
|
1085
|
+
};
|
|
1086
|
+
Dmy.prototype.getNextDay = function() {
|
|
1087
|
+
return this.addDays(1);
|
|
1088
|
+
};
|
|
1089
|
+
Dmy.prototype.addDays = function(amount) {
|
|
1090
|
+
let day = this.day;
|
|
1091
|
+
let month = this.month;
|
|
1092
|
+
let year = this.year;
|
|
1093
|
+
const direction = amount < 0 ? -1 : 1;
|
|
1094
|
+
let remaining = Math.abs(Math.trunc(amount));
|
|
1095
|
+
while (remaining > 0) {
|
|
1096
|
+
if (direction > 0) {
|
|
1097
|
+
day++;
|
|
1098
|
+
if (day > daysInMonth(year, month)) {
|
|
1099
|
+
day = 1;
|
|
1100
|
+
month++;
|
|
1101
|
+
if (month > 12) {
|
|
1102
|
+
month = 1;
|
|
1103
|
+
year++;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
} else {
|
|
1107
|
+
day--;
|
|
1108
|
+
if (day < 1) {
|
|
1109
|
+
month--;
|
|
1110
|
+
if (month < 1) {
|
|
1111
|
+
month = 12;
|
|
1112
|
+
year--;
|
|
1113
|
+
}
|
|
1114
|
+
day = daysInMonth(year, month);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
remaining--;
|
|
1118
|
+
}
|
|
1119
|
+
return createAdjustedDmy(this, {
|
|
1120
|
+
year,
|
|
1121
|
+
month,
|
|
1122
|
+
day,
|
|
1123
|
+
hour: this.hour,
|
|
1124
|
+
minute: this.minute,
|
|
1125
|
+
second: this.second,
|
|
1126
|
+
millisecond: this.millisecond
|
|
1127
|
+
});
|
|
1128
|
+
};
|
|
1129
|
+
Dmy.prototype.addMilliseconds = function(amount) {
|
|
1130
|
+
let date = this;
|
|
1131
|
+
let milliseconds = this.getMillisecondsOfDay() + Math.trunc(amount);
|
|
1132
|
+
while (milliseconds < 0) {
|
|
1133
|
+
date = date.addDays(-1);
|
|
1134
|
+
milliseconds += MILLISECONDS_PER_DAY;
|
|
1135
|
+
}
|
|
1136
|
+
while (milliseconds >= MILLISECONDS_PER_DAY) {
|
|
1137
|
+
date = date.addDays(1);
|
|
1138
|
+
milliseconds -= MILLISECONDS_PER_DAY;
|
|
1139
|
+
}
|
|
1140
|
+
const hour = Math.floor(milliseconds / MILLISECONDS_PER_HOUR);
|
|
1141
|
+
milliseconds -= hour * MILLISECONDS_PER_HOUR;
|
|
1142
|
+
const minute = Math.floor(milliseconds / MILLISECONDS_PER_MINUTE);
|
|
1143
|
+
milliseconds -= minute * MILLISECONDS_PER_MINUTE;
|
|
1144
|
+
const second = Math.floor(milliseconds / MILLISECONDS_PER_SECOND);
|
|
1145
|
+
const millisecond = milliseconds - second * MILLISECONDS_PER_SECOND;
|
|
1146
|
+
return createAdjustedDmy(this, {
|
|
1147
|
+
year: date.year,
|
|
1148
|
+
month: date.month,
|
|
1149
|
+
day: date.day,
|
|
1150
|
+
hour,
|
|
1151
|
+
minute,
|
|
1152
|
+
second,
|
|
1153
|
+
millisecond
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1156
|
+
Dmy.prototype.addSeconds = function(amount) {
|
|
1157
|
+
return this.addMilliseconds(amount * MILLISECONDS_PER_SECOND);
|
|
1158
|
+
};
|
|
1159
|
+
Dmy.prototype.addMinutes = function(amount) {
|
|
1160
|
+
return this.addMilliseconds(amount * MILLISECONDS_PER_MINUTE);
|
|
1161
|
+
};
|
|
1162
|
+
Dmy.prototype.addHours = function(amount) {
|
|
1163
|
+
return this.addMilliseconds(amount * MILLISECONDS_PER_HOUR);
|
|
1164
|
+
};
|
|
1165
|
+
Dmy.prototype.addMonths = function(amount) {
|
|
1166
|
+
let month = this.month;
|
|
1167
|
+
let year = this.year;
|
|
1168
|
+
for (let i = 0; i < amount; i++) {
|
|
1169
|
+
month++;
|
|
1170
|
+
if (month > 12) {
|
|
1171
|
+
month = 1;
|
|
1172
|
+
year++;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
return createAdjustedDmy(this, { year, month, day: 1 });
|
|
1176
|
+
};
|
|
1177
|
+
Dmy.prototype.getPreviousDay = function() {
|
|
1178
|
+
return this.addDays(-1);
|
|
1179
|
+
};
|
|
1180
|
+
Dmy.prototype.getNextMonth = function() {
|
|
1181
|
+
let month = this.month;
|
|
1182
|
+
let year = this.year;
|
|
1183
|
+
month++;
|
|
1184
|
+
if (month > 12) {
|
|
1185
|
+
month = 1;
|
|
1186
|
+
year++;
|
|
1187
|
+
}
|
|
1188
|
+
return createAdjustedDmy(this, { year, month, day: 1 });
|
|
1189
|
+
};
|
|
1190
|
+
Dmy.prototype.getPreviousMonth = function() {
|
|
1191
|
+
let month = this.month;
|
|
1192
|
+
let year = this.year;
|
|
1193
|
+
month--;
|
|
1194
|
+
if (month < 1) {
|
|
1195
|
+
month = 12;
|
|
1196
|
+
year--;
|
|
1197
|
+
}
|
|
1198
|
+
return createAdjustedDmy(this, { year, month, day: 1 });
|
|
1199
|
+
};
|
|
1200
|
+
Dmy.prototype.addYears = function(amount) {
|
|
1201
|
+
return createAdjustedDmy(this, { year: this.year + amount, month: 1, day: 1 });
|
|
1202
|
+
};
|
|
1203
|
+
function pad(value, length) {
|
|
1204
|
+
return String(value).padStart(length, "0");
|
|
1205
|
+
}
|
|
1206
|
+
__name(pad, "pad");
|
|
1207
|
+
Dmy.prototype.format = function(format, options) {
|
|
1208
|
+
options = options || {};
|
|
1209
|
+
format = format || "D MMM YYYY";
|
|
1210
|
+
const prefixSettings = options.yearPrefix;
|
|
1211
|
+
const bceText = typeof options.bceText === "string" ? options.bceText : " ʙᴄᴇ";
|
|
1212
|
+
const isBc = this.year <= 0;
|
|
1213
|
+
const is1Bc = this.year === 0;
|
|
1214
|
+
const thousandsSeparator = options.thousandsSeparator;
|
|
1215
|
+
if (prefixSettings && !is1Bc) {
|
|
1216
|
+
const prefixValue = prefixSettings.value || 1;
|
|
1217
|
+
const prefixLabel = prefixSettings.label || "";
|
|
1218
|
+
let formattedYear;
|
|
1219
|
+
if (isBc) {
|
|
1220
|
+
formattedYear = digitGroupedNumber((-this.year + 1) / prefixValue, thousandsSeparator) + prefixLabel + bceText;
|
|
1221
|
+
} else {
|
|
1222
|
+
formattedYear = digitGroupedNumber(this.year / prefixValue, thousandsSeparator) + prefixLabel;
|
|
1223
|
+
}
|
|
1224
|
+
return formattedYear;
|
|
1225
|
+
}
|
|
1226
|
+
return format.replace(
|
|
1227
|
+
"YYYY",
|
|
1228
|
+
isBc ? digitGroupedNumber(-this.year + 1, thousandsSeparator) + bceText : digitGroupedNumber(this.year, thousandsSeparator)
|
|
1229
|
+
).replace("D", this.day).replace("MMM", MONTH_NAMES[this.month - 1]).replace("HH", pad(this.hour, 2)).replace("mm", pad(this.minute, 2)).replace("ss", pad(this.second, 2)).replace("SSS", pad(this.millisecond, 3));
|
|
1230
|
+
};
|
|
1231
|
+
Dmy.prototype.isSame = function(other) {
|
|
1232
|
+
return other.year === this.year && other.month === this.month && other.day === this.day && (other.hour || 0) === this.hour && (other.minute || 0) === this.minute && (other.second || 0) === this.second && (other.millisecond || 0) === this.millisecond;
|
|
1233
|
+
};
|
|
1234
|
+
Dmy.prototype.toKeyString = function() {
|
|
1235
|
+
const dateKey = `${this.year}|${this.month}|${this.day}`;
|
|
1236
|
+
if (this.getMillisecondsOfDay() === 0) {
|
|
1237
|
+
return dateKey;
|
|
1238
|
+
}
|
|
1239
|
+
return `${dateKey}|${this.hour}|${this.minute}|${this.second}|${this.millisecond}`;
|
|
1240
|
+
};
|
|
1241
|
+
Dmy.prototype.isAfter = function(other) {
|
|
1242
|
+
const fields = ["year", "month", "day", "hour", "minute", "second", "millisecond"];
|
|
1243
|
+
for (let i = 0; i < fields.length; i++) {
|
|
1244
|
+
const field = fields[i];
|
|
1245
|
+
const thisValue = this[field] || 0;
|
|
1246
|
+
const otherValue = other[field] || 0;
|
|
1247
|
+
if (thisValue !== otherValue) {
|
|
1248
|
+
return thisValue > otherValue;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
return false;
|
|
1252
|
+
};
|
|
1253
|
+
Dmy.prototype.isBetween = function(from, to) {
|
|
1254
|
+
return this.isAfter(from) && to.isAfter(this);
|
|
1255
|
+
};
|
|
1256
|
+
Dmy.prototype.compare = function(other) {
|
|
1257
|
+
if (this.isSame(other)) {
|
|
1258
|
+
return 0;
|
|
1259
|
+
}
|
|
1260
|
+
if (this.isAfter(other)) {
|
|
1261
|
+
return 1;
|
|
1262
|
+
}
|
|
1263
|
+
return -1;
|
|
1264
|
+
};
|
|
1265
|
+
Dmy.prototype.asFloat = function() {
|
|
1266
|
+
const m = this.month - 1;
|
|
1267
|
+
const d = this.day - 1;
|
|
1268
|
+
const dayFraction = this.getMillisecondsOfDay() / MILLISECONDS_PER_DAY;
|
|
1269
|
+
if (m === 0 && d === 0 && dayFraction === 0) {
|
|
1270
|
+
return this.year;
|
|
1271
|
+
}
|
|
1272
|
+
return Math.round((this.year + (m * 31 + d + dayFraction) / 371) * 100) / 100;
|
|
1273
|
+
};
|
|
1274
|
+
Dmy.prototype.isInFuture = function() {
|
|
1275
|
+
const date = /* @__PURE__ */ new Date();
|
|
1276
|
+
const now = new Dmy(
|
|
1277
|
+
date.getFullYear(),
|
|
1278
|
+
date.getMonth() + 1,
|
|
1279
|
+
date.getDate(),
|
|
1280
|
+
date.getHours(),
|
|
1281
|
+
date.getMinutes(),
|
|
1282
|
+
date.getSeconds(),
|
|
1283
|
+
date.getMilliseconds()
|
|
1284
|
+
);
|
|
1285
|
+
return this.isAfter(now);
|
|
1286
|
+
};
|
|
1287
|
+
Dmy.prototype.convertToIso = function() {
|
|
1288
|
+
if (this.year < 0) {
|
|
1289
|
+
this.year += 1;
|
|
1290
|
+
}
|
|
1291
|
+
return this;
|
|
1292
|
+
};
|
|
1293
|
+
Dmy.CreateAsStartOfPeriod = function(isoDmy, precision) {
|
|
1294
|
+
const isoYear = isoDmy.year;
|
|
1295
|
+
const month = isoDmy.month || 1;
|
|
1296
|
+
const day = isoDmy.day || 1;
|
|
1297
|
+
precision = normalizePrecision(precision);
|
|
1298
|
+
if (precision === "millisecond") {
|
|
1299
|
+
return new Dmy(isoDmy);
|
|
1300
|
+
}
|
|
1301
|
+
if (precision === "second") {
|
|
1302
|
+
return new Dmy(isoYear, month, day, isoDmy.hour, isoDmy.minute, isoDmy.second, 0);
|
|
1303
|
+
}
|
|
1304
|
+
if (precision === "minute") {
|
|
1305
|
+
return new Dmy(isoYear, month, day, isoDmy.hour, isoDmy.minute, 0, 0);
|
|
1306
|
+
}
|
|
1307
|
+
if (precision === "hour") {
|
|
1308
|
+
return new Dmy(isoYear, month, day, isoDmy.hour, 0, 0, 0);
|
|
1309
|
+
}
|
|
1310
|
+
if (precision === "day") {
|
|
1311
|
+
return new Dmy(isoYear, month, day);
|
|
1312
|
+
}
|
|
1313
|
+
if (precision === "month") {
|
|
1314
|
+
return new Dmy(isoYear, month, 1);
|
|
1315
|
+
}
|
|
1316
|
+
if (precision === "year") {
|
|
1317
|
+
return new Dmy(isoYear, 1, 1);
|
|
1318
|
+
}
|
|
1319
|
+
if (precision === "million-years" || precision === "billion-years") {
|
|
1320
|
+
const size = precision === "million-years" ? 1e6 : 1e9;
|
|
1321
|
+
return new Dmy(
|
|
1322
|
+
isoYear <= 0 ? getHistoricalPeriodBounds(isoYear, size).startYear : isoYear,
|
|
1323
|
+
1,
|
|
1324
|
+
1
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1327
|
+
if (precision === "decade") {
|
|
1328
|
+
return new Dmy(getDecadeBounds(isoYear).startYear, 1, 1);
|
|
1329
|
+
}
|
|
1330
|
+
if (precision === "century") {
|
|
1331
|
+
return new Dmy(getHistoricalPeriodBounds(isoYear, 100).startYear, 1, 1);
|
|
1332
|
+
}
|
|
1333
|
+
if (precision === "millennium") {
|
|
1334
|
+
return new Dmy(getHistoricalPeriodBounds(isoYear, 1e3).startYear, 1, 1);
|
|
1335
|
+
}
|
|
1336
|
+
return new Dmy(isoYear, month, day);
|
|
1337
|
+
};
|
|
1338
|
+
Dmy.CreateAsEndOfPeriod = function(isoDmy, precision) {
|
|
1339
|
+
const isoYear = isoDmy.year;
|
|
1340
|
+
const month = isoDmy.month || 1;
|
|
1341
|
+
const day = isoDmy.day || 1;
|
|
1342
|
+
precision = normalizePrecision(precision);
|
|
1343
|
+
if (precision === "millisecond") {
|
|
1344
|
+
return new Dmy(isoDmy);
|
|
1345
|
+
}
|
|
1346
|
+
if (precision === "second") {
|
|
1347
|
+
return new Dmy(isoYear, month, day, isoDmy.hour, isoDmy.minute, isoDmy.second, 999);
|
|
1348
|
+
}
|
|
1349
|
+
if (precision === "minute") {
|
|
1350
|
+
return new Dmy(isoYear, month, day, isoDmy.hour, isoDmy.minute, 59, 999);
|
|
1351
|
+
}
|
|
1352
|
+
if (precision === "hour") {
|
|
1353
|
+
return new Dmy(isoYear, month, day, isoDmy.hour, 59, 59, 999);
|
|
1354
|
+
}
|
|
1355
|
+
if (precision === "day") {
|
|
1356
|
+
return new Dmy(isoYear, month, day);
|
|
1357
|
+
}
|
|
1358
|
+
if (precision === "month") {
|
|
1359
|
+
return new Dmy(isoYear, month, daysInMonth(isoYear, month));
|
|
1360
|
+
}
|
|
1361
|
+
if (precision === "year") {
|
|
1362
|
+
return new Dmy(isoYear, 12, 31);
|
|
1363
|
+
}
|
|
1364
|
+
if (precision === "decade") {
|
|
1365
|
+
return new Dmy(getDecadeBounds(isoYear).endYear, 12, 31);
|
|
1366
|
+
}
|
|
1367
|
+
if (precision === "century") {
|
|
1368
|
+
return new Dmy(getHistoricalPeriodBounds(isoYear, 100).endYear, 12, 31);
|
|
1369
|
+
}
|
|
1370
|
+
if (precision === "millennium") {
|
|
1371
|
+
return new Dmy(getHistoricalPeriodBounds(isoYear, 1e3).endYear, 12, 31);
|
|
1372
|
+
}
|
|
1373
|
+
if (precision === "million-years" || precision === "billion-years") {
|
|
1374
|
+
const size = precision === "million-years" ? 1e6 : 1e9;
|
|
1375
|
+
return new Dmy(
|
|
1376
|
+
isoYear <= 0 ? getHistoricalPeriodBounds(isoYear, size).endYear : isoYear + size - 1,
|
|
1377
|
+
12,
|
|
1378
|
+
31
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
Logger.error("precision is not implemented");
|
|
1382
|
+
return new Dmy(isoYear, month, day);
|
|
1383
|
+
};
|
|
1384
|
+
Dmy.CreateAsExclusiveEndOfPeriod = function(isoDmy, precision) {
|
|
1385
|
+
precision = normalizePrecision(precision);
|
|
1386
|
+
const start = Dmy.CreateAsStartOfPeriod(isoDmy, precision);
|
|
1387
|
+
if (precision === "millisecond") {
|
|
1388
|
+
return start.addMilliseconds(1);
|
|
1389
|
+
}
|
|
1390
|
+
if (precision === "second") {
|
|
1391
|
+
return start.addSeconds(1);
|
|
1392
|
+
}
|
|
1393
|
+
if (precision === "minute") {
|
|
1394
|
+
return start.addMinutes(1);
|
|
1395
|
+
}
|
|
1396
|
+
if (precision === "hour") {
|
|
1397
|
+
return start.addHours(1);
|
|
1398
|
+
}
|
|
1399
|
+
if (precision === "day") {
|
|
1400
|
+
return start.addDays(1);
|
|
1401
|
+
}
|
|
1402
|
+
return Dmy.CreateAsEndOfPeriod(isoDmy, precision).addDays(1);
|
|
1403
|
+
};
|
|
1404
|
+
Dmy.now = function() {
|
|
1405
|
+
const now = /* @__PURE__ */ new Date();
|
|
1406
|
+
return new Dmy({
|
|
1407
|
+
year: now.getYear() + 1900,
|
|
1408
|
+
month: now.getMonth() + 1,
|
|
1409
|
+
day: now.getDate()
|
|
1410
|
+
});
|
|
1411
|
+
};
|
|
1412
|
+
function parseDmyString(dateString) {
|
|
1413
|
+
const match = String(dateString).match(DMY_STRING_PATTERN);
|
|
1414
|
+
if (!match) {
|
|
1415
|
+
return null;
|
|
1416
|
+
}
|
|
1417
|
+
const year = parseInt(match[1], 10);
|
|
1418
|
+
const month = match[2] == null ? 1 : parseInt(match[2], 10);
|
|
1419
|
+
const day = match[3] == null ? 1 : parseInt(match[3], 10);
|
|
1420
|
+
const hour = match[4] == null ? 0 : parseInt(match[4], 10);
|
|
1421
|
+
const minute = match[5] == null ? 0 : parseInt(match[5], 10);
|
|
1422
|
+
const second = match[6] == null ? 0 : parseInt(match[6], 10);
|
|
1423
|
+
const millisecond = match[7] ? parseInt(match[7].padEnd(3, "0"), 10) : 0;
|
|
1424
|
+
return {
|
|
1425
|
+
// These fields are already defaulted; keep string parsing outside object inference.
|
|
1426
|
+
date: new Dmy(year, month, day, hour, minute, second, millisecond),
|
|
1427
|
+
hasMonth: match[2] != null,
|
|
1428
|
+
hasDay: match[3] != null,
|
|
1429
|
+
hasTime: match[4] != null
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
__name(parseDmyString, "parseDmyString");
|
|
1433
|
+
Dmy.fromString = function(dateString) {
|
|
1434
|
+
const parsed = parseDmyString(dateString);
|
|
1435
|
+
return parsed ? parsed.date : new Dmy(NaN, 1, 1);
|
|
1436
|
+
};
|
|
1437
|
+
function merge(target, ...sources) {
|
|
1438
|
+
return Object.assign(target, ...sources);
|
|
1439
|
+
}
|
|
1440
|
+
__name(merge, "merge");
|
|
1441
|
+
function deepMerge(target, ...sources) {
|
|
1442
|
+
const ensureSafeProto = /* @__PURE__ */ __name((obj) => {
|
|
1443
|
+
if (obj && typeof obj === "object" && !Object.prototype.hasOwnProperty.call(obj, "__proto__")) {
|
|
1444
|
+
try {
|
|
1445
|
+
Object.defineProperty(obj, "__proto__", {
|
|
1446
|
+
value: void 0,
|
|
1447
|
+
writable: true,
|
|
1448
|
+
enumerable: false,
|
|
1449
|
+
configurable: true
|
|
1450
|
+
});
|
|
1451
|
+
} catch (e) {
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}, "ensureSafeProto");
|
|
1455
|
+
ensureSafeProto(target);
|
|
1456
|
+
const isUnsafeKey = /* @__PURE__ */ __name((key) => key === "__proto__" || key === "constructor" || key === "prototype", "isUnsafeKey");
|
|
1457
|
+
const isPlainObject = /* @__PURE__ */ __name((obj) => {
|
|
1458
|
+
if (obj === null || typeof obj !== "object") {
|
|
1459
|
+
return false;
|
|
1460
|
+
}
|
|
1461
|
+
const proto = Object.getPrototypeOf(obj);
|
|
1462
|
+
return proto === Object.prototype || proto === null;
|
|
1463
|
+
}, "isPlainObject");
|
|
1464
|
+
for (const src of sources) {
|
|
1465
|
+
if (!src || typeof src !== "object") {
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
for (const k of Object.keys(src)) {
|
|
1469
|
+
if (isUnsafeKey(k)) {
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
const v = src[k];
|
|
1473
|
+
if (Array.isArray(v)) {
|
|
1474
|
+
target[k] = v.slice();
|
|
1475
|
+
continue;
|
|
1476
|
+
}
|
|
1477
|
+
if (isPlainObject(v)) {
|
|
1478
|
+
const base = isPlainObject(target[k]) ? target[k] : {};
|
|
1479
|
+
ensureSafeProto(base);
|
|
1480
|
+
target[k] = deepMerge(base, v);
|
|
1481
|
+
continue;
|
|
1482
|
+
}
|
|
1483
|
+
target[k] = v;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
ensureSafeProto(target);
|
|
1487
|
+
return target;
|
|
1488
|
+
}
|
|
1489
|
+
__name(deepMerge, "deepMerge");
|
|
1490
|
+
function buildObjectFromPath(path, value) {
|
|
1491
|
+
const pathParts = path.split(".");
|
|
1492
|
+
const pathEnd = pathParts[pathParts.length - 1];
|
|
1493
|
+
let obj = {};
|
|
1494
|
+
obj[pathEnd] = value;
|
|
1495
|
+
for (let i = pathParts.length - 2; i >= 0; i--) {
|
|
1496
|
+
const previousPathPart = pathParts[i];
|
|
1497
|
+
const objClone = deepMerge({}, obj);
|
|
1498
|
+
obj = {};
|
|
1499
|
+
obj[previousPathPart] = objClone;
|
|
1500
|
+
}
|
|
1501
|
+
return obj;
|
|
1502
|
+
}
|
|
1503
|
+
__name(buildObjectFromPath, "buildObjectFromPath");
|
|
1504
|
+
function defineValueOrFunctionProperty(obj, propName) {
|
|
1505
|
+
const privatePropertyName = `_${propName}`;
|
|
1506
|
+
obj[privatePropertyName] = void 0;
|
|
1507
|
+
Object.defineProperty(obj, propName, {
|
|
1508
|
+
get() {
|
|
1509
|
+
const value = this[privatePropertyName];
|
|
1510
|
+
if (typeof value === "function") {
|
|
1511
|
+
return value(this);
|
|
1512
|
+
}
|
|
1513
|
+
return value;
|
|
1514
|
+
},
|
|
1515
|
+
set(value) {
|
|
1516
|
+
this[privatePropertyName] = value;
|
|
1517
|
+
},
|
|
1518
|
+
enumerable: true,
|
|
1519
|
+
configurable: false
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
__name(defineValueOrFunctionProperty, "defineValueOrFunctionProperty");
|
|
1523
|
+
function isUndefined(value) {
|
|
1524
|
+
return typeof value === "undefined";
|
|
1525
|
+
}
|
|
1526
|
+
__name(isUndefined, "isUndefined");
|
|
1527
|
+
const propertyAbbreviations = {
|
|
1528
|
+
id: "i",
|
|
1529
|
+
title: "t",
|
|
1530
|
+
rank: "r",
|
|
1531
|
+
subtitle: "s",
|
|
1532
|
+
"from.year": "fy",
|
|
1533
|
+
"from.month": "fm",
|
|
1534
|
+
"from.day": "fd",
|
|
1535
|
+
"from.hour": "fhr",
|
|
1536
|
+
"from.minute": "fmi",
|
|
1537
|
+
"from.second": "fs",
|
|
1538
|
+
"from.millisecond": "fms",
|
|
1539
|
+
"from.precision": "fp",
|
|
1540
|
+
"to.year": "ty",
|
|
1541
|
+
"to.month": "tm",
|
|
1542
|
+
"to.day": "td",
|
|
1543
|
+
"to.hour": "thr",
|
|
1544
|
+
"to.minute": "tmi",
|
|
1545
|
+
"to.second": "ts",
|
|
1546
|
+
"to.millisecond": "tms",
|
|
1547
|
+
"to.precision": "tp",
|
|
1548
|
+
isToPresent: "p",
|
|
1549
|
+
isStarred: "v",
|
|
1550
|
+
"offset.left": "ol",
|
|
1551
|
+
"offset.top": "ot",
|
|
1552
|
+
imageUrl: "m",
|
|
1553
|
+
lane: "ln",
|
|
1554
|
+
style: "st",
|
|
1555
|
+
activeStyle: "ast",
|
|
1556
|
+
hiddenByFilter: "h",
|
|
1557
|
+
hidePeriodLine: "hp"
|
|
1558
|
+
};
|
|
1559
|
+
function extractProperty(data, property) {
|
|
1560
|
+
return Object.prototype.hasOwnProperty.call(data, property) ? data[property] : data[propertyAbbreviations[property]];
|
|
1561
|
+
}
|
|
1562
|
+
__name(extractProperty, "extractProperty");
|
|
1563
|
+
function extractPropertyFromPath(data, path) {
|
|
1564
|
+
const pathParts = path.split(".");
|
|
1565
|
+
const value = pathParts.reduce((curr, next) => curr ? curr[next] : void 0, data);
|
|
1566
|
+
return isUndefined(value) ? data[propertyAbbreviations[path]] : value;
|
|
1567
|
+
}
|
|
1568
|
+
__name(extractPropertyFromPath, "extractPropertyFromPath");
|
|
1569
|
+
function isPath(property) {
|
|
1570
|
+
return property.indexOf(".") > -1;
|
|
1571
|
+
}
|
|
1572
|
+
__name(isPath, "isPath");
|
|
1573
|
+
function getPropertyFromData(data, property) {
|
|
1574
|
+
if (isPath(property)) {
|
|
1575
|
+
return extractPropertyFromPath(data, property);
|
|
1576
|
+
}
|
|
1577
|
+
return extractProperty(data, property);
|
|
1578
|
+
}
|
|
1579
|
+
__name(getPropertyFromData, "getPropertyFromData");
|
|
1580
|
+
function getDmyFromData(data, prefix) {
|
|
1581
|
+
const precision = getDatePrecision(
|
|
1582
|
+
Object.fromEntries(
|
|
1583
|
+
["precision", "hour", "minute", "second", "millisecond"].map((key) => [
|
|
1584
|
+
key,
|
|
1585
|
+
getPropertyFromData(data, `${prefix}.${key}`)
|
|
1586
|
+
])
|
|
1587
|
+
)
|
|
1588
|
+
);
|
|
1589
|
+
const parts = Object.fromEntries(
|
|
1590
|
+
["year", "month", "day", "hour", "minute", "second", "millisecond"].map((key) => [
|
|
1591
|
+
key,
|
|
1592
|
+
parseInt(getPropertyFromData(data, `${prefix}.${key}`))
|
|
1593
|
+
])
|
|
1594
|
+
);
|
|
1595
|
+
return new Dmy(__spreadProps(__spreadValues({}, parts), { precision }));
|
|
1596
|
+
}
|
|
1597
|
+
__name(getDmyFromData, "getDmyFromData");
|
|
1598
|
+
function existsInData(data, property) {
|
|
1599
|
+
if (isPath(property)) {
|
|
1600
|
+
return !isUndefined(extractPropertyFromPath(data, property));
|
|
1601
|
+
}
|
|
1602
|
+
return !isUndefined(extractProperty(data, property));
|
|
1603
|
+
}
|
|
1604
|
+
__name(existsInData, "existsInData");
|
|
1605
|
+
defineValueOrFunctionProperty(Article.prototype, "hidePeriodLine");
|
|
1606
|
+
defineValueOrFunctionProperty(Article.prototype, "hiddenByFilter");
|
|
1607
|
+
function Article(owner, id) {
|
|
1608
|
+
this.id = id;
|
|
1609
|
+
this.owner = owner;
|
|
1610
|
+
this.isDataLoaded = false;
|
|
1611
|
+
this.imageLoaded = false;
|
|
1612
|
+
this.stacking = 0;
|
|
1613
|
+
this.groupIndex = 0;
|
|
1614
|
+
this.isActive = false;
|
|
1615
|
+
this.isVisible = false;
|
|
1616
|
+
this.isVisibleInLane = true;
|
|
1617
|
+
this.isInRange = false;
|
|
1618
|
+
this.isInView = false;
|
|
1619
|
+
this.isVisibleInGroup = false;
|
|
1620
|
+
this.isVisibleInRows = true;
|
|
1621
|
+
this.isStarred = false;
|
|
1622
|
+
this.isMouseOverStar = false;
|
|
1623
|
+
this.isMouseover = false;
|
|
1624
|
+
this.isDragging = false;
|
|
1625
|
+
this.registeredPosition = { left: 0, top: 0 };
|
|
1626
|
+
this.position = { left: 0, top: 0 };
|
|
1627
|
+
this.dragStartOffset = { left: 0, top: 0 };
|
|
1628
|
+
this.indicator = { fromX: 0, toX: 0 };
|
|
1629
|
+
this.offset = { left: 0, top: 0 };
|
|
1630
|
+
this.finalOffset = { left: 0, top: 0 };
|
|
1631
|
+
this.isVisibleAfterFade = false;
|
|
1632
|
+
this.opacity = 0;
|
|
1633
|
+
this.fadeAnimation = {
|
|
1634
|
+
finalOpacity: 0,
|
|
1635
|
+
dummyElement: null
|
|
1636
|
+
};
|
|
1637
|
+
this.moveAnimation = {
|
|
1638
|
+
finalOffset: { left: 0, top: 0 },
|
|
1639
|
+
dummyElement: void 0
|
|
1640
|
+
};
|
|
1641
|
+
this.row = 0;
|
|
1642
|
+
this.laneId = null;
|
|
1643
|
+
this.laneOrder = 0;
|
|
1644
|
+
this.isFading = false;
|
|
1645
|
+
this.isMoving = false;
|
|
1646
|
+
this._cachedHeight = 0;
|
|
1647
|
+
this._cachedWidth = 0;
|
|
1648
|
+
this._sizeValid = false;
|
|
1649
|
+
this._sizeCacheKey = null;
|
|
1650
|
+
this._layoutCaches = null;
|
|
1651
|
+
this._resolvedDefaultCardLayout = null;
|
|
1652
|
+
this._resolvedCardLayoutName = null;
|
|
1653
|
+
}
|
|
1654
|
+
__name(Article, "Article");
|
|
1655
|
+
Article.prototype.setupByReceivedData = function(receivedData) {
|
|
1656
|
+
this.owner._assignArticleToLane(this, this.owner._resolveLaneIdFromArticleData(receivedData));
|
|
1657
|
+
const articleDefaultData = this.owner._getResolvedArticleOptions(this).defaultData;
|
|
1658
|
+
const data = deepMerge({}, articleDefaultData, receivedData);
|
|
1659
|
+
if (!existsInData(receivedData, "to")) {
|
|
1660
|
+
delete data.to;
|
|
1661
|
+
}
|
|
1662
|
+
this.data = deepMerge({}, receivedData);
|
|
1663
|
+
this.title = getPropertyFromData(data, "title") || "";
|
|
1664
|
+
this.rank = getPropertyFromData(data, "rank") || 0;
|
|
1665
|
+
this.subtitle = getPropertyFromData(data, "subtitle") || "";
|
|
1666
|
+
this._setupArticlePeriod(data);
|
|
1667
|
+
this.offset.left = this.finalOffset.left = this.moveAnimation.finalOffset.left = data.offsetLeft || 0;
|
|
1668
|
+
this.offset.top = this.finalOffset.top = this.moveAnimation.finalOffset.top = data.offsetTop || 0;
|
|
1669
|
+
this.isStarred = !!data.starred;
|
|
1670
|
+
this.cardLayout = getPropertyFromData(data, "cardLayout") || null;
|
|
1671
|
+
this.initialiseStyles(data);
|
|
1672
|
+
this.hiddenByFilter = getPropertyFromData(data, "hiddenByFilter");
|
|
1673
|
+
this.hidePeriodLine = existsInData(data, "hidePeriodLine") ? getPropertyFromData(data, "hidePeriodLine") : this.owner.options.article.periodLine.defaultHide;
|
|
1674
|
+
this.isDataLoaded = true;
|
|
1675
|
+
this.isImageInfoLoaded = false;
|
|
1676
|
+
};
|
|
1677
|
+
Article.prototype._setupArticlePeriod = function(data) {
|
|
1678
|
+
let fromDmy = getDmyFromData(data, "from");
|
|
1679
|
+
fromDmy = this.owner.getDmyFromInput(fromDmy);
|
|
1680
|
+
const fromPrecision = fromDmy.precision;
|
|
1681
|
+
const isToPresentProp = getPropertyFromData(data, "isToPresent");
|
|
1682
|
+
const isToPresent = isToPresentProp === true || isToPresentProp === 1;
|
|
1683
|
+
let toDmy, toPrecision;
|
|
1684
|
+
if (isToPresent) {
|
|
1685
|
+
toDmy = Dmy.now();
|
|
1686
|
+
} else if (existsInData(data, "to")) {
|
|
1687
|
+
toDmy = getDmyFromData(data, "to");
|
|
1688
|
+
toDmy = this.owner.getDmyFromInput(toDmy);
|
|
1689
|
+
toPrecision = toDmy.precision;
|
|
1690
|
+
} else {
|
|
1691
|
+
toDmy = fromDmy;
|
|
1692
|
+
toPrecision = fromPrecision;
|
|
1693
|
+
}
|
|
1694
|
+
const from = Dmy.CreateAsStartOfPeriod(fromDmy, fromPrecision);
|
|
1695
|
+
const to = Dmy.CreateAsExclusiveEndOfPeriod(toDmy, toPrecision);
|
|
1696
|
+
this.period = { from, to, isToPresent };
|
|
1697
|
+
this.period.years = this.period.to.asFloat() - this.period.from.asFloat();
|
|
1698
|
+
};
|
|
1699
|
+
Article.prototype.setImage = function() {
|
|
1700
|
+
this.isImageInfoLoaded = true;
|
|
1701
|
+
if (getPropertyFromData(this.data, "imageUrl")) {
|
|
1702
|
+
this.owner.enqueueImageLoad(this);
|
|
1703
|
+
} else {
|
|
1704
|
+
this._releaseImageResource();
|
|
1705
|
+
this.image = null;
|
|
1706
|
+
this.imageLoaded = false;
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
Article.prototype._releaseImageResource = function(options = {}) {
|
|
1710
|
+
const releaser = typeof this._closeImage === "function" ? this._closeImage : null;
|
|
1711
|
+
if (releaser) {
|
|
1712
|
+
this._closeImage = null;
|
|
1713
|
+
try {
|
|
1714
|
+
releaser(options);
|
|
1715
|
+
} catch (e) {
|
|
1716
|
+
}
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
if (!options.keepState) {
|
|
1720
|
+
this.image = null;
|
|
1721
|
+
this.imageLoaded = false;
|
|
1722
|
+
this._loadedImageKey = null;
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
Article.prototype.registerPosition = function(pos) {
|
|
1726
|
+
this.registeredPosition = this.position = pos;
|
|
1727
|
+
};
|
|
1728
|
+
Article.prototype.overlaps = function(other) {
|
|
1729
|
+
return other.period.from.isSame(this.period.from) && other.period.to.isSame(this.period.to) || other.period.from.isBetween(this.period.from, this.period.to) || other.period.to.isBetween(this.period.from, this.period.to) || this.period.from.isBetween(other.period.from, other.period.to) || this.period.to.isBetween(other.period.from, other.period.to);
|
|
1730
|
+
};
|
|
1731
|
+
Article.prototype.overlapsInclusiveWithDates = function(from, to) {
|
|
1732
|
+
return !(this.period.from.isAfter(to) || from.isAfter(this.period.to));
|
|
1733
|
+
};
|
|
1734
|
+
Article.prototype.overlapsInclusive = function(other) {
|
|
1735
|
+
return this.overlapsInclusiveWithDates(other.period.from, other.period.to);
|
|
1736
|
+
};
|
|
1737
|
+
Article.prototype.isInside = function(pos) {
|
|
1738
|
+
if (!this.isVisible) {
|
|
1739
|
+
return false;
|
|
1740
|
+
}
|
|
1741
|
+
this._ensureSizeCache();
|
|
1742
|
+
const left = this.position.left;
|
|
1743
|
+
const top = this.position.top;
|
|
1744
|
+
const width = this._cachedWidth;
|
|
1745
|
+
const height = this._cachedHeight;
|
|
1746
|
+
return pos.left >= left && pos.left <= left + width && pos.top >= top && pos.top <= top + height;
|
|
1747
|
+
};
|
|
1748
|
+
Article.prototype.pointerEnter = function(event) {
|
|
1749
|
+
this.isMouseover = true;
|
|
1750
|
+
this.owner.trigger("article-pointerenter", this, event);
|
|
1751
|
+
};
|
|
1752
|
+
Article.prototype.pointerLeave = function(event) {
|
|
1753
|
+
this.isMouseover = false;
|
|
1754
|
+
this.owner.trigger("article-pointerleave", this, event);
|
|
1755
|
+
};
|
|
1756
|
+
Article.prototype.updateIsMouseOverStar = function(pos) {
|
|
1757
|
+
const star = this.getIconBox();
|
|
1758
|
+
if (!star) {
|
|
1759
|
+
return false;
|
|
1760
|
+
}
|
|
1761
|
+
const oldState = this.isMouseOverStar;
|
|
1762
|
+
this.isMouseOverStar = pos.left >= star.left && pos.left <= star.left + star.width && pos.top >= star.top && pos.top <= star.top + star.height;
|
|
1763
|
+
if (this.isMouseOverStar !== oldState && !this.owner.isAnimating) {
|
|
1764
|
+
this.owner.redraw();
|
|
1765
|
+
}
|
|
1766
|
+
return this.isMouseOverStar;
|
|
1767
|
+
};
|
|
1768
|
+
Article.prototype.getCursor = function(pos) {
|
|
1769
|
+
const cursor = this.owner.options.style.cursor;
|
|
1770
|
+
if (this.isDragging) {
|
|
1771
|
+
return cursor.article.dragging;
|
|
1772
|
+
}
|
|
1773
|
+
this.updateIsMouseOverStar(pos);
|
|
1774
|
+
if (!this.owner.options.article.draggable) {
|
|
1775
|
+
return cursor.clickable;
|
|
1776
|
+
}
|
|
1777
|
+
if (this.isActive) {
|
|
1778
|
+
return this.isMouseOverStar ? cursor.clickable : cursor.article.hoverDraggable;
|
|
1779
|
+
}
|
|
1780
|
+
return cursor.clickable;
|
|
1781
|
+
};
|
|
1782
|
+
Article.prototype.clicked = function(pos) {
|
|
1783
|
+
this.updateIsMouseOverStar(pos);
|
|
1784
|
+
if (this.isMouseOverStar) {
|
|
1785
|
+
this.isStarred = !this.isStarred;
|
|
1786
|
+
return true;
|
|
1787
|
+
}
|
|
1788
|
+
return false;
|
|
1789
|
+
};
|
|
1790
|
+
Article.prototype.getStatusForSave = function() {
|
|
1791
|
+
const state = { i: this.id };
|
|
1792
|
+
if (this.offset.left !== 0) {
|
|
1793
|
+
state.l = this.offset.left;
|
|
1794
|
+
}
|
|
1795
|
+
if (this.offset.top !== 0) {
|
|
1796
|
+
state.t = this.offset.top;
|
|
1797
|
+
}
|
|
1798
|
+
if (this.isStarred) {
|
|
1799
|
+
state.v = true;
|
|
1800
|
+
}
|
|
1801
|
+
return state;
|
|
1802
|
+
};
|
|
1803
|
+
Article.prototype.headerOverlapsWith = function(other) {
|
|
1804
|
+
const thisLeft = this.registeredPosition.left;
|
|
1805
|
+
const otherLeft = other.registeredPosition.left;
|
|
1806
|
+
const thisRight = thisLeft + this.getWidth();
|
|
1807
|
+
const otherRight = otherLeft + other.getWidth();
|
|
1808
|
+
return otherRight >= thisLeft && thisRight >= otherLeft;
|
|
1809
|
+
};
|
|
1810
|
+
Article.prototype._getWidth = function() {
|
|
1811
|
+
return this.getCurrentStyle().width;
|
|
1812
|
+
};
|
|
1813
|
+
Article.prototype.getWidth = function() {
|
|
1814
|
+
this._ensureSizeCache();
|
|
1815
|
+
return this._cachedWidth;
|
|
1816
|
+
};
|
|
1817
|
+
Article.prototype.getHeight = function() {
|
|
1818
|
+
this._ensureSizeCache();
|
|
1819
|
+
return this._cachedHeight;
|
|
1820
|
+
};
|
|
1821
|
+
Article.prototype.setOption = function(option, value) {
|
|
1822
|
+
let needsDefaultRedraw = false;
|
|
1823
|
+
if (typeof option === "string") {
|
|
1824
|
+
if (typeof value === "undefined") {
|
|
1825
|
+
const selectedOption = getPropertyFromData(this.data, option);
|
|
1826
|
+
return selectedOption;
|
|
1827
|
+
}
|
|
1828
|
+
option = buildObjectFromPath(option, value);
|
|
1829
|
+
}
|
|
1830
|
+
deepMerge(this.data, option);
|
|
1831
|
+
if (existsInData(option, "id")) {
|
|
1832
|
+
this.id = option.id;
|
|
1833
|
+
}
|
|
1834
|
+
if (existsInData(option, "title")) {
|
|
1835
|
+
this.title = option.title;
|
|
1836
|
+
this.titleLines = void 0;
|
|
1837
|
+
}
|
|
1838
|
+
if (existsInData(option, "subtitle")) {
|
|
1839
|
+
this.subtitle = option.subtitle;
|
|
1840
|
+
this.summarisedSubtitle = void 0;
|
|
1841
|
+
}
|
|
1842
|
+
if (existsInData(option, "from") || existsInData(option, "to") || existsInData(option, "isToPresent")) {
|
|
1843
|
+
this._setupArticlePeriod(this.data);
|
|
1844
|
+
needsDefaultRedraw = true;
|
|
1845
|
+
}
|
|
1846
|
+
if (existsInData(option, "imageUrl")) {
|
|
1847
|
+
this.setImage();
|
|
1848
|
+
}
|
|
1849
|
+
if (existsInData(option, "rank")) {
|
|
1850
|
+
this.rank = option.rank;
|
|
1851
|
+
needsDefaultRedraw = true;
|
|
1852
|
+
}
|
|
1853
|
+
if (existsInData(option, "starred")) {
|
|
1854
|
+
this.isStarred = option.starred;
|
|
1855
|
+
}
|
|
1856
|
+
if (existsInData(option, "hiddenByFilter")) {
|
|
1857
|
+
this.hiddenByFilter = option.hiddenByFilter;
|
|
1858
|
+
}
|
|
1859
|
+
if (existsInData(option, "hidePeriodLine")) {
|
|
1860
|
+
this.hidePeriodLine = option.hidePeriodLine;
|
|
1861
|
+
}
|
|
1862
|
+
const laneChanged = existsInData(option, "lane");
|
|
1863
|
+
if (laneChanged) {
|
|
1864
|
+
this.owner._assignArticleToLane(this, option.lane);
|
|
1865
|
+
this.initialiseStyles(this.data);
|
|
1866
|
+
this.invalidateCaches();
|
|
1867
|
+
needsDefaultRedraw = true;
|
|
1868
|
+
}
|
|
1869
|
+
const styleChanged = existsInData(option, "style");
|
|
1870
|
+
const activeStyleChanged = existsInData(option, "activeStyle");
|
|
1871
|
+
const hoverStyleChanged = existsInData(option, "hoverStyle");
|
|
1872
|
+
if (styleChanged || hoverStyleChanged || activeStyleChanged) {
|
|
1873
|
+
this.initialiseStyles(this.data);
|
|
1874
|
+
}
|
|
1875
|
+
this.invalidateCaches();
|
|
1876
|
+
const cardLayoutChanged = existsInData(option, "cardLayout");
|
|
1877
|
+
if (cardLayoutChanged) {
|
|
1878
|
+
this.setCardLayout(option.cardLayout);
|
|
1879
|
+
}
|
|
1880
|
+
if (laneChanged) {
|
|
1881
|
+
this.owner.updateArticlesGroupIndex();
|
|
1882
|
+
}
|
|
1883
|
+
if (needsDefaultRedraw) {
|
|
1884
|
+
this.owner.requestRedraw();
|
|
1885
|
+
} else {
|
|
1886
|
+
this.owner.requestRedraw(this.redraw);
|
|
1887
|
+
}
|
|
1888
|
+
};
|
|
1889
|
+
Article.prototype.initialiseStyles = function(data = this.data) {
|
|
1890
|
+
const resolvedDefaultCardLayout = this.owner._resolveDefaultCardLayoutName(this);
|
|
1891
|
+
const explicitCardLayout = this.owner._getExplicitArticleCardLayout(this);
|
|
1892
|
+
const cardLayout = explicitCardLayout || resolvedDefaultCardLayout;
|
|
1893
|
+
this._resolvedDefaultCardLayout = resolvedDefaultCardLayout;
|
|
1894
|
+
this._resolvedCardLayoutName = cardLayout;
|
|
1895
|
+
const styleOverrides = this.owner._getResolvedArticleStyleOverrides(this, cardLayout);
|
|
1896
|
+
const style = deepMerge({}, styleOverrides.style, getPropertyFromData(data, "style") || {});
|
|
1897
|
+
const activeStyle = deepMerge(
|
|
1898
|
+
{},
|
|
1899
|
+
styleOverrides.activeStyle,
|
|
1900
|
+
getPropertyFromData(data, "activeStyle") || {}
|
|
1901
|
+
);
|
|
1902
|
+
const hoverStyle = deepMerge(
|
|
1903
|
+
{},
|
|
1904
|
+
styleOverrides.hoverStyle,
|
|
1905
|
+
getPropertyFromData(data, "hoverStyle") || {}
|
|
1906
|
+
);
|
|
1907
|
+
this.style = style;
|
|
1908
|
+
this.activeStyle = deepMerge({}, style, activeStyle);
|
|
1909
|
+
this.hoverStyle = deepMerge({}, style, hoverStyle);
|
|
1910
|
+
this.activeHoverStyle = deepMerge({}, style, hoverStyle, activeStyle);
|
|
1911
|
+
};
|
|
1912
|
+
Article.prototype.setStyle = function(option, value) {
|
|
1913
|
+
if (typeof option === "string") {
|
|
1914
|
+
if (typeof value === "undefined") {
|
|
1915
|
+
return getPropertyFromData(this.style, option);
|
|
1916
|
+
}
|
|
1917
|
+
option = buildObjectFromPath(option, value);
|
|
1918
|
+
}
|
|
1919
|
+
this.data.style = deepMerge(this.data.style || {}, option);
|
|
1920
|
+
this.initialiseStyles(this.data);
|
|
1921
|
+
this.invalidateCaches();
|
|
1922
|
+
this.owner.requestRedraw();
|
|
1923
|
+
};
|
|
1924
|
+
Article.prototype.setHoverStyle = function(option, value) {
|
|
1925
|
+
if (typeof option === "string") {
|
|
1926
|
+
if (typeof value === "undefined") {
|
|
1927
|
+
return getPropertyFromData(this.activeStyle, option);
|
|
1928
|
+
}
|
|
1929
|
+
option = buildObjectFromPath(option, value);
|
|
1930
|
+
}
|
|
1931
|
+
this.data.hoverStyle = deepMerge(this.data.hoverStyle || {}, option);
|
|
1932
|
+
this.initialiseStyles(this.data);
|
|
1933
|
+
this.owner.requestRedraw();
|
|
1934
|
+
};
|
|
1935
|
+
Article.prototype.setActiveStyle = function(option, value) {
|
|
1936
|
+
if (typeof option === "string") {
|
|
1937
|
+
if (typeof value === "undefined") {
|
|
1938
|
+
return getPropertyFromData(this.activeStyle, option);
|
|
1939
|
+
}
|
|
1940
|
+
option = buildObjectFromPath(option, value);
|
|
1941
|
+
}
|
|
1942
|
+
this.data.activeStyle = deepMerge(this.data.activeStyle || {}, option);
|
|
1943
|
+
this.initialiseStyles(this.data);
|
|
1944
|
+
this.owner.requestRedraw();
|
|
1945
|
+
};
|
|
1946
|
+
Article.prototype.activated = function() {
|
|
1947
|
+
Logger.warn(
|
|
1948
|
+
'DEPRECATION WARNING: article.activated() was deprecated in v1.3.0. Use timeline.select(article.id) and handle selection with options.on["article-select"] instead.'
|
|
1949
|
+
);
|
|
1950
|
+
this.owner.trigger("article-click", this);
|
|
1951
|
+
};
|
|
1952
|
+
Article.prototype.updateVisibility = function() {
|
|
1953
|
+
const oldVisibility = this.isVisibleAfterFade;
|
|
1954
|
+
const newVisibility = this.isInRange && this.isVisibleInLane && this.isVisibleInGroup && this.isVisibleInRows && !this.isHiddenByFilter;
|
|
1955
|
+
if (!this.isVisibleInLane) {
|
|
1956
|
+
this.setVisibility(false);
|
|
1957
|
+
return;
|
|
1958
|
+
}
|
|
1959
|
+
if (oldVisibility === newVisibility) {
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
if (newVisibility && !this.isImageInfoLoaded) {
|
|
1963
|
+
this.setImage();
|
|
1964
|
+
}
|
|
1965
|
+
if (!this.owner.options.article.animation.fade.active) {
|
|
1966
|
+
this.setVisibility(newVisibility);
|
|
1967
|
+
return;
|
|
1968
|
+
}
|
|
1969
|
+
this.setVisibilityWithFade(newVisibility);
|
|
1970
|
+
};
|
|
1971
|
+
Article.prototype.setVisibility = function(visibility) {
|
|
1972
|
+
var _a, _b, _c, _d;
|
|
1973
|
+
if (this.isFading && ((_b = (_a = this.fadeAnimation) == null ? void 0 : _a.dummyElement) == null ? void 0 : _b.stop)) {
|
|
1974
|
+
this.fadeAnimation.dummyElement.stop();
|
|
1975
|
+
this.isFading = false;
|
|
1976
|
+
if (((_d = (_c = this.owner) == null ? void 0 : _c.lastAnimatingArticle) == null ? void 0 : _d.id) === this.id && this.owner.lastAnimatingArticle.animationType === "fade") {
|
|
1977
|
+
this.owner.isAnimatingArticles = false;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
this.isVisible = visibility;
|
|
1981
|
+
this.isVisibleAfterFade = visibility;
|
|
1982
|
+
this.opacity = visibility ? 1 : 0;
|
|
1983
|
+
if (!visibility) {
|
|
1984
|
+
this._releaseImageResource({ skipRedraw: true });
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
Article.prototype.setVisibilityWithFade = function(visibility) {
|
|
1988
|
+
var _a, _b, _c, _d;
|
|
1989
|
+
const me = this;
|
|
1990
|
+
if (visibility === me.isVisibleAfterFade) {
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
if (me.isFading && ((_b = (_a = me.fadeAnimation) == null ? void 0 : _a.dummyElement) == null ? void 0 : _b.stop)) {
|
|
1994
|
+
me.fadeAnimation.dummyElement.stop();
|
|
1995
|
+
}
|
|
1996
|
+
me.isFading = true;
|
|
1997
|
+
me.isVisibleAfterFade = visibility;
|
|
1998
|
+
me.fadeAnimation = me.fadeAnimation || {};
|
|
1999
|
+
me.fadeAnimation.finalOpacity = visibility;
|
|
2000
|
+
if (visibility) {
|
|
2001
|
+
me.isVisible = true;
|
|
2002
|
+
}
|
|
2003
|
+
me.owner.notifyArticleAnimating("fade", me.id);
|
|
2004
|
+
const settings = me.owner.options.article.animation.fade;
|
|
2005
|
+
const duration = (_c = settings.duration) != null ? _c : 400;
|
|
2006
|
+
const easingName = (_d = settings.easing) != null ? _d : "swing";
|
|
2007
|
+
const easingFn = EASINGS[easingName] || EASINGS.swing;
|
|
2008
|
+
const startOpacity = me.opacity;
|
|
2009
|
+
const endOpacity = visibility ? 1 : 0;
|
|
2010
|
+
const fadeTween = tween({
|
|
2011
|
+
from: startOpacity,
|
|
2012
|
+
to: endOpacity,
|
|
2013
|
+
duration,
|
|
2014
|
+
easing: easingFn,
|
|
2015
|
+
/** Fired every animation frame */
|
|
2016
|
+
onUpdate(value) {
|
|
2017
|
+
me.opacity = value;
|
|
2018
|
+
me.owner.requestRedraw();
|
|
2019
|
+
},
|
|
2020
|
+
/** Finalise */
|
|
2021
|
+
onComplete() {
|
|
2022
|
+
me.isFading = false;
|
|
2023
|
+
if (!visibility) {
|
|
2024
|
+
me.isVisible = false;
|
|
2025
|
+
me._releaseImageResource({ skipRedraw: true });
|
|
2026
|
+
}
|
|
2027
|
+
const last = me.owner.lastAnimatingArticle;
|
|
2028
|
+
if (me.id === last.id && last.animationType === "fade") {
|
|
2029
|
+
me.owner.isAnimatingArticles = false;
|
|
2030
|
+
}
|
|
2031
|
+
if (typeof settings.complete === "function") {
|
|
2032
|
+
settings.complete.call(me);
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
});
|
|
2036
|
+
me.fadeAnimation.dummyElement = fadeTween;
|
|
2037
|
+
};
|
|
2038
|
+
Article.prototype.moveToOffset = function(destination) {
|
|
2039
|
+
this.finalOffset.top = this.offset.top = destination.top || this.offset.top;
|
|
2040
|
+
this.finalOffset.left = this.offset.left = destination.left || this.offset.left;
|
|
2041
|
+
this.position.top = this.registeredPosition.top + this.offset.top;
|
|
2042
|
+
this.position.left = this.registeredPosition.left + this.offset.left;
|
|
2043
|
+
};
|
|
2044
|
+
Article.prototype.moveTo = function(destination) {
|
|
2045
|
+
const finalOffset = {
|
|
2046
|
+
left: destination.left - this.registeredPosition.left,
|
|
2047
|
+
top: destination.top - this.registeredPosition.top
|
|
2048
|
+
};
|
|
2049
|
+
this.moveToOffset(finalOffset);
|
|
2050
|
+
};
|
|
2051
|
+
Article.prototype.moveToWithAnim = function(destination) {
|
|
2052
|
+
const finalOffset = {
|
|
2053
|
+
left: destination.left - this.registeredPosition.left,
|
|
2054
|
+
top: destination.top - this.registeredPosition.top
|
|
2055
|
+
};
|
|
2056
|
+
this.moveToOffsetWithAnim(finalOffset);
|
|
2057
|
+
};
|
|
2058
|
+
Article.prototype.moveToOffsetWithAnim = function(destination) {
|
|
2059
|
+
var _a, _b, _c;
|
|
2060
|
+
const me = this;
|
|
2061
|
+
const moveAnimation = me.moveAnimation;
|
|
2062
|
+
if (destination.top === moveAnimation.finalOffset.top && destination.left === moveAnimation.finalOffset.left) {
|
|
2063
|
+
return;
|
|
2064
|
+
}
|
|
2065
|
+
if (me.isMoving && ((_a = moveAnimation == null ? void 0 : moveAnimation.dummyElement) == null ? void 0 : _a.stop)) {
|
|
2066
|
+
moveAnimation.dummyElement.stop();
|
|
2067
|
+
}
|
|
2068
|
+
moveAnimation.finalOffset = this.finalOffset = {
|
|
2069
|
+
left: destination.left,
|
|
2070
|
+
top: destination.top
|
|
2071
|
+
};
|
|
2072
|
+
me.isMoving = true;
|
|
2073
|
+
me.owner.notifyArticleAnimating("move", me.id);
|
|
2074
|
+
const settings = me.owner.options.article.animation.move;
|
|
2075
|
+
const duration = (_b = settings.duration) != null ? _b : 400;
|
|
2076
|
+
const easingName = (_c = settings.easing) != null ? _c : "swing";
|
|
2077
|
+
const easingFn = EASINGS[easingName] || EASINGS.swing;
|
|
2078
|
+
const startTop = me.offset.top;
|
|
2079
|
+
const startLeft = me.offset.left;
|
|
2080
|
+
const deltaTop = destination.top - startTop;
|
|
2081
|
+
const deltaLeft = destination.left - startLeft;
|
|
2082
|
+
const moveTween = tween({
|
|
2083
|
+
from: 0,
|
|
2084
|
+
to: 1,
|
|
2085
|
+
duration,
|
|
2086
|
+
easing: easingFn,
|
|
2087
|
+
onUpdate(progress) {
|
|
2088
|
+
me.offset.top = startTop + deltaTop * progress;
|
|
2089
|
+
me.offset.left = startLeft + deltaLeft * progress;
|
|
2090
|
+
me.position.top = me.registeredPosition.top + me.offset.top;
|
|
2091
|
+
me.position.left = me.registeredPosition.left + me.offset.left;
|
|
2092
|
+
me.owner.requestRedraw();
|
|
2093
|
+
},
|
|
2094
|
+
onComplete() {
|
|
2095
|
+
me.offset.top = destination.top;
|
|
2096
|
+
me.offset.left = destination.left;
|
|
2097
|
+
me.position.top = me.registeredPosition.top + destination.top;
|
|
2098
|
+
me.position.left = me.registeredPosition.left + destination.left;
|
|
2099
|
+
me.isMoving = false;
|
|
2100
|
+
const last = me.owner.lastAnimatingArticle;
|
|
2101
|
+
if (me.id === last.id && last.animationType === "move") {
|
|
2102
|
+
me.owner.isAnimatingArticles = false;
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
});
|
|
2106
|
+
moveAnimation.dummyElement = moveTween;
|
|
2107
|
+
};
|
|
2108
|
+
function roundPixel(value) {
|
|
2109
|
+
return Math.round(value);
|
|
2110
|
+
}
|
|
2111
|
+
__name(roundPixel, "roundPixel");
|
|
2112
|
+
function snapPixel(value, dpr = 1) {
|
|
2113
|
+
const ratio = typeof dpr === "number" && isFinite(dpr) && dpr > 0 ? dpr : 1;
|
|
2114
|
+
return Math.round(value * ratio) / ratio;
|
|
2115
|
+
}
|
|
2116
|
+
__name(snapPixel, "snapPixel");
|
|
2117
|
+
function retainPixel(value) {
|
|
2118
|
+
return value;
|
|
2119
|
+
}
|
|
2120
|
+
__name(retainPixel, "retainPixel");
|
|
2121
|
+
function createPixelSnap(dpr = 1, mode = "device") {
|
|
2122
|
+
if (mode === false || mode === "none") {
|
|
2123
|
+
return retainPixel;
|
|
2124
|
+
}
|
|
2125
|
+
if (mode === "css") {
|
|
2126
|
+
return roundPixel;
|
|
2127
|
+
}
|
|
2128
|
+
return /* @__PURE__ */ __name(function snapToDevicePixel(value) {
|
|
2129
|
+
return snapPixel(value, dpr);
|
|
2130
|
+
}, "snapToDevicePixel");
|
|
2131
|
+
}
|
|
2132
|
+
__name(createPixelSnap, "createPixelSnap");
|
|
2133
|
+
function createStrokePixelSnap(dpr = 1, mode = "device", lineWidth = 1) {
|
|
2134
|
+
if (mode === false || mode === "none") {
|
|
2135
|
+
return retainPixel;
|
|
2136
|
+
}
|
|
2137
|
+
const deviceRatio = typeof dpr === "number" && isFinite(dpr) && dpr > 0 ? dpr : 1;
|
|
2138
|
+
const ratio = mode === "css" ? 1 : deviceRatio;
|
|
2139
|
+
const width = typeof lineWidth === "number" && isFinite(lineWidth) && lineWidth > 0 ? lineWidth : 1;
|
|
2140
|
+
const halfPhysicalWidth = width * ratio / 2;
|
|
2141
|
+
return /* @__PURE__ */ __name(function snapStrokeCentre(value) {
|
|
2142
|
+
return (Math.round(value * ratio - halfPhysicalWidth) + halfPhysicalWidth) / ratio;
|
|
2143
|
+
}, "snapStrokeCentre");
|
|
2144
|
+
}
|
|
2145
|
+
__name(createStrokePixelSnap, "createStrokePixelSnap");
|
|
2146
|
+
function createInnerSpace(outerSpace, borderWidth, snap) {
|
|
2147
|
+
if (!snap) {
|
|
2148
|
+
snap = roundPixel;
|
|
2149
|
+
}
|
|
2150
|
+
const halfBorder = borderWidth / 2;
|
|
2151
|
+
return {
|
|
2152
|
+
left: snap(outerSpace.left + halfBorder),
|
|
2153
|
+
top: snap(outerSpace.top + halfBorder),
|
|
2154
|
+
width: snap(outerSpace.width - borderWidth),
|
|
2155
|
+
height: snap(outerSpace.height - borderWidth)
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
__name(createInnerSpace, "createInnerSpace");
|
|
2159
|
+
Article.prototype.draw = function(ctx) {
|
|
2160
|
+
if (!this.isDataLoaded || isNaN(this.position.left)) {
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
this._ensureSizeCache();
|
|
2164
|
+
ctx.globalAlpha = this.opacity;
|
|
2165
|
+
const cardLayout = this._getCurrentCardLayout();
|
|
2166
|
+
cardLayout.draw.call(this, ctx);
|
|
2167
|
+
};
|
|
2168
|
+
Article.prototype.getCurrentStyle = function() {
|
|
2169
|
+
if (this.isActive) {
|
|
2170
|
+
return this.isMouseover ? this.activeHoverStyle : this.activeStyle;
|
|
2171
|
+
}
|
|
2172
|
+
return this.isMouseover ? this.hoverStyle : this.style;
|
|
2173
|
+
};
|
|
2174
|
+
Article.prototype._getCurrentStyle = function() {
|
|
2175
|
+
return this.getCurrentStyle();
|
|
2176
|
+
};
|
|
2177
|
+
Article.prototype._getPeriodLineRenderGeometry = function(axisY) {
|
|
2178
|
+
const resolvedArticleOptions = this.owner._getResolvedArticleOptions(this);
|
|
2179
|
+
const periodLineOptions = resolvedArticleOptions.periodLine || {};
|
|
2180
|
+
const globalPeriodLineOptions = this.owner.options.article.periodLine || {};
|
|
2181
|
+
const position = globalPeriodLineOptions.position || "axis";
|
|
2182
|
+
const baselineGap = Number.isFinite(periodLineOptions.baselineGap) ? periodLineOptions.baselineGap : 0;
|
|
2183
|
+
const spacing = this.hidePeriodLine ? 0 : periodLineOptions.spacing || 0;
|
|
2184
|
+
const thickness = this.hidePeriodLine ? 0 : periodLineOptions.thickness || 0;
|
|
2185
|
+
const offset = (spacing + thickness) * this.stacking;
|
|
2186
|
+
let anchorY = axisY;
|
|
2187
|
+
let anchorOffset = this.owner.options.style.mainLine.size / 2;
|
|
2188
|
+
if (position === "lane" && this.owner._isLaneLayoutActive()) {
|
|
2189
|
+
const lane = this.owner.getLaneById(this.laneId);
|
|
2190
|
+
if (lane && lane.geometry) {
|
|
2191
|
+
anchorY = Math.floor(lane.geometry.bottom);
|
|
2192
|
+
anchorOffset = 0;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
const y = anchorY - baselineGap - offset - anchorOffset - thickness / 2;
|
|
2196
|
+
return {
|
|
2197
|
+
position,
|
|
2198
|
+
baselineGap,
|
|
2199
|
+
spacing,
|
|
2200
|
+
thickness,
|
|
2201
|
+
anchorY,
|
|
2202
|
+
anchorOffset,
|
|
2203
|
+
y
|
|
2204
|
+
};
|
|
2205
|
+
};
|
|
2206
|
+
Article.prototype.drawPeriodLinesAndConnectors = function(ctx, axisY) {
|
|
2207
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2208
|
+
ctx.globalAlpha = this.opacity;
|
|
2209
|
+
const style = this.getCurrentStyle();
|
|
2210
|
+
const geometry = this._getPeriodLineRenderGeometry(axisY);
|
|
2211
|
+
const y = geometry.y;
|
|
2212
|
+
if (!this.hidePeriodLine) {
|
|
2213
|
+
const fromX = this.indicator.fromX, toX = this.indicator.toX;
|
|
2214
|
+
ctx.beginPath();
|
|
2215
|
+
ctx.lineWidth = geometry.thickness;
|
|
2216
|
+
ctx.moveTo(fromX, y);
|
|
2217
|
+
ctx.lineTo(toX, y);
|
|
2218
|
+
if (this.period.isToPresent) {
|
|
2219
|
+
const periodLength = toX - fromX, maxFadeLength = 15, fadeStartColorStop = Math.max(1 - maxFadeLength / periodLength, 0.7), grad = ctx.createLinearGradient(fromX, y, toX, y);
|
|
2220
|
+
grad.addColorStop(0, style.color);
|
|
2221
|
+
grad.addColorStop(fadeStartColorStop, style.color);
|
|
2222
|
+
grad.addColorStop(1, "rgba(255,255,255,0)");
|
|
2223
|
+
ctx.strokeStyle = grad;
|
|
2224
|
+
} else {
|
|
2225
|
+
ctx.strokeStyle = style.color;
|
|
2226
|
+
}
|
|
2227
|
+
ctx.stroke();
|
|
2228
|
+
}
|
|
2229
|
+
if (!style.connectorLine.visible) {
|
|
2230
|
+
return;
|
|
2231
|
+
}
|
|
2232
|
+
const cardLayout = this._getCurrentCardLayout();
|
|
2233
|
+
const connectorEnd = typeof cardLayout.getConnectorEnd === "function" ? cardLayout.getConnectorEnd.call(this) : {
|
|
2234
|
+
left: this.position.left + style.connectorLine.offsetX,
|
|
2235
|
+
top: this.position.top + this.getHeight() + style.connectorLine.offsetY
|
|
2236
|
+
};
|
|
2237
|
+
const x1 = Math.max(0, this.indicator.fromX);
|
|
2238
|
+
const y1 = y;
|
|
2239
|
+
const x2 = connectorEnd.left;
|
|
2240
|
+
const y2 = connectorEnd.top;
|
|
2241
|
+
const isVertical = Math.abs(x1 - x2) < Number.EPSILON;
|
|
2242
|
+
const pixelSnapMode = (_d = (_c = (_b = (_a = this.owner) == null ? void 0 : _a.options) == null ? void 0 : _b.article) == null ? void 0 : _c.rendering) == null ? void 0 : _d.pixelSnap;
|
|
2243
|
+
const snapStroke = createStrokePixelSnap(
|
|
2244
|
+
((_f = (_e = this.owner) == null ? void 0 : _e.getCanvasDpr) == null ? void 0 : _f.call(_e)) || 1,
|
|
2245
|
+
pixelSnapMode,
|
|
2246
|
+
style.connectorLine.thickness
|
|
2247
|
+
);
|
|
2248
|
+
const connectorX = isVertical ? snapStroke(x2) : null;
|
|
2249
|
+
const drawX1 = connectorX != null ? connectorX : x1;
|
|
2250
|
+
const drawX2 = connectorX != null ? connectorX : x2;
|
|
2251
|
+
ctx.strokeStyle = ctx.fillStyle = style.color;
|
|
2252
|
+
ctx.lineWidth = style.connectorLine.thickness;
|
|
2253
|
+
ctx.beginPath();
|
|
2254
|
+
ctx.moveTo(drawX1, y1);
|
|
2255
|
+
ctx.lineTo(drawX2, y2);
|
|
2256
|
+
ctx.stroke();
|
|
2257
|
+
const radians = Math.atan((y2 - y1) / (drawX2 - drawX1)) + (drawX2 >= drawX1 ? -90 : 90) * Math.PI / 180;
|
|
2258
|
+
ctx.save();
|
|
2259
|
+
ctx.beginPath();
|
|
2260
|
+
ctx.translate(drawX2, y2);
|
|
2261
|
+
ctx.rotate(radians);
|
|
2262
|
+
ctx.moveTo(-style.connectorLine.arrow.width, 0);
|
|
2263
|
+
ctx.lineTo(style.connectorLine.arrow.width, 0);
|
|
2264
|
+
ctx.lineTo(0, -style.connectorLine.arrow.height);
|
|
2265
|
+
ctx.closePath();
|
|
2266
|
+
ctx.restore();
|
|
2267
|
+
ctx.fill();
|
|
2268
|
+
};
|
|
2269
|
+
Article.prototype.getIconBox = function() {
|
|
2270
|
+
const cardLayout = this._getCurrentCardLayout();
|
|
2271
|
+
return cardLayout.getIconBox.call(this);
|
|
2272
|
+
};
|
|
2273
|
+
Article.prototype.startDragging = function(pos, evt) {
|
|
2274
|
+
if (this.isMoving) {
|
|
2275
|
+
this.moveAnimation.dummyElement.stop();
|
|
2276
|
+
}
|
|
2277
|
+
this.isDragging = true;
|
|
2278
|
+
this.dragInitialPosition = { left: this.position.left, top: this.position.top };
|
|
2279
|
+
this.lastDragPosition = { left: this.position.left, top: this.position.top };
|
|
2280
|
+
this.dragStartOffset = {
|
|
2281
|
+
left: pos.left - this.position.left,
|
|
2282
|
+
top: pos.top - this.position.top
|
|
2283
|
+
};
|
|
2284
|
+
this.owner.startAnimation();
|
|
2285
|
+
if (this.owner && typeof this.owner.trigger === "function") {
|
|
2286
|
+
this.owner.trigger("article-drag-start", this, evt);
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
Article.prototype.stopDragging = function(evt) {
|
|
2290
|
+
var _a, _b;
|
|
2291
|
+
this.offset = this.finalOffset = this.moveAnimation.finalOffset = {
|
|
2292
|
+
left: this.position.left - this.registeredPosition.left,
|
|
2293
|
+
top: this.position.top - this.registeredPosition.top
|
|
2294
|
+
};
|
|
2295
|
+
this.isDragging = false;
|
|
2296
|
+
(_b = (_a = this.owner) == null ? void 0 : _a._markTimelineStateChanged) == null ? void 0 : _b.call(_a);
|
|
2297
|
+
if (this.owner && typeof this.owner.trigger === "function") {
|
|
2298
|
+
this.owner.trigger("article-drag-end", this, evt);
|
|
2299
|
+
}
|
|
2300
|
+
};
|
|
2301
|
+
Article.prototype.dragging = function(pos, evt) {
|
|
2302
|
+
const newPosition = {
|
|
2303
|
+
left: pos.left - this.dragStartOffset.left,
|
|
2304
|
+
top: pos.top - this.dragStartOffset.top
|
|
2305
|
+
};
|
|
2306
|
+
const previousPosition = this.lastDragPosition || {
|
|
2307
|
+
left: this.position.left,
|
|
2308
|
+
top: this.position.top
|
|
2309
|
+
};
|
|
2310
|
+
const initialPosition = this.dragInitialPosition || previousPosition;
|
|
2311
|
+
const dx = newPosition.left - previousPosition.left;
|
|
2312
|
+
const dy = newPosition.top - previousPosition.top;
|
|
2313
|
+
const totalDx = newPosition.left - initialPosition.left;
|
|
2314
|
+
const totalDy = newPosition.top - initialPosition.top;
|
|
2315
|
+
this.position = newPosition;
|
|
2316
|
+
this.lastDragPosition = newPosition;
|
|
2317
|
+
if (this.owner && typeof this.owner.trigger === "function") {
|
|
2318
|
+
this.owner.trigger("article-drag", this, { dx, dy, totalDx, totalDy }, evt);
|
|
2319
|
+
}
|
|
2320
|
+
};
|
|
2321
|
+
Article.prototype._cacheBucket = function() {
|
|
2322
|
+
const name = this._getCurrentCardLayoutName();
|
|
2323
|
+
if (!this._layoutCaches) {
|
|
2324
|
+
this._layoutCaches = /* @__PURE__ */ Object.create(null);
|
|
2325
|
+
}
|
|
2326
|
+
return this._layoutCaches[name] || (this._layoutCaches[name] = /* @__PURE__ */ Object.create(null));
|
|
2327
|
+
};
|
|
2328
|
+
Article.prototype.memo = function(key, factory) {
|
|
2329
|
+
const bucket = this._cacheBucket();
|
|
2330
|
+
return key in bucket ? bucket[key] : bucket[key] = factory.call(this);
|
|
2331
|
+
};
|
|
2332
|
+
Article.prototype._getSizeCacheKey = function() {
|
|
2333
|
+
var _a, _b;
|
|
2334
|
+
const style = typeof this.getCurrentStyle === "function" ? this.getCurrentStyle() : null;
|
|
2335
|
+
const imageStyle = style && style.image || {};
|
|
2336
|
+
const header = style && style.header || {};
|
|
2337
|
+
const subheader = style && style.subheader || {};
|
|
2338
|
+
const border = style && style.border || {};
|
|
2339
|
+
const layout = typeof this._getCurrentCardLayoutName === "function" ? this._getCurrentCardLayoutName() : "";
|
|
2340
|
+
const hasImage = this.imageLoaded && this.image;
|
|
2341
|
+
const keyParts = [
|
|
2342
|
+
layout,
|
|
2343
|
+
style && style.width,
|
|
2344
|
+
style && style.height,
|
|
2345
|
+
header.height,
|
|
2346
|
+
subheader.height,
|
|
2347
|
+
border.width,
|
|
2348
|
+
(_a = imageStyle.margin) != null ? _a : 0,
|
|
2349
|
+
imageStyle.shape || "",
|
|
2350
|
+
(_b = imageStyle.maxHeight) != null ? _b : "",
|
|
2351
|
+
style && style.maxImageHeight !== void 0 ? style.maxImageHeight : "",
|
|
2352
|
+
hasImage ? this.image.width : "noimg",
|
|
2353
|
+
hasImage ? this.image.height : ""
|
|
2354
|
+
];
|
|
2355
|
+
return keyParts.join("|");
|
|
2356
|
+
};
|
|
2357
|
+
Article.prototype.updateCachedSize = function() {
|
|
2358
|
+
const cardLayout = this._getCurrentCardLayout();
|
|
2359
|
+
this._cachedWidth = cardLayout.getWidth.call(this);
|
|
2360
|
+
this._cachedHeight = cardLayout.getHeight.call(this);
|
|
2361
|
+
this.height = this._cachedHeight;
|
|
2362
|
+
this._sizeValid = true;
|
|
2363
|
+
this._sizeCacheKey = this._getSizeCacheKey();
|
|
2364
|
+
};
|
|
2365
|
+
Article.prototype._ensureSizeCache = function() {
|
|
2366
|
+
const cacheKey = this._getSizeCacheKey();
|
|
2367
|
+
if (!this._sizeValid || cacheKey !== this._sizeCacheKey) {
|
|
2368
|
+
this.updateCachedSize();
|
|
2369
|
+
}
|
|
2370
|
+
};
|
|
2371
|
+
Article.prototype.invalidateCaches = function() {
|
|
2372
|
+
this._sizeValid = false;
|
|
2373
|
+
this._sizeCacheKey = null;
|
|
2374
|
+
if (this._layoutCaches) {
|
|
2375
|
+
const buckets = this._layoutCaches;
|
|
2376
|
+
for (const layoutName in buckets) {
|
|
2377
|
+
const bucket = buckets[layoutName];
|
|
2378
|
+
if (!bucket) {
|
|
2379
|
+
continue;
|
|
2380
|
+
}
|
|
2381
|
+
for (const k in bucket) {
|
|
2382
|
+
const v = bucket[k];
|
|
2383
|
+
if (v && typeof v.close === "function") {
|
|
2384
|
+
try {
|
|
2385
|
+
v.close();
|
|
2386
|
+
} catch (e) {
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
this._layoutCaches = null;
|
|
2393
|
+
};
|
|
2394
|
+
Article.prototype._getCurrentCardLayoutName = function() {
|
|
2395
|
+
return this._resolvedCardLayoutName || this.cardLayout || this._resolvedDefaultCardLayout || this.owner._resolveArticleCardLayoutName(this);
|
|
2396
|
+
};
|
|
2397
|
+
Article.prototype._getCurrentCardLayout = function() {
|
|
2398
|
+
return this.owner.getCardLayout(this._getCurrentCardLayoutName());
|
|
2399
|
+
};
|
|
2400
|
+
Article.prototype.setCardLayout = function(cardLayout) {
|
|
2401
|
+
const layout = this.owner.getCardLayout(cardLayout);
|
|
2402
|
+
if (!layout) {
|
|
2403
|
+
throw new Error(`Card layout "${cardLayout}" not found`);
|
|
2404
|
+
}
|
|
2405
|
+
this.cardLayout = cardLayout;
|
|
2406
|
+
this._resolvedCardLayoutName = cardLayout;
|
|
2407
|
+
this.initialiseStyles();
|
|
2408
|
+
this.invalidateCaches();
|
|
2409
|
+
this.owner.requestRedraw(this.redraw);
|
|
2410
|
+
};
|
|
2411
|
+
function compareArticleIds(idA, idB) {
|
|
2412
|
+
const numA = Number(idA);
|
|
2413
|
+
const numB = Number(idB);
|
|
2414
|
+
const idsAreNumeric = Number.isFinite(numA) && Number.isFinite(numB);
|
|
2415
|
+
if (idsAreNumeric) {
|
|
2416
|
+
return numA - numB;
|
|
2417
|
+
}
|
|
2418
|
+
const strA = String(idA);
|
|
2419
|
+
const strB = String(idB);
|
|
2420
|
+
if (strA === strB) {
|
|
2421
|
+
return 0;
|
|
2422
|
+
}
|
|
2423
|
+
return strA < strB ? -1 : 1;
|
|
2424
|
+
}
|
|
2425
|
+
__name(compareArticleIds, "compareArticleIds");
|
|
2426
|
+
function ARTICLE_DURATION_SORTER(articleA, articleB) {
|
|
2427
|
+
const a = articleA.period.from.getDaysTo(articleA.period.to);
|
|
2428
|
+
const b = articleB.period.from.getDaysTo(articleB.period.to);
|
|
2429
|
+
if (a < b) {
|
|
2430
|
+
return 1;
|
|
2431
|
+
}
|
|
2432
|
+
if (a > b) {
|
|
2433
|
+
return -1;
|
|
2434
|
+
}
|
|
2435
|
+
return compareArticleIds(articleA.id, articleB.id);
|
|
2436
|
+
}
|
|
2437
|
+
__name(ARTICLE_DURATION_SORTER, "ARTICLE_DURATION_SORTER");
|
|
2438
|
+
function ARTICLE_DURATION_YEARS_SORTER(articleA, articleB) {
|
|
2439
|
+
const a = articleA.period.years;
|
|
2440
|
+
const b = articleB.period.years;
|
|
2441
|
+
if (a < b) {
|
|
2442
|
+
return 1;
|
|
2443
|
+
}
|
|
2444
|
+
if (a > b) {
|
|
2445
|
+
return -1;
|
|
2446
|
+
}
|
|
2447
|
+
return compareArticleIds(articleA.id, articleB.id);
|
|
2448
|
+
}
|
|
2449
|
+
__name(ARTICLE_DURATION_YEARS_SORTER, "ARTICLE_DURATION_YEARS_SORTER");
|
|
2450
|
+
function ARTICLE_IMAGE_QUEUE_SORTER(articleA, articleB) {
|
|
2451
|
+
const a = articleA.isInView && articleA.isVisible;
|
|
2452
|
+
const b = articleB.isInView && articleB.isVisible;
|
|
2453
|
+
if (!a && b) {
|
|
2454
|
+
return -1;
|
|
2455
|
+
}
|
|
2456
|
+
if (a && !b) {
|
|
2457
|
+
return 1;
|
|
2458
|
+
}
|
|
2459
|
+
return articleA.position.top - articleB.position.top;
|
|
2460
|
+
}
|
|
2461
|
+
__name(ARTICLE_IMAGE_QUEUE_SORTER, "ARTICLE_IMAGE_QUEUE_SORTER");
|
|
2462
|
+
function ARTICLE_FROM_SORTER(articleA, articleB) {
|
|
2463
|
+
const a = articleA.period.from;
|
|
2464
|
+
const b = articleB.period.from;
|
|
2465
|
+
let result = a.compare(b);
|
|
2466
|
+
if (result === 0) {
|
|
2467
|
+
result = compareArticleIds(articleB.id, articleA.id);
|
|
2468
|
+
}
|
|
2469
|
+
return result;
|
|
2470
|
+
}
|
|
2471
|
+
__name(ARTICLE_FROM_SORTER, "ARTICLE_FROM_SORTER");
|
|
2472
|
+
function ARTICLE_TO_SORTER(articleA, articleB) {
|
|
2473
|
+
const a = articleA.period.to;
|
|
2474
|
+
const b = articleB.period.to;
|
|
2475
|
+
let result = b.compare(a);
|
|
2476
|
+
if (result === 0) {
|
|
2477
|
+
result = compareArticleIds(articleB.id, articleA.id);
|
|
2478
|
+
}
|
|
2479
|
+
return result;
|
|
2480
|
+
}
|
|
2481
|
+
__name(ARTICLE_TO_SORTER, "ARTICLE_TO_SORTER");
|
|
2482
|
+
function ARTICLE_TOP_SORTER(articleA, articleB) {
|
|
2483
|
+
const a = articleA.position.top;
|
|
2484
|
+
const b = articleB.position.top;
|
|
2485
|
+
if (a < b) {
|
|
2486
|
+
return -1;
|
|
2487
|
+
}
|
|
2488
|
+
if (a > b) {
|
|
2489
|
+
return 1;
|
|
2490
|
+
}
|
|
2491
|
+
return compareArticleIds(articleB.id, articleA.id);
|
|
2492
|
+
}
|
|
2493
|
+
__name(ARTICLE_TOP_SORTER, "ARTICLE_TOP_SORTER");
|
|
2494
|
+
function ARTICLE_ROW_SORTER(articleA, articleB) {
|
|
2495
|
+
const laneOrderA = articleA.laneOrder || 0;
|
|
2496
|
+
const laneOrderB = articleB.laneOrder || 0;
|
|
2497
|
+
if (laneOrderA > laneOrderB) {
|
|
2498
|
+
return -1;
|
|
2499
|
+
}
|
|
2500
|
+
if (laneOrderA < laneOrderB) {
|
|
2501
|
+
return 1;
|
|
2502
|
+
}
|
|
2503
|
+
const a = articleA.row;
|
|
2504
|
+
const b = articleB.row;
|
|
2505
|
+
if (a < b) {
|
|
2506
|
+
return 1;
|
|
2507
|
+
}
|
|
2508
|
+
if (a > b) {
|
|
2509
|
+
return -1;
|
|
2510
|
+
}
|
|
2511
|
+
return compareArticleIds(articleB.id, articleA.id);
|
|
2512
|
+
}
|
|
2513
|
+
__name(ARTICLE_ROW_SORTER, "ARTICLE_ROW_SORTER");
|
|
2514
|
+
function ARTICLE_RANK_SORTER(articleA, articleB) {
|
|
2515
|
+
const a = articleA.rank;
|
|
2516
|
+
const b = articleB.rank;
|
|
2517
|
+
if (a < b) {
|
|
2518
|
+
return 1;
|
|
2519
|
+
}
|
|
2520
|
+
if (a > b) {
|
|
2521
|
+
return -1;
|
|
2522
|
+
}
|
|
2523
|
+
return compareArticleIds(articleB.id, articleA.id);
|
|
2524
|
+
}
|
|
2525
|
+
__name(ARTICLE_RANK_SORTER, "ARTICLE_RANK_SORTER");
|
|
2526
|
+
function ARTICLE_EFFECTIVE_RANK_SORTER(articleA, articleB) {
|
|
2527
|
+
const a = articleA.effectiveRank;
|
|
2528
|
+
const b = articleB.effectiveRank;
|
|
2529
|
+
if (a < b) {
|
|
2530
|
+
return 1;
|
|
2531
|
+
}
|
|
2532
|
+
if (a > b) {
|
|
2533
|
+
return -1;
|
|
2534
|
+
}
|
|
2535
|
+
return compareArticleIds(articleB.id, articleA.id);
|
|
2536
|
+
}
|
|
2537
|
+
__name(ARTICLE_EFFECTIVE_RANK_SORTER, "ARTICLE_EFFECTIVE_RANK_SORTER");
|
|
2538
|
+
function ARTICLE_POSITION_SORTER(articleA, articleB) {
|
|
2539
|
+
const a = articleA.position.left;
|
|
2540
|
+
const b = articleB.position.left;
|
|
2541
|
+
let result = a < b ? 1 : a > b ? -1 : 0;
|
|
2542
|
+
if (result === 0) {
|
|
2543
|
+
result = articleA.position.top - articleB.position.top;
|
|
2544
|
+
if (result === 0) {
|
|
2545
|
+
result = articleA.period.from.compare(articleB.period.from);
|
|
2546
|
+
if (result === 0) {
|
|
2547
|
+
result = compareArticleIds(articleA.id, articleB.id);
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
return result;
|
|
2552
|
+
}
|
|
2553
|
+
__name(ARTICLE_POSITION_SORTER, "ARTICLE_POSITION_SORTER");
|
|
2554
|
+
const sorters = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2488
2555
|
__proto__: null,
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
PRECISION_DAY,
|
|
2500
|
-
PRECISION_DECADE,
|
|
2501
|
-
PRECISION_HOUR,
|
|
2502
|
-
PRECISION_MILLENNIUM,
|
|
2503
|
-
PRECISION_MILLION_YEARS,
|
|
2504
|
-
PRECISION_MILLISECOND,
|
|
2505
|
-
PRECISION_MINUTE,
|
|
2506
|
-
PRECISION_MONTH,
|
|
2507
|
-
PRECISION_SECOND,
|
|
2508
|
-
PRECISION_YEAR,
|
|
2509
|
-
RANGE_ALL,
|
|
2510
|
-
RANGE_SCREEN,
|
|
2511
|
-
YEAR_PREFIXES,
|
|
2512
|
-
ZOOM_100_MILLION_YEARS,
|
|
2513
|
-
ZOOM_100_THOUSAND_YEARS,
|
|
2514
|
-
ZOOM_10_MILLION_YEARS,
|
|
2515
|
-
ZOOM_10_THOUSAND_YEARS,
|
|
2516
|
-
ZOOM_BILLION_YEARS,
|
|
2517
|
-
ZOOM_CENTURY,
|
|
2518
|
-
ZOOM_DAY,
|
|
2519
|
-
ZOOM_DECADE,
|
|
2520
|
-
ZOOM_HOUR,
|
|
2521
|
-
ZOOM_MILLENNIUM,
|
|
2522
|
-
ZOOM_MILLION_YEARS,
|
|
2523
|
-
ZOOM_MILLISECOND,
|
|
2524
|
-
ZOOM_MINUTE,
|
|
2525
|
-
ZOOM_MONTH,
|
|
2526
|
-
ZOOM_SECOND,
|
|
2527
|
-
ZOOM_YEAR
|
|
2556
|
+
ARTICLE_DURATION_SORTER,
|
|
2557
|
+
ARTICLE_DURATION_YEARS_SORTER,
|
|
2558
|
+
ARTICLE_EFFECTIVE_RANK_SORTER,
|
|
2559
|
+
ARTICLE_FROM_SORTER,
|
|
2560
|
+
ARTICLE_IMAGE_QUEUE_SORTER,
|
|
2561
|
+
ARTICLE_POSITION_SORTER,
|
|
2562
|
+
ARTICLE_RANK_SORTER,
|
|
2563
|
+
ARTICLE_ROW_SORTER,
|
|
2564
|
+
ARTICLE_TOP_SORTER,
|
|
2565
|
+
ARTICLE_TO_SORTER
|
|
2528
2566
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2529
2567
|
const CHART_RENDERERS = /* @__PURE__ */ new Map();
|
|
2530
2568
|
function registerChartRenderer(type, renderer) {
|
|
@@ -3749,16 +3787,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3749
3787
|
}
|
|
3750
3788
|
const month = parseFiniteInteger(input.month, 1);
|
|
3751
3789
|
const day = parseFiniteInteger(input.day, 1);
|
|
3752
|
-
const precision = input
|
|
3753
|
-
let dmy = new Dmy(
|
|
3790
|
+
const precision = getDatePrecision(input);
|
|
3791
|
+
let dmy = new Dmy({
|
|
3754
3792
|
year,
|
|
3755
3793
|
month,
|
|
3756
3794
|
day,
|
|
3757
|
-
|
|
3758
|
-
parseFiniteInteger(input.
|
|
3759
|
-
parseFiniteInteger(input.
|
|
3760
|
-
parseFiniteInteger(input.
|
|
3761
|
-
|
|
3795
|
+
precision,
|
|
3796
|
+
hour: parseFiniteInteger(input.hour, 0),
|
|
3797
|
+
minute: parseFiniteInteger(input.minute, 0),
|
|
3798
|
+
second: parseFiniteInteger(input.second, 0),
|
|
3799
|
+
millisecond: parseFiniteInteger(input.millisecond, 0)
|
|
3800
|
+
});
|
|
3762
3801
|
dmy = owner.getDmyFromInput(dmy);
|
|
3763
3802
|
return Dmy.CreateAsStartOfPeriod(dmy, precision);
|
|
3764
3803
|
}
|
|
@@ -4176,12 +4215,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
4176
4215
|
}
|
|
4177
4216
|
__name(resolveDistanceToBaselineValue, "resolveDistanceToBaselineValue");
|
|
4178
4217
|
const ARTICLE_DATA_DEFAULTS = {
|
|
4179
|
-
from: {
|
|
4180
|
-
|
|
4181
|
-
},
|
|
4182
|
-
to: {
|
|
4183
|
-
precision: "day"
|
|
4184
|
-
},
|
|
4218
|
+
from: {},
|
|
4219
|
+
to: {},
|
|
4185
4220
|
rank: 0,
|
|
4186
4221
|
starred: false,
|
|
4187
4222
|
hidePeriodLine: false,
|
|
@@ -4984,17 +5019,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
4984
5019
|
this.isDataLoaded = true;
|
|
4985
5020
|
};
|
|
4986
5021
|
TimeBand.prototype._setupPeriod = function(data) {
|
|
4987
|
-
let fromDmy =
|
|
4988
|
-
parseInt(getPropertyFromData(data, "from.year")),
|
|
4989
|
-
parseInt(getPropertyFromData(data, "from.month")),
|
|
4990
|
-
parseInt(getPropertyFromData(data, "from.day")),
|
|
4991
|
-
parseInt(getPropertyFromData(data, "from.hour")),
|
|
4992
|
-
parseInt(getPropertyFromData(data, "from.minute")),
|
|
4993
|
-
parseInt(getPropertyFromData(data, "from.second")),
|
|
4994
|
-
parseInt(getPropertyFromData(data, "from.millisecond"))
|
|
4995
|
-
);
|
|
5022
|
+
let fromDmy = getDmyFromData(data, "from");
|
|
4996
5023
|
fromDmy = this.owner.getDmyFromInput(fromDmy);
|
|
4997
|
-
const fromPrecision =
|
|
5024
|
+
const fromPrecision = fromDmy.precision;
|
|
4998
5025
|
const isToPresentProp = getPropertyFromData(data, "isToPresent");
|
|
4999
5026
|
const isToPresent = isToPresentProp === true || isToPresentProp === 1;
|
|
5000
5027
|
let toDmy;
|
|
@@ -5002,17 +5029,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
5002
5029
|
if (isToPresent) {
|
|
5003
5030
|
toDmy = Dmy.now();
|
|
5004
5031
|
} else if (existsInData(data, "to")) {
|
|
5005
|
-
toDmy =
|
|
5006
|
-
parseInt(getPropertyFromData(data, "to.year")),
|
|
5007
|
-
parseInt(getPropertyFromData(data, "to.month")),
|
|
5008
|
-
parseInt(getPropertyFromData(data, "to.day")),
|
|
5009
|
-
parseInt(getPropertyFromData(data, "to.hour")),
|
|
5010
|
-
parseInt(getPropertyFromData(data, "to.minute")),
|
|
5011
|
-
parseInt(getPropertyFromData(data, "to.second")),
|
|
5012
|
-
parseInt(getPropertyFromData(data, "to.millisecond"))
|
|
5013
|
-
);
|
|
5032
|
+
toDmy = getDmyFromData(data, "to");
|
|
5014
5033
|
toDmy = this.owner.getDmyFromInput(toDmy);
|
|
5015
|
-
toPrecision =
|
|
5034
|
+
toPrecision = toDmy.precision;
|
|
5016
5035
|
} else {
|
|
5017
5036
|
toDmy = fromDmy;
|
|
5018
5037
|
toPrecision = fromPrecision;
|
|
@@ -5898,14 +5917,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
5898
5917
|
return new Dmy(value.year, value.month, 1);
|
|
5899
5918
|
case ZOOM_YEAR:
|
|
5900
5919
|
return new Dmy(value.year, 1, 1);
|
|
5901
|
-
case ZOOM_DECADE:
|
|
5902
|
-
|
|
5903
|
-
return new Dmy(Math.floor(value.year / 10) * 10, 1, 1);
|
|
5904
|
-
}
|
|
5905
|
-
const displayedYear = 1 - value.year;
|
|
5906
|
-
const displayedDecade = Math.floor(displayedYear / 10) * 10;
|
|
5907
|
-
return new Dmy(1 - (displayedDecade + 9), 1, 1);
|
|
5908
|
-
}
|
|
5920
|
+
case ZOOM_DECADE:
|
|
5921
|
+
return Dmy.CreateAsStartOfPeriod(value, "decade");
|
|
5909
5922
|
case ZOOM_CENTURY:
|
|
5910
5923
|
return Dmy.CreateAsStartOfPeriod(value, "century");
|
|
5911
5924
|
case ZOOM_MILLENNIUM:
|
|
@@ -5930,7 +5943,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
5930
5943
|
case ZOOM_YEAR:
|
|
5931
5944
|
return start.addYears(1);
|
|
5932
5945
|
case ZOOM_DECADE:
|
|
5933
|
-
return
|
|
5946
|
+
return Dmy.CreateAsExclusiveEndOfPeriod(start, "decade");
|
|
5934
5947
|
case ZOOM_CENTURY:
|
|
5935
5948
|
return Dmy.CreateAsExclusiveEndOfPeriod(start, "century");
|
|
5936
5949
|
case ZOOM_MILLENNIUM:
|
|
@@ -6069,6 +6082,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
6069
6082
|
case ZOOM_DECADE: {
|
|
6070
6083
|
const displayedYear = value.year <= 0 ? 1 - value.year : value.year;
|
|
6071
6084
|
const decade = Math.floor(displayedYear / 10) * 10;
|
|
6085
|
+
if (decade === 0) {
|
|
6086
|
+
return value.year <= 0 ? `9–1${options.bceText}` : "1–9";
|
|
6087
|
+
}
|
|
6072
6088
|
const formattedDecade = new Dmy(decade, 1, 1).format("YYYY", {
|
|
6073
6089
|
thousandsSeparator: options.thousandsSeparator,
|
|
6074
6090
|
bceText: ""
|
|
@@ -7499,6 +7515,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
7499
7515
|
}
|
|
7500
7516
|
option = buildObjectFromPath(normalizedOptionPath, value);
|
|
7501
7517
|
}
|
|
7518
|
+
const previousTop = this.top;
|
|
7502
7519
|
option = handleDeprecatedOptions(option);
|
|
7503
7520
|
if (existsInData(option, "article")) {
|
|
7504
7521
|
deepMerge(this._explicitArticleOptions, option.article || {});
|
|
@@ -7576,6 +7593,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
7576
7593
|
const articleStyleScope = articleImpact.styleChanged ? "all" : laneRefreshState.styleLaneIds.size > 0 ? laneRefreshState.styleLaneIds : null;
|
|
7577
7594
|
this._refreshResolvedLanesFromOptions({ articleStyleScope });
|
|
7578
7595
|
}
|
|
7596
|
+
if (this.top !== previousTop && this.options.article.autoStacking.fitToHeight && !this._isLaneLayoutActive()) {
|
|
7597
|
+
this.fitToHeight();
|
|
7598
|
+
}
|
|
7579
7599
|
this.requestRedraw();
|
|
7580
7600
|
};
|
|
7581
7601
|
Timeline.prototype.setSize = function(width, height) {
|
|
@@ -7953,6 +7973,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
7953
7973
|
throw new Error("Date input requires a numeric year or canonical Histropedia date string");
|
|
7954
7974
|
}
|
|
7955
7975
|
return new Dmy({
|
|
7976
|
+
precision: getDatePrecision(parsed),
|
|
7956
7977
|
year: parsed.year,
|
|
7957
7978
|
month: (_b = parsed.month) != null ? _b : 1,
|
|
7958
7979
|
day: (_c = parsed.day) != null ? _c : 1,
|
|
@@ -8181,15 +8202,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
8181
8202
|
return normaliseZoomForManager(manager, targetZoom);
|
|
8182
8203
|
}
|
|
8183
8204
|
__name(getFitZoomForInternalDates, "getFitZoomForInternalDates");
|
|
8184
|
-
function getFitZoom(timeline, startDate, endDate, padding) {
|
|
8185
|
-
return getFitZoomForInternalDates(
|
|
8186
|
-
timeline,
|
|
8187
|
-
timeline.getDmyFromInput(normaliseDateInput(startDate)),
|
|
8188
|
-
timeline.getDmyFromInput(normaliseDateInput(endDate)),
|
|
8189
|
-
padding
|
|
8190
|
-
);
|
|
8191
|
-
}
|
|
8192
|
-
__name(getFitZoom, "getFitZoom");
|
|
8193
8205
|
function normaliseBoundDate(timeline, date) {
|
|
8194
8206
|
if (date == null) {
|
|
8195
8207
|
return null;
|
|
@@ -8539,10 +8551,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
8539
8551
|
const fitPixelSpan = getFitPixelSpan(timeline, padding);
|
|
8540
8552
|
const startPointAtPadding = getDayPointAtPixel(timeline, padding.left);
|
|
8541
8553
|
const startEndPointAtPadding = getDayPointAtPixel(timeline, padding.left + fitPixelSpan);
|
|
8542
|
-
const
|
|
8543
|
-
const
|
|
8544
|
-
const targetPoint = getDayPoint(targetInternalStart);
|
|
8545
|
-
const targetEndPoint = getDayPoint(targetInternalEnd);
|
|
8554
|
+
const targetPoint = getDayPoint(targetStartDate);
|
|
8555
|
+
const targetEndPoint = getDayPoint(targetEndDate);
|
|
8546
8556
|
const canInterpolateBoundaries = compareDayPoints(startEndPointAtPadding, startPointAtPadding) > 0 && compareDayPoints(targetEndPoint, targetPoint) > 0;
|
|
8547
8557
|
const rangeTween = tween({
|
|
8548
8558
|
from: 0,
|
|
@@ -8575,7 +8585,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
8575
8585
|
if (targetZoom !== timeline.timescaleManager.zoom) {
|
|
8576
8586
|
timeline.timescaleManager.setZoom(targetZoom);
|
|
8577
8587
|
}
|
|
8578
|
-
setInternalStartDate(timeline,
|
|
8588
|
+
setInternalStartDate(timeline, targetStartDate, padding.left, true);
|
|
8579
8589
|
timeline.isPanning = false;
|
|
8580
8590
|
}
|
|
8581
8591
|
});
|
|
@@ -9342,7 +9352,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
9342
9352
|
}
|
|
9343
9353
|
};
|
|
9344
9354
|
Timeline.prototype.getDmyFromInput = function(dmy) {
|
|
9345
|
-
var _a, _b, _c
|
|
9355
|
+
var _a, _b, _c;
|
|
9346
9356
|
let normalised;
|
|
9347
9357
|
if (typeof dmy === "string") {
|
|
9348
9358
|
normalised = Dmy.fromString(dmy);
|
|
@@ -9353,16 +9363,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
9353
9363
|
normalised = new Dmy(dmy);
|
|
9354
9364
|
} else {
|
|
9355
9365
|
normalised = new Dmy({
|
|
9366
|
+
precision: dmy.precision,
|
|
9356
9367
|
year: dmy.year,
|
|
9357
9368
|
month: (_a = dmy.month) != null ? _a : 1,
|
|
9358
9369
|
day: (_b = dmy.day) != null ? _b : 1,
|
|
9359
|
-
hour:
|
|
9360
|
-
minute:
|
|
9361
|
-
second:
|
|
9362
|
-
millisecond:
|
|
9370
|
+
hour: dmy.hour,
|
|
9371
|
+
minute: dmy.minute,
|
|
9372
|
+
second: dmy.second,
|
|
9373
|
+
millisecond: dmy.millisecond
|
|
9363
9374
|
});
|
|
9364
9375
|
}
|
|
9365
|
-
if (!((
|
|
9376
|
+
if (!((_c = this.options) == null ? void 0 : _c.shiftBceDates)) {
|
|
9366
9377
|
return normalised;
|
|
9367
9378
|
}
|
|
9368
9379
|
if (normalised.year < 0) {
|
|
@@ -12522,25 +12533,32 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
12522
12533
|
Timeline.prototype.setCentreDate = function(dmy, pixelOffset) {
|
|
12523
12534
|
this.setStartDate(dmy, { padding: this.getWidth() / 2 + (pixelOffset || 0) });
|
|
12524
12535
|
};
|
|
12525
|
-
|
|
12536
|
+
function fitInternalDateRange(timeline, startDate, endDate, options = {}) {
|
|
12526
12537
|
var _a;
|
|
12527
12538
|
const padding = normalisePadding(options.padding);
|
|
12539
|
+
const targetZoom = getFitZoomForInternalDates(timeline, startDate, endDate, padding);
|
|
12540
|
+
if ((_a = options.animation) == null ? void 0 : _a.active) {
|
|
12541
|
+
animateDateRangeFit(timeline, startDate, endDate, targetZoom, padding, options.animation);
|
|
12542
|
+
return;
|
|
12543
|
+
}
|
|
12544
|
+
if (targetZoom !== timeline.timescaleManager.zoom) {
|
|
12545
|
+
timeline.setZoom(targetZoom);
|
|
12546
|
+
}
|
|
12547
|
+
setInternalStartDate(timeline, startDate, padding.left, true);
|
|
12548
|
+
}
|
|
12549
|
+
__name(fitInternalDateRange, "fitInternalDateRange");
|
|
12550
|
+
Timeline.prototype.fitDateRange = /* @__PURE__ */ __name(function fitDateRange(start, end, options = {}) {
|
|
12528
12551
|
let startRange = normaliseDateRangeInput(start);
|
|
12529
12552
|
let endRange = normaliseDateRangeInput(end);
|
|
12530
12553
|
if (startRange.start.compare(endRange.start) > 0) {
|
|
12531
12554
|
[startRange, endRange] = [endRange, startRange];
|
|
12532
12555
|
}
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
}
|
|
12540
|
-
if (targetZoom !== this.timescaleManager.zoom) {
|
|
12541
|
-
this.setZoom(targetZoom);
|
|
12542
|
-
}
|
|
12543
|
-
this.setStartDate(startDate, { padding: padding.left });
|
|
12556
|
+
fitInternalDateRange(
|
|
12557
|
+
this,
|
|
12558
|
+
this.getDmyFromInput(startRange.start),
|
|
12559
|
+
this.getDmyFromInput(endRange.end),
|
|
12560
|
+
options
|
|
12561
|
+
);
|
|
12544
12562
|
}, "fitDateRange");
|
|
12545
12563
|
Timeline.prototype.settleDateBounds = /* @__PURE__ */ __name(function settleDateBounds(options = {}) {
|
|
12546
12564
|
var _a;
|
|
@@ -12599,7 +12617,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
12599
12617
|
if (!((_a = article == null ? void 0 : article.period) == null ? void 0 : _a.from) || !article.period.to) {
|
|
12600
12618
|
return false;
|
|
12601
12619
|
}
|
|
12602
|
-
this
|
|
12620
|
+
fitInternalDateRange(this, article.period.from, article.period.to, {
|
|
12603
12621
|
padding: options.padding,
|
|
12604
12622
|
animation: options.animation
|
|
12605
12623
|
});
|
|
@@ -12619,7 +12637,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
12619
12637
|
left: requestedPadding.left + articleRange.maxCardLeftOffset,
|
|
12620
12638
|
right: requestedPadding.right + articleRange.maxCardRightOffset
|
|
12621
12639
|
};
|
|
12622
|
-
this
|
|
12640
|
+
fitInternalDateRange(this, articleRange.earliest, articleRange.latest, {
|
|
12623
12641
|
padding: fitPadding,
|
|
12624
12642
|
animation: options.animation
|
|
12625
12643
|
});
|