Commit f4ec4b92 authored by Akikonata's avatar Akikonata

Merge branch 'dev' of https://github.com/kitygraph/kityminder into dev

parents ef57be43 19fbe3dc
......@@ -20,13 +20,13 @@ kity.extendClass( Minder, {
}
},
execCommand: function ( name ) {
var TargetCommand, command, cmdArgs, eventParams, stoped;
var TargetCommand, command, cmdArgs, eventParams, stoped, isTopCommand;
TargetCommand = this._getCommand( name );
console.log( TargetCommand );
if ( !TargetCommand ) {
return false;
}
command = new TargetCommand();
cmdArgs = Array.prototype.slice.call( arguments, 1 );
......@@ -37,20 +37,23 @@ kity.extendClass( Minder, {
commandArgs: cmdArgs
};
this._executingCommand = this._executingCommand || command;
if ( this._executingCommand == command ) {
stoped = this._fire( new MinderEvent( 'beforecommand', eventParams, true ) );
if ( !stoped ) {
if ( !this._executingCommand ) {
this._executingCommand = command;
isTopCommand = true;
} else {
isTopCommand = false;
}
this._fire( new MinderEvent( "precommand", eventParams, false ) );
stoped = this._fire( new MinderEvent( 'beforecommand', eventParams, true ) );
command.execute.apply( command, [ this ].concat( cmdArgs ) );
if ( !stoped ) {
this._fire( new MinderEvent( "command", eventParams, false ) );
this._fire( new MinderEvent( "precommand", eventParams, false ) );
command.execute.apply( command, [ this ].concat( cmdArgs ) );
this._fire( new MinderEvent( "command", eventParams, false ) );
// 顶级命令才触发事件
if ( isTopCommand ) {
if ( command.isContentChanged() ) {
this._firePharse( new MinderEvent( 'contentchange' ) );
}
......@@ -59,10 +62,11 @@ kity.extendClass( Minder, {
}
this._firePharse( new MinderEvent( 'interactchange' ) );
}
}
// 顶级事件执行完毕才能清楚顶级事件的执行标记
if ( isTopCommand ) {
this._executingCommand = null;
} else {
command.execute.apply( command, [ this ].concat( cmdArgs ) );
}
},
......
......@@ -7,6 +7,10 @@ kity.extendClass( Minder, {
this._bindPaperEvents();
this._bindKeyboardEvents();
},
_resetEvents: function () {
this._initEvents();
this._bindEvents();
},
// TODO: mousemove lazy bind
_bindPaperEvents: function () {
var minder = this;
......
......@@ -12,15 +12,17 @@
var MinderDefaultOptions = {};
var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
constructor: function ( options ) {
this._options = options || {};
options = Utils.extend( window.KITYMINDER_CONFIG || {}, MinderDefaultOptions, options || {} );
constructor: function ( arg0, arg1 ) {
var options = typeof ( arg0 ) === 'string' ? Utils.extend( arg1 || {}, {
renderTo: arg0
} ) : ( arg0 || {} );
this._options = Utils.extend( window.KITYMINDER_CONFIG || {}, MinderDefaultOptions, options );
this._initEvents();
this._initMinder( options );
this._initModules( options );
this._initMinder();
this._initModules();
},
_initMinder: function ( option ) {
_initMinder: function () {
this._rc = new kity.Group();
this._paper = new kity.Paper();
......@@ -29,8 +31,8 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._root = new MinderNode( this );
this._rc.addShape( this._root.getRenderContainer() );
if ( option.renderTo ) {
this.renderTo( option.renderTo );
if ( this._options.renderTo ) {
this.renderTo( this._options.renderTo );
}
},
......
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