Index: lams_central/web/includes/javascript/progressBar.js
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/progressBar.js,v
diff -u -r1.16 -r1.17
--- lams_central/web/includes/javascript/progressBar.js 25 Oct 2014 17:13:47 -0000 1.16
+++ lams_central/web/includes/javascript/progressBar.js 2 Jul 2015 12:26:06 -0000 1.17
@@ -33,6 +33,15 @@
PATH_QUARTER_CIRCLE = " a16 16 0 0 0 16 16 v-16 z",
PATH_TRIANGLE = " l8 16 l8 -16 z",
PATH_OCTAGON = " l-7 7 v12 l7 7 h12 l7 -7 v-12 l-7 -7 z",
+
+ // filled in when paper gets created
+ GLOW_FILTER = null,
+
+ DEFAULT_TEXT_ATTRIBUTES = {
+ 'text-anchor' : 'middle',
+ 'font-size' : 10,
+ 'font-family' : 'sans-serif'
+ },
isPreview = false,
controlFramePadding = 0;
@@ -221,11 +230,11 @@
// real
activity.addDecoration = function(act) {
var paper = act.bar.paper;
- act.decoration = paper.set();
+ act.decoration = Snap.set();
// get exact Y where inner shape was drawn
// it is different than activity.y in OptionalActivity
// because of gray square around it
- var y = act.shape.attr('path')[0][2],
+ var y = Snap.parsePathString(act.shape.attr('path'))[0][2],
arc = paper.path('M ' + (act.middle - 8) + ' ' + y
+ PATH_QUARTER_CIRCLE),
transformation = act.shape.transform();
@@ -258,20 +267,18 @@
activity.addDecoration = function(act) {
var paper = act.bar.paper;
- act.decoration = paper.set();
+ act.decoration = Snap.set();
// should be internationalised?
- var text = paper.text(act.middle, act.y + 16, 'STOP');
+ var text = paper.text(act.middle, act.y + 16, 'STOP')
+ .attr(DEFAULT_TEXT_ATTRIBUTES);
text.attr({
'opacity' : 0,
'font-size' : 9,
- 'font' : 'sans-serif',
'stroke' : COLOR_GATE_TEXT,
'cursor' : 'pointer'
});
- // correct Raphael bug
- $('tspan', text.node).attr('dy', 0);
act.decoration.push(text);
@@ -308,6 +315,7 @@
+ PATH_BIG_SQUARE);
square.attr({
'opacity' : 0,
+ 'stroke' : COLOR_STROKE_ACTIVITY,
'fill' : COLOR_COMPLEX_BACKGROUND,
'cursor' : 'pointer'
});
@@ -317,13 +325,13 @@
square.decorationWraps = true;
if (!act.decoration) {
- act.decoration = paper.set();
+ act.decoration = Snap.set();
}
act.decoration.push(square);
}
},
- // return some attributes in Raphael consumable way
+ // return some attributes in Snap consumable way
getShapeAttributes : function(activity) {
return {
'path' : activity.path,
@@ -339,7 +347,7 @@
// all elements that activity consists of
// so they all can be moved at once
var paper = activity.bar.paper;
- activity.elements = paper.set();
+ activity.elements = Snap.set();
// only now do the real drawing, add event handlers etc.
activity.shape = paper.path(activity.path);
// add Activity attributes
@@ -356,28 +364,30 @@
content = content.substring(0,20) + '...';
}
label = paper.text(activity.middle,
- 40 + (activity.index % 2 == 0 ? 0 : 15),
- content);
+ 40 + (activity.index % 2 == 0 ? 0 : 15),
+ content)
+ .attr(DEFAULT_TEXT_ATTRIBUTES);
} else {
content = ActivityUtils.breakTitle(content, paper.width);
label = paper.text(activity.middle,
- 47 + 60 * activity.index + (isLarger ? 10 : 0),
- content);
+ 47 + 60 * activity.index + (isLarger ? 10 : 0),
+ content)
+ .attr(DEFAULT_TEXT_ATTRIBUTES);
}
- // correct Raphael bug
- $('tspan:first-child', label.node).attr('dy', 0);
activity.elements.push(label);
if (!isLast) {
// line between activities; last activity does not have it
var line = null;
if (isHorizontalBar) {
- line = paper.path('M ' + (activity.middle + 15) + ' 18 h 30');
+ line = paper.path('M ' + (activity.middle + 15) + ' 18 h 30')
+ .attr('stroke', COLOR_STROKE_ACTIVITY)
} else {
var startY = activity.y + label.getBBox().height + (isLarger ? 28 : 18),
endY = 20 + 60 * (activity.index + 1);
if (startY < endY) {
- line = paper.path('M ' + activity.middle + ' ' + startY + ' L ' + activity.middle + ' ' + endY);
+ line = paper.path('M ' + activity.middle + ' ' + startY + ' L ' + activity.middle + ' ' + endY)
+ .attr('stroke', COLOR_STROKE_ACTIVITY);
}
}
@@ -394,7 +404,7 @@
// show in 1 second
elem.animate({
'opacity' : 1
- }, 1000, "linear");
+ }, 1000);
});
}
@@ -423,43 +433,43 @@
}
var mouseover = function(e, x, y) {
- ActivityUtils.addGlow(activity);
+ ActivityUtils.addGlow(activity);
+
+ // add tooltip
+ var tooltipText = '' + activity.name + '
'
+ + activity.statusTooltip;
+ // move to proper place and show
+ $('#tooltip').stop(true, true).css("left", x + 10).css("top", y + 20)
+ .html(tooltipText).delay(1000).fadeIn();
+ },
- // add tooltip
- var tooltipText = '' + activity.name + '
'
- + activity.statusTooltip;
- // move to proper place and show
- $('#tooltip').stop(true, true).css("left", x + 10).css("top", y + 20)
- .html(tooltipText).delay(1000).fadeIn();
- }
+ mouseout = function() {
+ // remove glow
+ ActivityUtils.removeGlow(activity);
+ $('#tooltip').stop(true, true).fadeOut();
+ },
- var mouseout = function() {
- // remove glow
- ActivityUtils.removeGlow(activity);
- $('#tooltip').stop(true, true).fadeOut();
- }
-
- var isSupportActivity = activity instanceof SupportActivity;
- var dblclick = activity.url ? function() {
- // open pop up or dialog if it is a support or completed activity
- if (isSupportActivity
- || activity.status == 1
- || (!hasContentFrame && activity.status <= 2)) {
- openActivity(activity.url);
-
- if (isSupportActivity) {
- // do not ask server, just mark the activity as attempted
- activity.transformToAttempted();
+ isSupportActivity = activity instanceof SupportActivity,
+ dblclick = activity.url ? function() {
+ // open pop up or dialog if it is a support or completed activity
+ if (isSupportActivity
+ || activity.status == 1
+ || (!hasContentFrame && activity.status <= 2)) {
+ openActivity(activity.url);
+
+ if (isSupportActivity) {
+ // do not ask server, just mark the activity as attempted
+ activity.transformToAttempted();
+ }
+ } else {
+ loadFrame(activity);
}
- } else {
- loadFrame(activity);
- }
- } : null;
+ } : null,
- var click = activity.isComplex ? function() {
- // show complex (Optional, Branching) activity inner content
- ActivityUtils.showComplexContent(activity);
- } : null;
+ click = activity.isComplex ? function() {
+ // show complex (Optional, Branching) activity inner content
+ ActivityUtils.showComplexContent(activity);
+ } : null;
// assign handlers
activity.shape.hover(mouseover, mouseout);
@@ -475,7 +485,9 @@
},
addGlow : function(activity) {
- if (!activity.shape.glowRef) {
+ if (!activity.glows) {
+ var paper = activity.bar.paper,
+ target = null;
// add glowing effect on hover
if (activity.decorationWraps) {
activity.decoration.forEach(function(elem) {
@@ -484,25 +496,23 @@
// glow the wrapping decoration element
// for example gray square in Optonal Activity container
// is bigger than inner activity shape, so it should glow
- activity.shape.glowRef = elem.glow({
- color : elem.attr('fill')
- });
+ elem.attr('filter', GLOW_FILTER);
+ activity.glows = elem;
return false;
}
});
} else {
- activity.shape.glowRef = activity.shape.glow({
- color : activity.shape.attr('fill')
- });
+ activity.shape.attr('filter', GLOW_FILTER);
+ activity.glows = activity.shape;
}
}
},
// remove glow when mouse leaves shape
removeGlow : function(activity, force) {
- if (activity.shape.glowRef && (force || activity.bar.displayedActivity != activity)) {
- activity.shape.glowRef.remove();
- activity.shape.glowRef = null;
+ if (activity.glows && (force || activity.bar.displayedActivity != activity)) {
+ activity.glows.attr('filter', null);
+ activity.glows = null;
}
},
@@ -564,7 +574,7 @@
ActivityUtils.addDecoration(activity, oldDecoration, false);
// transform the shape
activity.shape.animate(ActivityUtils.getShapeAttributes(activity),
- 2000, 'linear', function() {
+ 2000, undefined, function() {
if (!(activity instanceof OptionalActivity)) {
// inner activities do not have glow and tooltip
// effects
@@ -585,17 +595,17 @@
}
elem.animate({
'opacity' : 0
- }, quick ? 0 : 1000, 'linear', function() {
+ }, quick ? 0 : 1000, undefined, function() {
elem.remove();
});
});
}
// run function that draws decoration
if (activity.addDecoration) {
- var animation = Raphael.animation({
+ var animation = Snap.animation({
'opacity' : 1
- }, quick ? 0 : 1000, "linear");
+ }, quick ? 0 : 1000);
activity.addDecoration(activity);
activity.decoration.forEach(function(elem) {
@@ -605,13 +615,16 @@
if (elem.decorationWraps) {
// decoration element is bigger that activity shape,
// put it in background
- elem.toBack();
+ $(elem.node).parent().prepend(elem.node);
} else {
- elem.toFront();
+ $(elem.node).parent().append(elem.node);
}
-
- elem.animate(animation.delay(oldDecoration ? 1000
- : undefined));
+
+ // delay animation if there is old decroation to remove
+ setTimeout(function(){
+ elem.animate(animation);
+ }, oldDecoration ? 1000 : 0);
+
});
}
},
@@ -680,16 +693,14 @@
}
var cellId = parentId + 'child'
- + childActivityIndex;
- var cell = $('