From 7f8dd6a11ec530acac133c713d7276303509fce8 Mon Sep 17 00:00:00 2001 From: lduarte1991 Date: Thu, 25 Sep 2014 13:19:57 -0400 Subject: [PATCH] Annotation Tools: Thumbnail check breaks on creation - Fixed second similar function. Conflicts: common/static/js/vendor/ova/OpenSeaDragonAnnotation.js --- .../js/vendor/ova/OpenSeaDragonAnnotation.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js b/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js index 950718f337..3b65823abd 100644 --- a/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js +++ b/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js @@ -581,8 +581,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // 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); + + // code runs on annotation creation before thumbnail is created + var targetThumb = an.target ? an.target.thumb : false; + if (isContainer) { + // reason why this is okay is that we are trying to ascertain that the annotation + // is related to the image drawn. If thumbnail attribute is empty it means the annotation + // was just created and should still be considered an annotation of this image. + isSource = targetThumb ? (targetThumb.indexOf(sourceId) !== -1) : true; + } return (isOpenSeaDragon && isContainer && isImage && isRP && isSource); }, @@ -840,13 +847,13 @@ Annotator.Plugin.OpenSeaDragon = (function(_super) { // Makes sure OSD exists and that annotation is an image annotation // with a position in the OSD instance var isOpenSeaDragon = (typeof annotator.osda != 'undefined'); - var isContainer = (typeof an.target!='undefined' && an.target.container==this.viewer.id ); + var isContainer = (typeof an.target!='undefined' && an.target.container==osda.viewer.id ); var isImage = (typeof an.media!='undefined' && an.media=='image'); var isRP = (typeof rp!='undefined'); var isSource = false; // Double checks that the image being displayed matches the annotations - var source = this.viewer.source; + var source = osda.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, ' ');