forked from nestjs/typescript-starter
-
Notifications
You must be signed in to change notification settings - Fork 246
/
Copy pathsourceCode.js
58 lines (52 loc) · 2.12 KB
/
sourceCode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
document.addEventListener('DOMContentLoaded', function() {
var $tabSource = document.querySelector('#source-tab'),
$tabInfo = document.querySelector('#info-tab'),
$tabReadme = document.querySelector('#readme-tab'),
$tabTemplate = document.querySelector('#templateData-tab'),
$tabTree = document.querySelector('#tree-tab'),
$tabExample = document.querySelector('#example-tab'),
$prismPre = document.querySelector('pre.compodoc-sourcecode');
if ($tabSource && $prismPre) {
$prismCode = $prismPre.querySelector('code'),
$content = document.querySelector('.content'),
prismLinks = document.querySelectorAll('.link-to-prism')
for (var i = 0; i < prismLinks.length; i++) {
prismLinks[i].addEventListener('click', linkToPrism, false);
}
function linkToPrism(event) {
var targetLine = event.target.getAttribute('data-line');
event.preventDefault();
$prismPre.setAttribute('data-line', targetLine);
Prism.highlightElement($prismCode, function() {});
$tabSource.click();
setTimeout(function() {
var $prismHighlightLine = document.querySelector('.line-highlight'),
top = parseInt(getComputedStyle($prismHighlightLine)['top']);
$content.scrollTop = top;
}, 500);
};
window.onhashchange = function(event) {
switch (window.location.hash) {
case '':
case '#info':
$tabInfo.click();
break;
case '#readme':
$tabReadme.click();
break;
case '#source':
$tabSource.click();
break;
case '#template':
$tabTemplate.click();
break;
case '#dom-tree':
$tabTree.click();
break;
case '#example':
$tabExample.click();
break;
}
}
}
});