Commit f48b3d54 authored by Akikonata's avatar Akikonata

Merge branch 'dev' of https://github.com/kitygraph/kityminder into dev

parents 230e65df e7bca98e
......@@ -7,7 +7,9 @@ Utils.extend( KityMinder, {
return KityMinder._protocals[ name ] || null;
},
getSupportedProtocals: function () {
return Utils.keys( KityMinder._protocals );
return Utils.keys( KityMinder._protocals ).sort(function(a, b) {
return KityMinder._protocals[b].recognizePriority - KityMinder._protocals[a].recognizePriority;
});
},
getAllRegisteredProtocals: function () {
return KityMinder._protocals;
......@@ -70,7 +72,7 @@ kity.extendClass( Minder, {
if ( test.recognize && test.recognize( local ) ) {
protocal = test;
}
return !test;
return !protocal;
} );
}
......
......@@ -105,6 +105,14 @@ function findAvailableParents( nodes, root ) {
return availables;
}
var lastActivedDropTarget = null;
function activeDropTarget( node ) {
if(lastActivedDropTarget != node) {
node.getRenderContainer().fxScale(1.6, 1.6, 200, 'ease').fxScale(1/1.6, 1/1.6, 300, 'ease');
lastActivedDropTarget = node;
}
}
KityMinder.registerModule( "DragTree", function () {
var dragStartPosition, dragBox, dragTargets, dropTargets, dragTargetBoxes, dropTarget;
......@@ -147,13 +155,18 @@ KityMinder.registerModule( "DragTree", function () {
dragBox.blue();
dropTarget = null;
}
dropTargets.forEach( function ( test ) {
if ( GM.isBoxIntersect( dragBox.getRenderBox(), test.getRenderContainer().getRenderBox() ) ) {
if ( !dropTarget && GM.isBoxIntersect( dragBox.getRenderBox(), test.getRenderContainer().getRenderBox() ) ) {
activeDropTarget(test);
//test.getRenderContainer().scale( 1.25 );
dropTarget = test;
dragBox.green();
}
} );
if( !dropTarget ) {
lastActivedDropTarget = null;
}
},
mouseup: function ( e ) {
dragStartPosition = null;
......@@ -161,12 +174,13 @@ KityMinder.registerModule( "DragTree", function () {
dragBox.remove();
dragBox = null;
if ( dropTarget ) {
dragTargets.forEach( function ( target ) {
for(var i = dragTargets.length - 1, target; i >= 0; i--) {
target = dragTargets[i];
if ( target.parent ) {
target.parent.removeChild( target );
dropTarget.appendChild( target );
}
} );
}
this.removeAllSelectedNodes();
this.initStyle( this.getRoot() );
}
......
......@@ -95,5 +95,17 @@ KityMinder.Geometry = ( function () {
return unknown;
};
g.expandBox = function( box, sizeX, sizeY ) {
if(sizeY === undefined) {
sizeY = sizeX;
}
return wrapBox( {
left: box.left - sizeX,
top: box.top - sizeY,
right: box.right + sizeX,
bottom: box.bottom + sizeY
} );
};
return g;
} )();
\ No newline at end of file
......@@ -73,6 +73,7 @@ KityMinder.registerModule( "Select", function () {
};
} )();
var singleSelectOnUp = null;
return {
"events": {
mousedown: function ( e ) {
......@@ -84,13 +85,16 @@ KityMinder.registerModule( "Select", function () {
this.toggleSelect( clickNode );
} else if ( !clickNode.isSelected() ) {
this.select( clickNode, true );
} else if ( !this.isSingleSelect() ) {
singleSelectOnUp = clickNode;
}
},
mousemove: marqueeActivator.selectMove,
mouseup: function ( e ) {
var clickNode = e.getTargetNode();
if ( clickNode && clickNode.isSelected() && !this.isSingleSelect() ) {
this.select( clickNode, true );
if ( clickNode && singleSelectOnUp == clickNode ) {
this.select( singleSelectOnUp, true );
singleSelectOnUp = null;
}
marqueeActivator.selectEnd( e );
}
......
......@@ -16,6 +16,7 @@ KityMinder.registerProtocal( 'json', function () {
},
recognize: function ( local ) {
return Utils.isString( local ) && local.charAt( 0 ) == '{' && local.charAt( local.length - 1 ) == '}';
}
},
recognizePriority: 0
};
} );
\ No newline at end of file
......@@ -96,6 +96,7 @@ KityMinder.registerProtocal( "plain", function () {
}
return decode( local );
},
recognize: recognize
recognize: recognize,
recognizePriority: -1
};
} );
\ 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