@knight-lab/timelinejs 3.9.2 → 3.9.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knight-lab/timelinejs",
3
- "version": "3.9.2",
3
+ "version": "3.9.3",
4
4
  "license": "MPL-2.0",
5
5
  "description": "TimelineJS v3: A Storytelling Timeline built in JavaScript, made by Northwestern University Knight Lab.",
6
6
  "dependencies": {
@@ -150,7 +150,7 @@
150
150
  var options = optionsFromUrlParams();
151
151
  createEmbedDiv('timeline-embed', options.width, options.height);
152
152
  // ga_property_id is not something we let users override
153
- options.ga_property_id = 'UA-27829802-4';
153
+ options.ga_measurement_id = 'G-LVEFKMG087'
154
154
  if (typeof(options.source) == 'undefined') {
155
155
  options.source = '1xuY4upIooEeszZ_lCmeNx24eSFWe0rHe9ZdqH2xqVNk' // women in computing
156
156
  }
@@ -154,7 +154,13 @@ export async function readGoogleAsCSV(url, sheets_proxy) {
154
154
  if (error_json.proxy_err_code == 'response_not_csv') {
155
155
  throw new TLError('Timeline could not read the data for your timeline. Make sure you have published it to the web.')
156
156
  }
157
- throw new TLError(error_json.message)
157
+ let msg = "undefined error"
158
+ if (Array.isArray(error_json.message)) {
159
+ msg = error_json.message.join('<br>')
160
+ } else {
161
+ msg = String(error_json.message)
162
+ }
163
+ throw new TLError(msg)
158
164
  })
159
165
 
160
166
  let timeline_config = { 'events': [], 'errors': [], 'warnings': [], 'eras': [] }
@@ -334,4 +340,4 @@ function handleRow(event, timeline_config) {
334
340
  } else {
335
341
  timeline_config.events.push(event);
336
342
  }
337
- }
343
+ }
@@ -1,6 +1,5 @@
1
1
  import "wicg-inert";
2
2
 
3
- import { addClass } from "../dom/DOMUtil"
4
3
  import { I18NMixins } from "../language/I18NMixins";
5
4
  import Events from "../core/Events";
6
5
  import { DOMMixins } from "../dom/DOMMixins";
