Commit b78aaca2 authored by Akikonata's avatar Akikonata

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

parents a18615c0 95d27ab5
This diff is collapsed.
var KityMinder = window.KM = window.KityMinder = {}; var KityMinder =
window.KM =
KityMinder.version = '1.0.0.0'; window.KityMinder = function(){
var instanceMap = {}, instanceId = 0;
KityMinder.createMinder = function ( renderTarget, options ) { return {
version : '1.0.0',
createMinder : function ( renderTarget, options ) {
options = options || {}; options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget; options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
return new Minder( options ); var minder = new Minder( options );
}; this.addMinder(options.renderTo,minder);
return minder;
var instanceMap = {}, instanceId = 0; },
KityMinder.addMinderInstance = function ( target, minder ) { addMinder : function ( target, minder ) {
var id; var id;
if ( typeof ( target ) === 'string' ) { if ( typeof ( target ) === 'string' ) {
id = target; id = target;
...@@ -17,8 +19,16 @@ KityMinder.addMinderInstance = function ( target, minder ) { ...@@ -17,8 +19,16 @@ KityMinder.addMinderInstance = function ( target, minder ) {
id = target.id || ( "KM_INSTANCE_" + instanceId++ ); id = target.id || ( "KM_INSTANCE_" + instanceId++ );
} }
instanceMap[ id ] = minder; instanceMap[ id ] = minder;
}; },
getMinder : function(target,options){
var id;
if ( typeof ( target ) === 'string' ) {
id = target;
} else {
id = target.id || ( "KM_INSTANCE_" + instanceId++ );
}
return instanceMap[ id ] || this.createMinder(target,options);
}
}
}();
KityMinder.getMinder = function ( id ) {
return instanceMap[ id ] || this.createMinder( id );
};
\ No newline at end of file
...@@ -47,7 +47,6 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -47,7 +47,6 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
renderTo: function ( target ) { renderTo: function ( target ) {
this._paper.renderTo( this._renderTarget = target ); this._paper.renderTo( this._renderTarget = target );
this._bindEvents(); this._bindEvents();
KityMinder.addMinderInstance( target, this );
}, },
getRenderContainer: function () { getRenderContainer: function () {
......
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