Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] added possibility for collapsing sections (#1594)
* added possibility to collapse long sections in docs * added contents in the installation guide
- Loading branch information
1 parent
542c34d
commit 8ff1e94
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,29 @@ | ||
$(function() { | ||
$('a[href^="./"][href*=".rst"]').attr('href', (i, val) => { return val.replace('.rst', '.html'); }); /* Replace '.rst' with '.html' in all internal links like './[Something].rst[#anchor]' */ | ||
$('.wy-nav-content').each(function () { this.style.setProperty('max-width', 'none', 'important'); }); | ||
|
||
$('.wy-nav-content').each(function () { this.style.setProperty('max-width', 'none', 'important'); }); /* Use wider container for the page content */ | ||
|
||
/* Collapse specified sections in the installation guide */ | ||
if(window.location.pathname.toLocaleLowerCase().indexOf('installation-guide') != -1) { | ||
$('<style>.closed, .opened {cursor: pointer;} .closed:before, .opened:before {font-family: FontAwesome; display: inline-block; padding-right: 6px;} .closed:before {content: "\\f078";} .opened:before {content: "\\f077";}</style>').appendTo('body'); | ||
var collapsable = ['#build-mpi-version', '#build-gpu-version', '#build-hdfs-version', '#build-java-wrapper']; | ||
$.each(collapsable, function(i, val) { | ||
var header = val + ' > :header:first'; | ||
var content = val + ' :not(:header:first)'; | ||
$(header).addClass('closed'); | ||
$(content).hide(); | ||
$(header).click(function() { | ||
$(header).toggleClass('closed opened'); | ||
$(content).slideToggle(0); | ||
}); | ||
}); | ||
/* Uncollapse parent sections when nested section is specified in the URL or before navigate to it from navbar */ | ||
function uncollapse(section) { | ||
section.parents().each((i, val) => { $(val).children('.closed').click(); }); | ||
} | ||
uncollapse($(window.location.hash)); | ||
$('.wy-menu.wy-menu-vertical li a.reference.internal').click(function() { | ||
uncollapse($($(this).attr('href'))); | ||
}); | ||
} | ||
}); |