index.html 9.0 KB
Newer Older
1 2
<!doctype html>
<html lang="en">
M
Mr.doob 已提交
3
	<head>
4
		<meta charset="utf-8">
M
Mr.doob 已提交
5
		<title>three.js / documentation</title>
M
r68  
Mr.doob 已提交
6
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
7
		<style>
M
Mr.doob 已提交
8

9 10 11 12 13 14 15
			@font-face {
				font-family: 'inconsolata';
				src: url('files/inconsolata.woff') format('woff');
				font-weight: normal;
				font-style: normal;
			}

M
Mr.doob 已提交
16 17 18
			*{
				box-sizing: border-box;
			}
M
r68  
Mr.doob 已提交
19

20 21 22 23 24
			html {
				height: 100%;
			}

			body {
M
r67  
Mr.doob 已提交
25
				background-color: #ffffff;
M
Mr.doob 已提交
26
				margin: 0px;
27 28 29 30 31 32 33 34 35 36
				height: 100%;
				color: #555;
				font-family: 'inconsolata';
				font-size: 15px;
				line-height: 18px;
				overflow: hidden;
			}

			a {
				color: #2194CE;
M
r63  
Mr.doob 已提交
37
				text-decoration: none;
38 39
			}

M
Mr.doob 已提交
40
			#panel {
41
				position: fixed;
M
r67  
Mr.doob 已提交
42
				left: 0px;
43 44 45
				width: 260px;
				height: 100%;
				overflow: auto;
M
r67  
Mr.doob 已提交
46
				background: #fafafa;
47 48 49
			}

				#panel h1 {
M
r67  
Mr.doob 已提交
50
					margin-top: 30px;
M
r63  
Mr.doob 已提交
51
					margin-bottom: 40px;
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
					margin-left: 20px;
					font-size: 25px;
					font-weight: normal;
				}

				#panel h2 {
					color: #454545;
					font-size: 18px;
					font-weight: normal;

					margin-top: 20px;
					margin-left: 20px;
				}

				#panel h3 {
					color: #666;
					font-size: 16px;
					font-weight: normal;

					margin-top: 20px;
					margin-left: 20px;
				}

				#panel ul {
					list-style-type: none;
					padding: 0px;
					margin-left: 20px;
				}

			#viewer {
M
Mr.doob 已提交
82
				position: absolute;
83
				border: 0px;
M
Mr.doob 已提交
84 85
				left: 260px;
				width: calc(100% - 260px);
86 87 88 89
				height: 100%;
				overflow: auto;
			}

M
r68  
Mr.doob 已提交
90 91 92 93 94 95 96
			.filterBlock{
				margin: 20px;
				position: relative;
			}
			.filterBlock p {
				margin: 0;
			}
M
Mr.doob 已提交
97

M
r68  
Mr.doob 已提交
98 99 100 101 102 103 104 105
			#filterInput {
				width: 100%;
				padding: 5px;
				font-family: inherit;
				font-size: 15px;
				outline: none;
				border: 1px solid #dedede;
			}
M
Mr.doob 已提交
106

M
r68  
Mr.doob 已提交
107 108 109
			#filterInput:focus{
				border: 1px solid #2194CE;
			}
M
Mr.doob 已提交
110

M
r68  
Mr.doob 已提交
111
			#clearFilterButton {
M
Mr.doob 已提交
112
				position: absolute;
M
r68  
Mr.doob 已提交
113 114 115 116 117 118 119 120 121 122 123 124
				right: 6px;
				top: 50%;
				margin-top: -8px;
				width: 16px;
				height: 16px;
				font-size: 14px;
				color: grey;
				text-align: center;
				line-height: 0;
				padding-top: 7px;
				opacity: .5;
			}
M
Mr.doob 已提交
125 126

			#clearFilterButton:hover {
M
r68  
Mr.doob 已提交
127 128
				opacity: 1;
			}
M
Mr.doob 已提交
129 130

			.filtered {
M
r68  
Mr.doob 已提交
131 132
				display: none;
			}
M
Mr.doob 已提交
133 134

			#panel li b {
M
r68  
Mr.doob 已提交
135 136
				font-weight: bold;
			}
M
Mr.doob 已提交
137 138 139 140

			/* mobile */

			#expandButton {
M
r68  
Mr.doob 已提交
141 142 143 144 145 146 147
				display: none;
				position: absolute;
				right: 20px;
				top: 12px;
				width: 32px;
				height: 32px;
			}
