Commit 3cdfdae8 by Sarina Canelake

Merge pull request #5305 from lduarte1991/lduarte-harvardx-pr28

Fixes check for Image Annotation Tool to include ID from image server and fix scrolling bug
parents 328c076b 29cddbca
...@@ -115,7 +115,7 @@ class ImageAnnotationModule(AnnotatableFields, XModule): ...@@ -115,7 +115,7 @@ class ImageAnnotationModule(AnnotatableFields, XModule):
if self.runtime.get_real_user is not None: if self.runtime.get_real_user is not None:
try: try:
self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
except: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
self.user_email = _("No email address found.") self.user_email = _("No email address found.")
def _extract_instructions(self, xmltree): def _extract_instructions(self, xmltree):
......
...@@ -109,7 +109,7 @@ class TextAnnotationModule(AnnotatableFields, XModule): ...@@ -109,7 +109,7 @@ class TextAnnotationModule(AnnotatableFields, XModule):
if self.runtime.get_real_user is not None: if self.runtime.get_real_user is not None:
try: try:
self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
except: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
self.user_email = _("No email address found.") self.user_email = _("No email address found.")
def _extract_instructions(self, xmltree): def _extract_instructions(self, xmltree):
......
...@@ -109,7 +109,7 @@ class VideoAnnotationModule(AnnotatableFields, XModule): ...@@ -109,7 +109,7 @@ class VideoAnnotationModule(AnnotatableFields, XModule):
if self.runtime.get_real_user is not None: if self.runtime.get_real_user is not None:
try: try:
self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email self.user_email = self.runtime.get_real_user(self.runtime.anonymous_student_id).email
except: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
self.user_email = _("No email address found.") self.user_email = _("No email address found.")
def _extract_instructions(self, xmltree): def _extract_instructions(self, xmltree):
......
...@@ -577,13 +577,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -577,13 +577,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
var isRP = (typeof rp!='undefined'); var isRP = (typeof rp!='undefined');
var isSource = false; var isSource = false;
// Double checks that the image being displayed matches the annotations // Though it would be better to store server ids of images in the annotation that
var source = this.viewer.source; // would require changing annotations that were already made, instead we check if
var tilesUrl = typeof source.tilesUrl!='undefined'?source.tilesUrl:''; // the id is a substring of the thumbnail, which according to OpenSeaDragon API should be the case.
var functionUrl = typeof source.getTileUrl!='undefined'?source.getTileUrl:''; var sourceId = this.viewer.source['@id'];
var compareUrl = tilesUrl!=''?tilesUrl:('' + functionUrl).replace(/\s+/g, ' '); var targetThumb = an.target.thumb;
if(isContainer) isSource = (an.target.src == compareUrl); if (isContainer) {
isSource = (targetThumb.indexOf(sourceId) !== -1);
}
return (isOpenSeaDragon && isContainer && isImage && isRP && isSource); return (isOpenSeaDragon && isContainer && isImage && isRP && isSource);
}, },
......
...@@ -874,7 +874,9 @@ CatchAnnotation.prototype = { ...@@ -874,7 +874,9 @@ CatchAnnotation.prototype = {
var an = allannotations[item]; var an = allannotations[item];
// Makes sure that all images are set to transparent in case one was // Makes sure that all images are set to transparent in case one was
// previously selected. // previously selected.
an.highlights[0].style.background = "rgba(0, 0, 0, 0)"; if (an.highlights) {
an.highlights[0].style.background = "rgba(0, 0, 0, 0)";
}
if (typeof an.id !== 'undefined' && an.id === osdaId) { // this is the annotation if (typeof an.id !== 'undefined' && an.id === osdaId) { // this is the annotation
var bounds = new OpenSeadragon.Rect(an.bounds.x, an.bounds.y, an.bounds.width, an.bounds.height); var bounds = new OpenSeadragon.Rect(an.bounds.x, an.bounds.y, an.bounds.width, an.bounds.height);
osda.viewer.viewport.fitBounds(bounds, false); osda.viewer.viewport.fitBounds(bounds, false);
...@@ -883,7 +885,9 @@ CatchAnnotation.prototype = { ...@@ -883,7 +885,9 @@ CatchAnnotation.prototype = {
'slow'); 'slow');
// signifies a selected annotation once OSD has zoomed in on the // signifies a selected annotation once OSD has zoomed in on the
// appropriate area, it turns the background a bit yellow // appropriate area, it turns the background a bit yellow
an.highlights[0].style.background = "rgba(255, 255, 10, 0.2)"; if (an.highlights !== undefined) {
an.highlights[0].style.background = "rgba(255, 255, 10, 0.2)";
}
} }
} }
}, },
...@@ -912,7 +916,7 @@ CatchAnnotation.prototype = { ...@@ -912,7 +916,7 @@ CatchAnnotation.prototype = {
startOffset = hasRanges?an.ranges[0].startOffset:'', startOffset = hasRanges?an.ranges[0].startOffset:'',
endOffset = hasRanges?an.ranges[0].endOffset:''; endOffset = hasRanges?an.ranges[0].endOffset:'';
if (typeof startOffset !== 'undefined' && typeof endOffset !== 'undefined') { if (typeof startOffset !== 'undefined' && typeof endOffset !== 'undefined' && typeof an.highlights) {
$(an.highlights).parent().find('.annotator-hl').removeClass('api'); $(an.highlights).parent().find('.annotator-hl').removeClass('api');
// change the color // change the color
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment