clean-jsdoc-theme 4.1.7 → 4.1.9

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