M
Mr.doob 已提交
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165

				#expandButton span {
					height: 2px;
					background-color: #2194CE;
					width: 16px;
					position: absolute;
					left: 8px;
					top: 10px;
				}

				#expandButton span:nth-child(1) {
					top: 16px;
				}

				#expandButton span:nth-child(2) {
					top: 22px;
				}

M
r68  
Mr.doob 已提交
166 167 168 169 170 171 172 173 174 175 176 177
			@media all and ( max-width: 640px ) {
				#panel{
					position: absolute;
					left: 0;
					top: 0;
					height: 480px;
					width: 100%;
					right: 0;
					z-index: 100;
					overflow: hidden;
					border-bottom: 1px solid #dedede;
				}
M
Mr.doob 已提交
178 179 180 181
				#panel h1{
					margin-top: 20px;
					margin-bottom: 20px;
				}
M
r68  
Mr.doob 已提交
182 183 184
				#content{
					position: absolute;
					left: 0;
M
Mr.doob 已提交
185
					top: 90px;
M
r68  
Mr.doob 已提交
186 187
					right: 0;
					bottom: 0;
M
Mr.doob 已提交
188 189 190
					font-size: 17px;
					line-height: 22px;
					overflow: auto;
M
r68  
Mr.doob 已提交
191 192 193 194
				}
				#viewer{
					position: absolute;
					left: 0;
M
Mr.doob 已提交
195 196 197
					top: 56px;
					width: 100%;
					height: calc(100% - 56px);
M
r68  
Mr.doob 已提交
198 199 200 201 202 203 204 205
				}
				#expandButton{
					display: block;
				}
				#panel.collapsed{
					height: 56px;
				}
			}
206
		</style>
M
Mr.doob 已提交
207
	</head>
208
	<body>
M
Mr.doob 已提交
209 210 211 212 213 214 215 216 217 218 219 220 221 222
		<script type="text/javascript">

		  var _gaq = _gaq || [];
		  _gaq.push(['_setAccount', 'UA-86951-15']);
		  _gaq.push(['_trackPageview']);

		  (function() {
		    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		  })();

		</script>

M
r68  
Mr.doob 已提交
223
		<div id="panel" class="collapsed">
M
Mr.doob 已提交
224
			<h1><a href="http://threejs.org">three.js</a> / docs</h1>
M
r68  
Mr.doob 已提交
225
			<a id="expandButton" href="#" >
M
Mr.doob 已提交
226 227 228
				<span></span>
				<span></span>
				<span></span>
M
r68  
Mr.doob 已提交
229 230 231 232 233
			</a>
			<div class="filterBlock" >
				<input type="text" id="filterInput" placeholder="Type to filter"/>
				<a href="#" id="clearFilterButton" >x</a>
			</div>
M
Mr.doob 已提交
234
			<div id="content"></div>
M
r68  
Mr.doob 已提交
235
		</div>
236 237 238 239 240 241 242
		<iframe id="viewer"></iframe>

		<script src="list.js"></script>
		<script>
			var panel = document.getElementById( 'panel' );
			var viewer = document.getElementById( 'viewer' );

M
Mr.doob 已提交
243 244
			var expandButton = document.getElementById( 'expandButton' );
			expandButton.addEventListener( 'click', function ( event ) {
M
r68  
Mr.doob 已提交
245
				panel.classList.toggle( 'collapsed' );
M
Mr.doob 已提交
246
				event.preventDefault();
M
r68  
Mr.doob 已提交
247
			} );
248

M
Mr.doob 已提交
249 250 251
			var filterInput = document.getElementById( 'filterInput' );
			var clearFilterButton = document.getElementById( 'clearFilterButton' );

252
			var DELIMITER = '/';
M
r69  
Mr.doob 已提交
253
			var MEMBER_DELIMITER = '.';
254
			var nameCategoryMap = {};
M
r68  
Mr.doob 已提交
255 256 257
			var sections = [];

			var content = document.getElementById( 'content' );
