提交 d71c0e28 编写于 作者: D Daniel

Minor changes

- after a browser refresh the last executed undo is now selected in the
Sidebar.History
上级 2436aa4c
......@@ -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
......@@ -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 ] );
},
......
module( "Serialization" );
test( "Test Serialization (simple)", function() {
test( "Test Serialization", function() {
// setup
var editor = new Editor();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册