Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -re837b7b90d6cbae5ecf051b9c9ba61b3097e0c51 -rb5f9c6df8c12ecc62e27fab71c6b3e8d8c3d499b --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision e837b7b90d6cbae5ecf051b9c9ba61b3097e0c51) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision b5f9c6df8c12ecc62e27fab71c6b3e8d8c3d499b) @@ -730,20 +730,22 @@ 'stroke' : layout.colors.selectEffect, 'stroke-dasharray' : '-' }); - object.items.resizeButton.show(); - object.items.resizeButton.toFront(); object.items.selectEffect = true; - // also select encapsulated activities - var childActivities = DecorationLib.getChildActivities(object.items.shape); - if (childActivities.length > 0) { - object.items.fitButton.show(); - - $.each(childActivities, function(){ - if (!this.parentActivity || !(this.parentActivity instanceof DecorationDefs.Container)) { - ActivityLib.addSelectEffect(this, false); - } - }); + if (!isReadOnlyMode) { + object.items.resizeButton.show(); + object.items.resizeButton.toFront(); + // also select encapsulated activities + var childActivities = DecorationLib.getChildActivities(object.items.shape); + if (childActivities.length > 0) { + object.items.fitButton.show(); + + $.each(childActivities, function(){ + if (!this.parentActivity || !(this.parentActivity instanceof DecorationDefs.Container)) { + ActivityLib.addSelectEffect(this, false); + } + }); + } } } else if (object instanceof ActivityDefs.Transition) { // show only if Transition is selectable, i.e. is a branch, has a title Index: lams_central/web/includes/javascript/authoring/authoringDecoration.js =================================================================== diff -u -re837b7b90d6cbae5ecf051b9c9ba61b3097e0c51 -rb5f9c6df8c12ecc62e27fab71c6b3e8d8c3d499b --- lams_central/web/includes/javascript/authoring/authoringDecoration.js (.../authoringDecoration.js) (revision e837b7b90d6cbae5ecf051b9c9ba61b3097e0c51) +++ lams_central/web/includes/javascript/authoring/authoringDecoration.js (.../authoringDecoration.js) (revision b5f9c6df8c12ecc62e27fab71c6b3e8d8c3d499b) @@ -155,13 +155,13 @@ this.items.shape = paper.text(x, y, this.title) .attr(layout.defaultTextAttributes) .attr('text-anchor', 'start'); + this.items.push(this.items.shape); + + this.items.shape.attr('cursor', 'pointer'); + this.items.click(HandlerLib.itemClickHandler); if (!isReadOnlyMode){ - this.items.shape.attr('cursor', 'pointer'); - this.items.shape.mousedown(HandlerDecorationLib.labelMousedownHandler) - .click(HandlerLib.itemClickHandler); + this.items.shape.mousedown(HandlerDecorationLib.labelMousedownHandler); } - - this.items.push(this.items.shape); this.items.data('parentObject', this); } Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== diff -u -re837b7b90d6cbae5ecf051b9c9ba61b3097e0c51 -rb5f9c6df8c12ecc62e27fab71c6b3e8d8c3d499b --- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision e837b7b90d6cbae5ecf051b9c9ba61b3097e0c51) +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision b5f9c6df8c12ecc62e27fab71c6b3e8d8c3d499b) @@ -566,6 +566,9 @@ } ]), + /** + * Button for saving the current design. + */ 'buttonsSave' : sharedButtons.concat([ { 'class' : 'defaultFocus', @@ -645,25 +648,39 @@ } ]), + + /**' + * Button for importing activities from an existing LD. + */ 'buttonsImportPart' : sharedButtons.concat([ { 'id' : 'importPartLdStoreButton', 'class' : 'defaultFocus', 'text' : LABELS.IMPORT_BUTTON, 'click' : function() { var dialog = $(this), - frameActivities = $('#ldStoreDialogImportPartFrame', dialog)[0].contentWindow.layout.activities, + frameLayout = $('#ldStoreDialogImportPartFrame', dialog)[0].contentWindow.layout, selectedActivities = [], - addActivities = []; + addActivities = [], + selectedAnnotations = []; + - $.each(frameActivities, function(){ + $.each(frameLayout.activities, function(){ if (this.items.selectEffect) { selectedActivities.push(this); dialog.dialog('option', 'importActivity')(this, addActivities); } }); + $.each(frameLayout.regions.concat(frameLayout.labels), function(){ + if (this.items.selectEffect) { + selectedAnnotations.push(this); + // unlike importActivity(), this method already takes care of UIIDs + // and adding new items to collections + dialog.dialog('option', 'importAnnotation')(this); + } + }); - if (selectedActivities.length == 0) { + if (addActivities.length == 0 && selectedAnnotations.length == 0) { alert('Click on activities to select them for import'); return; } @@ -709,7 +726,7 @@ layout.activities = layout.activities.concat(addActivities); } - + dialog.dialog('close'); } } @@ -835,6 +852,24 @@ addActivities.push(addActivity); } + }, + + /** + * Extracts a selected annotation from another LD. + */ + 'importAnnotation' : function(annotation) { + // annotations in the another LD have different clousures, so they can not be imported directly + // they need to be recreated from a scratch with current LD being their context + var frameWindow = $('#ldStoreDialogImportPartFrame', layout.ldStoreDialog)[0].contentWindow, + frameDecorationDefs = frameWindow.DecorationDefs, + box = annotation.items.shape.getBBox(); + + // there are no transitions or child/parent relations, so they can be directly recreated + if (annotation instanceof frameDecorationDefs.Region) { + DecorationLib.addRegion(box.x, box.y, box.x2, box.y2, annotation.title, annotation.items.shape.attr('fill')); + } else if (annotation instanceof frameDecorationDefs.Label) { + DecorationLib.addLabel(box.x, box.y, annotation.title); + } } }); @@ -1803,10 +1838,10 @@ $.each(ld.annotations, function(){ var isRegion = this.endXcoord; if (isRegion) { - DecorationDefs.addRegion(this.xcoord, this.ycoord, this.endXcoord, this.endYcoord, + DecorationLib.addRegion(this.xcoord, this.ycoord, this.endXcoord, this.endYcoord, this. title, this.color); } else { - DecorationDefs.addLabel(this.xcoord, this.ycoord, this.title); + DecorationLib.addLabel(this.xcoord, this.ycoord, this.title); } }); @@ -2201,14 +2236,14 @@ isRegion = this instanceof DecorationDefs.Region; annotations.push({ - 'id' : this.id, + 'id' : this.id, 'annotationUIID' : this.uiid, - 'title' : this.title, - 'xCoord' : box.x, - 'yCoord' : box.y, - 'endXCoord' : isRegion ? box.x2 : null, - 'endYCoord' : isRegion ? box.y2 : null, - 'color' : isRegion ? this.items.shape.attr('fill') : null + 'title' : this.title, + 'xCoord' : parseInt(box.x), + 'yCoord' : parseInt(box.y), + 'endXCoord' : isRegion ? parseInt(box.x2) : null, + 'endYCoord' : isRegion ? parseInt(box.y2) : null, + 'color' : isRegion ? this.items.shape.attr('fill') : null }); }); Index: lams_central/web/includes/javascript/authoring/authoringMenu.js =================================================================== diff -u -re837b7b90d6cbae5ecf051b9c9ba61b3097e0c51 -rb5f9c6df8c12ecc62e27fab71c6b3e8d8c3d499b --- lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision e837b7b90d6cbae5ecf051b9c9ba61b3097e0c51) +++ lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision b5f9c6df8c12ecc62e27fab71c6b3e8d8c3d499b) @@ -414,6 +414,8 @@ if (!iconCode) { // no precached PNG image, generate one from SVG + // the PNG image can not be fetched using Ajax(!): + // it can be done only asynchronously or the binary stream has to be converted to text $.ajax({ url : iconPath, async: false,