Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r0d275bf753620ae71aeb4e7589c540c9777532cb -r1ab5b0aabad85e5cee0203bd43e0da1c83f69fb9 Binary files differ Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== diff -u -r88e98be30293b57a81d4a8a6e5cdaf5c62e97883 -r1ab5b0aabad85e5cee0203bd43e0da1c83f69fb9 --- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 88e98be30293b57a81d4a8a6e5cdaf5c62e97883) +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 1ab5b0aabad85e5cee0203bd43e0da1c83f69fb9) @@ -87,6 +87,15 @@ initTemplates(); PropertyLib.init(); MenuLib.init(); + + window.onbeforeunload = function(){ + if (layout.activities.length > 0 + || layout.regions.length > 0 + || layout.labels.length > 0 + || layout.floatingActivity) { + return 'Your design is not saved.\nAny changes you made since you last saved will be lost.'; + } + }; }); @@ -424,11 +433,7 @@ $('#ldDescriptionFieldTitle').text(ld.title); CKEDITOR.instances['ldDescriptionFieldDescription'].setData(ld.description); - var resizeNeeded = false, - arrangeNeeded = false, - // current paper dimensions - paperWidth = paper.width, - paperHeight = paper.height, + var arrangeNeeded = false, branchToBranching = {}, // helper for finding last activity in a branch branchToActivities = {}; @@ -450,8 +455,8 @@ activityData.activityUIID, activityData.toolContentID, activityData.toolID, - activityData.xCoord, - activityData.yCoord, + activityData.xCoord ? activityData.xCoord : 1, + activityData.yCoord ? activityData.yCoord : 1, activityData.activityTitle, activityData.supportsOutputs); // for later reference @@ -616,22 +621,6 @@ branchData.firstActivity = activity; } } - - // if we do arranging afterwards, paper will be resized anyway - if (!arrangeNeeded) { - // find new dimensions of paper - var activityBox = activity.items.shape.getBBox(), - maxX = activityBox.x + activityBox.width, - maxY = activityBox.y + activityBox.height; - if (maxX > paperWidth) { - resizeNeeded = true; - paperWidth = maxX; - } - if (maxY > paperHeight) { - resizeNeeded = true; - paperHeight = maxY; - } - } }); // assign previously extracted branches to branching activities @@ -818,7 +807,23 @@ if (arrangeNeeded) { MenuLib.arrangeActivities(); } else { - if (resizeNeeded) { + // if we do arranging afterwards, paper will be resized anyway + var paperWidth = paper.width, + paperHeight = paper.height; + $.each(layout.activities, function(){ + // find new dimensions of paper + var activityBox = this.items.shape.getBBox(), + maxX = activityBox.x + activityBox.width, + maxY = activityBox.y + activityBox.height; + if (maxX > paperWidth) { + paperWidth = maxX; + } + if (maxY > paperHeight) { + paperHeight = maxY; + } + }); + + if (paperWidth > paper.width || paperHeight > paper.height) { resizePaper(paperWidth, paperHeight); } else { HandlerLib.resetCanvasMode(true); @@ -894,6 +899,8 @@ $.each(layoutActivities, function(){ var activity = this, activityBox = activity.items ? activity.items.shape.getBBox() : null, + x = activityBox ? parseInt(activityBox.x) : null, + y = activityBox ? parseInt(activityBox.y) : null, activityTypeID = null, toolID = activity.toolID, learningLibraryID = toolID ? toolID : activity.learningLibraryID, @@ -985,8 +992,14 @@ } else if (activity instanceof ActivityLib.FloatingActivity){ activityTypeID = 15; } - + if (activity.parentActivity && activity.parentActivity instanceof DecorationLib.Container){ + // positions are relative to parent container + var activityBox = activity.parentActivity.items.getBBox(); + x -= activityBox.x; + y -= activityBox.y; + } + // add activity activities.push({ 'activityID' : activity.id, @@ -1002,8 +1015,8 @@ 'parentActivityID' : activity.parentActivity ? activity.parentActivity.id : null, 'parentUIID' : activity.parentActivity ? activity.parentActivity.uiid : null, 'libraryActivityUIImage' : iconPath, - 'xCoord' : activityBox ? parseInt(activityBox.x) : null, - 'yCoord' : activityBox ? parseInt(activityBox.y) : null, + 'xCoord' : x, + 'yCoord' : y, 'activityTitle' : activity.title, 'activityCategoryID' : activity instanceof ActivityLib.ToolActivity || activity instanceof ActivityLib.ParallelActivity ? Index: lams_central/web/includes/javascript/authoring/authoringMenu.js =================================================================== diff -u -r9fb16007bc803d29180994effaed30ebb0a2e561 -r1ab5b0aabad85e5cee0203bd43e0da1c83f69fb9 --- lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision 9fb16007bc803d29180994effaed30ebb0a2e561) +++ lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision 1ab5b0aabad85e5cee0203bd43e0da1c83f69fb9) @@ -687,6 +687,8 @@ resizePaper(); } else { + // do not prompt again + window.onbeforeunload = null; // full window reload so new content ID gets generated document.location.href = LAMS_URL + 'authoring/author.do?method=openAuthoring'; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/LearningDesignDTO.java =================================================================== diff -u -r0144e9d0f7fc574a887933024183a8a9049bc414 -r1ab5b0aabad85e5cee0203bd43e0da1c83f69fb9 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/LearningDesignDTO.java (.../LearningDesignDTO.java) (revision 0144e9d0f7fc574a887933024183a8a9049bc414) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/LearningDesignDTO.java (.../LearningDesignDTO.java) (revision 1ab5b0aabad85e5cee0203bd43e0da1c83f69fb9) @@ -84,7 +84,7 @@ private ArrayList transitions; private ArrayList branchMappings; private ArrayList competences; - private Set annotations; + private ArrayList annotations; public LearningDesignDTO() { } @@ -142,8 +142,8 @@ this.activities = populateActivities(learningDesign, languageCode); this.transitions = populateTransitions(learningDesign); this.competences = populateCompetences(learningDesign); - this.annotations = learningDesign.getAnnotations(); - + this.annotations = new ArrayList(); + this.annotations.addAll(learningDesign.getAnnotations()); } /** @@ -740,11 +740,11 @@ this.competences = competences; } - public Set getAnnotations() { + public ArrayList getAnnotations() { return annotations; } - public void setAnnotations(Set annotations) { + public void setAnnotations(ArrayList annotations) { this.annotations = annotations; } } \ No newline at end of file