@@ -17,11 +17,13 @@ dc_graph.match_ports = function(diagram, symbolPorts) {
17
17
nids . push ( diagram . portNodeKey . eval ( source . port ) ) ;
18
18
symbolPorts . animateNodes ( nids ) ;
19
19
}
20
+ function is_valid ( sourcePort , targetPort ) {
21
+ return ( _behavior . allowParallel ( ) || ! _wedges . some ( function ( e ) {
22
+ return sourcePort . edges . indexOf ( e ) >= 0 && targetPort . edges . indexOf ( e ) >= 0 ;
23
+ } ) ) && _behavior . isValid ( ) ( sourcePort , targetPort ) ;
24
+ }
20
25
var _behavior = {
21
26
isValid : property ( function ( sourcePort , targetPort ) {
22
- if ( ! _behavior . allowParallel ( ) && _wedges . some ( function ( e ) {
23
- return sourcePort . edges . indexOf ( e ) >= 0 && targetPort . edges . indexOf ( e ) >= 0 ;
24
- } ) ) return false ;
25
27
return targetPort !== sourcePort && targetPort . name === sourcePort . name ;
26
28
} ) ,
27
29
allowParallel : property ( false ) . react ( function ( v ) {
@@ -30,15 +32,15 @@ dc_graph.match_ports = function(diagram, symbolPorts) {
30
32
} ) ,
31
33
hoverPort : function ( port ) {
32
34
if ( port ) {
33
- _validTargets = _wports . filter ( _behavior . isValid ( ) . bind ( null , port ) ) ;
35
+ _validTargets = _wports . filter ( is_valid . bind ( null , port ) ) ;
34
36
if ( _validTargets . length )
35
37
return change_state ( _validTargets , 'shimmer-medium' ) ;
36
38
} else if ( _validTargets )
37
39
return change_state ( _validTargets , 'small' ) ;
38
40
return null ;
39
41
} ,
40
42
startDragEdge : function ( source ) {
41
- _validTargets = _wports . filter ( _behavior . isValid ( ) . bind ( null , source . port ) ) ;
43
+ _validTargets = _wports . filter ( is_valid . bind ( null , source . port ) ) ;
42
44
var nids = change_state ( _validTargets , 'shimmer' ) ;
43
45
if ( _validTargets . length ) {
44
46
symbolPorts . enableHover ( false ) ;
@@ -50,7 +52,7 @@ dc_graph.match_ports = function(diagram, symbolPorts) {
50
52
return _validTargets . length !== 0 ;
51
53
} ,
52
54
changeDragTarget : function ( source , target ) {
53
- var nids , valid = target && _behavior . isValid ( ) ( source . port , target . port ) , before ;
55
+ var nids , valid = target && is_valid ( source . port , target . port ) , before ;
54
56
if ( valid ) {
55
57
nids = change_state ( _validTargets , 'small' ) ;
56
58
target . port . state = 'large' ; // it's one of the valid
@@ -66,7 +68,7 @@ dc_graph.match_ports = function(diagram, symbolPorts) {
66
68
finishDragEdge : function ( source , target ) {
67
69
symbolPorts . enableHover ( true ) ;
68
70
reset_ports ( source ) ;
69
- return _behavior . isValid ( ) ( source . port , target . port ) ;
71
+ return is_valid ( source . port , target . port ) ;
70
72
} ,
71
73
cancelDragEdge : function ( source ) {
72
74
symbolPorts . enableHover ( true ) ;
0 commit comments