clean-jsdoc-theme 4.1.6 → 4.1.8

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.
@@ -11,50 +11,50 @@ var MIN_FONT_SIZE = 10;
11
11
  var localStorage = window.localStorage;
12
12
 
13
13
  function getTheme() {
14
- var body = document.body;
14
+ var body = document.body;
15
15
 
16
- return body.getAttribute('data-theme');
16
+ return body.getAttribute('data-theme');
17
17
  }
18
18
 
19
19
  function updateTheme(theme) {
20
- var body = document.body;
21
- var svgUse = document.querySelectorAll('.theme-svg-use');
22
- var iconID = theme === 'dark' ? '#light-theme-icon' : '#dark-theme-icon';
20
+ var body = document.body;
21
+ var svgUse = document.querySelectorAll('.theme-svg-use');
22
+ var iconID = theme === 'dark' ? '#light-theme-icon' : '#dark-theme-icon';
23
23
 
24
- body.setAttribute('data-theme', theme);
25
- body.classList.remove('dark', 'light');
26
- body.classList.add(theme);
24
+ body.setAttribute('data-theme', theme);
25
+ body.classList.remove('dark', 'light');
26
+ body.classList.add(theme);
27
27
 
28
- svgUse.forEach(function(svg) {
29
- svg.setAttribute('xlink:href', iconID);
30
- });
28
+ svgUse.forEach(function (svg) {
29
+ svg.setAttribute('xlink:href', iconID);
30
+ });
31
31
 
32
- localStorage.setItem(themeLocalStorageKey, theme);
32
+ localStorage.setItem(themeLocalStorageKey, theme);
33
33
  }
34
34
 
35
35
  function toggleTheme() {
36
- var body = document.body;
37
- var theme = body.getAttribute('data-theme');
36
+ var body = document.body;
37
+ var theme = body.getAttribute('data-theme');
38
38
 
39
- var newTheme = theme === 'dark' ? 'light' : 'dark';
39
+ var newTheme = theme === 'dark' ? 'light' : 'dark';
40
40
 
41
- updateTheme(newTheme);
41
+ updateTheme(newTheme);
42
42
  }
43
43
 