@@ -321,17 +320,17 @@ export class Slide {
321
320
 
322
321
  // Add to DOM
323
322
  if (!this.has.text && !this.has.headline && this.has.media) {
324
- addClass(this._el.container, 'tl-slide-media-only');
323
+ this._el.container.classList.add('tl-slide-media-only');
325
324
  this._media.addTo(this._el.content);
326
325
  } else if (this.has.headline && this.has.media && !this.has.text) {
327
- addClass(this._el.container, 'tl-slide-media-only');
326
+ this._el.container.classList.add('tl-slide-media-only');
328
327
  this._text.addTo(this._el.content);
329
328
  this._media.addTo(this._el.content);
330
329
  } else if (this.has.text && this.has.media) {
331
330
  this._text.addTo(this._el.content);
332
331
  this._media.addTo(this._el.content);
333
332
  } else if (this.has.text || this.has.headline) {
334
- addClass(this._el.container, 'tl-slide-text-only');
333
+ this._el.container.classList.add('tl-slide-text-only');
335
334
  this._text.addTo(this._el.content);
336
335
  }
337
336
 
@@ -6,7 +6,6 @@ import { Animate } from "../animation/Animate"
6
6
  import * as DOM from "../dom/DOM"
7
7
  import { DOMEvent } from "../dom/DOMEvent"
8
8
  import * as Browser from "../core/Browser"
9
- import { addClass } from "../dom/DOMUtil"
10
9
  import Swipable from "../ui/Swipable";
11
10
  import Message from "../ui/Message"
12
11
  import { Slide } from "./Slide"
@@ -394,7 +393,7 @@ export class StorySlider {
394
393
  ================================================== */
395
394
  _initLayout() {
396
395
 
397
- addClass(this._el.container, 'tl-storyslider');
396
+ this._el.container.classList.add('tl-storyslider');
398
397
 
399
398
  // Create Navigation
400
399
  this._nav.previous = new SlideNav({ title: "Previous", description: "description" }, { direction: "previous" }, this._el.container);
@@ -1,5 +1,4 @@
1
1
  import * as DOM from "../dom/DOM"
2
- import { addClass } from "../dom/DOMUtil"
3
2
  import { hexToRgb, mergeData, classMixin, isTrue, trace, addTraceHandler } from "../core/Util";
4
3
  import { easeInOutQuint, easeOutStrong } from "../animation/Ease";
5
4
  import Message from "../ui/Message"
@@ -134,6 +133,7 @@ class Timeline {
134
133
  slide_default_fade: "0%", // landscape fade
135
134
  zoom_sequence: [0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89], // Array of Fibonacci numbers for TimeNav zoom levels
136
135
  language: "en",
136
+ ga_measurement_id: null,
137
137
  ga_property_id: null,
138
138
  track_events: ['back_to_start', 'nav_next', 'nav_previous', 'zoom_in', 'zoom_out'],
139
139
  theme: null,
@@ -192,17 +192,17 @@ class Timeline {
192
192
  }
193
193
 
194
194
  // Apply base class to container
195
- addClass(this._el.container, 'tl-timeline');
195
+ this._el.container.classList.add('tl-timeline');
196
196
  this._el.container.setAttribute('tabindex', '0');
197
197
  this._el.container.setAttribute('role', 'region');
198
198
  this._el.container.setAttribute('aria-label', this._('aria_label_timeline'));
199
199
 
200
200
  if (this.options.is_embed) {
201
- addClass(this._el.container, 'tl-timeline-embed');
201
+ this._el.container.classList.add('tl-timeline-embed');
202
202
  }
203
203
 
204
204
  if (this.options.is_full_embed) {
205
- addClass(this._el.container, 'tl-timeline-full-embed');
205
+ this._el.container.classList.add('tl-timeline-full-embed');
206
206
  }
207
207
 
208
208
  this._loadLanguage(data);
@@ -992,31 +992,23 @@ class Timeline {
992
992
  this._el.container.focus();
993
993
  }
994
994
 
995
- _initGoogleAnalytics() {
996
- (function(i, s, o, g, r, a, m) {
997
- i['GoogleAnalyticsObject'] = r;
998
- i[r] = i[r] || function() {
999
- (i[r].q = i[r].q || []).push(arguments)
1000
- }, i[r].l = 1 * new Date();
1001
- a = s.createElement(o), m = s.getElementsByTagName(o)[0];
1002
- a.async = 1;
1003
- a.src = g;
1004
- m.parentNode.insertBefore(a, m)
1005
- })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
1006
-
1007
- ga('create', this.options.ga_property_id, 'auto');
1008
- ga('set', 'anonymizeIp', true);
995
+ _initGoogleAnalytics(measurement_id) {
996
+ loadJS(`https://www.googletagmanager.com/gtag/js?id=${measurement_id}`)
997
+ window.dataLayer = window.dataLayer || [];
998
+ window.gtag = function(){dataLayer.push(arguments);}
999
+ gtag('js', new Date());
1000
+ gtag('config', measurement_id);
1009
1001
  }
1010
1002
 
1011
1003
  _initAnalytics() {
1012
- if (this.options.ga_property_id === null) { return; }
1013
- this._initGoogleAnalytics();
1014
- ga('send', 'pageview');
1004
+ let measurement_id = this.options.ga_measurement_id || this.options.ga_property_id || null;
1005
+ if (!measurement_id) { return; }
1006
+ this._initGoogleAnalytics(measurement_id);
1015
1007
  var events = this.options.track_events;
1016
1008
  for (let i = 0; i < events.length; i++) {
1017
1009
  var event_ = events[i];
1018
1010
  this.addEventListener(event_, function(e) {
1019
- ga('send', 'event', e.type, 'clicked');
1011
+ gtag('event', e.type);
1020
1012
  });
1021
1013
  }
1022
1014
  }
@@ -2,7 +2,6 @@ import { classMixin, unlinkify, mergeData } from "../core/Util"
2
2
  import Events from "../core/Events"
3
3
  import { DOMMixins } from "../dom/DOMMixins"
4
4
  import * as Browser from "../core/Browser"
5
- import { removeClass } from "../dom/DOMUtil";
6
5
  import { easeInSpline } from "../animation/Ease";
7
6
  import * as DOM from "../dom/DOM"
8
7
 
@@ -156,7 +155,7 @@ export class TimeEra {
156
155
  this.setPosition({ top: n });
157
156
 
158
157
  if (remainder < 56) {
159
- removeClass(this._el.content_container, "tl-timeera-content-container-small");
158
+ this._el.content_container.remove("tl-timeera-content-container-small");
160
159
  }
161
160
  }
162
161
 
@@ -3,7 +3,6 @@ import Events from "../core/Events"
3
3
  import { DOMMixins } from "../dom/DOMMixins"
4
4
  import { DOMEvent } from "../dom/DOMEvent"
5
5
 
6
- import { addClass, removeClass } from "../dom/DOMUtil"
7
6
  import * as DOM from "../dom/DOM"
8
7
  import { webkit as BROWSER_WEBKIT } from "../core/Browser";
9
8
  import { easeInSpline } from "../animation/Ease";
@@ -181,9 +180,9 @@ export class TimeMarker {
181
180
  }
182
181
 
183
182
  if (h <= 56) {
184
- addClass(this._el.content_container, "tl-timemarker-content-container-small");
183
+ this._el.content_container.classList.add("tl-timemarker-content-container-small");
185
184
  } else {
186
- removeClass(this._el.content_container, "tl-timemarker-content-container-small");
185
+ this._el.content_container.classList.remove("tl-timemarker-content-container-small");
187
186
  }
188
187
 
189
188
  // Handle number of lines visible vertically
@@ -13,6 +13,7 @@
13
13
  hash_bookmark: true,
14
14
  start_at_end: false,
15
15
  autolink: false,
16
+ ga_measurement_id: 'G-LVEFKMG087',
16
17
  sheets_proxy: 'https://sheets-proxy.knightlab.com/proxy/'
17
18
  }
18
19
 
@@ -1,25 +0,0 @@
1
- /* DomUtil
2
- Inspired by Leaflet
3
- DomUtil contains various utility functions for working with DOM
4
- Why are they in DOMUtil and not DOM?
5
- ================================================== */
6
-
7
- function hasClass(el, name) {
8
- return (el.className.length > 0) &&
9
- new RegExp("(^|\\s)" + name + "(\\s|$)").test(el.className);
10
- }
11
-
12
- export function addClass(el, name) {
13
- if (!hasClass(el, name)) {
14
- el.className += (el.className ? ' ' : '') + name;
15
- }
16
- }
17
-
18
- export function removeClass(el, name) {
19
- el.className = el.className.replace(/(\S+)\s*/g, function(w, match) {
20
- if (match === name) {
21
- return '';
22
- }
23
- return w;
24
- }).replace(/^\s+/, '');
25
- }