Commit 3cb3e8bc authored by Akikonata's avatar Akikonata

dev

parent 94ba87d1
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
</body> </body>
<script> <script>
minder = new km.KityMinder(null,{ minder = new KityMinder.Minder(null,{
modules:["test","test1","test2"] modules:["ExampleModule"]
}); });
minder.importData({ minder.importData({
...@@ -40,6 +40,6 @@ ...@@ -40,6 +40,6 @@
}] }]
}] }]
}); });
minder.execCommand( 'rendertree', node ); 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',
......
...@@ -21,8 +21,10 @@ kity.extendClass( Minder, { ...@@ -21,8 +21,10 @@ kity.extendClass( Minder, {
}, },
execCommand: function ( name ) { execCommand: function ( name ) {
var me = this; var me = this;
var _commands = this._commands; var _action = this._getCommand( name );
var _action = new _commands[ name.toLowerCase() ](); if ( !_action ) {
return false;
}
var cmdArgs = Array.prototype.slice.call( arguments, 1 ); var cmdArgs = Array.prototype.slice.call( arguments, 1 );
......
// 导入导出 // 导入导出
kity.extendClass( KityMinder, { kity.extendClass( Minder, {
exportData: function ( node ) { exportData: function ( node ) {
var exported = {}; var exported = {};
node = node || this.getRoot(); node = node || this.getRoot();
......
// 事件机制 // 事件机制
kity.extendClass( KityMinder, { kity.extendClass( Minder, {
_initEvents: function () { _initEvents: function () {
this._eventCallbacks = {}; this._eventCallbacks = {};
this._bindPaperEvents(); this._bindPaperEvents();
......
...@@ -3,7 +3,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -3,7 +3,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
// 初始化 // 初始化
this._initMinder( id, option || {} ); this._initMinder( id, option || {} );
this._initEvents(); this._initEvents();
this._initModules(); this._initModules( option );
}, },
_initMinder: function ( id, option ) { _initMinder: function ( id, option ) {
......
// 模块声明周期维护 // 模块声明周期维护
kity.extendClass( Minder, { kity.extendClass( Minder, {
_initModules: function () { _initModules: function ( option ) {
this._commands = {}; this._commands = {};
this._query = {}; this._query = {};
var _modules = Minder.getModules(); var _modules = KityMinder.getModules();
var _modulesList = ( function () { var _modulesList = ( function () {
var _list = []; var _list = [];
for ( var key in _modules ) { for ( var key in _modules ) {
_list.push( key ); _list.push( key );
} }
} )(); } )();
var _configModules = this.option.modules || _modulesList; var _configModules = option.modules || _modulesList;
if ( _modules ) { if ( _modules ) {
var me = this; var me = this;
for ( var i = 0; i < _configModules.length; i++ ) { for ( var i = 0; i < _configModules.length; i++ ) {
......
// 选区管理 // 选区管理
kity.extendClass( KityMinder, { kity.extendClass( Minder, {
getSelectedNodes: function () { getSelectedNodes: function () {
return this._selectedNodes || ( this._selectedNodes = [] ); return this._selectedNodes || ( this._selectedNodes = [] );
}, },
......
var MinderEvent = kity.createClass( 'MindEvent', {
constructor: function ( type, params, cancelable ) {
params = params || {};
if ( params.getType && params.getType() == 'ShapeEvent' ) {
this.kityEvent = params;
this.getPosition = params.getPosition.bind( params );
} else {
kity.Utils.extend( this, params );
}
this.type = type;
this._cancelable = cancelable || false;
if ( params.targetShape ) {
this.getTargetNode = function () {
var findShape = params.targetShape;
while ( !findShape.minderNode && findShape.container ) {
findShape = findShape.container;
}
return findShape.minderNode || null;
};
}
},
cancel: function () {
this._canceled = true;
},
cancelImmediately: function () {
this._immediatelyCanceld = true;
this._canceled = true;
},
shouldCancel: function () {
return this._cancelable && this._canceled;
},
shouldCancelImmediately: function () {
return this._cancelable && this._immediatelyCanceld;
}
} );
\ 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