Commit 19fbe3dc authored by techird's avatar techird

merge

parents f7937942 2c1d1e6e
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
</body> </body>
<script> <script>
minder = new KityMinder.Minder({ minder = new KityMinder.Minder({
modules:["ExampleModule","RenderModule"],
renderTo: document.body renderTo: document.body
}); });
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
}] }]
}] }]
}); });
minder.execCommand( 'renderroot' ); minder.execCommand( 'renderroot',minder);
minder.reset();
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -26,6 +26,7 @@ kity.extendClass( Minder, { ...@@ -26,6 +26,7 @@ kity.extendClass( Minder, {
if ( !TargetCommand ) { if ( !TargetCommand ) {
return false; return false;
} }
command = new TargetCommand(); command = new TargetCommand();
cmdArgs = Array.prototype.slice.call( arguments, 1 ); cmdArgs = Array.prototype.slice.call( arguments, 1 );
......
// 模块声明周期维护 // 模块声明周期维护
kity.extendClass( Minder, { kity.extendClass( Minder, {
_initModules: function ( option ) { _initModules: function () {
this._commands = {}; this._commands = {};
this._query = {}; this._query = {};
this._modules = {};
var _modules = KityMinder.getModules(); var _modules = KityMinder.getModules();
var _modulesList = ( function () { var _modulesList = ( function () {
var _list = []; var _list = [];
...@@ -11,14 +12,16 @@ kity.extendClass( Minder, { ...@@ -11,14 +12,16 @@ kity.extendClass( Minder, {
} }
return _list; return _list;
} )(); } )();
var _configModules = option.modules || _modulesList; var _configModules = this._options.modules || _modulesList;
console.log( _configModules );
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++ ) {
var key = _configModules[ i ]; var key = _configModules[ i ];
if ( !_modules[ key ] ) continue;
//执行模块初始化,抛出后续处理对象 //执行模块初始化,抛出后续处理对象
var moduleDeals = _modules[ key ].call( me ); var moduleDeals = _modules[ key ].call( me );
this._modules[ key ] = moduleDeals;
if ( moduleDeals.initial ) { if ( moduleDeals.initial ) {
moduleDeals.initial.call( me ); moduleDeals.initial.call( me );
} }
...@@ -44,10 +47,23 @@ kity.extendClass( Minder, { ...@@ -44,10 +47,23 @@ kity.extendClass( Minder, {
}, },
destroy: function () { destroy: function () {
var me = this;
var _modulesList = me._options.modules;
var _modules = me._modules;
//解除事件绑定
me._resetEvents();
for ( var key in _modules ) {
if ( !_modules[ key ].destroy ) continue;
_modules[ key ].destroy.call( me );
}
}, },
reset: function () { reset: function () {
var me = this;
var _modules = this._modules;
for ( var key in _modules ) {
if ( !_modules[ key ].reset ) continue;
_modules[ key ].reset.call( me );
}
} }
} ); } );
\ No newline at end of file
...@@ -93,6 +93,16 @@ KityMinder.registerModule( "ExampleModule", function () { ...@@ -93,6 +93,16 @@ KityMinder.registerModule( "ExampleModule", function () {
"selectionchange": function ( e ) { "selectionchange": function ( e ) {
// 选区改变后的事件 // 选区改变后的事件
} }
},
// TODO: 定义模块的destroy方法
"destroy": function () {
console.log( "destroy" );
},
// TODO: 定义模块的reset方法
"reset": function () {
console.log( "reset" );
} }
}; };
} ); } );
\ No newline at end of file
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