Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -r63294ac2f257e0d77fa89432b6ce1a0326b29d10 -rdb8d5783fabce3070377df165b401f6426fd5ca2 --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 63294ac2f257e0d77fa89432b6ce1a0326b29d10) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision db8d5783fabce3070377df165b401f6426fd5ca2) @@ -743,17 +743,19 @@ var path = Snap.format('M {startX} {startY}', points), horizontalDelta = points.endX - points.startX, verticalDelta = points.endY - points.startY; + // if activities are too close for curves, draw a straight line instead of bezier if (Math.abs(horizontalDelta) < threshold || Math.abs(verticalDelta) < threshold) { path += Snap.format(' L {endX} {endY}', points); } else { - // detect if it is left/right or up/down - var horizontalModifier = points.endX > points.startX ? 1 : -1, - verticalModifier = points.endY > points.startY ? 1 : -1; + // adjust according to whether it is right/left and down/up + var horizontalModifier = horizontalDelta > 0 ? 1 : -1, + verticalModifier = verticalDelta > 0 ? 1 : -1; switch (points.direction) { - case 'vertical' : + case 'up' : + case 'down' : // go to almost the middle of the activities path += ' V ' + (points.middleY - verticalModifier * curve); @@ -764,10 +766,12 @@ path += ' l ' + (points.endX - points.startX - 2 * horizontalModifier * curve) + ' 0'; // second curve path += ' q ' + horizontalModifier * curve + ' 0 ' + horizontalModifier * curve + ' ' + verticalModifier * curve; - + break; - case 'horizontal' : + case 'left' : + case 'right' : + path += ' H ' + (points.middleX - horizontalModifier * curve); path += ' q ' + horizontalModifier * curve + ' 0 '; path += horizontalModifier * curve + ' ' + verticalModifier * curve; @@ -783,11 +787,48 @@ this.items.shape = paper.path(path).attr({ 'fill' : 'none', - 'stroke' : layout.colors.transition, - 'stroke-width' : 2 + 'stroke' : layout.colors.transition }); this.items.append(this.items.shape); - + + var dot = null, + radius = layout.conf.transitionCircleRadius, + triangle = null, + side = layout.conf.transitionArrowLength; + + switch (points.direction) { + case 'up' : + dot = paper.circle(points.startX, points.startY - radius - 1, radius); + triangle = paper.polygon(points.endX, points.endY, points.endX + side, points.endY + 2 * side, points.endX - side, points.endY + 2 * side); + break; + case 'down' : + dot = paper.circle(points.startX, points.startY + radius + 1, radius); + triangle = paper.polygon(points.endX, points.endY, points.endX - side, points.endY - 2 * side, points.endX + side, points.endY - 2 * side); + break; + case 'left' : + dot = paper.circle(points.startX - radius - 1, points.startY, radius); + triangle = paper.polygon(points.endX, points.endY, points.endX + 2 * side, points.endY - side, points.endX + 2 * side, points.endY + side); + break; + case 'right' : + dot = paper.circle(points.startX + radius + 1, points.startY, radius); + triangle = paper.polygon(points.endX, points.endY, points.endX - 2 * side, points.endY - side, points.endX - 2 * side, points.endY + side); + break; + } + + dot.attr({ + 'fill' : layout.colors.transition, + 'stroke' : layout.colors.transition, + }); + this.items.append(dot); + + triangle.attr({ + 'fill' : layout.colors.transition, + 'stroke' : layout.colors.transition, + }); + this.items.append(triangle); + + + this.items.attr('uiid', this.uiid); if (this.title) { // adjust X & Y, so the label does not overlap with the transition; @@ -1382,44 +1423,44 @@ if (direction === 'vertical') { if (fromActivityBox.cy < toActivityBox.cy) { - // down points = { - 'startX' : fromActivityBox.x + fromActivityBox.width / 2 - (fromActivity.items.groupingEffect ? 0.5 * layout.conf.groupingEffectPadding : 0), - 'startY' : fromActivityBox.y2, - 'endX' : toActivityBox.x + toActivityBox.width / 2, - 'endY' : toActivityBox.y + 'startX' : fromActivityBox.x + fromActivityBox.width / 2 - (fromActivity.items.groupingEffect ? 0.5 * layout.conf.groupingEffectPadding : 0), + 'startY' : fromActivityBox.y2, + 'endX' : toActivityBox.x + toActivityBox.width / 2, + 'endY' : toActivityBox.y, + 'direction' : 'down' }; } else { - // up points = { - 'startX' : fromActivityBox.x + fromActivityBox.width / 2, - 'startY' : fromActivityBox.y, - 'endX' : toActivityBox.x + toActivityBox.width / 2 - (toActivity.items.groupingEffect ? 0.5 * layout.conf.groupingEffectPadding : 0), - 'endY' : toActivityBox.y2 + 'startX' : fromActivityBox.x + fromActivityBox.width / 2, + 'startY' : fromActivityBox.y, + 'endX' : toActivityBox.x + toActivityBox.width / 2 - (toActivity.items.groupingEffect ? 0.5 * layout.conf.groupingEffectPadding : 0), + 'endY' : toActivityBox.y2, + 'direction' : 'up' }; } } else { if (fromActivityBox.cx < toActivityBox.cx) { - // right points = { - 'startX' : fromActivityBox.x2, - 'startY' : fromActivityBox.y + fromActivityBox.height / 2 - (fromActivity.items.groupingEffect ? 0.5 * layout.conf.groupingEffectPadding : 0), - 'endX' : toActivityBox.x, - 'endY' : toActivityBox.y + toActivityBox.height / 2 + 'startX' : fromActivityBox.x2, + 'startY' : fromActivityBox.y + fromActivityBox.height / 2 - (fromActivity.items.groupingEffect ? 0.5 * layout.conf.groupingEffectPadding : 0), + 'endX' : toActivityBox.x, + 'endY' : toActivityBox.y + toActivityBox.height / 2, + 'direction' : 'right' }; } else { // left points = { - 'startX' : fromActivityBox.x, - 'startY' : fromActivityBox.y + fromActivityBox.height / 2, - 'endX' : toActivityBox.x2, - 'endY' : toActivityBox.y + toActivityBox.height / 2 - (toActivity.items.groupingEffect ? 0.5 * layout.conf.groupingEffectPadding : 0) + 'startX' : fromActivityBox.x, + 'startY' : fromActivityBox.y + fromActivityBox.height / 2, + 'endX' : toActivityBox.x2, + 'endY' : toActivityBox.y + toActivityBox.height / 2 - (toActivity.items.groupingEffect ? 0.5 * layout.conf.groupingEffectPadding : 0), + 'direction' : 'left' }; } } if (points) { - points.direction = direction; // middle point of the transition points.middleX = points.startX + (points.endX - points.startX)/2; points.middleY = points.startY + (points.endY - points.startY)/2; Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== diff -u -r240f31b379582c5cef0b7db0280c1c052de1b527 -rdb8d5783fabce3070377df165b401f6426fd5ca2 --- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 240f31b379582c5cef0b7db0280c1c052de1b527) +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision db8d5783fabce3070377df165b401f6426fd5ca2) @@ -78,6 +78,8 @@ // the bigger this number, the larger bezier curves will be 'transitionCurve' : 15, + 'transitionCircleRadius' : 5, + 'transitionArrowLength' : 5, // snapping grid step when dragging an activity 'snapGridX' : 100,