clean-jsdoc-theme 3.2.9 → 3.3.2
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 +4 -4
- package/.eslintrc.js +3 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +43 -43
- package/.github/ISSUE_TEMPLATE/feature_request.md +27 -27
- package/.github/pull_request_template.md +16 -16
- package/.github/workflows/codeql-analysis.yml +67 -67
- package/.prettierignore +2 -2
- package/.prettierrc +5 -5
- package/.stylelintignore +3 -3
- package/.stylelintrc +23 -23
- package/.travis.yml +30 -30
- package/CHANGELOG.md +216 -191
- package/CODE_OF_CONDUCT.md +76 -76
- package/CODE_OF_CONDUCT_HINDI.md +46 -46
- package/CONTRIBUTING.md +24 -24
- package/LICENSE +21 -21
- package/README.md +546 -510
- package/SECURITY.md +21 -21
- package/helpers/down-arrow.js +9 -9
- package/jsdoc-config.json +60 -59
- package/package.json +46 -46
- package/publish.js +1196 -948
- package/static/fonts/Montserrat-Regular.ttf +0 -0
- package/static/fonts/OFL-hind.txt +0 -0
- package/static/fonts/OFL-montserrat.txt +0 -0
- package/static/scripts/fix-code-block.js +53 -53
- package/static/scripts/fix-navbar.js +25 -25
- package/static/scripts/linenumber.js +25 -25
- package/static/scripts/misc.js +217 -217
- package/static/scripts/resize.js +85 -85
- package/static/scripts/search.js +83 -83
- package/static/scripts/third-party/Apache-License-2.0.txt +202 -202
- package/static/scripts/third-party/fuse.js +8 -8
- package/static/scripts/third-party/lang-css.js +2 -2
- package/static/scripts/third-party/prettify.js +28 -28
- package/static/styles/clean-jsdoc-theme-base.css +393 -393
- package/static/styles/clean-jsdoc-theme-dark.css +324 -324
- package/static/styles/clean-jsdoc-theme-light.css +319 -319
- package/static/styles/reset.css +351 -346
- package/static/styles/third-party/ionicons.min.css +11 -11
- package/static/styles/third-party/prettify-jsdoc.css +111 -111
- package/static/styles/third-party/prettify-tomorrow.css +5 -5
- package/tmpl/augments.tmpl +10 -10
- package/tmpl/container.tmpl +189 -189
- package/tmpl/details.tmpl +208 -209
- package/tmpl/example.tmpl +3 -3
- package/tmpl/examples.tmpl +38 -38
- package/tmpl/exceptions.tmpl +32 -32
- package/tmpl/icons.tmpl +34 -34
- package/tmpl/layout.tmpl +165 -171
- package/tmpl/mainpage.tmpl +10 -10
- package/tmpl/members.tmpl +43 -43
- package/tmpl/method.tmpl +140 -140
- package/tmpl/params.tmpl +124 -124
- package/tmpl/properties.tmpl +109 -109
- package/tmpl/returns.tmpl +18 -18
- package/tmpl/source.tmpl +7 -7
- package/tmpl/tutorial.tmpl +19 -19
- package/tmpl/type.tmpl +6 -6
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
(function() {
|
|
3
|
-
var targets = document.querySelectorAll('pre');
|
|
4
|
-
var main = document.querySelector('#main');
|
|
5
|
-
|
|
6
|
-
var footer = document.querySelector('#footer');
|
|
7
|
-
var pageTitle = document.querySelector('#page-title');
|
|
8
|
-
var pageTitleHeight = 0;
|
|
9
|
-
|
|
10
|
-
var footerHeight = footer.getBoundingClientRect().height;
|
|
11
|
-
|
|
12
|
-
if (pageTitle) {
|
|
13
|
-
pageTitleHeight = pageTitle.getBoundingClientRect().height;
|
|
14
|
-
|
|
15
|
-
// Adding margin (Outer height)
|
|
16
|
-
pageTitleHeight += 45;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// subtracted 20 for extra padding.
|
|
20
|
-
// eslint-disable-next-line no-undef
|
|
21
|
-
var divMaxHeight = window.innerHeight - pageTitleHeight - footerHeight - 80;
|
|
22
|
-
|
|
23
|
-
setTimeout(function() {
|
|
24
|
-
targets.forEach(function(item) {
|
|
25
|
-
var innerHTML = item.innerHTML;
|
|
26
|
-
var divElement = document.createElement('div');
|
|
27
|
-
|
|
28
|
-
divElement.style.maxHeight = divMaxHeight + 'px';
|
|
29
|
-
divElement.style.marginTop = '2rem';
|
|
30
|
-
divElement.innerHTML = innerHTML;
|
|
31
|
-
// item.removeChild();
|
|
32
|
-
item.innerHTML = '';
|
|
33
|
-
item.appendChild(divElement);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line no-undef
|
|
37
|
-
main.style.minHeight = window.innerHeight - footerHeight - 15 + 'px';
|
|
38
|
-
|
|
39
|
-
// See if we have to move something into view
|
|
40
|
-
// eslint-disable-next-line no-undef
|
|
41
|
-
var location = window.location.href.split('#')[1];
|
|
42
|
-
|
|
43
|
-
if (location && location.length > 0) {
|
|
44
|
-
try {
|
|
45
|
-
var element = document.querySelector('#'.concat(decodeURI(location)));
|
|
46
|
-
|
|
47
|
-
element.scrollIntoView();
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.log(error);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}, 300);
|
|
53
|
-
})();
|
|
1
|
+
/* global document */
|
|
2
|
+
(function() {
|
|
3
|
+
var targets = document.querySelectorAll('pre');
|
|
4
|
+
var main = document.querySelector('#main');
|
|
5
|
+
|
|
6
|
+
var footer = document.querySelector('#footer');
|
|
7
|
+
var pageTitle = document.querySelector('#page-title');
|
|
8
|
+
var pageTitleHeight = 0;
|
|
9
|
+
|
|
10
|
+
var footerHeight = footer.getBoundingClientRect().height;
|
|
11
|
+
|
|
12
|
+
if (pageTitle) {
|
|
13
|
+
pageTitleHeight = pageTitle.getBoundingClientRect().height;
|
|
14
|
+
|
|
15
|
+
// Adding margin (Outer height)
|
|
16
|
+
pageTitleHeight += 45;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// subtracted 20 for extra padding.
|
|
20
|
+
// eslint-disable-next-line no-undef
|
|
21
|
+
var divMaxHeight = window.innerHeight - pageTitleHeight - footerHeight - 80;
|
|
22
|
+
|
|
23
|
+
setTimeout(function() {
|
|
24
|
+
targets.forEach(function(item) {
|
|
25
|
+
var innerHTML = item.innerHTML;
|
|
26
|
+
var divElement = document.createElement('div');
|
|
27
|
+
|
|
28
|
+
divElement.style.maxHeight = divMaxHeight + 'px';
|
|
29
|
+
divElement.style.marginTop = '2rem';
|
|
30
|
+
divElement.innerHTML = innerHTML;
|
|
31
|
+
// item.removeChild();
|
|
32
|
+
item.innerHTML = '';
|
|
33
|
+
item.appendChild(divElement);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line no-undef
|
|
37
|
+
main.style.minHeight = window.innerHeight - footerHeight - 15 + 'px';
|
|
38
|
+
|
|
39
|
+
// See if we have to move something into view
|
|
40
|
+
// eslint-disable-next-line no-undef
|
|
41
|
+
var location = window.location.href.split('#')[1];
|
|
42
|
+
|
|
43
|
+
if (location && location.length > 0) {
|
|
44
|
+
try {
|
|
45
|
+
var element = document.querySelector('#'.concat(decodeURI(location)));
|
|
46
|
+
|
|
47
|
+
element.scrollIntoView();
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.log(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, 300);
|
|
53
|
+
})();
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
(function() {
|
|
3
|
-
function setNavbarMainContentHeight() {
|
|
4
|
-
var heading = document.querySelector('#navbar-heading');
|
|
5
|
-
var searchBox = document.querySelector('#search-box');
|
|
6
|
-
var sidebarMainContent = document.querySelector('#sidebar-main-content');
|
|
7
|
-
|
|
8
|
-
var heightToSubtract = 32;
|
|
9
|
-
|
|
10
|
-
if (heading) {
|
|
11
|
-
heightToSubtract += heading.getBoundingClientRect().height;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (searchBox) {
|
|
15
|
-
heightToSubtract += searchBox.getBoundingClientRect().height;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line no-undef
|
|
19
|
-
sidebarMainContent.style.height += window.innerHeight - heightToSubtract + 'px';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
setNavbarMainContentHeight();
|
|
23
|
-
// eslint-disable-next-line no-undef
|
|
24
|
-
window.addEventListener('resize', setNavbarMainContentHeight);
|
|
25
|
-
})();
|
|
1
|
+
/* global document */
|
|
2
|
+
(function() {
|
|
3
|
+
function setNavbarMainContentHeight() {
|
|
4
|
+
var heading = document.querySelector('#navbar-heading');
|
|
5
|
+
var searchBox = document.querySelector('#search-box');
|
|
6
|
+
var sidebarMainContent = document.querySelector('#sidebar-main-content');
|
|
7
|
+
|
|
8
|
+
var heightToSubtract = 32;
|
|
9
|
+
|
|
10
|
+
if (heading) {
|
|
11
|
+
heightToSubtract += heading.getBoundingClientRect().height;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (searchBox) {
|
|
15
|
+
heightToSubtract += searchBox.getBoundingClientRect().height;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line no-undef
|
|
19
|
+
sidebarMainContent.style.height += window.innerHeight - heightToSubtract + 'px';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setNavbarMainContentHeight();
|
|
23
|
+
// eslint-disable-next-line no-undef
|
|
24
|
+
window.addEventListener('resize', setNavbarMainContentHeight);
|
|
25
|
+
})();
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
(function() {
|
|
3
|
-
var source = document.getElementsByClassName('prettyprint source linenums');
|
|
4
|
-
var i = 0;
|
|
5
|
-
var lineNumber = 0;
|
|
6
|
-
var lineId;
|
|
7
|
-
var lines;
|
|
8
|
-
var totalLines;
|
|
9
|
-
var anchorHash;
|
|
10
|
-
|
|
11
|
-
if (source && source[0]) {
|
|
12
|
-
anchorHash = document.location.hash.substring(1);
|
|
13
|
-
lines = source[0].getElementsByTagName('li');
|
|
14
|
-
totalLines = lines.length;
|
|
15
|
-
|
|
16
|
-
for (; i < totalLines; i++) {
|
|
17
|
-
lineNumber++;
|
|
18
|
-
lineId = 'line' + lineNumber;
|
|
19
|
-
lines[i].id = lineId;
|
|
20
|
-
if (lineId === anchorHash) {
|
|
21
|
-
lines[i].className += ' selected';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
})();
|
|
1
|
+
/* global document */
|
|
2
|
+
(function() {
|
|
3
|
+
var source = document.getElementsByClassName('prettyprint source linenums');
|
|
4
|
+
var i = 0;
|
|
5
|
+
var lineNumber = 0;
|
|
6
|
+
var lineId;
|
|
7
|
+
var lines;
|
|
8
|
+
var totalLines;
|
|
9
|
+
var anchorHash;
|
|
10
|
+
|
|
11
|
+
if (source && source[0]) {
|
|
12
|
+
anchorHash = document.location.hash.substring(1);
|
|
13
|
+
lines = source[0].getElementsByTagName('li');
|
|
14
|
+
totalLines = lines.length;
|
|
15
|
+
|
|
16
|
+
for (; i < totalLines; i++) {
|
|
17
|
+
lineNumber++;
|
|
18
|
+
lineId = 'line' + lineNumber;
|
|
19
|
+
lines[i].id = lineId;
|
|
20
|
+
if (lineId === anchorHash) {
|
|
21
|
+
lines[i].className += ' selected';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})();
|
package/static/scripts/misc.js
CHANGED
|
@@ -1,217 +1,217 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
var accordionLocalStorageKey = 'accordion-id';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line no-undef
|
|
5
|
-
var localStorage = window.localStorage;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {string} value
|
|
10
|
-
*/
|
|
11
|
-
function copy(value) {
|
|
12
|
-
const el = document.createElement('textarea');
|
|
13
|
-
const editedValue = value.replace(/JAVASCRIPT\nCopied!$/, '');
|
|
14
|
-
|
|
15
|
-
el.value = editedValue;
|
|
16
|
-
document.body.appendChild(el);
|
|
17
|
-
el.select();
|
|
18
|
-
document.execCommand('copy');
|
|
19
|
-
document.body.removeChild(el);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function showTooltip(id) {
|
|
23
|
-
var tooltip = document.getElementById(id);
|
|
24
|
-
|
|
25
|
-
tooltip.classList.add('show-tooltip');
|
|
26
|
-
setTimeout(function() {
|
|
27
|
-
tooltip.classList.remove('show-tooltip');
|
|
28
|
-
}, 3000);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* eslint-disable-next-line */
|
|
32
|
-
function copyFunction(id) {
|
|
33
|
-
// selecting the pre element
|
|
34
|
-
var code = document.getElementById(id);
|
|
35
|
-
|
|
36
|
-
// selecting the ol.linenums
|
|
37
|
-
var element = code.querySelector('.linenums');
|
|
38
|
-
|
|
39
|
-
if (!element) {
|
|
40
|
-
// selecting the code block
|
|
41
|
-
element = code.querySelector('code');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// copy
|
|
45
|
-
copy(element.innerText);
|
|
46
|
-
|
|
47
|
-
// show tooltip
|
|
48
|
-
showTooltip('tooltip-' + id);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
(function() {
|
|
52
|
-
// capturing all pre element on the page
|
|
53
|
-
var allPre = document.getElementsByTagName('pre');
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var i, classList;
|
|
57
|
-
|
|
58
|
-
for ( i = 0; i < allPre.length; i++) {
|
|
59
|
-
// get the list of class in current pre element
|
|
60
|
-
classList = allPre[i].classList;
|
|
61
|
-
var id = 'pre-id-' + i;
|
|
62
|
-
|
|
63
|
-
// tooltip
|
|
64
|
-
var tooltip = '<div class="tooltip" id="tooltip-' + id + '">Copied!</div>';
|
|
65
|
-
|
|
66
|
-
// template of copy to clipboard icon container
|
|
67
|
-
var copyToClipboard = '<div class="code-copy-icon-container" onclick="copyFunction(\'' + id + '\')"><div><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>' + tooltip + '<div></div>';
|
|
68
|
-
|
|
69
|
-
// extract the code language
|
|
70
|
-
var langName = classList[classList.length - 1];
|
|
71
|
-
|
|
72
|
-
if (typeof langName === 'string') {
|
|
73
|
-
langName = langName.split('-')[1];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* By default language name is javascript.
|
|
78
|
-
*/
|
|
79
|
-
if ( langName === undefined ) { langName = 'JavaScript'; }
|
|
80
|
-
|
|
81
|
-
// if(langName != undefined)
|
|
82
|
-
var langNameDiv = '<div class="code-lang-name-container"><div class="code-lang-name">' + langName.toLocaleUpperCase() + '</div></div>';
|
|
83
|
-
// else langNameDiv = '';
|
|
84
|
-
|
|
85
|
-
// appending everything to the current pre element
|
|
86
|
-
allPre[i].innerHTML += '<div class="pre-top-bar-container">' + langNameDiv + copyToClipboard + '</div>';
|
|
87
|
-
allPre[i].setAttribute('id', id);
|
|
88
|
-
}
|
|
89
|
-
})();
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Function to set accordion id to localStorage.
|
|
94
|
-
* @param {string} id Accordion id
|
|
95
|
-
*/
|
|
96
|
-
function setAccordionIdToLocalStorage(id) {
|
|
97
|
-
/**
|
|
98
|
-
* @type {object}
|
|
99
|
-
*/
|
|
100
|
-
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
101
|
-
|
|
102
|
-
ids[id] = id;
|
|
103
|
-
localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Function to remove accordion id from localStorage.
|
|
108
|
-
* @param {string} id Accordion id
|
|
109
|
-
*/
|
|
110
|
-
function removeAccordionIdFromLocalStorage(id) {
|
|
111
|
-
/**
|
|
112
|
-
* @type {object}
|
|
113
|
-
*/
|
|
114
|
-
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
115
|
-
|
|
116
|
-
delete ids[id];
|
|
117
|
-
localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Function to get all accordion ids from localStorage.
|
|
122
|
-
*
|
|
123
|
-
* @returns {object}
|
|
124
|
-
*/
|
|
125
|
-
function getAccordionIdsFromLocalStorage() {
|
|
126
|
-
/**
|
|
127
|
-
* @type {object}
|
|
128
|
-
*/
|
|
129
|
-
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
130
|
-
|
|
131
|
-
return ids || {};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
function toggleAccordion(element, isImmediate) {
|
|
136
|
-
var currentNode = element;
|
|
137
|
-
var isCollapsed = currentNode.classList.contains('collapsed');
|
|
138
|
-
var currentNodeUL = currentNode.querySelector('.accordion-content');
|
|
139
|
-
|
|
140
|
-
if (isCollapsed) {
|
|
141
|
-
if (isImmediate) {
|
|
142
|
-
currentNode.classList.remove('collapsed');
|
|
143
|
-
currentNodeUL.style.height = 'auto';
|
|
144
|
-
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
var scrollHeight = currentNodeUL.scrollHeight;
|
|
149
|
-
|
|
150
|
-
currentNodeUL.style.height = scrollHeight + 'px';
|
|
151
|
-
currentNode.classList.remove('collapsed');
|
|
152
|
-
setAccordionIdToLocalStorage(currentNode.id);
|
|
153
|
-
setTimeout(function() {
|
|
154
|
-
if (!currentNode.classList.contains('collapsed'))
|
|
155
|
-
{ currentNodeUL.style.height = 'auto'; }
|
|
156
|
-
}, 600);
|
|
157
|
-
} else {
|
|
158
|
-
currentNodeUL.style.height = '0px';
|
|
159
|
-
currentNode.classList.add('collapsed');
|
|
160
|
-
removeAccordionIdFromLocalStorage(currentNode.id);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
(function() {
|
|
165
|
-
if (localStorage.getItem(accordionLocalStorageKey) === undefined ||
|
|
166
|
-
localStorage.getItem(accordionLocalStorageKey) === null
|
|
167
|
-
) {
|
|
168
|
-
localStorage.setItem(accordionLocalStorageKey, '{}');
|
|
169
|
-
}
|
|
170
|
-
var allAccordion = document.querySelectorAll('.accordion-heading');
|
|
171
|
-
var ids = getAccordionIdsFromLocalStorage();
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
allAccordion.forEach(function(item) {
|
|
175
|
-
var parent = item.parentNode;
|
|
176
|
-
|
|
177
|
-
item.addEventListener('click', function() { toggleAccordion(parent); } );
|
|
178
|
-
if (parent.id in ids) {
|
|
179
|
-
toggleAccordion(parent, true);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
})();
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
*
|
|
187
|
-
* @param {HTMLElement} element
|
|
188
|
-
* @param {HTMLElement} navbar
|
|
189
|
-
*/
|
|
190
|
-
function toggleNavbar(element, navbar) {
|
|
191
|
-
/**
|
|
192
|
-
* If class is present than it is expanded.
|
|
193
|
-
*/
|
|
194
|
-
var isExpanded = element.classList.contains('expanded');
|
|
195
|
-
|
|
196
|
-
if (isExpanded) {
|
|
197
|
-
element.classList.remove('expanded');
|
|
198
|
-
navbar.classList.remove('expanded');
|
|
199
|
-
} else {
|
|
200
|
-
element.classList.add('expanded');
|
|
201
|
-
navbar.classList.add('expanded');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Navbar ham
|
|
207
|
-
*/
|
|
208
|
-
(function() {
|
|
209
|
-
var navbarHam = document.querySelector('#navbar-ham');
|
|
210
|
-
var navbar = document.querySelector('#navbar');
|
|
211
|
-
|
|
212
|
-
if (navbarHam && navbar) {
|
|
213
|
-
navbarHam.addEventListener('click', function() {
|
|
214
|
-
toggleNavbar(navbarHam, navbar);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
})();
|
|
1
|
+
/* global document */
|
|
2
|
+
var accordionLocalStorageKey = 'accordion-id';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line no-undef
|
|
5
|
+
var localStorage = window.localStorage;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {string} value
|
|
10
|
+
*/
|
|
11
|
+
function copy(value) {
|
|
12
|
+
const el = document.createElement('textarea');
|
|
13
|
+
const editedValue = value.replace(/JAVASCRIPT\nCopied!$/, '');
|
|
14
|
+
|
|
15
|
+
el.value = editedValue;
|
|
16
|
+
document.body.appendChild(el);
|
|
17
|
+
el.select();
|
|
18
|
+
document.execCommand('copy');
|
|
19
|
+
document.body.removeChild(el);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function showTooltip(id) {
|
|
23
|
+
var tooltip = document.getElementById(id);
|
|
24
|
+
|
|
25
|
+
tooltip.classList.add('show-tooltip');
|
|
26
|
+
setTimeout(function() {
|
|
27
|
+
tooltip.classList.remove('show-tooltip');
|
|
28
|
+
}, 3000);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* eslint-disable-next-line */
|
|
32
|
+
function copyFunction(id) {
|
|
33
|
+
// selecting the pre element
|
|
34
|
+
var code = document.getElementById(id);
|
|
35
|
+
|
|
36
|
+
// selecting the ol.linenums
|
|
37
|
+
var element = code.querySelector('.linenums');
|
|
38
|
+
|
|
39
|
+
if (!element) {
|
|
40
|
+
// selecting the code block
|
|
41
|
+
element = code.querySelector('code');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// copy
|
|
45
|
+
copy(element.innerText);
|
|
46
|
+
|
|
47
|
+
// show tooltip
|
|
48
|
+
showTooltip('tooltip-' + id);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
(function() {
|
|
52
|
+
// capturing all pre element on the page
|
|
53
|
+
var allPre = document.getElementsByTagName('pre');
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var i, classList;
|
|
57
|
+
|
|
58
|
+
for ( i = 0; i < allPre.length; i++) {
|
|
59
|
+
// get the list of class in current pre element
|
|
60
|
+
classList = allPre[i].classList;
|
|
61
|
+
var id = 'pre-id-' + i;
|
|
62
|
+
|
|
63
|
+
// tooltip
|
|
64
|
+
var tooltip = '<div class="tooltip" id="tooltip-' + id + '">Copied!</div>';
|
|
65
|
+
|
|
66
|
+
// template of copy to clipboard icon container
|
|
67
|
+
var copyToClipboard = '<div class="code-copy-icon-container" onclick="copyFunction(\'' + id + '\')"><div><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>' + tooltip + '<div></div>';
|
|
68
|
+
|
|
69
|
+
// extract the code language
|
|
70
|
+
var langName = classList[classList.length - 1];
|
|
71
|
+
|
|
72
|
+
if (typeof langName === 'string') {
|
|
73
|
+
langName = langName.split('-')[1];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* By default language name is javascript.
|
|
78
|
+
*/
|
|
79
|
+
if ( langName === undefined ) { langName = 'JavaScript'; }
|
|
80
|
+
|
|
81
|
+
// if(langName != undefined)
|
|
82
|
+
var langNameDiv = '<div class="code-lang-name-container"><div class="code-lang-name">' + langName.toLocaleUpperCase() + '</div></div>';
|
|
83
|
+
// else langNameDiv = '';
|
|
84
|
+
|
|
85
|
+
// appending everything to the current pre element
|
|
86
|
+
allPre[i].innerHTML += '<div class="pre-top-bar-container">' + langNameDiv + copyToClipboard + '</div>';
|
|
87
|
+
allPre[i].setAttribute('id', id);
|
|
88
|
+
}
|
|
89
|
+
})();
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Function to set accordion id to localStorage.
|
|
94
|
+
* @param {string} id Accordion id
|
|
95
|
+
*/
|
|
96
|
+
function setAccordionIdToLocalStorage(id) {
|
|
97
|
+
/**
|
|
98
|
+
* @type {object}
|
|
99
|
+
*/
|
|
100
|
+
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
101
|
+
|
|
102
|
+
ids[id] = id;
|
|
103
|
+
localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Function to remove accordion id from localStorage.
|
|
108
|
+
* @param {string} id Accordion id
|
|
109
|
+
*/
|
|
110
|
+
function removeAccordionIdFromLocalStorage(id) {
|
|
111
|
+
/**
|
|
112
|
+
* @type {object}
|
|
113
|
+
*/
|
|
114
|
+
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
115
|
+
|
|
116
|
+
delete ids[id];
|
|
117
|
+
localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Function to get all accordion ids from localStorage.
|
|
122
|
+
*
|
|
123
|
+
* @returns {object}
|
|
124
|
+
*/
|
|
125
|
+
function getAccordionIdsFromLocalStorage() {
|
|
126
|
+
/**
|
|
127
|
+
* @type {object}
|
|
128
|
+
*/
|
|
129
|
+
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
|
|
130
|
+
|
|
131
|
+
return ids || {};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
function toggleAccordion(element, isImmediate) {
|
|
136
|
+
var currentNode = element;
|
|
137
|
+
var isCollapsed = currentNode.classList.contains('collapsed');
|
|
138
|
+
var currentNodeUL = currentNode.querySelector('.accordion-content');
|
|
139
|
+
|
|
140
|
+
if (isCollapsed) {
|
|
141
|
+
if (isImmediate) {
|
|
142
|
+
currentNode.classList.remove('collapsed');
|
|
143
|
+
currentNodeUL.style.height = 'auto';
|
|
144
|
+
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var scrollHeight = currentNodeUL.scrollHeight;
|
|
149
|
+
|
|
150
|
+
currentNodeUL.style.height = scrollHeight + 'px';
|
|
151
|
+
currentNode.classList.remove('collapsed');
|
|
152
|
+
setAccordionIdToLocalStorage(currentNode.id);
|
|
153
|
+
setTimeout(function() {
|
|
154
|
+
if (!currentNode.classList.contains('collapsed'))
|
|
155
|
+
{ currentNodeUL.style.height = 'auto'; }
|
|
156
|
+
}, 600);
|
|
157
|
+
} else {
|
|
158
|
+
currentNodeUL.style.height = '0px';
|
|
159
|
+
currentNode.classList.add('collapsed');
|
|
160
|
+
removeAccordionIdFromLocalStorage(currentNode.id);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
(function() {
|
|
165
|
+
if (localStorage.getItem(accordionLocalStorageKey) === undefined ||
|
|
166
|
+
localStorage.getItem(accordionLocalStorageKey) === null
|
|
167
|
+
) {
|
|
168
|
+
localStorage.setItem(accordionLocalStorageKey, '{}');
|
|
169
|
+
}
|
|
170
|
+
var allAccordion = document.querySelectorAll('.accordion-heading');
|
|
171
|
+
var ids = getAccordionIdsFromLocalStorage();
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
allAccordion.forEach(function(item) {
|
|
175
|
+
var parent = item.parentNode;
|
|
176
|
+
|
|
177
|
+
item.addEventListener('click', function() { toggleAccordion(parent); } );
|
|
178
|
+
if (parent.id in ids) {
|
|
179
|
+
toggleAccordion(parent, true);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
})();
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* @param {HTMLElement} element
|
|
188
|
+
* @param {HTMLElement} navbar
|
|
189
|
+
*/
|
|
190
|
+
function toggleNavbar(element, navbar) {
|
|
191
|
+
/**
|
|
192
|
+
* If class is present than it is expanded.
|
|
193
|
+
*/
|
|
194
|
+
var isExpanded = element.classList.contains('expanded');
|
|
195
|
+
|
|
196
|
+
if (isExpanded) {
|
|
197
|
+
element.classList.remove('expanded');
|
|
198
|
+
navbar.classList.remove('expanded');
|
|
199
|
+
} else {
|
|
200
|
+
element.classList.add('expanded');
|
|
201
|
+
navbar.classList.add('expanded');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Navbar ham
|
|
207
|
+
*/
|
|
208
|
+
(function() {
|
|
209
|
+
var navbarHam = document.querySelector('#navbar-ham');
|
|
210
|
+
var navbar = document.querySelector('#navbar');
|
|
211
|
+
|
|
212
|
+
if (navbarHam && navbar) {
|
|
213
|
+
navbarHam.addEventListener('click', function() {
|
|
214
|
+
toggleNavbar(navbarHam, navbar);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
})();
|