@@ -288,15 +288,14 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', {
288
288
289
289
annotations . each ( function ( annotation ) {
290
290
291
+ var annoId = annotation . get ( 'id' ) ;
291
292
var name = annotation . get ( 'title' ) ;
292
293
var uri = annotation . get ( 'uri' ) ;
293
294
var categories = annotation . get ( 'categories' ) ;
294
295
var priority = annotation . get ( 'priority' ) ;
295
296
var fn = annotation . get ( 'fn' ) ;
296
297
var plist = Ext . Array . toArray ( annotation . get ( 'plist' ) ) ;
297
298
298
- Ext . Array . insert ( me . shapes . get ( 'annotations' ) , 0 , plist ) ;
299
-
300
299
Ext . Array . each ( plist , function ( shape ) {
301
300
302
301
var id = shape . id ;
@@ -306,33 +305,43 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', {
306
305
var height = shape . lry - shape . uly ;
307
306
var partType = shape . type ;
308
307
309
- var anno = document . createElement ( "div" ) ;
310
- anno . id = me . id + '_' + id ;
311
- anno . className = "annotation " + categories + ' ' + priority + ' ' + partType ;
308
+ var anno = me . viewer . getOverlayById ( me . id + '_' + id ) ;
309
+ if ( anno === null ) {
310
+
311
+ var anno = document . createElement ( 'div' ) ;
312
+ anno . id = me . id + '_' + id ;
313
+ anno . className = 'annotation' ;
314
+
315
+ var annoIcon = document . createElement ( 'div' ) ;
316
+ annoIcon . id = annoId + '_' + anno . id + '_inner' ;
317
+ annoIcon . className = 'annotIcon ' + categories + ' ' + priority + ' ' + partType ;
318
+ anno . append ( annoIcon ) ;
319
+
320
+ var point = me . viewer . viewport . imageToViewportCoordinates ( x , y ) ;
321
+ var rect = me . viewer . viewport . imageToViewportRectangle ( x , y , width , height ) ;
322
+
323
+ me . viewer . addOverlay ( { element :anno , location :new OpenSeadragon . Rect ( point . x , point . y , rect . width , rect . height ) } ) ;
312
324
313
- var annoIcon = document . createElement ( "div" ) ;
314
- annoIcon . id = anno . id + '_inner' ;
315
- annoIcon . className = "annotIcon" ;
316
- anno . append ( annoIcon ) ;
325
+ } else {
326
+
327
+ var anno = me . el . getById ( me . id + '_' + id ) ;
328
+ var annoIcon = document . createElement ( 'div' ) ;
329
+ annoIcon . id = annoId + '_' + anno . id + '_inner' ;
330
+ annoIcon . className = 'annotIcon ' + categories + ' ' + priority + ' ' + partType ;
331
+ anno . dom . append ( annoIcon ) ;
332
+ }
333
+
334
+ Ext . Array . push ( me . shapes . get ( 'annotations' ) , annoId + '_' + anno . id + '_inner' ) ;
335
+ var annoIcon = me . el . getById ( annoId + '_' + anno . id + '_inner' ) ;
317
336
318
- var point = me . viewer . viewport . imageToViewportCoordinates ( x , y ) ;
319
- var rect = me . viewer . viewport . imageToViewportRectangle ( x , y , width , height ) ;
320
-
321
- me . viewer . addOverlay ( {
322
- element : anno ,
323
- location : new OpenSeadragon . Rect ( point . x , point . y , rect . width , rect . height )
324
- } ) ;
325
-
326
- var anno = me . el . getById ( me . id + '_' + id ) ;
327
-
328
- anno . on ( 'click' , me . openShapeLink , me , {
337
+ annoIcon . on ( 'click' , me . openShapeLink , me , {
329
338
single : true ,
330
339
stopEvent : true ,
331
340
fn : fn
332
341
} ) ;
333
342
334
343
var tip = Ext . create ( 'Ext.tip.ToolTip' , {
335
- target : me . id + '_' + id ,
344
+ target : annoId + '_' + anno . id + '_inner' ,
336
345
cls : 'annotationTip' ,
337
346
width : me . annotTipWidth ,
338
347
maxWidth : me . annotTipMaxWidth ,
@@ -386,7 +395,11 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', {
386
395
getShapeElem : function ( shapeId ) {
387
396
388
397
var me = this ;
389
- return me . el . getById ( me . id + '_' + shapeId ) ;
398
+ var elem = me . el . getById ( me . id + '_' + shapeId ) ;
399
+ if ( elem === null )
400
+ elem = me . el . getById ( shapeId ) ;
401
+
402
+ return elem ;
390
403
} ,
391
404
392
405
listenForShapeLink : function ( e , dom , args ) {
0 commit comments