44
- (function() {
45
- var theme = getTheme();
44
+ (function () {
45
+ var theme = getTheme();
46
46
 
47
- var themeStoredInLocalStorage = localStorage.getItem(themeLocalStorageKey);
47
+ var themeStoredInLocalStorage = localStorage.getItem(themeLocalStorageKey);
48
48
 
49
- if (themeStoredInLocalStorage) {
50
- if (theme === themeStoredInLocalStorage) {
51
- return;
52
- }
49
+ if (themeStoredInLocalStorage) {
50
+ if (theme === themeStoredInLocalStorage) {
51
+ return;
52
+ }
53
53
 
54
- updateTheme(themeStoredInLocalStorage);
55
- } else {
56
- localStorage.setItem(themeLocalStorageKey, theme);
57
- }
54
+ updateTheme(themeStoredInLocalStorage);
55
+ } else {
56
+ localStorage.setItem(themeLocalStorageKey, theme);
57
+ }
58
58
  })();
59
59
 
60
60
  /**
@@ -62,13 +62,13 @@ function toggleTheme() {
62
62
  * @param {string} id Accordion id
63
63
  */
64
64
  function setAccordionIdToLocalStorage(id) {
65
- /**
65
+ /**
66
66
  * @type {object}
67
67
  */
68
- var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
68
+ var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
69
69
 
70
- ids[id] = id;
71
- localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
70
+ ids[id] = id;
71
+ localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
72
72
  }
73
73
 
74
74
  /**
@@ -76,13 +76,13 @@ function setAccordionIdToLocalStorage(id) {
76
76
  * @param {string} id Accordion id
77
77
  */
78
78
  function removeAccordionIdFromLocalStorage(id) {
79
- /**
79
+ /**
80
80
  * @type {object}
81
81
  */
82
- var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
82
+ var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
83
83
 
84
- delete ids[id];
85
- localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
84
+ delete ids[id];
85
+ localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
86
86
  }
87
87
 
88
88
  /**
@@ -91,147 +91,157 @@ function removeAccordionIdFromLocalStorage(id) {
91
91
  * @returns {object}
92
92
  */
93
93
  function getAccordionIdsFromLocalStorage() {
94
- /**
94
+ /**
95
95
  * @type {object}
96
96
  */
97
- var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
97
+ var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
98
98
 
99
- return ids || {};
99
+ return ids || {};
100
100
  }
101
101
 
102
102
  function toggleAccordion(element) {
103
- var currentNode = element;
104
- var isCollapsed = currentNode.getAttribute('data-isopen') === 'false';
105
-
106
- if (isCollapsed) {
107
- currentNode.setAttribute('data-isopen', 'true');
108
- setAccordionIdToLocalStorage(currentNode.id);
109
- } else {
110
- currentNode.setAttribute('data-isopen', 'false');
111
- removeAccordionIdFromLocalStorage(currentNode.id);
112
- }
103
+ var currentNode = element;
104
+ var isCollapsed = currentNode.getAttribute('data-isopen') === 'false';
105
+
106
+ if (isCollapsed) {
107
+ currentNode.setAttribute('data-isopen', 'true');
108
+ setAccordionIdToLocalStorage(currentNode.id);
109
+ } else {
110
+ currentNode.setAttribute('data-isopen', 'false');
111
+ removeAccordionIdFromLocalStorage(currentNode.id);
112
+ }
113
113
  }
114
114
 
115
115
  function initAccordion() {
116
- if (
117
- localStorage.getItem(accordionLocalStorageKey) === undefined ||
116
+ if (
117
+ localStorage.getItem(accordionLocalStorageKey) === undefined ||
118
118
  localStorage.getItem(accordionLocalStorageKey) === null
119
- ) {
120
- localStorage.setItem(accordionLocalStorageKey, '{}');
121
- }
122
- var allAccordion = document.querySelectorAll('.sidebar-section-title');
123
- var ids = getAccordionIdsFromLocalStorage();
124
-
125
- allAccordion.forEach(function(item) {
126
- item.addEventListener('click', function() {
127
- toggleAccordion(item);
128
- });
129
- if (item.id in ids) {
130
- toggleAccordion(item);
119
+ ) {
120
+ localStorage.setItem(accordionLocalStorageKey, '{}');
131
121
  }
132
- });
122
+ var allAccordion = document.querySelectorAll('.sidebar-section-title');
123
+ var ids = getAccordionIdsFromLocalStorage();
124
+
125
+ allAccordion.forEach(function (item) {
126
+ item.addEventListener('click', function () {
127
+ toggleAccordion(item);
128
+ });
129
+ if (item.id in ids) {
130
+ toggleAccordion(item);
131
+ }
132
+ });
133
133
  }
134
134
 
135
135
  function isSourcePage() {
136
- return Boolean(document.querySelector('#source-page'));
136
+ return Boolean(document.querySelector('#source-page'));
137
137
  }
138
138
 
139
139
  function bringElementIntoView(element, updateHistory = true) {
140
- // If element is null then we are not going further
141
- if (!element) {
142
- return;
143
- }
140
+ // If element is null then we are not going further
141
+ if (!element) {
142
+ return;
143
+ }
144
144
 
145
- var navbar = document.querySelector('.navbar-container');
146
- var body = document.querySelector('.main-content');
147
- var elementTop = element.getBoundingClientRect().top;
145
+ /**
146
+ * tocbotInstance is defined in layout.tmpl
147
+ * It is defined when we are initializing tocbot.
148
+ *
149
+ */
150
+ // eslint-disable-next-line no-undef
151
+ if (tocbotInstance) {
152
+ // eslint-disable-next-line no-undef
153
+ setTimeout(() => tocbotInstance.updateTocListActiveElement(element), 60)
154
+ }
155
+ var navbar = document.querySelector('.navbar-container');
156
+ var body = document.querySelector('.main-content');
157
+ var elementTop = element.getBoundingClientRect().top;
148
158
 
149
- var offset = 16;
159
+ var offset = 16;
150
160
 
151
- if (navbar) {
152
- offset += navbar.scrollHeight;
153
- }
161
+ if (navbar) {
162
+ offset += navbar.scrollHeight;
163
+ }
154
164
 
155
- if (body) {
156
- body.scrollBy(0, elementTop - offset);
157
- }
165
+ if (body) {
166
+ body.scrollBy(0, elementTop - offset);
167
+ }
158
168
 
159
- if (updateHistory) {
160
- // eslint-disable-next-line no-undef
161
- history.pushState(null, null, '#' + element.id);
162
- }
169
+ if (updateHistory) {
170
+ // eslint-disable-next-line no-undef
171
+ history.pushState(null, null, '#' + element.id);
172
+ }
163
173
  }
164
174
 
165
175
  // eslint-disable-next-line no-unused-vars
166
176
  function bringLinkToView(event) {
167
- event.preventDefault();
168
- event.stopPropagation();
169
- var id = event.currentTarget.getAttribute('href');
177
+ event.preventDefault();
178
+ event.stopPropagation();
179
+ var id = event.currentTarget.getAttribute('href');
170
180
 
171
- if (!id) {
172
- return;
173
- }
181
+ if (!id) {
182
+ return;
183
+ }
174
184
 
175
- var element = document.getElementById(id.slice(1));
185
+ var element = document.getElementById(id.slice(1));
176
186
 
177
- if (element) {
178
- bringElementIntoView(element);
179
- }
187
+ if (element) {
188
+ bringElementIntoView(element);
189
+ }
180
190
  }
181
191
 
182
192
  function bringIdToViewOnMount() {
183
- if (isSourcePage()) {
184
- return;
185
- }
193
+ if (isSourcePage()) {
194
+ return;
195
+ }
186
196
 
187
- // eslint-disable-next-line no-undef
188
- var id = window.location.hash;
197
+ // eslint-disable-next-line no-undef
198
+ var id = window.location.hash;
189
199
 
190
- if (id === '') {
191
- return;
192
- }
200
+ if (id === '') {
201
+ return;
202
+ }
193
203
 
194
- var element = document.getElementById(id.slice(1));
204
+ var element = document.getElementById(id.slice(1));
195
205
 
196
- if (!element) {
197
- id = decodeURI(id);
198
- element = document.getElementById(id.slice(1));
199
- }
206
+ if (!element) {
207
+ id = decodeURI(id);
208
+ element = document.getElementById(id.slice(1));
209
+ }
200
210
 
201
- if (element) {
202
- bringElementIntoView(element, false);
203
- }
211
+ if (element) {
212
+ bringElementIntoView(element, false);
213
+ }
204
214
  }
205
215
 
206
216
  function createAnchorElement(id) {
207
- var anchor = document.createElement('a');
217
+ var anchor = document.createElement('a');
208
218
 
209
- anchor.textContent = '#';
210
- anchor.href = '#' + id;
211
- anchor.classList.add('link-anchor');
212
- anchor.onclick = bringLinkToView;
219
+ anchor.textContent = '#';
220
+ anchor.href = '#' + id;
221
+ anchor.classList.add('link-anchor');
222
+ anchor.onclick = bringLinkToView;
213
223
 
214
- return anchor;
224
+ return anchor;
215
225
  }
216
226
 
217
227
  function addAnchor() {
218
- var main = document.querySelector('.main-content').querySelector('section');
228
+ var main = document.querySelector('.main-content').querySelector('section');
219
229
 
220
- var h1 = main.querySelectorAll('h1');
221
- var h2 = main.querySelectorAll('h2');
222
- var h3 = main.querySelectorAll('h3');
223
- var h4 = main.querySelectorAll('h4');
230
+ var h1 = main.querySelectorAll('h1');
231
+ var h2 = main.querySelectorAll('h2');
232
+ var h3 = main.querySelectorAll('h3');
233
+ var h4 = main.querySelectorAll('h4');
224
234
 
225
- var targets = [h1, h2, h3, h4];
235
+ var targets = [h1, h2, h3, h4];
226
236
 
227
- targets.forEach(function(target) {
228
- target.forEach(function(heading) {
229
- var anchor = createAnchorElement(heading.id);
237
+ targets.forEach(function (target) {
238
+ target.forEach(function (heading) {
239
+ var anchor = createAnchorElement(heading.id);
230
240
 
231
- heading.classList.add('has-anchor');
232
- heading.append(anchor);
241
+ heading.classList.add('has-anchor');
242
+ heading.append(anchor);
243
+ });
233
244
  });
234
- });
235
245
  }
236
246
 
237
247
  /**
@@ -239,211 +249,211 @@ function addAnchor() {
239
249
  * @param {string} value
240
250
  */
241
251
  function copy(value) {
242
- const el = document.createElement('textarea');
252
+ console.log(value);
253
+ const el = document.createElement('textarea');
243
254
 
244
- el.value = value;
245
- document.body.appendChild(el);
246
- el.select();
247
- document.execCommand('copy');
248
- document.body.removeChild(el);
255
+ el.value = value;
256
+ document.body.appendChild(el);
257
+ el.select();
258
+ document.execCommand('copy');
259
+ document.body.removeChild(el);
249
260
  }
250
261
 
251
262
  function showTooltip(id) {
252
- var tooltip = document.getElementById(id);
263
+ var tooltip = document.getElementById(id);
253
264
 
254
- tooltip.classList.add('show-tooltip');
255
- setTimeout(function() {
256
- tooltip.classList.remove('show-tooltip');
257
- }, 3000);
265
+ tooltip.classList.add('show-tooltip');
266
+ setTimeout(function () {
267
+ tooltip.classList.remove('show-tooltip');
268
+ }, 3000);
258
269
  }
259
270
 
260
271
  /* eslint-disable-next-line */
261
272
  function copyFunction(id) {
262
- // selecting the pre element
263
- var code = document.getElementById(id);
273
+ // selecting the pre element
274
+ var code = document.getElementById(id);
264
275
 
265
- // selecting the ol.linenums
266
- var element = code.querySelector('.linenums');
276
+ // selecting the ol.linenums
277
+ var element = code.querySelector('.linenums');
267
278
 
268
- if (!element) {
269
- // selecting the code block
270
- element = code.querySelector('code');
271
- }
279
+ if (!element) {
280
+ // selecting the code block
281
+ element = code.querySelector('code');
282
+ }
272
283
 
273
- // copy
274
- copy(element.innerText);
284
+ // copy
285
+ copy(element.innerText.trim().replace(/(^\t)/gm, ''));
275
286
 
276
- // show tooltip
277
- showTooltip('tooltip-' + id);
287
+ // show tooltip
288
+ showTooltip('tooltip-' + id);
278
289
  }
279
290
 
280
291
  function hideTocOnSourcePage() {
281
- if (isSourcePage()) {
282
- document.querySelector('.toc-container').style.display = 'none';
283
- }
292
+ if (isSourcePage()) {
293
+ document.querySelector('.toc-container').style.display = 'none';
294
+ }
284
295
  }
285
296
 
286
297
  function getPreTopBar(id, lang = '') {
287
- // tooltip
288
- var tooltip = '<div class="tooltip" id="tooltip-' + id + '">Copied!</div>';
298
+ // tooltip
299
+ var tooltip = '<div class="tooltip" id="tooltip-' + id + '">Copied!</div>';
289
300
 
290
- // template of copy to clipboard icon container
291
- var copyToClipboard =
301
+ // template of copy to clipboard icon container
302
+ var copyToClipboard =
292
303
  '<button aria-label="copy code" class="icon-button copy-code" onclick="copyFunction(\'' +
293
304
  id +
294
305
  '\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>' +
295
306
  tooltip +
296
307
  '</button>';
297
308
 
298
- var langNameDiv =
309
+ var langNameDiv =
299
310
  '<div class="code-lang-name-container"><div class="code-lang-name">' +
300
311
  lang.toLocaleUpperCase() +
301
312
  '</div></div>';
302
313
 
303
- var topBar =
314
+ var topBar =
304
315
  '<div class="pre-top-bar-container">' +
305
316
  langNameDiv +
306
317
  copyToClipboard +
307
318
  '</div>';
308
319
 
309
- return topBar;
320
+ return topBar;
310
321
  }
311
322
 
312
323
  function getPreDiv() {
313
- var divElement = document.createElement('div');
324
+ var divElement = document.createElement('div');
314
325
 
315
- divElement.classList.add('pre-div');
326
+ divElement.classList.add('pre-div');
316
327
 
317
- return divElement;
328
+ return divElement;
318
329
  }
319
330
 
320
331
  function processAllPre() {
321
- var targets = document.querySelectorAll('pre');
322
- var footer = document.querySelector('#PeOAagUepe');
323
- var navbar = document.querySelector('#VuAckcnZhf');
332
+ var targets = document.querySelectorAll('pre');
333
+ var footer = document.querySelector('#PeOAagUepe');
334
+ var navbar = document.querySelector('#VuAckcnZhf');
324
335
 
325
- var navbarHeight = 0;
326
- var footerHeight = 0;
336
+ var navbarHeight = 0;
337
+ var footerHeight = 0;
327
338
 
328
- if (footer) {
329
- footerHeight = footer.getBoundingClientRect().height;
330
- }
339
+ if (footer) {
340
+ footerHeight = footer.getBoundingClientRect().height;
341
+ }
331
342
 
332
- if (navbar) {
333
- navbarHeight = navbar.getBoundingClientRect().height;
334
- }
343
+ if (navbar) {
344
+ navbarHeight = navbar.getBoundingClientRect().height;
345
+ }
335
346
 
336
- // eslint-disable-next-line no-undef
337
- var preMaxHeight = window.innerHeight - navbarHeight - footerHeight - 250;
347
+ // eslint-disable-next-line no-undef
348
+ var preMaxHeight = window.innerHeight - navbarHeight - footerHeight - 250;
338
349
 
339
- targets.forEach(function(pre, idx) {
340
- var parent = pre.parentNode;
350
+ targets.forEach(function (pre, idx) {
351
+ var parent = pre.parentNode;
341
352
 
342
- if (parent && parent.getAttribute('data-skip-pre-process') === 'true') {
343
- return;
344
- }
353
+ if (parent && parent.getAttribute('data-skip-pre-process') === 'true') {
354
+ return;
355
+ }
345
356
 
346
- var div = getPreDiv();
347
- var id = 'ScDloZOMdL' + idx;
357
+ var div = getPreDiv();
358
+ var id = 'ScDloZOMdL' + idx;
348
359
 
349
- var lang = pre.getAttribute('data-lang') || 'code';
350
- var topBar = getPreTopBar(id, lang);
360
+ var lang = pre.getAttribute('data-lang') || 'code';
361
+ var topBar = getPreTopBar(id, lang);
351
362
 
352
- div.innerHTML = topBar;
363
+ div.innerHTML = topBar;
353
364
 
354
- pre.style.maxHeight = preMaxHeight + 'px';
355
- pre.id = id;
356
- pre.classList.add('prettyprint');
357
- pre.parentNode.insertBefore(div, pre);
358
- div.appendChild(pre);
359
- });
365
+ pre.style.maxHeight = preMaxHeight + 'px';
366
+ pre.id = id;
367
+ pre.classList.add('prettyprint');
368
+ pre.parentNode.insertBefore(div, pre);
369
+ div.appendChild(pre);
370
+ });
360
371
  }
361
372
 
362
373
  function highlightAndBringLineIntoView() {
363
- // eslint-disable-next-line no-undef
364
- var lineNumber = window.location.hash.replace('#line', '');
374
+ // eslint-disable-next-line no-undef
375
+ var lineNumber = window.location.hash.replace('#line', '');
365
376
 
366
- try {
367
- var selector = '[data-line-number="' + lineNumber + '"';
377
+ try {
378
+ var selector = '[data-line-number="' + lineNumber + '"';
368
379
 
369
- var element = document.querySelector(selector);
380
+ var element = document.querySelector(selector);
370
381
 
371
- element.scrollIntoView();
372
- element.parentNode.classList.add('selected');
373
- } catch (error) {
374
- console.error(error);
375
- }
382
+ element.scrollIntoView();
383
+ element.parentNode.classList.add('selected');
384
+ } catch (error) {
385
+ console.error(error);
386
+ }
376
387
  }
377
388
 
378
389
  function getFontSize() {
379
- var currentFontSize = 16;
380
-
381
- try {
382
- currentFontSize = Number.parseInt(
383
- html.style.fontSize.split('px')[0],
384
- 10
385
- );
386
- } catch (error) {
387
- console.log(error);
388
- }
390
+ var currentFontSize = 16;
391
+
392
+ try {
393
+ currentFontSize = Number.parseInt(
394
+ html.style.fontSize.split('px')[0],
395
+ 10
396
+ );
397
+ } catch (error) {
398
+ console.log(error);
399
+ }
389
400
 
390
- return currentFontSize;
401
+ return currentFontSize;
391
402
  }
392
403
 
393
404
  function updateFontSize(fontSize) {
394
- html.style.fontSize = fontSize + 'px';
395
- localStorage.setItem(fontSizeLocalStorageKey, fontSize);
396
- var fontSizeText = document.querySelector(
397
- '#b77a68a492f343baabea06fad81f651e'
398
- );
405
+ html.style.fontSize = fontSize + 'px';
406
+ localStorage.setItem(fontSizeLocalStorageKey, fontSize);
407
+ var fontSizeText = document.querySelector(
408
+ '#b77a68a492f343baabea06fad81f651e'
409
+ );
399
410
 
400
- if (fontSizeText) {
401
- fontSizeText.innerHTML = fontSize;
402
- }
411
+ if (fontSizeText) {
412
+ fontSizeText.innerHTML = fontSize;
413
+ }
403
414
  }
404
415
 
405
- (function() {
406
- var fontSize = getFontSize();
407
- var fontSizeInLocalStorage = localStorage.getItem(fontSizeLocalStorageKey);
416
+ (function () {
417
+ var fontSize = getFontSize();
418
+ var fontSizeInLocalStorage = localStorage.getItem(fontSizeLocalStorageKey);
408
419
 
409
- if (fontSizeInLocalStorage) {
410
- var n = Number.parseInt(fontSizeInLocalStorage, 10);
420
+ if (fontSizeInLocalStorage) {
421
+ var n = Number.parseInt(fontSizeInLocalStorage, 10);
411
422
 
412
- if (n === fontSize) {
413
- return;
423
+ if (n === fontSize) {
424
+ return;
425
+ }
426
+ updateFontSize(n);
427
+ } else {
428
+ updateFontSize(fontSize);
414
429
  }
415
- updateFontSize(n);
416
- } else {
417
- updateFontSize(fontSize);
418
- }
419
430
  })();
420
431
 
421
432
  // eslint-disable-next-line no-unused-vars
422
433
  function incrementFont(event) {
423
- var n = getFontSize();
434
+ var n = getFontSize();
424
435
 
425
- if (n < MAX_FONT_SIZE) {
426
- updateFontSize(n + 1);
427
- }
436
+ if (n < MAX_FONT_SIZE) {
437
+ updateFontSize(n + 1);
438
+ }
428
439
  }
429
440
 
430
441
  // eslint-disable-next-line no-unused-vars
431
442
  function decrementFont(event) {
432
- var n = getFontSize();
443
+ var n = getFontSize();
433
444
 
434
- if (n > MIN_FONT_SIZE) {
435
- updateFontSize(n - 1);
436
- }
445
+ if (n > MIN_FONT_SIZE) {
446
+ updateFontSize(n - 1);
447
+ }
437
448
  }
438
449
 
439
450
  function fontSizeTooltip() {
440
- var fontSize = getFontSize();
451
+ var fontSize = getFontSize();
441
452
 
442
- return `
453
+ return `
443
454
  <div class="font-size-tooltip">
444
- <button aria-label="decrease-font-size" class="icon-button ${
445
- fontSize >= MAX_FONT_SIZE ? 'disabled' : ''
446
- }" onclick="decrementFont(event)">
455
+ <button aria-label="decrease-font-size" class="icon-button ${fontSize >= MAX_FONT_SIZE ? 'disabled' : ''
456
+ }" onclick="decrementFont(event)">
447
457
  <svg>
448
458
  <use xlink:href="#minus-icon"></use>
449
459
  </svg>
@@ -451,9 +461,8 @@ function fontSizeTooltip() {
451
461
  <div class="font-size-text" id="b77a68a492f343baabea06fad81f651e">
452
462
  ${fontSize}
453
463
  </div>
454
- <button aria-label="increase-font-size" class="icon-button ${
455
- fontSize <= MIN_FONT_SIZE ? 'disabled' : ''
456
- }" onclick="incrementFont(event)">
464
+ <button aria-label="increase-font-size" class="icon-button ${fontSize <= MIN_FONT_SIZE ? 'disabled' : ''
465
+ }" onclick="incrementFont(event)">
457
466
  <svg>
458
467
  <use xlink:href="#add-icon"></use>
459
468
  </svg>
@@ -469,176 +478,185 @@ function fontSizeTooltip() {
469
478
  }
470
479
 
471
480
  function initTooltip() {
472
- // add tooltip to navbar item
473
- // eslint-disable-next-line no-undef
474
- tippy('.theme-toggle', {
475
- content: 'Toggle Theme',
476
- delay: 500
477
- });
478
-
479
- // eslint-disable-next-line no-undef
480
- tippy('.search-button', {
481
- content: 'Search',
482
- delay: 500
483
- });
484
-
485
- // eslint-disable-next-line no-undef
486
- tippy('.font-size', {
487
- content: 'Change font size',
488
- delay: 500
489
- });
490
-
491
- // eslint-disable-next-line no-undef
492
- tippy('.codepen-button', {
493
- content: 'Open code in CodePen',
494
- placement: 'left'
495
- });
496
-
497
- // eslint-disable-next-line no-undef
498
- tippy('.copy-code', {
499
- content: 'Copy this code',
500
- placement: 'left'
501
- });
502
-
503
- // eslint-disable-next-line no-undef
504
- tippy('.font-size', {
505
- content: fontSizeTooltip(),
506
- trigger: 'click',
507
- interactive: true,
508
- allowHTML: true,
509
- placement: 'left'
510
- });
481
+ // add tooltip to navbar item
482
+ // eslint-disable-next-line no-undef
483
+ tippy('.theme-toggle', {
484
+ content: 'Toggle Theme',
485
+ delay: 500
486
+ });
487
+
488
+ // eslint-disable-next-line no-undef
489
+ tippy('.search-button', {
490
+ content: 'Search',
491
+ delay: 500
492
+ });
493
+
494
+ // eslint-disable-next-line no-undef
495
+ tippy('.font-size', {
496
+ content: 'Change font size',
497
+ delay: 500
498
+ });
499
+
500
+ // eslint-disable-next-line no-undef
501
+ tippy('.codepen-button', {
502
+ content: 'Open code in CodePen',
503
+ placement: 'left'
504
+ });
505
+
506
+ // eslint-disable-next-line no-undef
507
+ tippy('.copy-code', {
508
+ content: 'Copy this code',
509
+ placement: 'left'
510
+ });
511
+
512
+ // eslint-disable-next-line no-undef
513
+ tippy('.font-size', {
514
+ content: fontSizeTooltip(),
515
+ trigger: 'click',
516
+ interactive: true,
517
+ allowHTML: true,
518
+ placement: 'left'
519
+ });
511
520
  }
512
521
 
513
522
  function fixTable() {
514
- var tables = document.querySelectorAll('table');
515
- var table;
516
-
517
- // eslint-disable-next-line no-undef
518
- if (window.innerWidth > 900) {
519
- // Only fixing table if width is smaller than 900px
520
- return;
521
- }
523
+ var tables = document.querySelectorAll('table');
524
+ var table;
522
525
 
523
- for (table of tables) {
524
- if (table.classList.contains('hljs-ln')) {
525
- // don't want to wrap code blocks.
526
- return;
526
+ // eslint-disable-next-line no-undef
527
+ if (window.innerWidth > 900) {
528
+ // Only fixing table if width is smaller than 900px
529
+ return;
527
530
  }
528
531
 
529
- var div = document.createElement('div');
532
+ for (table of tables) {
533
+ if (table.classList.contains('hljs-ln')) {
534
+ // don't want to wrap code blocks.
535
+ return;
536
+ }
530
537
 
531
- div.classList.add('table-div');
532
- table.parentNode.insertBefore(div, table);
533
- div.appendChild(table);
534
- }
538
+ var div = document.createElement('div');
539
+
540
+ div.classList.add('table-div');
541
+ table.parentNode.insertBefore(div, table);
542
+ div.appendChild(table);
543
+ }
535
544
  }
536
545
 
537
546
  function hideMobileMenu() {
538
- var mobileMenuContainer = document.querySelector('#mobile-sidebar');
539
- var target = document.querySelector('#mobile-menu');
540
- var svgUse = target.querySelector('use');
547
+ var mobileMenuContainer = document.querySelector('#mobile-sidebar');
548
+ var target = document.querySelector('#mobile-menu');
549
+ var svgUse = target.querySelector('use');
541
550
 
542
- if (mobileMenuContainer) {
543
- mobileMenuContainer.classList.remove('show');
544
- }
545
- if (target) {
546
- target.setAttribute('data-isopen', 'false');
547
- }
548
- if (svgUse) {
549
- svgUse.setAttribute('xlink:href', '#menu-icon');
550
- }
551
+ if (mobileMenuContainer) {
552
+ mobileMenuContainer.classList.remove('show');
553
+ }
554
+ if (target) {
555
+ target.setAttribute('data-isopen', 'false');
556
+ }
557
+ if (svgUse) {
558
+ svgUse.setAttribute('xlink:href', '#menu-icon');
559
+ }
551
560
  }
552
561
 
553
562
  function showMobileMenu() {
554
- var mobileMenuContainer = document.querySelector('#mobile-sidebar');
555
- var target = document.querySelector('#mobile-menu');
556
- var svgUse = target.querySelector('use');
563
+ var mobileMenuContainer = document.querySelector('#mobile-sidebar');
564
+ var target = document.querySelector('#mobile-menu');
565
+ var svgUse = target.querySelector('use');
557
566
 
558
- if (mobileMenuContainer) {
559
- mobileMenuContainer.classList.add('show');
560
- }
561
- if (target) {
562
- target.setAttribute('data-isopen', 'true');
563
- }
564
- if (svgUse) {
565
- svgUse.setAttribute('xlink:href', '#close-icon');
566
- }
567
+ if (mobileMenuContainer) {
568
+ mobileMenuContainer.classList.add('show');
569
+ }
570
+ if (target) {
571
+ target.setAttribute('data-isopen', 'true');
572
+ }
573
+ if (svgUse) {
574
+ svgUse.setAttribute('xlink:href', '#close-icon');
575
+ }
567
576
  }
568
577
 
569
578
  function onMobileMenuClick() {
570
- var target = document.querySelector('#mobile-menu');
571
- var isOpen = target.getAttribute('data-isopen') === 'true';
579
+ var target = document.querySelector('#mobile-menu');
580
+ var isOpen = target.getAttribute('data-isopen') === 'true';
572
581
 
573
- if (isOpen) {
574
- hideMobileMenu();
575
- } else {
576
- showMobileMenu();
577
- }
582
+ if (isOpen) {
583
+ hideMobileMenu();
584
+ } else {
585
+ showMobileMenu();
586
+ }
578
587
  }
579
588
 
580
589
  function initMobileMenu() {
581
- var menu = document.querySelector('#mobile-menu');
590
+ var menu = document.querySelector('#mobile-menu');
582
591
 
583
- if (menu) {
584
- menu.addEventListener('click', onMobileMenuClick);
585
- }
592
+ if (menu) {
593
+ menu.addEventListener('click', onMobileMenuClick);
594
+ }
586
595
  }
587
596
 
588
597
  function addHrefToSidebarTitle() {
589
- var titles = document.querySelectorAll('.sidebar-title-anchor');
598
+ var titles = document.querySelectorAll('.sidebar-title-anchor');
590
599
 
591
- titles.forEach(function(title) {
592
- // eslint-disable-next-line no-undef
593
- title.setAttribute('href', baseURL);
594
- });
600
+ titles.forEach(function (title) {
601
+ // eslint-disable-next-line no-undef
602
+ title.setAttribute('href', baseURL);
603
+ });
595
604
  }
596
605
 
597
606
  function onDomContentLoaded() {
598
- var themeButton = document.querySelectorAll('.theme-toggle');
607
+ var themeButton = document.querySelectorAll('.theme-toggle');
599
608
 
600
- initMobileMenu();
609
+ initMobileMenu();
601
610
 
602
- if (themeButton) {
603
- themeButton.forEach(function(button) {
604
- button.addEventListener('click', toggleTheme);
605
- });
606
- }
607
-
608
- // Highlighting code
609
-
610
- // eslint-disable-next-line no-undef
611
- hljs.addPlugin({
612
- 'after:highlightElement': function(obj) {
613
- // Replace 'code' with result.language when
614
- // we are able to cross check the correctness of
615
- // result.
616
- obj.el.parentNode.setAttribute('data-lang', 'code');
617
- }
618
- });
619
- // eslint-disable-next-line no-undef
620
- hljs.highlightAll();
621
- // eslint-disable-next-line no-undef
622
- hljs.initLineNumbersOnLoad({
623
- singleLine: true
624
- });
625
-
626
- // Highlight complete
627
-
628
- initAccordion();
629
- addAnchor();
630
- processAllPre();
631
- hideTocOnSourcePage();
632
- setTimeout(function() {
633
- bringIdToViewOnMount();
634
- if (isSourcePage()) {
635
- highlightAndBringLineIntoView();
611
+ if (themeButton) {
612
+ themeButton.forEach(function (button) {
613
+ button.addEventListener('click', toggleTheme);
614
+ });
636
615
  }
637
- }, 1000);
638
- initTooltip();
639
- fixTable();
640
- addHrefToSidebarTitle();
616
+
617
+ // Highlighting code
618
+
619
+ // eslint-disable-next-line no-undef
620
+ hljs.addPlugin({
621
+ 'after:highlightElement': function (obj) {
622
+ // Replace 'code' with result.language when
623
+ // we are able to cross-check the correctness of
624
+ // result.
625
+ obj.el.parentNode.setAttribute('data-lang', 'code');
626
+ }
627
+ });
628
+ // eslint-disable-next-line no-undef
629
+ hljs.highlightAll();
630
+ // eslint-disable-next-line no-undef
631
+ hljs.initLineNumbersOnLoad({
632
+ singleLine: true
633
+ });
634
+
635
+ // Highlight complete
636
+
637
+ initAccordion();
638
+ addAnchor();
639
+ processAllPre();
640
+ hideTocOnSourcePage();
641
+ setTimeout(function () {
642
+ bringIdToViewOnMount();
643
+ if (isSourcePage()) {
644
+ highlightAndBringLineIntoView();
645
+ }
646
+ }, 1000);
647
+ initTooltip();
648
+ fixTable();
649
+ addHrefToSidebarTitle();
641
650
  }
642
651
 
643
652
  // eslint-disable-next-line no-undef
644
653
  window.addEventListener('DOMContentLoaded', onDomContentLoaded);
654
+
655
+ // eslint-disable-next-line no-undef
656
+ window.addEventListener('hashchange', (event) => {
657
+ const url = new URL(event.newURL);
658
+
659
+ if (url.hash !== '') {
660
+ bringIdToViewOnMount(url.hash);
661
+ }
662
+ });