提交 851dddee 编写于 作者: M Mr.doob

Added "view source" button to examples viewer.

上级 ec530ea0
......@@ -85,6 +85,21 @@
}
#button {
position: fixed;
top: 20px;
right: 20px;
padding: 8px;
color: #fff;
background-color: #555;
opacity: 0.7;
}
#button:hover {
cursor: pointer;
opacity: 1;
}
</style>
</head>
<body>
......@@ -326,8 +341,22 @@
var container = document.createElement( 'div' );
list.appendChild( container );
var button = document.createElement( 'div' );
button.id = 'button';
button.textContent = 'View source';
button.addEventListener( 'click', function ( event ) {
var array = location.href.split( '/' );
array.pop();
window.open( 'view-source:' + array.join( '/' ) + '/' + selected + '.html' );
}, false );
button.style.display = 'none';
document.body.appendChild( button );
var divs = {};
var SELECTED = null;
var selected = null;
for ( var key in files ) {
......@@ -365,15 +394,17 @@
var load = function ( file ) {
if ( SELECTED !== null ) SELECTED.className = 'link';
if ( selected !== null ) divs[ selected ].className = 'link';
SELECTED = divs[ file ];
SELECTED.className = 'link selected';
selected = file;
divs[ selected ].className = 'link selected';
window.location.hash = file;
viewer.src = file + '.html';
viewer.focus();
button.style.display = '';
};
if ( window.location.hash !== '' ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册