Commit 5584facc authored by Akikonata's avatar Akikonata

undo

parent 60272950
kity.extendClass( Minder, { kity.extendClass(Minder, {
_getCommand: function ( name ) { _getCommand: function (name) {
return this._commands[ name.toLowerCase() ]; return this._commands[name.toLowerCase()];
}, },
_queryCommand: function ( name, type, args ) { _queryCommand: function (name, type, args) {
var cmd = this._getCommand( name ); var cmd = this._getCommand(name);
if ( cmd ) { if (cmd) {
var queryCmd = cmd[ 'query' + type ]; var queryCmd = cmd['query' + type];
if ( queryCmd ) if (queryCmd)
return queryCmd.apply( cmd, [ this ].concat( args ) ); return queryCmd.apply(cmd, [this].concat(args));
} }
return 0; return 0;
}, },
queryCommandState: function ( name ) { queryCommandState: function (name) {
return this._queryCommand( name, "State", Utils.argsToArray( 1 ) ); return this._queryCommand(name, "State", Utils.argsToArray(1));
}, },
queryCommandValue: function ( name ) { queryCommandValue: function (name) {
return this._queryCommand( name, "Value", Utils.argsToArray( 1 ) ); return this._queryCommand(name, "Value", Utils.argsToArray(1));
}, },
execCommand: function ( name ) { execCommand: function (name) {
name = name.toLowerCase(); name = name.toLowerCase();
var cmdArgs = Utils.argsToArray( arguments, 1 ), var cmdArgs = Utils.argsToArray(arguments, 1),
cmd, stoped, result, eventParams; cmd, stoped, result, eventParams;
var me = this; var me = this;
cmd = this._getCommand( name ); cmd = this._getCommand(name);
eventParams = { eventParams = {
command: cmd, command: cmd,
commandName: name.toLowerCase(), commandName: name.toLowerCase(),
commandArgs: cmdArgs commandArgs: cmdArgs
}; };
if ( !cmd ) { if (!cmd) {
return false; return false;
} }
if ( !this._hasEnterExecCommand && cmd.isNeedUndo() ) { if (!this._hasEnterExecCommand && cmd.isNeedUndo()) {
this._hasEnterExecCommand = true; this._hasEnterExecCommand = true;
stoped = this._fire( new MinderEvent( 'beforeExecCommand', eventParams, true ) ); stoped = this._fire(new MinderEvent('beforeExecCommand', eventParams, true));
if ( !stoped ) { if (!stoped) {
//保存场景 //保存场景
this._fire( new MinderEvent( 'saveScene' ) ); this._fire(new MinderEvent('saveScene'));
this._fire( new MinderEvent( "preExecCommand", eventParams, false ) ); this._fire(new MinderEvent("preExecCommand", eventParams, false));
result = cmd.execute.apply( cmd, [ me ].concat( cmdArgs ) ); result = cmd.execute.apply(cmd, [me].concat(cmdArgs));
this._fire( new MinderEvent( 'execCommand', eventParams, false ) ); this._fire(new MinderEvent('execCommand', eventParams, false));
//保存场景 //保存场景
this._fire( new MinderEvent( 'saveScene' ) ); this._fire(new MinderEvent('saveScene'));
if ( cmd.isContentChanged() ) { if (cmd.isContentChanged()) {
this._firePharse( new MinderEvent( 'contentchange' ) ); this._firePharse(new MinderEvent('contentchange'));
} }
if ( cmd.isSelectionChanged() ) { if (cmd.isSelectionChanged()) {
this._firePharse( new MinderEvent( 'selectionchange' ) ); this._firePharse(new MinderEvent('selectionchange'));
} }
this._firePharse( new MinderEvent( 'interactchange' ) ); this._firePharse(new MinderEvent('interactchange'));
} }
this._hasEnterExecCommand = false; this._hasEnterExecCommand = false;
} else { } else {
result = cmd.execute.apply( cmd, [ me ].concat( cmdArgs ) ); result = cmd.execute.apply(cmd, [me].concat(cmdArgs));
if(!this._hasEnterExecCommand){ if (!this._hasEnterExecCommand) {
if ( cmd.isSelectionChanged() ) { if (cmd.isSelectionChanged()) {
this._firePharse( new MinderEvent( 'selectionchange' ) ); this._firePharse(new MinderEvent('selectionchange'));
} }
this._firePharse( new MinderEvent( 'interactchange' ) ); this._firePharse(new MinderEvent('interactchange'));
} }
} }
return result === undefined ? null : result; return result === undefined ? null : result;
} }
} ); });
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
...@@ -266,7 +266,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -266,7 +266,7 @@ KityMinder.registerModule("LayoutDefault", function () {
var result = []; var result = [];
for (var len = 0; len < children.length; len++) { for (var len = 0; len < children.length; len++) {
var l = children[len].getLayout(); var l = children[len].getLayout();
if (l.added) { if (l && l.added) {
result.push(children[len]); result.push(children[len]);
} }
} }
...@@ -442,65 +442,6 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -442,65 +442,6 @@ KityMinder.registerModule("LayoutDefault", function () {
getCurrentLayoutStyle: function () { getCurrentLayoutStyle: function () {
return nodeStyles; return nodeStyles;
}, },
highlightNode: function (node) {
var highlight = node.isHighlight();
var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType];
var Layout = node.getLayout();
switch (nodeType) {
case "root":
case "main":
if (highlight) {
Layout.bgRect.fill(nodeStyle.highlight);
} else {
Layout.bgRect.fill(nodeStyle.fill);
}
break;
case "sub":
if (highlight) {
Layout.highlightshape.fill(nodeStyle.highlight).setOpacity(1);
node.getTextShape().fill(node.getData('fontcolor') || 'black');
} else {
Layout.highlightshape.setOpacity(0);
node.getTextShape().fill(node.getData('fontcolor') || 'white');
}
break;
default:
break;
}
},
updateLayout: function (node) {
node.getContRc().clear();
this._firePharse(new MinderEvent("RenderNodeLeft", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeCenter", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeRight", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeBottom", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeTop", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNode", {
node: node
}, false));
updateShapeByCont(node);
var set1 = updateLayoutHorizon(node);
var set2 = updateLayoutVertical(node, node.getParent(), "change");
var set = uSet(set1, set2);
for (var i = 0; i < set.length; i++) {
translateNode(set [i]);
updateConnectAndshIcon(set [i]);
}
if (this.isNodeSelected(node)) {
this.highlightNode(node)
}
},
initStyle: function () { initStyle: function () {
//渲染根节点 //渲染根节点
var _root = minder.getRoot(); var _root = minder.getRoot();
...@@ -545,6 +486,38 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -545,6 +486,38 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
_root.setPoint(_root.getLayout().x, _root.getLayout().y); _root.setPoint(_root.getLayout().x, _root.getLayout().y);
}, },
updateLayout: function (node) {
node.getContRc().clear();
this._firePharse(new MinderEvent("RenderNodeLeft", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeCenter", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeRight", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeBottom", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNodeTop", {
node: node
}, false));
this._firePharse(new MinderEvent("RenderNode", {
node: node
}, false));
updateShapeByCont(node);
var set1 = updateLayoutHorizon(node);
var set2 = updateLayoutVertical(node, node.getParent(), "change");
var set = uSet(set1, set2);
for (var i = 0; i < set.length; i++) {
translateNode(set [i]);
updateConnectAndshIcon(set [i]);
}
if (this.isNodeSelected(node)) {
this.highlightNode(node)
}
},
expandNode: function (ico) { expandNode: function (ico) {
var isExpand, node; var isExpand, node;
if (ico instanceof MinderNode) { if (ico instanceof MinderNode) {
...@@ -746,6 +719,33 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -746,6 +719,33 @@ KityMinder.registerModule("LayoutDefault", function () {
_buffer.shift(); _buffer.shift();
} }
} }
},
highlightNode: function (node) {
var highlight = node.isHighlight();
var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType];
var Layout = node.getLayout();
switch (nodeType) {
case "root":
case "main":
if (highlight) {
Layout.bgRect.fill(nodeStyle.highlight);
} else {
Layout.bgRect.fill(nodeStyle.fill);
}
break;
case "sub":
if (highlight) {
Layout.highlightshape.fill(nodeStyle.highlight).setOpacity(1);
node.getTextShape().fill(node.getData('fontcolor') || 'black');
} else {
Layout.highlightshape.setOpacity(0);
node.getTextShape().fill(node.getData('fontcolor') || 'white');
}
break;
default:
break;
}
} }
}; };
this.addLayoutStyle("default", _style); this.addLayoutStyle("default", _style);
......
...@@ -283,21 +283,21 @@ KityMinder.registerModule("LayoutModule", function () { ...@@ -283,21 +283,21 @@ KityMinder.registerModule("LayoutModule", function () {
cmdName: 'removenode' cmdName: 'removenode'
}, { }, {
divider: 1 divider: 1
},{ }, {
label: this.getLang('layout.default'), label: this.getLang('layout.default'),
exec: function () { exec: function () {
this.execCommand('switchlayout','default'); this.execCommand('switchlayout', 'default');
this.initStyle(); this.initStyle();
}, },
cmdName: 'switchlayout' cmdName: 'switchlayout'
},{ }, {
label: this.getLang('layout.bottom'), label: this.getLang('layout.bottom'),
exec: function () { exec: function () {
this.execCommand('switchlayout', 'bottom'); this.execCommand('switchlayout', 'bottom');
this.initStyle(); this.initStyle();
}, },
cmdName: 'switchlayout' cmdName: 'switchlayout'
} }
], ],
"defaultOptions": { "defaultOptions": {
......
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