Commit c9c91572 authored by techird's avatar techird

import

parent 1566b267
......@@ -70,7 +70,18 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this.setData( 'type', type );
},
getType: function ( type ) {
return this.getData( 'type' );
var cached = this.getData( 'type' );
if ( cached ) {
return cached;
}
var level = 0;
while ( this.parent ) {
level++;
if ( level > 1 ) break;
}
cached = [ 'root', 'main', 'sub' ][ level ];
this.setData( 'type', cached );
return cached;
},
setText: function ( text ) {
this.setData( 'text', text );
......@@ -231,7 +242,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
var _tmp = new KM.MinderNode( isClonedNode.getText() );
_tmp.data = Utils.clonePlainObject( isClonedNode.getData() );
_tmp.tmpData = Utils.clonePlainObject( isClonedNode.getTmpData() )
_tmp.tmpData = Utils.clonePlainObject( isClonedNode.getTmpData() )
_tmp.parent = parent;
if ( parent ) {
parent.children.push( _tmp );
......@@ -257,8 +268,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return false;
}
for ( var i = 0, ci;
( ci = this.children[ i ] );i++ ) {
if ( ci.equals( node.children[i] ) === false ) {
( ci = this.children[ i ] ); i++ ) {
if ( ci.equals( node.children[ i ] ) === false ) {
return false;
}
}
......@@ -274,26 +285,26 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
clearChildren: function () {
this.children = [];
},
isHighlight : function(){
return this.getTmpData('highlight')
isHighlight: function () {
return this.getTmpData( 'highlight' )
},
setTmpData : function(a,v){
setTmpData: function ( a, v ) {
var me = this;
if(utils.isObject(a)){
utils.each(a,function(val,key){
me.setTmpData(key,val)
})
if ( utils.isObject( a ) ) {
utils.each( a, function ( val, key ) {
me.setTmpData( key, val )
} )
}
if(v === undefined || v === null || v === ''){
delete this.tmpData[a];
}else {
this.tmpData[a] = v;
if ( v === undefined || v === null || v === '' ) {
delete this.tmpData[ a ];
} else {
this.tmpData[ a ] = v;
}
},
getTmpData:function(a){
getTmpData: function ( a ) {
if ( a === undefined ) {
return this.tmpData;
}
return this.tmpData[a]
return this.tmpData[ a ]
}
} );
\ No newline at end of file
......@@ -18,17 +18,13 @@ KityMinder.registerModule( "DropFile", function () {
var minder = this;
if ( e.dataTransfer.files ) {
var reader = new FileReader();
reader.onload = function () {};
var data = readFile( e.dataTransfer.files[ 0 ] );
minder.importData( data );
reader.onload = function ( e ) {
minder.importData( e.target.result );
};
reader.readAsText( e.dataTransfer.files[ 0 ] );
}
}
function readFile( e ) {
var reader = new FileReader();
return reader.readAsText();
}
return {
events: {
ready: init
......
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