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.
- package/.eslintignore +1 -1
- package/.eslintrc.js +2 -2
- package/.prettierignore +0 -1
- package/.stylelintignore +2 -2
- package/.stylelintrc +9 -14
- package/CHANGELOG.md +56 -35
- package/CODE_OF_CONDUCT.md +4 -4
- package/CODE_OF_CONDUCT_HINDI.md +25 -10
- package/CONTRIBUTING.md +19 -7
- package/README.md +104 -64
- package/SECURITY.md +2 -2
- package/css.js +124 -0
- package/jsdoc-config.json +1 -0
- package/minify.js +31 -23
- package/package.json +50 -48
- package/publish.js +798 -797
- package/static/scripts/core.js +401 -383
- package/static/scripts/core.min.js +2 -2
- package/static/scripts/resize.js +2 -2
- package/static/scripts/search.js +81 -108
- package/static/scripts/search.min.js +5 -10
- package/static/scripts/third-party/hljs-line-num-original.js +369 -0
- package/static/scripts/third-party/hljs-line-num.js +1 -1
- package/static/scripts/third-party/tocbot.js +672 -1
- package/static/scripts/third-party/tocbot.min.js +1 -0
- package/static/styles/clean-jsdoc-theme-base.css +29 -12
- package/static/styles/clean-jsdoc-theme.min.css +1 -1
- package/tmpl/layout.tmpl +4 -2
- package/tmpl/members.tmpl +1 -1
- package/tmpl/method.tmpl +1 -1
- package/tmpl/search.tmpl +1 -1
- package/tmpl/type.tmpl +8 -3
package/static/scripts/core.js
CHANGED
|
@@ -11,50 +11,50 @@ var MIN_FONT_SIZE = 10;
|
|
|
11
11
|
var localStorage = window.localStorage;
|
|
12
12
|
|
|
13
13
|
function getTheme() {
|
|
14
|
-
|
|
14
|
+
var body = document.body;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
return body.getAttribute('data-theme');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function updateTheme(theme) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
body.setAttribute('data-theme', theme);
|
|
25
|
+
body.classList.remove('dark', 'light');
|
|
26
|
+
body.classList.add(theme);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
svgUse.forEach(function (svg) {
|
|
29
|
+
svg.setAttribute('xlink:href', iconID);
|
|
30
|
+
});
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
localStorage.setItem(themeLocalStorageKey, theme);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function toggleTheme() {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
var body = document.body;
|
|
37
|
+
var theme = body.getAttribute('data-theme');
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
var newTheme = theme === 'dark' ? 'light' : 'dark';
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
updateTheme(newTheme);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
(function() {
|
|
45
|
-
|
|
44
|
+
(function () {
|
|
45
|
+
var theme = getTheme();
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
var themeStoredInLocalStorage = localStorage.getItem(themeLocalStorageKey);
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
if (themeStoredInLocalStorage) {
|
|
50
|
+
if (theme === themeStoredInLocalStorage) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
68
|
+
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
82
|
+
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
97
|
+
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
return ids || {};
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
function toggleAccordion(element) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
117
|
-
|
|
116
|
+
if (
|
|
117
|
+
localStorage.getItem(accordionLocalStorageKey) === undefined ||
|
|
118
118
|
localStorage.getItem(accordionLocalStorageKey) === null
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
136
|
+
return Boolean(document.querySelector('#source-page'));
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
function bringElementIntoView(element, updateHistory = true) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
// If element is null then we are not going further
|
|
141
|
+
if (!element) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
159
|
+
var offset = 16;
|
|
150
160
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
161
|
+
if (navbar) {
|
|
162
|
+
offset += navbar.scrollHeight;
|
|
163
|
+
}
|
|
154
164
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
165
|
+
if (body) {
|
|
166
|
+
body.scrollBy(0, elementTop - offset);
|
|
167
|
+
}
|
|
158
168
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
event.stopPropagation();
|
|
179
|
+
var id = event.currentTarget.getAttribute('href');
|
|
170
180
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
181
|
+
if (!id) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
174
184
|
|
|
175
|
-
|
|
185
|
+
var element = document.getElementById(id.slice(1));
|
|
176
186
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
187
|
+
if (element) {
|
|
188
|
+
bringElementIntoView(element);
|
|
189
|
+
}
|
|
180
190
|
}
|
|
181
191
|
|
|
182
192
|
function bringIdToViewOnMount() {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
if (isSourcePage()) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
186
196
|
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
// eslint-disable-next-line no-undef
|
|
198
|
+
var id = window.location.hash;
|
|
189
199
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
if (id === '') {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
193
203
|
|
|
194
|
-
|
|
204
|
+
var element = document.getElementById(id.slice(1));
|
|
195
205
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
206
|
+
if (!element) {
|
|
207
|
+
id = decodeURI(id);
|
|
208
|
+
element = document.getElementById(id.slice(1));
|
|
209
|
+
}
|
|
200
210
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
211
|
+
if (element) {
|
|
212
|
+
bringElementIntoView(element, false);
|
|
213
|
+
}
|
|
204
214
|
}
|
|
205
215
|
|
|
206
216
|
function createAnchorElement(id) {
|
|
207
|
-
|
|
217
|
+
var anchor = document.createElement('a');
|
|
208
218
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
219
|
+
anchor.textContent = '#';
|
|
220
|
+
anchor.href = '#' + id;
|
|
221
|
+
anchor.classList.add('link-anchor');
|
|
222
|
+
anchor.onclick = bringLinkToView;
|
|
213
223
|
|
|
214
|
-
|
|
224
|
+
return anchor;
|
|
215
225
|
}
|
|
216
226
|
|
|
217
227
|
function addAnchor() {
|
|
218
|
-
|
|
228
|
+
var main = document.querySelector('.main-content').querySelector('section');
|
|
219
229
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
235
|
+
var targets = [h1, h2, h3, h4];
|
|
226
236
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
237
|
+
targets.forEach(function (target) {
|
|
238
|
+
target.forEach(function (heading) {
|
|
239
|
+
var anchor = createAnchorElement(heading.id);
|
|
230
240
|
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
252
|
+
console.log(value);
|
|
253
|
+
const el = document.createElement('textarea');
|
|
243
254
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
263
|
+
var tooltip = document.getElementById(id);
|
|
253
264
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
263
|
-
|
|
273
|
+
// selecting the pre element
|
|
274
|
+
var code = document.getElementById(id);
|
|
264
275
|
|
|
265
|
-
|
|
266
|
-
|
|
276
|
+
// selecting the ol.linenums
|
|
277
|
+
var element = code.querySelector('.linenums');
|
|
267
278
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
279
|
+
if (!element) {
|
|
280
|
+
// selecting the code block
|
|
281
|
+
element = code.querySelector('code');
|
|
282
|
+
}
|
|
272
283
|
|
|
273
|
-
|
|
274
|
-
|
|
284
|
+
// copy
|
|
285
|
+
copy(element.innerText.trim().replace(/(^\t)/gm, ''));
|
|
275
286
|
|
|
276
|
-
|
|
277
|
-
|
|
287
|
+
// show tooltip
|
|
288
|
+
showTooltip('tooltip-' + id);
|
|
278
289
|
}
|
|
279
290
|
|
|
280
291
|
function hideTocOnSourcePage() {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
292
|
+
if (isSourcePage()) {
|
|
293
|
+
document.querySelector('.toc-container').style.display = 'none';
|
|
294
|
+
}
|
|
284
295
|
}
|
|
285
296
|
|
|
286
297
|
function getPreTopBar(id, lang = '') {
|
|
287
|
-
|
|
288
|
-
|
|
298
|
+
// tooltip
|
|
299
|
+
var tooltip = '<div class="tooltip" id="tooltip-' + id + '">Copied!</div>';
|
|
289
300
|
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
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
|
-
|
|
314
|
+
var topBar =
|
|
304
315
|
'<div class="pre-top-bar-container">' +
|
|
305
316
|
langNameDiv +
|
|
306
317
|
copyToClipboard +
|
|
307
318
|
'</div>';
|
|
308
319
|
|
|
309
|
-
|
|
320
|
+
return topBar;
|
|
310
321
|
}
|
|
311
322
|
|
|
312
323
|
function getPreDiv() {
|
|
313
|
-
|
|
324
|
+
var divElement = document.createElement('div');
|
|
314
325
|
|
|
315
|
-
|
|
326
|
+
divElement.classList.add('pre-div');
|
|
316
327
|
|
|
317
|
-
|
|
328
|
+
return divElement;
|
|
318
329
|
}
|
|
319
330
|
|
|
320
331
|
function processAllPre() {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
332
|
+
var targets = document.querySelectorAll('pre');
|
|
333
|
+
var footer = document.querySelector('#PeOAagUepe');
|
|
334
|
+
var navbar = document.querySelector('#VuAckcnZhf');
|
|
324
335
|
|
|
325
|
-
|
|
326
|
-
|
|
336
|
+
var navbarHeight = 0;
|
|
337
|
+
var footerHeight = 0;
|
|
327
338
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
339
|
+
if (footer) {
|
|
340
|
+
footerHeight = footer.getBoundingClientRect().height;
|
|
341
|
+
}
|
|
331
342
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
343
|
+
if (navbar) {
|
|
344
|
+
navbarHeight = navbar.getBoundingClientRect().height;
|
|
345
|
+
}
|
|
335
346
|
|
|
336
|
-
|
|
337
|
-
|
|
347
|
+
// eslint-disable-next-line no-undef
|
|
348
|
+
var preMaxHeight = window.innerHeight - navbarHeight - footerHeight - 250;
|
|
338
349
|
|
|
339
|
-
|
|
340
|
-
|
|
350
|
+
targets.forEach(function (pre, idx) {
|
|
351
|
+
var parent = pre.parentNode;
|
|
341
352
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
353
|
+
if (parent && parent.getAttribute('data-skip-pre-process') === 'true') {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
345
356
|
|
|
346
|
-
|
|
347
|
-
|
|
357
|
+
var div = getPreDiv();
|
|
358
|
+
var id = 'ScDloZOMdL' + idx;
|
|
348
359
|
|
|
349
|
-
|
|
350
|
-
|
|
360
|
+
var lang = pre.getAttribute('data-lang') || 'code';
|
|
361
|
+
var topBar = getPreTopBar(id, lang);
|
|
351
362
|
|
|
352
|
-
|
|
363
|
+
div.innerHTML = topBar;
|
|
353
364
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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
|
-
|
|
364
|
-
|
|
374
|
+
// eslint-disable-next-line no-undef
|
|
375
|
+
var lineNumber = window.location.hash.replace('#line', '');
|
|
365
376
|
|
|
366
|
-
|
|
367
|
-
|
|
377
|
+
try {
|
|
378
|
+
var selector = '[data-line-number="' + lineNumber + '"';
|
|
368
379
|
|
|
369
|
-
|
|
380
|
+
var element = document.querySelector(selector);
|
|
370
381
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
-
|
|
401
|
+
return currentFontSize;
|
|
391
402
|
}
|
|
392
403
|
|
|
393
404
|
function updateFontSize(fontSize) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
405
|
+
html.style.fontSize = fontSize + 'px';
|
|
406
|
+
localStorage.setItem(fontSizeLocalStorageKey, fontSize);
|
|
407
|
+
var fontSizeText = document.querySelector(
|
|
408
|
+
'#b77a68a492f343baabea06fad81f651e'
|
|
409
|
+
);
|
|
399
410
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
411
|
+
if (fontSizeText) {
|
|
412
|
+
fontSizeText.innerHTML = fontSize;
|
|
413
|
+
}
|
|
403
414
|
}
|
|
404
415
|
|
|
405
|
-
(function() {
|
|
406
|
-
|
|
407
|
-
|
|
416
|
+
(function () {
|
|
417
|
+
var fontSize = getFontSize();
|
|
418
|
+
var fontSizeInLocalStorage = localStorage.getItem(fontSizeLocalStorageKey);
|
|
408
419
|
|
|
409
|
-
|
|
410
|
-
|
|
420
|
+
if (fontSizeInLocalStorage) {
|
|
421
|
+
var n = Number.parseInt(fontSizeInLocalStorage, 10);
|
|
411
422
|
|
|
412
|
-
|
|
413
|
-
|
|
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
|
-
|
|
434
|
+
var n = getFontSize();
|
|
424
435
|
|
|
425
|
-
|
|
426
|
-
|
|
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
|
-
|
|
443
|
+
var n = getFontSize();
|
|
433
444
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
445
|
+
if (n > MIN_FONT_SIZE) {
|
|
446
|
+
updateFontSize(n - 1);
|
|
447
|
+
}
|
|
437
448
|
}
|
|
438
449
|
|
|
439
450
|
function fontSizeTooltip() {
|
|
440
|
-
|
|
451
|
+
var fontSize = getFontSize();
|
|
441
452
|
|
|
442
|
-
|
|
453
|
+
return `
|
|
443
454
|
<div class="font-size-tooltip">
|
|
444
|
-
<button aria-label="decrease-font-size" class="icon-button ${
|
|
445
|
-
|
|
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
|
-
|
|
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
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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
|
-
|
|
515
|
-
|
|
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
|
-
|
|
524
|
-
if (
|
|
525
|
-
|
|
526
|
-
|
|
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
|
-
|
|
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
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
-
|
|
539
|
-
|
|
540
|
-
|
|
547
|
+
var mobileMenuContainer = document.querySelector('#mobile-sidebar');
|
|
548
|
+
var target = document.querySelector('#mobile-menu');
|
|
549
|
+
var svgUse = target.querySelector('use');
|
|
541
550
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
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
|
-
|
|
555
|
-
|
|
556
|
-
|
|
563
|
+
var mobileMenuContainer = document.querySelector('#mobile-sidebar');
|
|
564
|
+
var target = document.querySelector('#mobile-menu');
|
|
565
|
+
var svgUse = target.querySelector('use');
|
|
557
566
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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
|
-
|
|
571
|
-
|
|
579
|
+
var target = document.querySelector('#mobile-menu');
|
|
580
|
+
var isOpen = target.getAttribute('data-isopen') === 'true';
|
|
572
581
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
582
|
+
if (isOpen) {
|
|
583
|
+
hideMobileMenu();
|
|
584
|
+
} else {
|
|
585
|
+
showMobileMenu();
|
|
586
|
+
}
|
|
578
587
|
}
|
|
579
588
|
|
|
580
589
|
function initMobileMenu() {
|
|
581
|
-
|
|
590
|
+
var menu = document.querySelector('#mobile-menu');
|
|
582
591
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
592
|
+
if (menu) {
|
|
593
|
+
menu.addEventListener('click', onMobileMenuClick);
|
|
594
|
+
}
|
|
586
595
|
}
|
|
587
596
|
|
|
588
597
|
function addHrefToSidebarTitle() {
|
|
589
|
-
|
|
598
|
+
var titles = document.querySelectorAll('.sidebar-title-anchor');
|
|
590
599
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
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
|
-
|
|
607
|
+
var themeButton = document.querySelectorAll('.theme-toggle');
|
|
599
608
|
|
|
600
|
-
|
|
609
|
+
initMobileMenu();
|
|
601
610
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
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
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
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
|
+
});
|