@@ -262,7 +262,9 @@ class AnnotationElement {
262
262
quadPoint [ 1 ] . y ,
263
263
] ;
264
264
this . data . rect = rect ;
265
- quadrilaterals . push ( this . _createContainer ( ignoreBorder ) ) ;
265
+ const quad = this . _createContainer ( ignoreBorder ) ;
266
+ quad . className = "highlightAnnotation" ;
267
+ quadrilaterals . push ( quad ) ;
266
268
}
267
269
this . data . rect = savedRect ;
268
270
return quadrilaterals ;
@@ -274,12 +276,17 @@ class AnnotationElement {
274
276
* are of a type that works with popups (such as Highlight annotations).
275
277
*
276
278
* @private
277
- * @param {HTMLSectionElement } container
278
279
* @param {HTMLDivElement|HTMLImageElement|null } trigger
279
280
* @param {Object } data
280
281
* @memberof AnnotationElement
281
282
*/
282
- _createPopup ( container , trigger , data ) {
283
+ _createPopup ( trigger , data ) {
284
+ let container = this . container ;
285
+ if ( this . quadrilaterals ) {
286
+ trigger = trigger || this . quadrilaterals ;
287
+ container = this . quadrilaterals [ 0 ] ;
288
+ }
289
+
283
290
// If no trigger element is specified, create it.
284
291
if ( ! trigger ) {
285
292
trigger = document . createElement ( "div" ) ;
@@ -433,7 +440,7 @@ class TextAnnotationElement extends AnnotationElement {
433
440
image . dataset . l10nArgs = JSON . stringify ( { type : this . data . name } ) ;
434
441
435
442
if ( ! this . data . hasPopup ) {
436
- this . _createPopup ( this . container , image , this . data ) ;
443
+ this . _createPopup ( image , this . data ) ;
437
444
}
438
445
439
446
this . container . appendChild ( image ) ;
@@ -790,6 +797,7 @@ class PopupAnnotationElement extends AnnotationElement {
790
797
constructor ( parameters ) {
791
798
const isRenderable = ! ! ( parameters . data . title || parameters . data . contents ) ;
792
799
super ( parameters , isRenderable ) ;
800
+ this . popup = true ;
793
801
}
794
802
795
803
/**
@@ -885,7 +893,6 @@ class PopupElement {
885
893
// disappear too. In that special case, hiding the wrapper suffices.
886
894
this . hideElement = this . hideWrapper ? wrapper : this . container ;
887
895
this . hideElement . setAttribute ( "hidden" , true ) ;
888
-
889
896
const popup = document . createElement ( "div" ) ;
890
897
popup . className = "popup" ;
891
898
@@ -1027,7 +1034,7 @@ class FreeTextAnnotationElement extends AnnotationElement {
1027
1034
this . container . className = "freeTextAnnotation" ;
1028
1035
1029
1036
if ( ! this . data . hasPopup ) {
1030
- this . _createPopup ( this . container , null , this . data ) ;
1037
+ this . _createPopup ( null , this . data ) ;
1031
1038
}
1032
1039
return this . container ;
1033
1040
}
@@ -1078,7 +1085,7 @@ class LineAnnotationElement extends AnnotationElement {
1078
1085
1079
1086
// Create the popup ourselves so that we can bind it to the line instead
1080
1087
// of to the entire container (which is the default).
1081
- this . _createPopup ( this . container , line , data ) ;
1088
+ this . _createPopup ( line , data ) ;
1082
1089
1083
1090
return this . container ;
1084
1091
}
@@ -1132,7 +1139,7 @@ class SquareAnnotationElement extends AnnotationElement {
1132
1139
1133
1140
// Create the popup ourselves so that we can bind it to the square instead
1134
1141
// of to the entire container (which is the default).
1135
- this . _createPopup ( this . container , square , data ) ;
1142
+ this . _createPopup ( square , data ) ;
1136
1143
1137
1144
return this . container ;
1138
1145
}
@@ -1186,7 +1193,7 @@ class CircleAnnotationElement extends AnnotationElement {
1186
1193
1187
1194
// Create the popup ourselves so that we can bind it to the circle instead
1188
1195
// of to the entire container (which is the default).
1189
- this . _createPopup ( this . container , circle , data ) ;
1196
+ this . _createPopup ( circle , data ) ;
1190
1197
1191
1198
return this . container ;
1192
1199
}
@@ -1248,7 +1255,7 @@ class PolylineAnnotationElement extends AnnotationElement {
1248
1255
1249
1256
// Create the popup ourselves so that we can bind it to the polyline
1250
1257
// instead of to the entire container (which is the default).
1251
- this . _createPopup ( this . container , polyline , data ) ;
1258
+ this . _createPopup ( polyline , data ) ;
1252
1259
1253
1260
return this . container ;
1254
1261
}
@@ -1285,7 +1292,7 @@ class CaretAnnotationElement extends AnnotationElement {
1285
1292
this . container . className = "caretAnnotation" ;
1286
1293
1287
1294
if ( ! this . data . hasPopup ) {
1288
- this . _createPopup ( this . container , null , this . data ) ;
1295
+ this . _createPopup ( null , this . data ) ;
1289
1296
}
1290
1297
return this . container ;
1291
1298
}
@@ -1347,7 +1354,7 @@ class InkAnnotationElement extends AnnotationElement {
1347
1354
1348
1355
// Create the popup ourselves so that we can bind it to the polyline
1349
1356
// instead of to the entire container (which is the default).
1350
- this . _createPopup ( this . container , polyline , data ) ;
1357
+ this . _createPopup ( polyline , data ) ;
1351
1358
1352
1359
svg . appendChild ( polyline ) ;
1353
1360
}
@@ -1379,9 +1386,10 @@ class HighlightAnnotationElement extends AnnotationElement {
1379
1386
this . container . className = "highlightAnnotation" ;
1380
1387
1381
1388
if ( ! this . data . hasPopup ) {
1382
- this . _createPopup ( this . container , null , this . data ) ;
1389
+ this . _createPopup ( null , this . data ) ;
1383
1390
}
1384
1391
return this . quadrilaterals || this . container ;
1392
+ // return this.container;
1385
1393
}
1386
1394
}
1387
1395
@@ -1406,7 +1414,7 @@ class UnderlineAnnotationElement extends AnnotationElement {
1406
1414
this . container . className = "underlineAnnotation" ;
1407
1415
1408
1416
if ( ! this . data . hasPopup ) {
1409
- this . _createPopup ( this . container , null , this . data ) ;
1417
+ this . _createPopup ( null , this . data ) ;
1410
1418
}
1411
1419
return this . container ;
1412
1420
}
@@ -1433,7 +1441,7 @@ class SquigglyAnnotationElement extends AnnotationElement {
1433
1441
this . container . className = "squigglyAnnotation" ;
1434
1442
1435
1443
if ( ! this . data . hasPopup ) {
1436
- this . _createPopup ( this . container , null , this . data ) ;
1444
+ this . _createPopup ( null , this . data ) ;
1437
1445
}
1438
1446
return this . container ;
1439
1447
}
@@ -1460,7 +1468,7 @@ class StrikeOutAnnotationElement extends AnnotationElement {
1460
1468
this . container . className = "strikeoutAnnotation" ;
1461
1469
1462
1470
if ( ! this . data . hasPopup ) {
1463
- this . _createPopup ( this . container , null , this . data ) ;
1471
+ this . _createPopup ( null , this . data ) ;
1464
1472
}
1465
1473
return this . container ;
1466
1474
}
@@ -1487,7 +1495,7 @@ class StampAnnotationElement extends AnnotationElement {
1487
1495
this . container . className = "stampAnnotation" ;
1488
1496
1489
1497
if ( ! this . data . hasPopup ) {
1490
- this . _createPopup ( this . container , null , this . data ) ;
1498
+ this . _createPopup ( null , this . data ) ;
1491
1499
}
1492
1500
return this . container ;
1493
1501
}
@@ -1528,7 +1536,7 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
1528
1536
trigger . addEventListener ( "dblclick" , this . _download . bind ( this ) ) ;
1529
1537
1530
1538
if ( ! this . data . hasPopup && ( this . data . title || this . data . contents ) ) {
1531
- this . _createPopup ( this . container , trigger , this . data ) ;
1539
+ this . _createPopup ( trigger , this . data ) ;
1532
1540
}
1533
1541
1534
1542
this . container . appendChild ( trigger ) ;
@@ -1615,7 +1623,12 @@ class AnnotationLayer {
1615
1623
parameters . div . appendChild ( renderedElement ) ;
1616
1624
}
1617
1625
} else {
1618
- parameters . div . appendChild ( rendered ) ;
1626
+ if ( element . popup ) {
1627
+ // popup div mustn't be on top of an annotation
1628
+ parameters . div . prepend ( rendered ) ;
1629
+ } else {
1630
+ parameters . div . appendChild ( rendered ) ;
1631
+ }
1619
1632
}
1620
1633
}
1621
1634
}
0 commit comments