Commit ad872831 authored by techird's avatar techird

Format Files

parent 65b73774
var MinderEvent = kity.createClass('MindEvent', { var MinderEvent = kity.createClass( 'MindEvent', {
constructor: function (type, params, cancelable) { constructor: function ( type, params, cancelable ) {
params = params || {}; params = params || {};
if(params.getType && params.getType() == 'ShapeEvent') { if ( params.getType && params.getType() == 'ShapeEvent' ) {
this.kityEvent = params; this.kityEvent = params;
this.getPosition = params.getPosition.bind(params); this.getPosition = params.getPosition.bind( params );
} else { } else {
kity.Utils.extend(this, params); kity.Utils.extend( this, params );
} }
this.type = type; this.type = type;
this._cancelable = cancelable || false; this._cancelable = cancelable || false;
if(params.targetShape) { if ( params.targetShape ) {
this.getTargetNode = function() { this.getTargetNode = function () {
var findShape = params.targetShape; var findShape = params.targetShape;
while(!findShape.minderNode && findShape.container) { while ( !findShape.minderNode && findShape.container ) {
findShape = findShape.container; findShape = findShape.container;
} }
return findShape.minderNode || null; return findShape.minderNode || null;
...@@ -20,20 +20,20 @@ var MinderEvent = kity.createClass('MindEvent', { ...@@ -20,20 +20,20 @@ var MinderEvent = kity.createClass('MindEvent', {
} }
}, },
cancel: function() { cancel: function () {
this._canceled = true; this._canceled = true;
}, },
cancelImmediately: function() { cancelImmediately: function () {
this._immediatelyCanceld = true; this._immediatelyCanceld = true;
this._canceled = true; this._canceled = true;
}, },
shouldCancel: function() { shouldCancel: function () {
return this._cancelable && this._canceled; return this._cancelable && this._canceled;
}, },
shouldCancelImmediately: function() { shouldCancelImmediately: function () {
return this._cancelable && this._immediatelyCanceld; return this._cancelable && this._immediatelyCanceld;
} }
}); } );
\ No newline at end of file \ No newline at end of file
var MinderNode = km.MinderNode = kity.createClass("MinderNode", { var MinderNode = km.MinderNode = kity.createClass( "MinderNode", {
constructor: function ( treeNotifyHandler ) { constructor: function ( treeNotifyHandler ) {
this.parent = null; this.parent = null;
this.children = []; this.children = [];
...@@ -8,88 +8,89 @@ var MinderNode = km.MinderNode = kity.createClass("MinderNode", { ...@@ -8,88 +8,89 @@ var MinderNode = km.MinderNode = kity.createClass("MinderNode", {
this.rc.minderNode = this; this.rc.minderNode = this;
}, },
getParent: function() { getParent: function () {
return this.parent; return this.parent;
}, },
getRoot: function() { getRoot: function () {
var root = this; var root = this;
while(root.parent) { while ( root.parent ) {
root = root.parent; root = root.parent;
} }
return root; return root;
}, },
getChildren: function() { getChildren: function () {
return this.children; return this.children;
}, },
getIndex: function() { getIndex: function () {
return this.parent ? this.parent.indexOf(this) : -1; return this.parent ? this.parent.indexOf( this ) : -1;
}, },
insertChild: function(node, index) { insertChild: function ( node, index ) {
if(index === undefined) { if ( index === undefined ) {
index = this.children.length; index = this.children.length;
} }
if(node.parent) { if ( node.parent ) {
node.parent.removeChild(node); node.parent.removeChild( node );
} }
node.parent = this; node.parent = this;
this.children.splice(index, 0, node); this.children.splice( index, 0, node );
this.handelInsert(node); this.handelInsert( node );
}, },
handelInsert: function(node) { handelInsert: function ( node ) {
var root = this.getRoot(); var root = this.getRoot();
if(root.tnh) { if ( root.tnh ) {
root.tnh.handelNodeInsert.call( root.tnh, node ); root.tnh.handelNodeInsert.call( root.tnh, node );
} }
}, },
appendChild: function(node) { appendChild: function ( node ) {
return this.insertChild(node); return this.insertChild( node );
}, },
prependChild: function(node) { prependChild: function ( node ) {
return this.insertChild(node, 0); return this.insertChild( node, 0 );
}, },
removeChild: function(elem) { removeChild: function ( elem ) {
var index = elem, removed; var index = elem,
if(elem instanceof MinderNode) { removed;
index = this.children.indexOf(elem); if ( elem instanceof MinderNode ) {
index = this.children.indexOf( elem );
} }
if(index >= 0) { if ( index >= 0 ) {
removed = this.children.splice(index, 1)[0]; removed = this.children.splice( index, 1 )[ 0 ];
removed.parent = null; removed.parent = null;
this.handelRemove(removed); this.handelRemove( removed );
} }
}, },
handelRemove: function(node) { handelRemove: function ( node ) {
var root = this.getRoot(); var root = this.getRoot();
if(root.tnh) { if ( root.tnh ) {
root.tnh.handelNodeRemove.call( root.tnh, node ); root.tnh.handelNodeRemove.call( root.tnh, node );
} }
}, },
getChild: function(index) { getChild: function ( index ) {
return this.children[index]; return this.children[ index ];
}, },
getData: function(name) { getData: function ( name ) {
if(name === undefined) { if ( name === undefined ) {
return this.data; return this.data;
} }
return this.data[name]; return this.data[ name ];
}, },
setData: function(name, value) { setData: function ( name, value ) {
this.data[name] = value; this.data[ name ] = value;
}, },
getRenderContainer: function() { getRenderContainer: function () {
return this.rc; return this.rc;
} }
}); } );
\ No newline at end of file \ 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