Просмотр исходного кода

Merge pull request #8392 from spite/dev

Access to example link from Examples page
Mr.doob 9 лет назад
Родитель
Сommit
4a461bf72c
1 измененных файлов с 23 добавлено и 15 удалено
  1. 23 15
      examples/index.html

+ 23 - 15
examples/index.html

@@ -87,17 +87,19 @@
 				overflow: auto;
 			}
 
-			#button {
-				position: fixed;
-				bottom: 20px;
-				right: 20px;
+			.action-button {
 				padding: 8px;
 				color: #fff;
 				background-color: #555;
 				opacity: 0.7;
+				float: left;
+				margin-left: 1px;
+				position: fixed;
+				bottom: 20px;
+				right: 20px;
 			}
-
-			#button:hover {
+			
+			.action-button:hover {
 				cursor: pointer;
 				opacity: 1;
 			}
@@ -237,7 +239,7 @@
 			</div>
 			<div id="content"></div>
 		</div>
-		<iframe id="viewer" allowfullscreen onmousewheel=""></iframe>
+		<iframe id="viewer" name="viewer" allowfullscreen onmousewheel=""></iframe>
 
 		<script src="files.js"></script>
 		<script>
@@ -272,6 +274,7 @@
 		content.appendChild( container );
 
 		var button = document.createElement( 'div' );
+		button.className = 'action-button';
 		button.id = 'button';
 		button.textContent = 'View source';
 		button.addEventListener( 'click', function ( event ) {
@@ -303,15 +306,13 @@
 					var link = document.createElement( 'a' );
 					link.className = 'link';
 					link.textContent = name;
-					link.href = "#" + file;
+					link.href = file + '.html';
+					link.setAttribute( 'target', 'viewer' );
 					link.addEventListener( 'click', function ( event ) {
 
 						if ( event.button === 0 ) {
 
-							event.preventDefault();
-
-							panel.classList.toggle( 'collapsed' );
-							load( file );
+							selectFile( file );
 
 						}
 
@@ -328,19 +329,26 @@
 
 		var load = function ( file ) {
 
+			selectFile( file );
+			viewer.src = file + '.html';
+
+		};
+
+		var selectFile = function( file ) {
+
 			if ( selected !== null ) links[ selected ].className = 'link';
 
 			links[ file ].className = 'link selected';
 
 			window.location.hash = file;
-			viewer.src = file + '.html';
 			viewer.focus();
 
 			button.style.display = '';
-
+			panel.classList.toggle( 'collapsed' );
+			
 			selected = file;
 
-		};
+		}
 
 		if ( window.location.hash !== '' ) {