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

Editor: Added autosave checkbox.

上级 d07c4d5f
......@@ -142,16 +142,26 @@
var timeout;
var saveState = function ( scene ) {
if ( editor.config.getKey( 'autosave' ) === false ) {
clearTimeout( timeout );
return;
}
editor.signals.savingStarted.dispatch();
clearTimeout( timeout );
timeout = setTimeout( function () {
editor.storage.set( editor.scene.toJSON() );
editor.signals.savingStarted.dispatch();
timeout = setTimeout( function () {
editor.storage.set( editor.scene.toJSON() );
editor.signals.savingFinished.dispatch();
editor.signals.savingFinished.dispatch();
}, 100 );
}, 1000 );
......
......@@ -3,6 +3,8 @@ var Config = function () {
var name = 'threejs-editor';
var storage = {
'autosave': true,
'theme': 'css/light.css',
'camera/position': [ 500, 250, 500 ],
'camera/target': [ 0, 0, 0 ],
......
......@@ -3,20 +3,28 @@ Menubar.Status = function ( editor ) {
var container = new UI.Panel();
container.setClass( 'menu right' );
var checkbox = new UI.Checkbox( editor.config.getKey( 'autosave' ) );
checkbox.onChange( function () {
editor.config.setKey( 'autosave', this.getValue() );
} );
container.add( checkbox );
var title = new UI.Panel();
title.setClass( 'title' );
title.setTextContent( '...' );
title.setTextContent( 'Autosave' );
container.add( title );
editor.signals.savingStarted.add( function () {
title.setTextContent( 'Saving' );
title.setTextDecoration( 'underline' );
} );
editor.signals.savingFinished.add( function () {
title.setTextContent( 'Saved' );
title.setTextDecoration( 'none' );
} );
......
......@@ -52,7 +52,7 @@ UI.Element.prototype = {
var properties = [ 'position', 'left', 'top', 'right', 'bottom', 'width', 'height', 'border', 'borderLeft',
'borderTop', 'borderRight', 'borderBottom', 'borderColor', 'display', 'overflow', 'margin', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'padding', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'color',
'backgroundColor', 'opacity', 'fontSize', 'fontWeight', 'textAlign', 'textTransform', 'cursor' ];
'backgroundColor', 'opacity', 'fontSize', 'fontWeight', 'textAlign', 'textDecoration', 'textTransform', 'cursor' ];
properties.forEach( function ( property ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册