瀏覽代碼

added button to get direct link to the example

Jaume Sanchez 9 年之前
父節點
當前提交
de98772690
共有 2 個文件被更改,包括 39 次插入5 次删除
  1. 1 0
      examples/files/external.svg
  2. 38 5
      examples/index.html

+ 1 - 0
examples/files/external.svg

@@ -0,0 +1 @@
+<?xml version="1.0" ?><svg height="48" viewBox="0 0 48 48" width="48" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h48v48h-48z" fill="none"/><path fill="#ffffff" d="M38 38h-28v-28h14v-4h-14c-2.21 0-4 1.79-4 4v28c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4v-14h-4v14zm-10-32v4h7.17l-19.66 19.66 2.83 2.83 19.66-19.66v7.17h4v-14h-14z"/></svg>

+ 38 - 5
examples/index.html

@@ -87,21 +87,33 @@
 				overflow: auto;
 			}
 
-			#button {
+			.action-panel{
 				position: fixed;
 				bottom: 20px;
 				right: 20px;
+			}
+
+			.action-button {
 				padding: 8px;
 				color: #fff;
 				background-color: #555;
 				opacity: 0.7;
+				float: left;
+				margin-left: 1px;
 			}
-
-			#button:hover {
+			
+			.action-button:hover {
 				cursor: pointer;
 				opacity: 1;
 			}
 
+			#open-external-button{
+				background-image: url(files/external.svg);
+				background-size: 50%;
+				background-position: 50% 50%;
+				background-repeat: no-repeat;
+			}
+
 			.filterBlock{
 				margin: 20px;
 				position: relative;
@@ -271,7 +283,12 @@
 		var container = document.createElement( 'div' );
 		content.appendChild( container );
 
+		var panel = document.createElement( 'div' );
+		panel.className = 'action-panel';
+		document.body.appendChild( panel );
+
 		var button = document.createElement( 'div' );
+		button.className = 'action-button';
 		button.id = 'button';
 		button.textContent = 'View source';
 		button.addEventListener( 'click', function ( event ) {
@@ -280,7 +297,20 @@
 
 		}, false );
 		button.style.display = 'none';
-		document.body.appendChild( button );
+		panel.appendChild( button );
+
+		var button2 = document.createElement( 'a' );
+		button2.className = 'action-button';
+		button2.id = 'open-external-button';
+		button2.innerHTML = '&nbsp;&nbsp;'
+		button2.addEventListener( 'click', function ( event ) {
+
+			window.open( selected + '.html' );
+			event.preventDefault();
+
+		}, false );
+		button2.style.display = 'none';
+		panel.appendChild( button2 );
 
 		var links = {};
 		var selected = null;
@@ -303,7 +333,7 @@
 					var link = document.createElement( 'a' );
 					link.className = 'link';
 					link.textContent = name;
-					link.href = "#" + file;
+					link.href = file + '.html';
 					link.addEventListener( 'click', function ( event ) {
 
 						if ( event.button === 0 ) {
@@ -337,9 +367,12 @@
 			viewer.focus();
 
 			button.style.display = '';
+			button2.style.display = '';
 
 			selected = file;
 
+			button2.href = selected + '.html'
+
 		};
 
 		if ( window.location.hash !== '' ) {