Skip to content

Commit 19c648d

Browse files
Merge pull request docker#602 from docker/htmltre
Pre-render left nav so it's immediately visible
2 parents a0719b1 + d549e4c commit 19c648d

File tree

4 files changed

+4
-34
lines changed

4 files changed

+4
-34
lines changed

_includes/tree.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% for item in tree %}{% if item.heading %}{% else %}{% if item.sectiontitle %}<li class="leaf menu-closed"><a href="/" class="expand-menu "><span class="menu-icon" aria-hidden="true"></span>{{ item.sectiontitle }}</a>
1+
{% for item in tree %}{% if item.heading %}{% else %}{% if item.sectiontitle %}<li class="leaf menu-closed"><a href="#" class="expand-menu "><span class="menu-icon" aria-hidden="true"></span>{{ item.sectiontitle }}</a>
22
<ul class="nav-sub">
33
{% assign tree = item.section %}{% include tree.html %}
44
</ul>

_layouts/docs.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@
187187
<div class="row">
188188
<div class="col-xs-12 col-sm-3 col-md-2 col-xl-2 docsidebarnav_section">
189189
<div class="region region-hero-sub"><ul class="nav-sub">
190-
190+
{% assign tree = site.data.toc.toc %}
191+
{% include tree.html %}
191192
</ul>
192193
</div>
193194
</div>

js/menu.js

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
11
var tocData;
2-
var treeOutput = new Array();
3-
function renderTree(tree)
4-
{
5-
for (var i=0; i < tree.length; i++)
6-
{
7-
if (tree[i].heading)
8-
{
9-
// render a heading
10-
} else {
11-
if (tree[i].sectiontitle) {
12-
treeOutput.push('<li class="leaf menu-closed"><a href="#" class="expand-menu "><span class="menu-icon" aria-hidden="true"></span>' + tree[i].sectiontitle + '</a>');
13-
treeOutput.push('<ul class="nav-sub">');
14-
renderTree(tree[i].section);
15-
treeOutput.push('</ul>');
16-
} else {
17-
treeOutput.push('<li class="leaf"><a href="' + tree[i].path +'" class="');
18-
if (tree[i].path == window.location.pathname) treeOutput.push('active currentPage');
19-
treeOutput.push('">' + tree[i].title + '</a></li>');
20-
}
21-
}
22-
}
23-
}
242
function hookupTOCEvents()
253
{
264
// do after tree render
@@ -41,12 +19,7 @@ function hookupTOCEvents()
4119
});
4220
}
4321
jQuery(document).ready(function(){
44-
$.getJSON( "/toc.txt", function( data ) {
45-
tocData = data;
46-
renderTree(data.toc);
47-
$(".nav-sub").html(treeOutput.join(''));
48-
hookupTOCEvents();
49-
});
22+
hookupTOCEvents();
5023
$("#TableOfContents ul").empty();
5124

5225
var prevH2Item = null;

toc.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)