Commit 7eae9ddd authored by Akikonata's avatar Akikonata

added new data

parent b96701df
......@@ -24,5 +24,7 @@
var val = e.target.value;
minder.execCommand("switchlayout",val);
},false);
// var b = new kity.Bezier([new kity.BezierPoint(0,0).setVertex(100,100),new kity.BezierPoint(100,0).setVertex(100,100)]);
// minder.getRenderContainer().addShape(b.stroke("white"));
</script>
</html>
\ No newline at end of file
......@@ -43,7 +43,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._paper.addShape( this._rc );
this._paper.getNode().setAttribute( 'contenteditable', true );
this._root = new MinderNode();
this._rc.addShape( this._root.getRenderContainer() );
this._root.setType( "root" );
if ( this._options.renderTo ) {
this.renderTo( this._options.renderTo );
}
......
......@@ -3,30 +3,38 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this.parent = null;
this.children = [];
this.data = {};
if ( utils.isString( options ) ) {
this.setData( 'text', options )
this._type = "main";
if ( Utils.isString( options ) ) {
this.setData( 'text', options );
} else {
this.setData( options );
}
this.rc = new kity.Group();
this.rc.minderNode = this;
},
setPoint:function(x,y){
this.setData('point',{
x:x,y:y
})
setPoint: function ( x, y ) {
this.setData( 'point', {
x: x,
y: y
} );
},
getPoint: function () {
return this.getData( 'point' );
},
setType: function ( type ) {
},
getPoint:function(){
return this.getData('point')
getType: function ( type ) {
},
setText: function ( text ) {
this.setData( 'text', text )
this.setData( 'text', text );
},
getText: function () {
return this.getData( 'text' )
return this.getData( 'text' );
},
isRoot: function () {
return this.getParent() == null ? true : false;
return this.getParent() === null ? true : false;
},
getParent: function () {
return this.parent;
......@@ -89,16 +97,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node.root = parent.root;
this.children.splice( index, 0, node );
// this.handelInsert( node );
},
//
// handelInsert: function ( node ) {
// var root = this.getRoot();
// if ( root.tnh ) {
// root.tnh.handelNodeInsert.call( root.tnh, node );
// }
// },
appendChild: function ( node ) {
return this.insertChild( node );
......@@ -132,10 +131,10 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return this.children[ index ];
},
getFirstChild: function () {
return this.children[ 0 ]
return this.children[ 0 ];
},
getLastChild: function () {
return this.children[ this.children.length - 1 ]
return this.children[ this.children.length - 1 ];
},
getData: function ( name ) {
if ( name === undefined ) {
......@@ -145,17 +144,17 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
setData: function ( name, value ) {
if(name === undefined){
this.data = {}
if ( name === undefined ) {
this.data = {};
}else if(utils.isObject(name)){
utils.extend(this.data,name)
}else{
if(value === undefined){
this.data[name] = null;
delete this.data[name]
}else{
this.data[name] = value;
} else if ( utils.isObject( name ) ) {
Utils.extend( this.data, name );
} else {
if ( value === undefined ) {
this.data[ name ] = null;
delete this.data[ name ];
} else {
this.data[ name ] = value;
}
}
},
......@@ -163,7 +162,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return this.rc;
},
getCommonAncestor: function ( node ) {
return utils.getNodeCommonAncestor(this,node)
return Utils.getNodeCommonAncestor( this, node );
},
contains: function ( node ) {
if ( this === node ) {
......@@ -173,44 +172,44 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return true;
}
var isContain = false;
utils.each( this.getChildren(), function ( i, n ) {
Utils.each( this.getChildren(), function ( i, n ) {
isContain = n.contains( node );
if ( isContain === true ) {
return false
return false;
}
} );
return isContain;
},
clone:function(){
function cloneNode(parent,isClonedNode){
clone: function () {
function cloneNode( parent, isClonedNode ) {
var _tmp = new KM.MinderNode();
_tmp.data = utils.clonePlainObject(isClonedNode.getData());
_tmp.data = Utils.clonePlainObject( isClonedNode.getData() );
_tmp.parent = parent;
if(parent){
parent.children.push(_tmp);
if ( parent ) {
parent.children.push( _tmp );
}
for(var i= 0,ci;ci=isClonedNode.children[i++];){
cloneNode(_tmp,ci);
for ( var i = 0, ci; ci = isClonedNode.children[ i++ ]; ) {
cloneNode( _tmp, ci );
}
return _tmp;
}
return function(){
return cloneNode(null,this);
return function () {
return cloneNode( null, this );
}
}(),
equals:function(node){
if(node.children.length != this.children.length){
equals: function ( node ) {
if ( node.children.length != this.children.length ) {
return false;
}
if(utils.compareObject(node.getData(),this.getData()) === false){
if ( utils.compareObject( node.getData(), this.getData() ) === false ) {
return false;
}
for(var i= 0,ci;ci=this.children[i++];){
if(ci.equals(node)===false){
for ( var i = 0, ci; ci = this.children[ i++ ]; ) {
if ( ci.equals( node ) === false ) {
return false;
}
}
......
This diff is collapsed.
......@@ -64,7 +64,7 @@ KityMinder.registerModule( "LayoutModule", function () {
} );
var switchLayout = function ( km, style ) {
var _root = km.getRoot();
km.getRenderContainer().clear().addShape( _root.getRenderContainer().clear() );
km.getRenderContainer().clear();
_root.preTraverse( function ( n ) {
n.clearLayout();
n.setPoint();
......
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