Index: lams_central/web/author2.jsp =================================================================== diff -u -ra3d8ca871cecdad8f45756fdcae6d697bd0e8499 -r874c54709961f76c4ca248e7f9dec90d79d6f30a --- lams_central/web/author2.jsp (.../author2.jsp) (revision a3d8ca871cecdad8f45756fdcae6d697bd0e8499) +++ lams_central/web/author2.jsp (.../author2.jsp) (revision 874c54709961f76c4ca248e7f9dec90d79d6f30a) @@ -106,5 +106,41 @@
+ + +
+ + + + + + + + + +
+ Title: + + +
+ Grouping: + + +
+
+ +
+ + + + + +
+ Title: + + +
+
+ \ No newline at end of file Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -ra3d8ca871cecdad8f45756fdcae6d697bd0e8499 -r874c54709961f76c4ca248e7f9dec90d79d6f30a --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision a3d8ca871cecdad8f45756fdcae6d697bd0e8499) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 874c54709961f76c4ca248e7f9dec90d79d6f30a) @@ -7,15 +7,112 @@ /** * Constructor for a Tool Activity. */ - ToolActivity: function(id, toolID, x, y, label) { + ToolActivity: function(id, toolID, x, y, title) { this.id = id; + this.toolID = toolID; + this.title = title; this.type = 'tool'; this.transitions = { 'from' : [], 'to' : [] }; - this.toolID = toolID; - this.draw = function(x, y) { + + this.loadPropertiesDialogContent = ActivityLib.loadPropertiesDialogContent.tool; + + this.draw = ActivityLib.draw.tool; + this.draw(x, y); + }, + + /** + * Constructor for a Grouping Activity. + */ + GroupingActivity : function(id, x, y, title) { + this.id = id; + this.type = 'grouping'; + this.title = title; + this.transitions = { + 'from' : [], + 'to' : [] + }; + + this.loadPropertiesDialogContent = ActivityLib.loadPropertiesDialogContent.grouping; + + this.draw = ActivityLib.draw.grouping; + this.draw(x, y); + }, + + /** + * Constructor for a Gate Activity. + */ + GateActivity : function(id, x, y) { + this.id = id; + this.type = 'gate'; + this.transitions = { + 'from' : [], + 'to' : [] + }; + + this.draw = ActivityLib.draw.gate; + this.draw(x, y); + }, + + + /** + * Either branching or converge point. + */ + BranchingEdgeActivity : function(id, x, y, branchingActivity) { + this.type = 'branchingEdge'; + this.transitions = { + 'from' : [], + 'to' : [] + }; + + if (branchingActivity) { + // branchingActivity already exists, so this is the converge point + this.isStart = false; + branchingActivity.end = this; + } else { + // this is the branching point + this.isStart = true; + branchingActivity = new ActivityLib.BranchingActivity(id, this); + } + this.branchingActivity = branchingActivity; + + this.draw = ActivityLib.draw.branching; + this.draw(x, y); + }, + + + /** + * Represents a set of branches. It is not displayed on canvas. + */ + BranchingActivity : function(id, branchingEdgeStart) { + this.id = id; + this.start = branchingEdgeStart; + this.branches = []; + }, + + + /** + * Represents a subsequence of activities. It is not displayed on canvas. + */ + BranchActivity : function(id, branchingActivity, transitionFrom) { + this.id = id; + this.transitionFrom = transitionFrom; + this.branchingActivity = branchingActivity; + }, + + + /** + * Mehtods for drawing various kinds of activities. + */ + draw : { + tool : function(x, y) { + if (x == undefined || y == undefined) { + x = this.items.shape.getBBox().x; + y = this.items.shape.getBBox().y; + } + if (this.items) { this.items.remove(); } @@ -26,35 +123,29 @@ .attr({ 'fill' : layout.colors.activity }); - paper.image(layout.toolIcons[toolID], x + 47, y + 2, 30, 30); - paper.text(x + 62, y + 40, label); + paper.image(layout.toolIcons[this.toolID], x + 47, y + 2, 30, 30); + paper.text(x + 62, y + 40, ActivityLib.shortenActivityTitle(this.title)); this.items = paper.setFinish(); this.items.shape = shape; - ActivityLib.initActivity(this); - }; + if (this.grouping) { + ActivityLib.addGroupingEffect(this); + } + + ActivityLib.activityHandlersInit(this); + }, - this.draw(x, y); - }, + + grouping : function(x, y) { + if (x == undefined || y == undefined) { + x = this.items.shape.getBBox().x; + y = this.items.shape.getBBox().y; + } - /** - * Constructor for a Grouping Activity. - */ - GroupingActivity : function(id, x, y) { - this.id = id; - this.type = 'group'; - this.transitions = { - 'from' : [], - 'to' : [] - }; - this.draw = function(x, y) { if (this.items) { this.items.remove(); } - - x-=47; - y-=2; // create activity SVG elements paper.setStart(); @@ -64,28 +155,21 @@ }); paper.image('../images/grouping.gif', x + 47, y + 2, 30, 30); - paper.text(x + 62, y + 40, 'Grouping'); + paper.text(x + 62, y + 40, ActivityLib.shortenActivityTitle(this.title)); this.items = paper.setFinish(); this.items.shape = shape; - ActivityLib.initActivity(this); - }; + ActivityLib.activityHandlersInit(this); + }, - this.draw(x, y); - }, + + gate : function(x, y) { + if (x == undefined || y == undefined) { + x = this.items.shape.getBBox().x; + y = this.items.shape.getBBox().y; + } - /** - * Constructor for a Gate Activity. - */ - GateActivity : function(id, x, y) { - this.id = id; - this.type = 'gate'; - this.transitions = { - 'from' : [], - 'to' : [] - }; - this.draw = function(x, y) { if (this.items) { this.items.remove(); } @@ -107,42 +191,25 @@ this.items = paper.setFinish(); this.items.shape = shape; - ActivityLib.initActivity(this); - }; + ActivityLib.activityHandlersInit(this); + }, - this.draw(x, y); - }, - - - /** - * Either branching or converge point. - */ - BranchingEdgeActivity : function(id, x, y, branchingActivity) { - this.type = 'branchingEdge'; - this.transitions = { - 'from' : [], - 'to' : [] - }; - if (branchingActivity) { - // branchingActivity already exists, so this is the converge point - this.isStart = false; - branchingActivity.end = this; - } else { - // this is the branching point - this.isStart = true; - branchingActivity = new ActivityLib.BranchingActivity(id, this); - } - this.branchingActivity = branchingActivity; - this.draw = function(x, y) { + branching : function(x, y) { + if (x == undefined || y == undefined) { + x = this.items.shape.getBBox().x; + y = this.items.shape.getBBox().y; + } + if (this.items) { this.items.remove(); } // create activity SVG elements paper.setStart(); - var shape = paper.path('M ' + x + ' ' + y + - (this.isStart ? layout.defs.branchingEdgeStart : layout.defs.branchingEdgeEnd)) + var shape = paper.path(Raphael.format('M {0} {1}' + + (this.isStart ? layout.defs.branchingEdgeStart : layout.defs.branchingEdgeEnd), + x, y)) .attr({ 'fill' : this.isStart ? layout.colors.branchingEdgeStart : layout.colors.branchingEdgeEnd @@ -158,37 +225,75 @@ this.items = paper.setFinish(); this.items.shape = shape; - ActivityLib.initActivity(this); - }; - - this.draw(x, y); + ActivityLib.activityHandlersInit(this); + } }, /** - * Represents a set of branches. It is not displayed on canvas. + * Methods initialising and refreshing properties dialog for various kinds of activities. */ - BranchingActivity : function(id, branchingEdgeStart) { - this.id = id; - this.start = branchingEdgeStart; - this.branches = []; + loadPropertiesDialogContent : { + tool : function() { + var activity = this; + var content = activity.propertiesContent; + if (!content) { + // first run, create the content + content = activity.propertiesContent = $('#propertiesContentTool').clone().show(); + $('.title', content).val(activity.title); + + $('input, select', content).change(function(){ + // extract changed properties and redraw the activity + activity.title = $('.title', activity.propertiesContent).val(); + activity.grouping = $('.grouping option:selected', activity.propertiesContent) + .data('grouping'); + activity.draw(); + }); + } + + // find all groupings on canvas and fill dropdown menu with their titles + var emptyOption = $('