This repository has been archived by the owner on Feb 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
wellcomeTimelineProvider.js
67 lines (49 loc) · 1.66 KB
/
wellcomeTimelineProvider.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
WellcomeTimelineProvider.prototype = new BaseProvider();
WellcomeTimelineProvider.prototype.constructor = WellcomeTimelineProvider;
function WellcomeTimelineProvider(options) {
$.extend(this.options, options, {
provider: this,
maxTicks: 100,
maxYearIntervalWidth: 500,
maxDecadeIntervalWidth: 2000,
maxCenturyIntervalWidth: 500,
zoomAnimationDuration: 1000,
eventFadeDuration: 500,
zoomFactor: 3,
eventStackSize: 3,
padding: 0
});
this.create = function (opts) {
var self = this;
$.extend(self.options, opts);
self.load();
self.options.element.timeline(self.options);
};
this.getTimelineStartDate = function() {
var self = this;
return self.getDate(self.data.EarliestJulianDay).add('years', self.options.padding * -1);
};
this.getTimelineEndDate = function () {
var self = this;
return self.getDate(self.data.LastJulianDay).add('years', self.options.padding);
};
this.setEventStartDate = function (evnt) {
var self = this;
evnt.startDate = self.getDate(evnt.JulianDayStart);
};
this.setEventEndDate = function (evnt) {
var self = this;
if (evnt.JulianDayEnd < 0) {
evnt.endDate = self.getDate(evnt.JulianDayStart);
} else {
evnt.endDate = self.getDate(evnt.JulianDayEnd);
}
};
this.getDate = function(julianDay) {
var dateObj = julianToGregorian(julianDay);
var m = moment(new Date(dateObj.year, dateObj.month - 1, dateObj.day));
return m;
};
this.remove = function() {
};
}