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

Editor: Refactored edit button code once again.

上级 b5cc08da
......@@ -13,6 +13,8 @@ var Config = function ( name ) {
'project/renderer/gammaInput': false,
'project/renderer/gammaOutput': false,
'project/renderer/shadows': true,
'project/editable': false,
'project/vr': false,
'settings/history': false
......
......@@ -285,6 +285,23 @@ Menubar.File = function ( editor ) {
content = content.replace( '<!-- includes -->', includes.join( '\n\t\t' ) );
var editButton = '';
if ( editor.config.getKey( 'project/editable' ) ) {
editButton = `
var button = document.createElement( 'a' );
button.href = 'https://threejs.org/editor/#file=' + location.href.split( '/' ).slice( 0, - 1 ).join( '/' ) + '/app.json';
button.style.cssText = 'position: absolute; bottom: 20px; right: 20px; padding: 7px 10px 6px 10px; color: #fff; border: 1px solid #fff; text-decoration: none;';
button.target = '_blank';
button.textContent = 'EDIT';
document.body.appendChild( button );
`;
}
content = content.replace( '/* edit button */', editButton );
zip.file( 'index.html', content );
} );
......
......@@ -101,13 +101,26 @@ Sidebar.Project = function ( editor ) {
container.add( rendererPropertiesRow );
// Editable
var editableRow = new UI.Row();
var editable = new UI.Checkbox( config.getKey( 'project/editable' ) ).setLeft( '100px' ).onChange( function () {
config.setKey( 'project/editable', this.getValue() );
} );
editableRow.add( new UI.Text( 'Editable' ).setWidth( '90px' ) );
editableRow.add( editable );
container.add( editableRow );
// VR
var vrRow = new UI.Row();
var vr = new UI.Checkbox( config.getKey( 'project/vr' ) ).setLeft( '100px' ).onChange( function () {
config.setKey( 'project/vr', this.getValue() );
// updateRenderer();
} );
......
......@@ -13,19 +13,6 @@
margin: 0px;
overflow: hidden;
}
#edit {
position: absolute;
bottom: 20px;
right: 20px;
padding: 8px;
text-decoration: none;
background-color: #fff;
color: #555;
opacity: 0.5;
}
#edit:hover {
opacity: 1;
}
</style>
</head>
<body ontouchstart="">
......@@ -47,18 +34,8 @@
window.addEventListener( 'resize', function () {
player.setSize( window.innerWidth, window.innerHeight );
} );
if ( location.search === '?edit' ) {
var button = document.createElement( 'a' );
button.id = 'edit';
button.href = 'https://threejs.org/editor/#file=' + location.href.split( '/' ).slice( 0, - 1 ).join( '/' ) + '/app.json';
button.target = '_blank';
button.textContent = 'EDIT';
document.body.appendChild( button );
}
} );
/* edit button */
</script>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册