Commit c9c91572 authored by techird's avatar techird

import

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