Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -ra3deb82a03e36c10d0c47c20382ce4275fef58c4 -rc6dfdf0a0370d091b4fb697afa2f151ba9fa56fa --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision a3deb82a03e36c10d0c47c20382ce4275fef58c4) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision c6dfdf0a0370d091b4fb697afa2f151ba9fa56fa) @@ -710,13 +710,11 @@ * Draws a Transition */ transition : function() { - var existingItems = this.items; - this.items = paper.g(); - if (existingItems) { - this.items.shape = existingItems.shape; + if (this.items) { + this.items.remove(); } + this.items = paper.g(); - var points = ActivityLib.findTransitionPoints(this.fromActivity, this.toActivity), curve = layout.transition.curve, threshold = 2 * curve + 2; @@ -763,19 +761,13 @@ path += Snap.format(' L {endX} {endY}', points); } - if (this.items.shape) { - this.items.shape.path = path; - } else { - this.items.shape = paper.path(path).attr({ - 'fill' : 'none', - 'stroke' : layout.colors.transition, - 'stroke-width' : 2 - }); - this.items.append(this.items.shape); - } + this.items.shape = paper.path(path).attr({ + 'fill' : 'none', + 'stroke' : layout.colors.transition, + 'stroke-width' : 2 + }); + this.items.append(this.items.shape); - - this.items.attr('uiid', this.uiid); if (this.title) { // adjust X & Y, so the label does not overlap with the transition; @@ -1363,6 +1355,7 @@ // if the box is more up/down then left/right, then arrow direction is vertical direction = horizontalDelta > verticalDelta ? 'horizontal' : 'vertical', points = null; + if (direction === 'vertical') { if (fromActivityBox.cy < toActivityBox.cy) { // down Index: lams_central/web/includes/javascript/authoring/authoringHandler.js =================================================================== diff -u -ra3deb82a03e36c10d0c47c20382ce4275fef58c4 -rc6dfdf0a0370d091b4fb697afa2f151ba9fa56fa --- lams_central/web/includes/javascript/authoring/authoringHandler.js (.../authoringHandler.js) (revision a3deb82a03e36c10d0c47c20382ce4275fef58c4) +++ lams_central/web/includes/javascript/authoring/authoringHandler.js (.../authoringHandler.js) (revision c6dfdf0a0370d091b4fb697afa2f151ba9fa56fa) @@ -78,14 +78,15 @@ /** * Start dragging an activity or a transition. */ - dragItemsStartHandler : function(items, draggedElement, mouseupHandler, event, startX, startY) { + dragItemsStartHandler : function(object, draggedElement, mouseupHandler, event, startX, startY) { if (layout.drawMode || (event.originalEvent ? event.originalEvent.defaultPrevented : event.defaultPrevented)){ return; } // if user clicks or drags very shortly, do not take it into account - var dragCancel = function(){ + var items = object.items, + dragCancel = function(){ canvas.off('mouseup'); // if there is already a function waiting to be started, clear it if (items.dragStarter) { @@ -126,7 +127,7 @@ } canvas.mousemove(function(event) { - HandlerLib.dragItemsMoveHandler(items, event, startX, startY); + HandlerLib.dragItemsMoveHandler(object, event, startX, startY); }); var mouseup = function(mouseupEvent){ @@ -144,7 +145,7 @@ }; /* The event is passed from items to canvas, so it is OK to assign it only to canvas. - Ufortunately, this does not apply to the icon. + Unfortunately, this does not apply to the icon. Also, if mousedown was on items and mouseup on canvas (very quick move), items will not accept mouseup until click. */ @@ -158,16 +159,21 @@ /** * Moves dragged elements on the canvas. */ - dragItemsMoveHandler : function(items, event, startX, startY) { + dragItemsMoveHandler : function(object, event, startX, startY) { var dx = event.pageX - startX, dy = event.pageY - startY; + + object.items.transform('t' + dx + ' ' + dy); - items.transform('t' + dx + ' ' + dy); + if (object.transitions) { + $.each(object.transitions.from, function(){ + this.draw(); + }); + $.each(object.transitions.to, function(){ + this.draw(); + }); + } -// if (items.groupingEffect) { -// GeneralLib.toBack(items.groupingEffect); -// } - // highlight rubbish bin if dragged elements are over it if (HandlerLib.isElemenentBinned(event)) { if (!layout.bin.glowEffect) { @@ -387,8 +393,10 @@ } } } + + var transitions = activity.transitions.from.concat(activity.transitions.to); // start dragging the activity - HandlerLib.dragItemsStartHandler(activity.items, this, mouseupHandler, event, x, y); + HandlerLib.dragItemsStartHandler(activity, this, mouseupHandler, event, x, y, transitions); } }, @@ -478,7 +486,7 @@ } } - HandlerLib.dragItemsStartHandler(container.items, this, mouseupHandler, event, x, y); + HandlerLib.dragItemsStartHandler(container, this, mouseupHandler, event, x, y); }, /** @@ -580,7 +588,7 @@ } } - HandlerLib.dragItemsStartHandler(label.items, this, mouseupHandler, event, x, y); + HandlerLib.dragItemsStartHandler(label, this, mouseupHandler, event, x, y); }, @@ -735,12 +743,14 @@ activity.tempTransition.remove(); activity.tempTransition = null; } - var endActivity = null, targetElement = Snap.getElementByPoint(event.pageX, event.pageY); if (targetElement) { endActivity = ActivityLib.getParentObject(targetElement); } + if (endActivity == null) { + endActivity = ActivityLib.getParentObject(targetElement.parent()); + } if (endActivity && activity != endActivity) { ActivityLib.addTransition(activity, endActivity); @@ -772,6 +782,6 @@ } } - HandlerLib.dragItemsStartHandler(transition.items, this, mouseupHandler, event, x, y); + HandlerLib.dragItemsStartHandler(transition, this, mouseupHandler, event, x, y); } };