Commit 50d3aa4b authored by campaign's avatar campaign

改进了undo/redo的交互方式

parent 132599f0
......@@ -255,22 +255,49 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
return cloneNode(null, this);
},
equals: function(node) {
equals: function(node,ignoreSelected) {
var me = this;
function restoreSelected(){
if(isSelectedA){
me.setSelectedFlag();
}
if(isSelectedB){
node.setSelectedFlag();
}
}
if(ignoreSelected){
var isSelectedA = false;
var isSelectedB = false;
if(me.isSelected()){
isSelectedA = true;
me.clearSelectedFlag();
}
if(node.isSelected()){
isSelectedB = true;
node.clearSelectedFlag();
}
}
if (node.children.length != this.children.length) {
restoreSelected();
return false;
}
if (utils.compareObject(node.getData(), this.getData()) === false) {
if (utils.compareObject(node.getData(), me.getData()) === false) {
restoreSelected();
return false;
}
if (utils.compareObject(node.getTmpData(), this.getTmpData()) === false) {
if (utils.compareObject(node.getTmpData(), me.getTmpData()) === false) {
restoreSelected();
return false;
}
for (var i = 0, ci;
(ci = this.children[i]); i++) {
if (ci.equals(node.children[i]) === false) {
(ci = me.children[i]); i++) {
if (ci.equals(node.children[i],ignoreSelected) === false) {
restoreSelected();
return false;
}
}
restoreSelected();
return true;
},
......
......@@ -14,27 +14,8 @@ KityMinder.registerModule("HistoryModule", function() {
return this.getData().clone();
},
equals: function(scene) {
var nodeA = scene.getData(),isSelectedA = false;
var nodeB = this.getData(),isSelectedB = false;
if(nodeA.isSelected()){
isSelectedA = true;
nodeA.clearSelectedFlag();
}
if(nodeB.isSelected()){
isSelectedB = true;
nodeB.clearSelectedFlag();
}
var result = nodeB.equals(nodeA);
return this.getData().equals(scene.getData());
if(isSelectedA){
nodeA.setSelectedFlag();
}
if(isSelectedB){
nodeB.setSelectedFlag();
}
return result;
},
isInputStatus:function(){
return this.inputStatus;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment