-
Notifications
You must be signed in to change notification settings - Fork 0
/
devhub.js
38 lines (30 loc) · 1.23 KB
/
devhub.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
( function() {
function syntaxHighlight() {
var collapsedHeight = 196;
if ( window.SyntaxHighlighter ) {
window.SyntaxHighlighter.highlight();
}
Array.from( document.querySelectorAll( '.source-content' ) ).forEach( function( sourceContent ) {
var container = sourceContent.querySelector( '.source-code-container' );
var showMore = sourceContent.querySelector( '.show-complete-source' );
var showLess = sourceContent.querySelector( '.less-complete-source' );
function listenMoreClick() {
container.style.setProperty( 'height', 'auto' );
showMore.style.setProperty( 'display', 'none' );
showLess.style.setProperty( 'display', 'inline-block' );
}
function listenLessClick() {
container.style.setProperty( 'height', '' + collapsedHeight + 'px' );
showMore.style.setProperty( 'display', 'inline-block' );
showLess.style.setProperty( 'display', 'none' );
}
if ( container.clientHeight > collapsedHeight ) {
container.style.setProperty( 'height', '' + collapsedHeight + 'px' );
showMore.style.setProperty( 'display', 'inline-block' );
showMore.addEventListener( 'click', listenMoreClick );
showLess.addEventListener( 'click', listenLessClick );
}
});
}
syntaxHighlight();
})();