From d71c0e2895eac39bd745947741a8fa3707c67a3e Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 6 Oct 2015 16:51:58 +0200 Subject: [PATCH] Minor changes - after a browser refresh the last executed undo is now selected in the Sidebar.History --- editor/js/Cmd.js | 1 - editor/js/History.js | 17 ++++++++--------- test/unit/editor/TestSerialization.js | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/editor/js/Cmd.js b/editor/js/Cmd.js index 954fce4b23..f3b43315bb 100755 --- a/editor/js/Cmd.js +++ b/editor/js/Cmd.js @@ -36,6 +36,5 @@ Cmd.prototype.fromJSON = function ( json ) { this.type = json.type; this.id = json.id; this.name = json.name; - this.json = json; }; \ No newline at end of file diff --git a/editor/js/History.js b/editor/js/History.js index 0a71ada501..58305926ef 100644 --- a/editor/js/History.js +++ b/editor/js/History.js @@ -70,10 +70,10 @@ History.prototype = { cmd.id = ++this.idCounter; } - cmd.name = optionalName !== undefined ? optionalName : cmd.name; + cmd.name = ( optionalName !== undefined ) ? optionalName : cmd.name; cmd.execute(); cmd.inMemory = true; - cmd.json = cmd.toJSON(); // serialize cmd immediately after execution + cmd.json = cmd.toJSON(); // serialize the cmd immediately after execution and append the json to the cmd this.lastCmdTime = new Date(); @@ -164,8 +164,7 @@ History.prototype = { for ( var i = 0 ; i < this.undos.length; i++ ) { - var cmd = this.undos[ i ]; - undos.push( cmd.json ); + undos.push( this.undos[ i ].json ); } @@ -177,8 +176,7 @@ History.prototype = { for ( var i = 0 ; i < this.redos.length; i++ ) { - var cmd = this.redos[ i ]; - redos.push( cmd.json ); + redos.push( this.redos[ i ].json ); } @@ -198,7 +196,7 @@ History.prototype = { var cmd = new window[ cmdJSON.type ](); // creates a new object of type "json.type" cmd.json = cmdJSON; this.undos.push( cmd ); - this.idCounter = cmdJSON.id > this.idCounter ? cmdJSON.id : this.idCounter; // set last used idCounter + this.idCounter = ( cmdJSON.id > this.idCounter ) ? cmdJSON.id : this.idCounter; // set last used idCounter } @@ -208,11 +206,12 @@ History.prototype = { var cmd = new window[ cmdJSON.type ](); // creates a new object of type "json.type" cmd.json = cmdJSON; this.redos.push( cmd ); - this.idCounter = cmdJSON.id > this.idCounter ? cmdJSON.id : this.idCounter; // set last used idCounter + this.idCounter = ( cmdJSON.id > this.idCounter ) ? cmdJSON.id : this.idCounter; // set last used idCounter } - this.editor.signals.historyChanged.dispatch(); + // Select the last executed undo-command + this.editor.signals.historyChanged.dispatch( this.undos[ this.undos.length - 1 ] ); }, diff --git a/test/unit/editor/TestSerialization.js b/test/unit/editor/TestSerialization.js index ae7e2b4f63..80680779a8 100755 --- a/test/unit/editor/TestSerialization.js +++ b/test/unit/editor/TestSerialization.js @@ -1,6 +1,6 @@ module( "Serialization" ); -test( "Test Serialization (simple)", function() { +test( "Test Serialization", function() { // setup var editor = new Editor(); -- GitLab