Browse Source

Editor: Added autosave checkbox.

Mr.doob 11 years ago
parent
commit
67251e6d4d
4 changed files with 28 additions and 8 deletions
  1. 14 4
      editor/index.html
  2. 2 0
      editor/js/Config.js
  3. 11 3
      editor/js/Menubar.Status.js
  4. 1 1
      editor/js/libs/ui.js

+ 14 - 4
editor/index.html

@@ -142,16 +142,26 @@
 				var timeout;
 				var timeout;
 
 
 				var saveState = function ( scene ) {
 				var saveState = function ( scene ) {
+				
+					if ( editor.config.getKey( 'autosave' ) === false ) {
 
 
-					clearTimeout( timeout );
+						return;
+
+					}
 
 
-					editor.signals.savingStarted.dispatch();
+					clearTimeout( timeout );
 
 
 					timeout = setTimeout( function () {
 					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 );
 					}, 1000 );
 
 

+ 2 - 0
editor/js/Config.js

@@ -3,6 +3,8 @@ var Config = function () {
 	var name = 'threejs-editor';
 	var name = 'threejs-editor';
 
 
 	var storage = {
 	var storage = {
+		'autosave': true,
+	
 		'theme': 'css/light.css',
 		'theme': 'css/light.css',
 		'camera/position': [ 500, 250, 500 ],
 		'camera/position': [ 500, 250, 500 ],
 		'camera/target': [ 0, 0, 0 ],
 		'camera/target': [ 0, 0, 0 ],

+ 11 - 3
editor/js/Menubar.Status.js

@@ -3,20 +3,28 @@ Menubar.Status = function ( editor ) {
 	var container = new UI.Panel();
 	var container = new UI.Panel();
 	container.setClass( 'menu right' );
 	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();
 	var title = new UI.Panel();
 	title.setClass( 'title' );
 	title.setClass( 'title' );
-	title.setTextContent( '...' );
+	title.setTextContent( 'Autosave' );
 	container.add( title );
 	container.add( title );
 
 
 	editor.signals.savingStarted.add( function () {
 	editor.signals.savingStarted.add( function () {
 
 
-		title.setTextContent( 'Saving' );
+		title.setTextDecoration( 'underline' );
 
 
 	} );
 	} );
 
 
 	editor.signals.savingFinished.add( function () {
 	editor.signals.savingFinished.add( function () {
 
 
-		title.setTextContent( 'Saved' );
+		title.setTextDecoration( 'none' );
 
 
 	} );
 	} );
 
 

+ 1 - 1
editor/js/libs/ui.js

@@ -52,7 +52,7 @@ UI.Element.prototype = {
 
 
 var properties = [ 'position', 'left', 'top', 'right', 'bottom', 'width', 'height', 'border', 'borderLeft',
 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',
 '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 ) {
 properties.forEach( function ( property ) {