Skip to content

Commit 5ff1e22

Browse files
authored
Merge pull request #14969 from mrdoob/docs
Docs: Added basic language navigation.
2 parents 63eca7a + 6023b2e commit 5ff1e22

File tree

3 files changed

+869
-418
lines changed

3 files changed

+869
-418
lines changed

docs/index.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ a {
5858
width: 260px;
5959
height: 100%;
6060
overflow: auto;
61-
padding-left: 20px;
61+
padding: 0px 20px 0px 20px;
6262
background: #fafafa;
6363
}
6464

@@ -77,7 +77,6 @@ iframe {
7777
}
7878

7979
.filterBlock {
80-
margin-right: 20px;
8180
position: relative;
8281
}
8382

docs/index.html

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
2222
<input type="text" id="filterInput" placeholder="Type to filter" autocorrect="off" autocapitalize="off" spellcheck="false">
2323
<a href="#" id="clearFilterButton">x</a>
2424
</div>
25+
26+
<div style="text-align:center">
27+
<br />
28+
<a href="javascript:setLanguage('en')">en</a> |
29+
<a href="javascript:setLanguage('zh')">zh</a>
30+
</div>
31+
2532
<div id="content"></div>
2633

2734
</div>
@@ -44,6 +51,15 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
4451

4552
//
4653

54+
var language = 'en';
55+
56+
function setLanguage( value ) {
57+
58+
language = value;
59+
createNavigation();
60+
61+
}
62+
4763
var panel = document.getElementById( 'panel' );
4864
var content = document.getElementById( 'content' );
4965
var clearFilterButton = document.getElementById( 'clearFilterButton' );
@@ -55,6 +71,8 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
5571
var titles = {};
5672
var categoryElements = [];
5773

74+
var navigation;
75+
5876

5977
// Functionality for hamburger button (on small devices)
6078

@@ -118,16 +136,24 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
118136

119137
function createNavigation() {
120138

139+
if ( navigation !== undefined ) {
140+
141+
content.removeChild( navigation );
142+
143+
}
144+
121145
// Create the navigation panel using data from list.js
122146

123-
var navigation = document.createElement( 'div' );
147+
navigation = document.createElement( 'div' );
124148
content.appendChild( navigation );
125149

126-
for ( var section in list ) {
150+
var localList = list[ language ];
151+
152+
for ( var section in localList ) {
127153

128154
// Create sections
129155

130-
var categories = list[ section ];
156+
var categories = localList[ section ];
131157

132158
var sectionHead = document.createElement( 'h2' );
133159
sectionHead.textContent = section;
@@ -157,8 +183,6 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
157183

158184
// Localisation
159185

160-
pageURL = pageURL.replace( '{lan}', 'en' );
161-
162186
var listElement = document.createElement( 'li' );
163187
categoryContent.appendChild( listElement );
164188

0 commit comments

Comments
 (0)