Commit 3cd99103 authored by techird's avatar techird

merge from panzheng

parents 9a66a05c 3bf2700e
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
</body> </body>
<script> <script>
minder = new km.KityMinder(); minder = new KityMinder.Minder(null,{
});
minder.importData({ minder.importData({
data: { data: {
...@@ -38,6 +40,6 @@ ...@@ -38,6 +40,6 @@
}] }]
}] }]
}); });
minder.update(); minder.execCommand( 'renderroot' );
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -3,9 +3,16 @@ ...@@ -3,9 +3,16 @@
$dependency = Array( $dependency = Array(
'src/core/km.js', 'src/core/km.js',
'src/core/command.js', 'src/core/command.js',
'src/core/mindernode.js', 'src/core/node.js',
'src/core/minderevent.js', 'src/core/module.js',
'src/core/kityminder.js', 'src/core/event.js',
'src/core/minder.js',
'src/core/minder.data.js',
'src/core/minder.event.js',
'src/core/minder.module.js',
'src/core/minder.command.js',
'src/core/minder.node.js',
'src/core/minder.select.js',
'src/module/connect.js', 'src/module/connect.js',
'src/module/history.js', 'src/module/history.js',
'src/module/icon.js', 'src/module/icon.js',
......
kity.extendClass( Minder, { kity.extendClass( Minder, {
_getCommand: function ( name ) {
return this._commands[ name.toLowerCase() ];
},
_getQuery: function ( name ) {
if ( !this._query[ name ] ) {
var Cmd = this._getCommand( name );
this._query[ name ] = new Cmd();
}
return this._query[ name ];
},
_queryCommand: function ( name, type ) {
var me = this;
var query = this._getQuery( name );
var queryFunc = query[ name ][ "state" + type ];
if ( queryFunc ) {
return queryFunc( me );
} else {
return 0;
}
},
execCommand: function ( name ) { execCommand: function ( name ) {
var TargetCommand, command, cmdArgs, eventParams, stoped; var TargetCommand, command, cmdArgs, eventParams, stoped;
TargetCommand = this._getCommand( name ); TargetCommand = this._getCommand( name );
if ( !TargetCommand ) {
return false;
}
command = new TargetCommand(); command = new TargetCommand();
cmdArgs = Array.prototype.slice.call( arguments, 1 ); cmdArgs = Array.prototype.slice.call( arguments, 1 );
...@@ -33,6 +56,7 @@ kity.extendClass( Minder, { ...@@ -33,6 +56,7 @@ kity.extendClass( Minder, {
if ( command.isSelectionChanged() ) { if ( command.isSelectionChanged() ) {
this._firePharse( new MinderEvent( 'selectionchange' ) ); this._firePharse( new MinderEvent( 'selectionchange' ) );
} }
this._firePharse( new MinderEvent( 'interactchange' ) );
} }
this._executingCommand = null; this._executingCommand = null;
...@@ -42,31 +66,10 @@ kity.extendClass( Minder, { ...@@ -42,31 +66,10 @@ kity.extendClass( Minder, {
}, },
queryCommandState: function ( name ) { queryCommandState: function ( name ) {
if ( !_commands[ name.toLowerCase() ] ) { return this._queryCommand( name, "State" );
return false;
}
if ( !_query[ name ] ) {
_query[ name ] = new _commands[ name ]();
}
if ( _query[ name ].queryState ) {
return _query[ name ].queryState( this );
} else {
return 0;
}
}, },
queryCommandValue: function ( name ) { queryCommandValue: function ( name ) {
if ( !_commands[ name.toLowerCase() ] ) { return this._queryCommand( name, "Value" );
return false;
}
if ( !_query[ name ] ) {
_query[ name ] = new _commands[ name ]();
}
if ( _query[ name ].queryValue ) {
return _query[ name ].queryValue( this );
} else {
return 0;
}
} }
} ); } );
\ No newline at end of file
...@@ -16,6 +16,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -16,6 +16,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
options = Utils.extend( KITYMINDER_CONFIG || {}, MinderDefaultOptions, options || {} ); options = Utils.extend( KITYMINDER_CONFIG || {}, MinderDefaultOptions, options || {} );
// 初始化 // 初始化
this._initMinder( options ); this._initMinder( options );
this._initEvents();
this._initModules( options ); this._initModules( options );
}, },
......
// 模块声明周期维护 // 模块声明周期维护
kity.extendClass( Minder, { kity.extendClass( Minder, {
_initModules: function () { _initModules: function ( option ) {
this._commands = {};
this._query = {};
var _modules = KityMinder.getModules(); var _modules = KityMinder.getModules();
var _modulesList = ( function () {
var _list = [];
for ( var key in _modules ) {
_list.push( key );
}
return _list;
} )();
var _configModules = option.modules || _modulesList;
if ( _modules ) { if ( _modules ) {
var me = this; var me = this;
for ( var key in _modules ) { for ( var i = 0; i < _configModules.length; i++ ) {
var key = _configModules[ i ];
//执行模块初始化,抛出后续处理对象 //执行模块初始化,抛出后续处理对象
var moduleDeals = _modules[ key ].call( me ); var moduleDeals = _modules[ key ].call( me );
...@@ -16,7 +27,7 @@ kity.extendClass( Minder, { ...@@ -16,7 +27,7 @@ kity.extendClass( Minder, {
var moduleDealsCommands = moduleDeals.commands; var moduleDealsCommands = moduleDeals.commands;
if ( moduleDealsCommands ) { if ( moduleDealsCommands ) {
for ( var _keyC in moduleDealsCommands ) { for ( var _keyC in moduleDealsCommands ) {
_commands[ _keyC ] = moduleDealsCommands[ _keyC ]; this._commands[ _keyC ] = moduleDealsCommands[ _keyC ];
} }
} }
......
...@@ -25,7 +25,7 @@ kity.extendClass( Minder, { ...@@ -25,7 +25,7 @@ kity.extendClass( Minder, {
}, },
update: function ( node ) { update: function ( node ) {
this.execCommand( 'renderroot', node );
return this; return this;
} }
} ); } );
\ No newline at end of file
var MinderNode = km.MinderNode = kity.createClass( "MinderNode", { var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
constructor: function ( treeNotifyHandler ) { constructor: function ( treeNotifyHandler ) {
this.parent = null; this.parent = null;
this.children = []; this.children = [];
......
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