Commit 41be9143 authored by techird's avatar techird

dev

parent de89ff45
......@@ -17,11 +17,11 @@ $dependency = Array(
'src/module/connect.js',
'src/module/history.js',
'src/module/icon.js',
'src/module/keyboard.js',
'src/module/layout.js',
'src/module/render.js',
'src/module/textedit.js',
'src/module/_example.js'
'src/module/mouse.js',
'src/module/keyboard.js',
'src/module/textedit.js'
);
$content = "";
......
......@@ -12,15 +12,15 @@ var MinderEvent = kity.createClass( 'MindEvent', {
}
this.type = type;
this._canstop = canstop || false;
if ( params.targetShape ) {
this.getTargetNode = function () {
var findShape = params.targetShape;
while ( !findShape.minderNode && findShape.container ) {
findShape = findShape.container;
}
return findShape.minderNode || null;
};
},
getTargetNode: function () {
var findShape = this.kityEvent && this.kityEvent.targetShape;
if ( !findShape ) return null;
while ( !findShape.minderNode && findShape.container ) {
findShape = findShape.container;
}
return findShape.minderNode || null;
},
stopPropagation: function () {
......
......@@ -17,6 +17,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._initEvents();
this._initMinder();
this._initCommandStack();
this._initSelection();
this._initModules();
},
......
// 选区管理
kity.extendClass( Minder, {
_initSelection: function () {
this._selectedNodes = [];
},
getSelectedNodes: function () {
return this._selectedNodes || ( this._selectedNodes = [] );
return this._selectedNodes.slice( 0 );
},
select: function ( nodes ) {
var selection = this.getSelectedNodes();
var selection = this._selectedNodes;
if ( false === nodes instanceof Array ) nodes = [ nodes ];
for ( var i = 0; i < nodes.length; i++ ) {
if ( selection.indexOf( nodes[ i ] ) === -1 ) {
......@@ -16,7 +20,7 @@ kity.extendClass( Minder, {
},
isNodeSelected: function ( node ) {
return !!~this.getSelectedNodes().indexOf( node );
return !!~this._selectedNodes.indexOf( node );
},
selectSingle: function ( node ) {
......@@ -24,7 +28,7 @@ kity.extendClass( Minder, {
},
toggleSelect: function ( nodes ) {
var selection = this.getSelectedNodes();
var selection = this._selectedNodes;
var needAdd = [],
needRemove = [];
if ( false === nodes instanceof Array ) nodes = [ nodes ];
......@@ -35,8 +39,7 @@ kity.extendClass( Minder, {
needRemove.push( nodes[ i ] );
}
}
this.clearSelect( needRemove );
this.select( needAdd );
return this.clearSelect( needRemove ).select( needAdd );
},
clearSelect: function ( nodes ) {
......@@ -45,7 +48,7 @@ kity.extendClass( Minder, {
return this;
}
if ( false === nodes instanceof Array ) nodes = [ nodes ];
var originSelection = this.getSelectedNodes();
var originSelection = this._selectedNodes;
var newSelection = [];
for ( var i = 0; i < originSelection.length; i++ ) {
if ( nodes.indexOf( originSelection[ i ] ) === -1 ) {
......
KityMinder.registerModule( "MouseModule", function () {
return {
"events": {
mousedown: function ( e ) {
var clickNode = e.getTargetNode();
var deltaNodes = this.getSelectedNodes();
this.selectSingle( clickNode );
if ( clickNode ) {
deltaNodes.push( clickNode );
}
this.execCommand( 'rendernode', deltaNodes );
}
}
};
} );
\ 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