MCPcopy
hub / github.com/NUKnightLab/TimelineJS3 / constructor

Method constructor

src/js/timeline/Timeline.js:63–210  ·  view source on GitHub ↗
(elem, data, options)

Source from the content-addressed store, hash-verified

61 */
62class Timeline {
63 constructor(elem, data, options) {
64 if (!options) {
65 options = {}
66 }
67 this.ready = false;
68 this._el = {
69 container: DOM.get(elem),
70 storyslider: {},
71 timenav: {},
72 menubar: {}
73 };
74
75 if (options.lang && !options.language) {
76 options.language = options.lang;
77 }
78
79 /** @type {Language} */
80 this.language = fallback;
81
82 /** @type {StorySlider} */
83 this._storyslider = {};
84
85 /** @type {TimeNav} */
86 this._timenav = {};
87
88 /** @type {MenuBar} */
89 this._menubar = {};
90
91 // Loaded State
92 this._loaded = { storyslider: false, timenav: false };
93
94 /** @type {TimelineConfig} */
95 this.config = null;
96
97 this.options = {
98 script_path: "https://cdn.knightlab.com/libs/timeline3/latest/js/", // as good a default as any
99 height: this._el.container.offsetHeight,
100 width: this._el.container.offsetWidth,
101 debug: false,
102 font: 'default',
103 is_embed: false,
104 is_full_embed: false,
105 hash_bookmark: false,
106 default_bg_color: { r: 255, g: 255, b: 255 },
107 scale_factor: 2, // How many screen widths wide should the timeline be
108 layout: "landscape", // portrait or landscape
109 timenav_position: "bottom", // timeline on top or bottom
110 optimal_tick_width: 60, // optimal distance (in pixels) between ticks on axis
111 base_class: "tl-timeline", // removing tl-timeline will break all default stylesheets...
112 timenav_height: null,
113 timenav_height_percentage: 25, // Overrides timenav height as a percentage of the screen
114 timenav_mobile_height_percentage: 40, // timenav height as a percentage on mobile devices
115 timenav_height_min: 175, // Minimum timenav height
116 marker_height_min: 30, // Minimum Marker Height
117 marker_width_min: 100, // Minimum Marker Width
118 marker_padding: 5, // Top Bottom Marker Padding
119 start_at_slide: 0,
120 start_at_end: false,

Callers

nothing calls this directly

Calls 15

determineScriptPathMethod · 0.95
_loadStylesMethod · 0.95
updateDisplayMethod · 0.95
_loadLanguageMethod · 0.95
hexToRgbFunction · 0.90
traceFunction · 0.90
mergeDataFunction · 0.90
loadCSSFunction · 0.90
loadJSFunction · 0.90
addTraceHandlerFunction · 0.90
make_keydown_handlerFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected