NUKnightLab / NUKnightLab/TimelineJS3

non-blank default script_path value prevents Timeline from computing correct value

Open
#718 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
JavaScript
Stars
3.2k
Forks
645
PR merge metrics
No merged PRs in 30d

Description

As reported in Zendesk 9021, a locally installed distribution of TimelineJS does not retrieve font.default.css from the local distribution.

In short, this is because Timeline comes with a default value for script_path as seen in
https://github.com/NUKnightLab/TimelineJS3/blob/master/src/js/timeline/Timeline.js#L99

This means that later, TimelineJS will not compute a proper relative script_path:
https://github.com/NUKnightLab/TimelineJS3/blob/master/src/js/timeline/Timeline.js#L169-L171

The workaround is to explicitly set script_path in the options passed to the Timeline constructor on a page using a locally served distribution. The explicit value should be a relative URL to the "js" directory of the distribution, eg https://example.com/timeline3/js/

Our intention is to support an undefined script_path option, where TimelineJS "introspects" the location of the file where its own code was loaded and uses that. Users should only need to define script_path if the TimelineJS code is bundled together with other JS resources so that the loaded bundle isn't located in the right place relative to the other resources (CSS and language localization files, generally) which may need to be loaded.

It may be as simple as blanking out the script_path value at https://github.com/NUKnightLab/TimelineJS3/blob/master/src/js/timeline/Timeline.js#L99 but of course that should be thoroughly tested.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/js/timeline/Timeline.js at the default script_path near line 99 and the path computation near lines 169-171. Verify the behavior with a locally served distribution, including loading font.default.css and localization resources. Done means an undefined script_path computes the distribution's relative path while an explicit value still overrides it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.