Skip to content

Commit

Permalink
Examples section > Converted 'View Source' button to an anchor element
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjoiner committed Sep 29, 2017
1 parent 0a529ac commit b4529d0
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions examples/index.html
Expand Up @@ -87,7 +87,7 @@
overflow: auto;
}

#button {
#viewSrcButton {
position: fixed;
bottom: 20px;
right: 20px;
Expand All @@ -97,7 +97,7 @@
opacity: 0.7;
}

#button:hover {
#viewSrcButton:hover {
cursor: pointer;
opacity: 1;
}
Expand Down Expand Up @@ -277,16 +277,12 @@ <h1><a href="http://threejs.org">three.js</a> / examples</h1>
var container = document.createElement( 'div' );
content.appendChild( container );

var button = document.createElement( 'div' );
button.id = 'button';
button.textContent = 'View source';
button.addEventListener( 'click', function ( event ) {

window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );

}, false );
button.style.display = 'none';
document.body.appendChild( button );
var viewSrcButton = document.createElement( 'a' );
viewSrcButton.id = 'viewSrcButton';
viewSrcButton.target = '_blank';
viewSrcButton.textContent = 'View source';
viewSrcButton.style.display = 'none';
document.body.appendChild( viewSrcButton );

var links = {};
var selected = null;
Expand Down Expand Up @@ -350,11 +346,15 @@ <h1><a href="http://threejs.org">three.js</a> / examples</h1>
window.location.hash = file;
viewer.focus();

button.style.display = '';
panel.classList.toggle( 'collapsed' );

selected = file;

// Reveal "View source" button and set attributes to this example
viewSrcButton.style.display = '';
viewSrcButton.href = 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html';
viewSrcButton.title = 'View source code for ' + getName(selected) + ' on GitHub';

}

if ( window.location.hash !== '' ) {
Expand Down

0 comments on commit b4529d0

Please sign in to comment.