258 259 260

			for ( var section in list ) {

M
r68  
Mr.doob 已提交
261 262
				var h2 = document.createElement( 'h2' );
				h2.textContent = section;
263

M
r68  
Mr.doob 已提交
264
				content.appendChild( h2 );
265 266 267

				for ( var category in list[ section ] ) {

M
r68  
Mr.doob 已提交
268 269 270 271
					var div = document.createElement( 'div' );

					var h3 = document.createElement( 'h3' );
					h3.textContent = category;
272

M
r68  
Mr.doob 已提交
273 274 275 276
					div.appendChild( h3 );

					var ul = document.createElement( 'ul' );
					div.appendChild( ul );
277 278 279 280 281

					for ( var i = 0; i < list[ section ][ category ].length; i ++ ) {

						var page = list[ section ][ category ][ i ];

M
r68  
Mr.doob 已提交
282 283 284 285 286 287 288 289 290 291 292 293
						var li = document.createElement( 'li' );
						var a = document.createElement( 'a' );
						a.setAttribute( 'href', '#' );
						( function( s, c, p ) { 
							a.addEventListener( 'click', function( e ) {
								goTo( s, c, p );
								e.preventDefault();
							} ) 
						} )( section, category, page[ 0 ] )
						a.textContent = page[ 0 ];
						li.appendChild( a );
						ul.appendChild( li );
294 295 296 297

						nameCategoryMap[page[0]] = {
							section: section,
							category: category,
M
r68  
Mr.doob 已提交
298 299
							name: page[0],
							element: a
300 301 302 303
						};

					}

M
r68  
Mr.doob 已提交
304 305
					content.appendChild( div );
					sections.push( ul );
306 307 308 309 310 311

				}


			}

M
r68  
Mr.doob 已提交
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
			panel.appendChild( content )

			function layoutList() {

				sections.forEach( function( el ) {
					var collapsed = true;
					Array.prototype.slice.apply( el.children ).forEach( function( item ) {
						if( !item.classList.contains( 'filtered' ) ) {
							collapsed = false;
							return;
						}
					} );
					if( collapsed ) {
						el.parentElement.classList.add( 'filtered' );
					} else {
						el.parentElement.classList.remove( 'filtered' );
					}
				} );
			}

			filterInput.addEventListener( 'input', function( e ) {
				updateFilter();
			} );

			clearFilterButton.addEventListener( 'click', function( e ) {
				filterInput.value = '';
				updateFilter();
				e.preventDefault();
			} );

			function updateFilter() {

				var exp = new RegExp( filterInput.value, 'gi' );
				for( var j in nameCategoryMap ) {
					var res = nameCategoryMap[ j ].name.match( exp );
					if( res && res.length > 0 ) {
						nameCategoryMap[ j ].element.parentElement.classList.remove( 'filtered' );
						var str = nameCategoryMap[ j ].name;
						for( var i = 0; i < res.length; i++ ) {
							str = str.replace( res[ i ], '<b>' + res[ i ] + '</b>' );
						}
						nameCategoryMap[ j ].element.innerHTML = str;
					} else {
						nameCategoryMap[ j ].element.parentElement.classList.add( 'filtered' );
						nameCategoryMap[ j ].element.textContent = nameCategoryMap[ j ].name;
					}
				}
				layoutList();

			}
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376

			function encodeUrl( path ) {

				return path.replace(/\ \/\ /g, '.').replace(/\ /g, '_');

			}

			function decodeUrl( path ) {

				return path.replace(/_/g, ' ').replace(/\./g, ' / ');

			}

			// Page loading

M
r69  
Mr.doob 已提交
377 378
			function goTo( section, category, name, member ) {
				var parts, location;
379 380 381

				// Fully resolve links that only provide a name
				if(arguments.length == 1) {
M
r69  
Mr.doob 已提交
382 383 384 385 386 387 388 389 390 391

					// Resolve links of the form 'Class.member'
					if(section.indexOf(MEMBER_DELIMITER) !== -1) {
						parts = section.split(MEMBER_DELIMITER)
						section = parts[0]; 
						member = parts[1];
					}

					location = nameCategoryMap[section];
					if (!location) return;
392 393 394
					section = location.section;
					category = location.category;
					name = location.name;
M
r69  
Mr.doob 已提交
395
				} 
396 397

				var title = 'three.js - documentation - ' + section + ' - ' + name;
M
r69  
Mr.doob 已提交
398
				var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name) + (!!member ? MEMBER_DELIMITER + encodeUrl(member) : '');
399 400 401 402

				window.location.hash = url;
				window.document.title = title;

M
r69  
Mr.doob 已提交
403 404
				viewer.src = pages[ section ][ category ][ name ] + '.html' + (!!member ? '#'+member : '');

M
r68  
Mr.doob 已提交
405
				panel.classList.add( 'collapsed' );
406 407 408 409 410 411

			}

			function goToHash() {

				var hash = window.location.hash.substring( 1 ).split(DELIMITER);
M
r69  
Mr.doob 已提交
412 413
				var member = hash[2].split(MEMBER_DELIMITER)
				goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(member[0]), decodeUrl(member.length > 1 ? member[1] : '') );
414 415 416 417 418 419 420 421 422

			}

			window.addEventListener( 'hashchange', goToHash, false );

			if ( window.location.hash.length > 0 ) goToHash();

		</script>
	</body>
M
Mr.doob 已提交
423
</html>