Commit 679bf01a authored by Akikonata's avatar Akikonata

added highlight

parent f965a887
...@@ -44,7 +44,7 @@ kity.extendClass( Minder, { ...@@ -44,7 +44,7 @@ kity.extendClass( Minder, {
stroke: "orange", stroke: "orange",
color: "black", color: "black",
padding: [ 5, 10, 5, 10 ], padding: [ 5, 10, 5, 10 ],
fontSize: 20, fontSize: 20
}; };
var kR = node.getRenderContainer(); var kR = node.getRenderContainer();
...@@ -79,6 +79,11 @@ kity.extendClass( Minder, { ...@@ -79,6 +79,11 @@ kity.extendClass( Minder, {
nodeShape.shape.setTransform( new kity.Matrix().translate( node.getData( "x" ), node.getData( "y" ) - _rectHeight / 2 ) ); nodeShape.shape.setTransform( new kity.Matrix().translate( node.getData( "x" ), node.getData( "y" ) - _rectHeight / 2 ) );
break; break;
} }
if ( node.getData( "highlight" ) ) {
nodeShape.highlight();
} else {
nodeShape.unhighlight();
}
}, },
renderNodes: function ( nodes ) { renderNodes: function ( nodes ) {
var km = this; var km = this;
......
...@@ -14,16 +14,21 @@ kity.extendClass( Minder, { ...@@ -14,16 +14,21 @@ kity.extendClass( Minder, {
for ( var i = 0; i < nodes.length; i++ ) { for ( var i = 0; i < nodes.length; i++ ) {
if ( selection.indexOf( nodes[ i ] ) === -1 ) { if ( selection.indexOf( nodes[ i ] ) === -1 ) {
selection.push( nodes[ i ] ); selection.push( nodes[ i ] );
this.highlightNode( nodes[ i ] );
} }
} }
return this; return this;
}, },
highlightNode: function ( node ) {
node.setData( "highlight", true );
this.renderNode( node );
},
isNodeSelected: function ( node ) { isNodeSelected: function ( node ) {
return !!~this._selectedNodes.indexOf( node ); return !!~this._selectedNodes.indexOf( node );
}, },
selectSingle: function ( node ) { selectSingle: function ( node ) {
this.highlightNode( node );
return this.clearSelect().select( node ); return this.clearSelect().select( node );
}, },
...@@ -35,8 +40,10 @@ kity.extendClass( Minder, { ...@@ -35,8 +40,10 @@ kity.extendClass( Minder, {
for ( var i = 0; i < nodes.length; i++ ) { for ( var i = 0; i < nodes.length; i++ ) {
if ( selection.indexOf( nodes[ i ] ) === -1 ) { if ( selection.indexOf( nodes[ i ] ) === -1 ) {
needAdd.push( nodes[ i ] ); needAdd.push( nodes[ i ] );
this.highlightNode( nodes[ i ] );
} else { } else {
needRemove.push( nodes[ i ] ); needRemove.push( nodes[ i ] );
this.unhighlightNode( nodes[ i ] );
} }
} }
return this.clearSelect( needRemove ).select( needAdd ); return this.clearSelect( needRemove ).select( needAdd );
...@@ -57,5 +64,9 @@ kity.extendClass( Minder, { ...@@ -57,5 +64,9 @@ kity.extendClass( Minder, {
} }
this._selectedNodes = newSelection; this._selectedNodes = newSelection;
return this; return this;
},
unhighlightNode: function ( node ) {
node.setData( "highlight", false );
this.renderNode( node );
} }
} ); } );
\ No newline at end of file
...@@ -83,7 +83,6 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -83,7 +83,6 @@ KityMinder.registerModule( "LayoutModule", function () {
}; };
var createChildNode = function ( km, parent, index ) { var createChildNode = function ( km, parent, index ) {
console.log( "cc" );
var root = km.getRoot(); var root = km.getRoot();
var appendSide = parent.getData( "appendside" ); var appendSide = parent.getData( "appendside" );
var _node = new MinderNode(); var _node = new MinderNode();
......
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