diff --git a/editor/index.html b/editor/index.html index 37ce816464f39c2e4f6c92b3cb0ef44f02838758..dcb0f55f17329e2bd1afa21f619f13af6402f121 100644 --- a/editor/index.html +++ b/editor/index.html @@ -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 ); diff --git a/editor/js/Config.js b/editor/js/Config.js index a55f2f4a7da2738c8d6e96fbac4687b3365cb86a..6c84d375a18e98805ce21d3d100424c00c6dd1c2 100644 --- a/editor/js/Config.js +++ b/editor/js/Config.js @@ -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 ], diff --git a/editor/js/Menubar.Status.js b/editor/js/Menubar.Status.js index bbbf00c6c64286ba54611f3407b5467ca240d3a8..28c89c91a382b79a04b9ce19bdd5b434e3ccc86e 100644 --- a/editor/js/Menubar.Status.js +++ b/editor/js/Menubar.Status.js @@ -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' ); } ); diff --git a/editor/js/libs/ui.js b/editor/js/libs/ui.js index df6644aad900840f3b12f4b1f587ed33d14a5a7b..0019d97861d5ece9aabe71e840668ffdb9a156e3 100644 --- a/editor/js/libs/ui.js +++ b/editor/js/libs/ui.js @@ -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 ) {