forked from adamlaska/circleci-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
54 lines (45 loc) · 1.92 KB
/
app.js
File metadata and controls
54 lines (45 loc) · 1.92 KB
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
/**
WARNING: Consider import & execution order carefully in the context of the
browser & the dom when modifying file
*/
import * as Cookie from 'js-cookie';
import Prism from 'prismjs';
import services from './services';
import '../styles/main.scss';
// adding "Clients" to the window object so they can be accessed by other js inside Jekyll
window.Cookie = Cookie;
window.AnalyticsClient = services.AnalyticsClient; // because it only has static methods, AnalyticsClient is not instantiated
window.OptimizelyClient = new services.OptimizelyClient();
import site from './site';
// set to manual so we can start highlighting once DOM is ready
Prism.manual = true;
services.rum.init();
$(() => {
services.instantsearch.init();
services.progressbar.init();
services.sectionShareButton.init();
services.lang.init();
// Boolean whether or not URL is in Guided Tour experiment
const isGatedPath =
['/docs/', '/docs/2.0/'].includes(window.location.pathname) ||
['-preview/', 'view/2.0/'].includes(window.location.pathname.slice?.(-9)) ||
/language-(javascript|python)/gm.test(window.location.pathname);
if (!isGatedPath) {
/** If URL is not in Guided Tour experiment, then we can attach eventListeners
* for highlighting the Table of Contents in the sidebar as user scrolls.
*
* If URL is in Guided Tour experiment, then it must wait for experiment
* logic to complete before attaching eventListeners since the ToC is
* different in treatment vs control.
*/
site.toc.highlightTocOnScrollOnce();
}
import(/* webpackPrefetch: true */ './experiments').then(
({ default: { languageGuides } = {} }) =>
isGatedPath ? languageGuides() : null,
); // ensure languageGuides is loaded; // imports all experiments
Prism.highlightAll();
// trackCopyCode service MUST be initialized after PrismJS is initialized
services.trackCopyCode.init();
services.trackExperimentEntry.init();
});