From 56340968257804c0c284e92efda7808cedbaaef6 Mon Sep 17 00:00:00 2001 From: lduarte1991 Date: Fri, 19 Sep 2014 12:34:02 -0400 Subject: [PATCH 1/3] Image Annotation Tool: Fixes _isOpenSeaDragon function --- .../static/js/vendor/ova/OpenSeaDragonAnnotation.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js b/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js index 37d674dbb8b2..950718f3377b 100644 --- a/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js +++ b/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js @@ -577,13 +577,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. var isRP = (typeof rp!='undefined'); var isSource = false; - // Double checks that the image being displayed matches the annotations - var source = this.viewer.source; - var tilesUrl = typeof source.tilesUrl!='undefined'?source.tilesUrl:''; - var functionUrl = typeof source.getTileUrl!='undefined'?source.getTileUrl:''; - var compareUrl = tilesUrl!=''?tilesUrl:('' + functionUrl).replace(/\s+/g, ' '); - if(isContainer) isSource = (an.target.src == compareUrl); - + // Though it would be better to store server ids of images in the annotation that + // would require changing annotations that were already made, instead we check if + // the id is a substring of the thumbnail, which according to OpenSeaDragon API should be the case. + var sourceId = this.viewer.source['@id']; + var targetThumb = an.target.thumb; + if (isContainer) isSource = (targetThumb.indexOf(sourceId) !== -1); return (isOpenSeaDragon && isContainer && isImage && isRP && isSource); }, From b7313d6d2e3e2bee6ab81115f99f3ef8b6585b7c Mon Sep 17 00:00:00 2001 From: lduarte1991 Date: Fri, 19 Sep 2014 12:37:02 -0400 Subject: [PATCH 2/3] Annotation Tools: Pylint Fix left over from previous PR --- common/lib/xmodule/xmodule/imageannotation_module.py | 2 +- common/lib/xmodule/xmodule/textannotation_module.py | 2 +- common/lib/xmodule/xmodule/videoannotation_module.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/lib/xmodule/xmodule/imageannotation_module.py b/common/lib/xmodule/xmodule/imageannotation_module.py index db4572c9140a..60d31fcfe4be 100644 --- a/common/lib/xmodule/xmodule/imageannotation_module.py +++ b/common/lib/xmodule/xmodule/imageannotation_module.py @@ -115,7 +115,7 @@ def __init__(self, *args, **kwargs): if self.runtime.get_real_user is not None: try: 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.") def _extract_instructions(self, xmltree): diff --git a/common/lib/xmodule/xmodule/textannotation_module.py b/common/lib/xmodule/xmodule/textannotation_module.py index 761585316fd6..662637f7c3f4 100644 --- a/common/lib/xmodule/xmodule/textannotation_module.py +++ b/common/lib/xmodule/xmodule/textannotation_module.py @@ -109,7 +109,7 @@ def __init__(self, *args, **kwargs): if self.runtime.get_real_user is not None: try: 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.") def _extract_instructions(self, xmltree): diff --git a/common/lib/xmodule/xmodule/videoannotation_module.py b/common/lib/xmodule/xmodule/videoannotation_module.py index 7825f6417f42..78ac023af41e 100644 --- a/common/lib/xmodule/xmodule/videoannotation_module.py +++ b/common/lib/xmodule/xmodule/videoannotation_module.py @@ -109,7 +109,7 @@ def __init__(self, *args, **kwargs): if self.runtime.get_real_user is not None: try: 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.") def _extract_instructions(self, xmltree): From 29cddbca2cb2853445ca8ff972ab252f3cd8785b Mon Sep 17 00:00:00 2001 From: lduarte1991 Date: Fri, 19 Sep 2014 12:48:38 -0400 Subject: [PATCH 3/3] Annotation Tools: Non-critical highlights == undefined fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i.e. they should be fixed but don’t cause the whole thing to break. - PR fixes - Reverted Fix --- common/static/js/vendor/ova/OpenSeaDragonAnnotation.js | 4 +++- common/static/js/vendor/ova/catch/js/catch.js | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js b/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js index 950718f3377b..a3da590ca387 100644 --- a/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js +++ b/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js @@ -582,7 +582,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // the id is a substring of the thumbnail, which according to OpenSeaDragon API should be the case. var sourceId = this.viewer.source['@id']; var targetThumb = an.target.thumb; - if (isContainer) isSource = (targetThumb.indexOf(sourceId) !== -1); + if (isContainer) { + isSource = (targetThumb.indexOf(sourceId) !== -1); + } return (isOpenSeaDragon && isContainer && isImage && isRP && isSource); }, diff --git a/common/static/js/vendor/ova/catch/js/catch.js b/common/static/js/vendor/ova/catch/js/catch.js index 1711c1b44cd7..75f037fc8dd7 100644 --- a/common/static/js/vendor/ova/catch/js/catch.js +++ b/common/static/js/vendor/ova/catch/js/catch.js @@ -874,7 +874,9 @@ CatchAnnotation.prototype = { var an = allannotations[item]; // Makes sure that all images are set to transparent in case one was // 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 var bounds = new OpenSeadragon.Rect(an.bounds.x, an.bounds.y, an.bounds.width, an.bounds.height); osda.viewer.viewport.fitBounds(bounds, false); @@ -883,7 +885,9 @@ CatchAnnotation.prototype = { 'slow'); // signifies a selected annotation once OSD has zoomed in on the // 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 = { startOffset = hasRanges?an.ranges[0].startOffset:'', 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'); // change the color