pdfjs-dist 2.0.943 → 2.4.456

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (192) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8286 -14230
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +25500 -26628
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25473 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +57878 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +407 -0
  29. package/es5/web/pdf_viewer.js +7757 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +2887 -4094
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +855 -778
  36. package/lib/core/arithmetic_decoder.js +325 -311
  37. package/lib/core/bidi.js +117 -50
  38. package/lib/core/ccitt.js +251 -89
  39. package/lib/core/ccitt_stream.js +26 -16
  40. package/lib/core/cff_parser.js +525 -197
  41. package/lib/core/charsets.js +6 -5
  42. package/lib/core/chunked_stream.js +541 -406
  43. package/lib/core/cmap.js +368 -253
  44. package/lib/core/colorspace.js +781 -800
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +609 -422
  47. package/lib/core/document.js +649 -481
  48. package/lib/core/encodings.js +33 -24
  49. package/lib/core/evaluator.js +1471 -736
  50. package/lib/core/font_renderer.js +289 -149
  51. package/lib/core/fonts.js +1067 -413
  52. package/lib/core/function.js +517 -287
  53. package/lib/core/glyphlist.js +4529 -4527
  54. package/lib/core/image.js +232 -114
  55. package/lib/core/image_utils.js +94 -0
  56. package/lib/core/jbig2.js +711 -342
  57. package/lib/core/jbig2_stream.js +31 -19
  58. package/lib/core/jpeg_stream.js +151 -26
  59. package/lib/core/jpg.js +433 -181
  60. package/lib/core/jpx.js +551 -143
  61. package/lib/core/jpx_stream.js +40 -28
  62. package/lib/core/metrics.js +2931 -2931
  63. package/lib/core/murmurhash3.js +104 -97
  64. package/lib/core/obj.js +1561 -1053
  65. package/lib/core/operator_list.js +192 -64
  66. package/lib/core/parser.js +1162 -864
  67. package/lib/core/pattern.js +224 -75
  68. package/lib/core/pdf_manager.js +154 -285
  69. package/lib/core/primitives.js +145 -69
  70. package/lib/core/ps_parser.js +212 -162
  71. package/lib/core/standard_fonts.js +245 -244
  72. package/lib/core/stream.js +353 -81
  73. package/lib/core/type1_parser.js +218 -68
  74. package/lib/core/unicode.js +1682 -1655
  75. package/lib/core/worker.js +233 -302
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +808 -862
  78. package/lib/display/api.js +1778 -1462
  79. package/lib/display/api_compatibility.js +14 -9
  80. package/lib/display/canvas.js +463 -140
  81. package/lib/display/content_disposition.js +86 -58
  82. package/lib/display/display_utils.js +524 -0
  83. package/lib/display/fetch_stream.js +202 -274
  84. package/lib/display/font_loader.js +311 -333
  85. package/lib/display/metadata.js +98 -88
  86. package/lib/display/network.js +343 -347
  87. package/lib/display/network_utils.js +46 -26
  88. package/lib/display/node_stream.js +326 -404
  89. package/lib/display/pattern_helper.js +168 -69
  90. package/lib/display/svg.js +1296 -885
  91. package/lib/display/text_layer.js +229 -103
  92. package/lib/display/transport_stream.js +290 -250
  93. package/lib/display/webgl.js +116 -83
  94. package/lib/display/worker_options.js +6 -5
  95. package/lib/display/xml_parser.js +358 -337
  96. package/lib/examples/node/domstubs.js +95 -39
  97. package/lib/pdf.js +49 -31
  98. package/lib/pdf.worker.js +7 -5
  99. package/lib/shared/compatibility.js +3 -145
  100. package/lib/shared/is_node.js +8 -7
  101. package/lib/shared/message_handler.js +367 -314
  102. package/lib/shared/util.js +421 -415
  103. package/lib/test/unit/annotation_spec.js +1570 -690
  104. package/lib/test/unit/api_spec.js +855 -493
  105. package/lib/test/unit/bidi_spec.js +12 -12
  106. package/lib/test/unit/cff_parser_spec.js +88 -61
  107. package/lib/test/unit/clitests_helper.js +9 -12
  108. package/lib/test/unit/cmap_spec.js +140 -88
  109. package/lib/test/unit/colorspace_spec.js +204 -152
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +194 -182
  112. package/lib/test/unit/custom_spec.js +50 -64
  113. package/lib/test/unit/display_svg_spec.js +53 -38
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +17 -22
  116. package/lib/test/unit/encodings_spec.js +15 -57
  117. package/lib/test/unit/evaluator_spec.js +90 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +219 -205
  120. package/lib/test/unit/jasmine-boot.js +68 -39
  121. package/lib/test/unit/message_handler_spec.js +187 -160
  122. package/lib/test/unit/metadata_spec.js +87 -34
  123. package/lib/test/unit/murmurhash3_spec.js +13 -13
  124. package/lib/test/unit/network_spec.js +26 -59
  125. package/lib/test/unit/network_utils_spec.js +187 -121
  126. package/lib/test/unit/node_stream_spec.js +98 -90
  127. package/lib/test/unit/parser_spec.js +173 -131
  128. package/lib/test/unit/pdf_find_controller_spec.js +148 -67
  129. package/lib/test/unit/pdf_find_utils_spec.js +35 -34
  130. package/lib/test/unit/pdf_history_spec.js +45 -33
  131. package/lib/test/unit/primitives_spec.js +161 -126
  132. package/lib/test/unit/stream_spec.js +22 -15
  133. package/lib/test/unit/test_utils.js +149 -98
  134. package/lib/test/unit/testreporter.js +36 -18
  135. package/lib/test/unit/type1_parser_spec.js +46 -44
  136. package/lib/test/unit/ui_utils_spec.js +388 -372
  137. package/lib/test/unit/unicode_spec.js +49 -46
  138. package/lib/test/unit/util_spec.js +144 -248
  139. package/lib/web/annotation_layer_builder.js +75 -95
  140. package/lib/web/app.js +1538 -1147
  141. package/lib/web/app_options.js +116 -104
  142. package/lib/web/base_viewer.js +950 -775
  143. package/lib/web/chromecom.js +217 -225
  144. package/lib/web/debugger.js +236 -148
  145. package/lib/web/download_manager.js +50 -50
  146. package/lib/web/firefox_print_service.js +51 -33
  147. package/lib/web/firefoxcom.js +225 -352
  148. package/lib/web/genericcom.js +30 -93
  149. package/lib/web/genericl10n.js +26 -143
  150. package/lib/web/grab_to_pan.js +57 -33
  151. package/lib/web/interfaces.js +105 -232
  152. package/lib/web/overlay_manager.js +73 -227
  153. package/lib/web/password_prompt.js +44 -62
  154. package/lib/web/pdf_attachment_viewer.js +118 -123
  155. package/lib/web/pdf_cursor_tools.js +89 -93
  156. package/lib/web/pdf_document_properties.js +242 -281
  157. package/lib/web/pdf_find_bar.js +157 -163
  158. package/lib/web/pdf_find_controller.js +598 -454
  159. package/lib/web/pdf_find_utils.js +32 -16
  160. package/lib/web/pdf_history.js +481 -355
  161. package/lib/web/pdf_link_service.js +355 -323
  162. package/lib/web/pdf_outline_viewer.js +167 -152
  163. package/lib/web/pdf_page_view.js +511 -457
  164. package/lib/web/pdf_presentation_mode.js +347 -335
  165. package/lib/web/pdf_print_service.js +133 -103
  166. package/lib/web/pdf_rendering_queue.js +98 -100
  167. package/lib/web/pdf_sidebar.js +323 -299
  168. package/lib/web/pdf_sidebar_resizer.js +107 -108
  169. package/lib/web/pdf_single_page_viewer.js +94 -146
  170. package/lib/web/pdf_thumbnail_view.js +319 -269
  171. package/lib/web/pdf_thumbnail_viewer.js +219 -199
  172. package/lib/web/pdf_viewer.component.js +111 -32
  173. package/lib/web/pdf_viewer.js +61 -101
  174. package/lib/web/preferences.js +87 -272
  175. package/lib/web/secondary_toolbar.js +207 -220
  176. package/lib/web/text_layer_builder.js +322 -322
  177. package/lib/web/toolbar.js +227 -180
  178. package/lib/web/ui_utils.js +476 -421
  179. package/lib/web/view_history.js +59 -208
  180. package/lib/web/viewer_compatibility.js +9 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +36 -22
  183. package/web/pdf_viewer.js +4407 -4516
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -441
  189. package/lib/shared/streams_polyfill.js +0 -39
  190. package/lib/shared/url_polyfill.js +0 -50
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
  192. package/lib/web/dom_events.js +0 -140
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,99 +19,104 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.AnnotationLayer = undefined;
27
+ exports.AnnotationLayer = void 0;
28
28
 
29
- var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
29
+ var _display_utils = require("./display_utils.js");
30
30
 
31
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
31
+ var _util = require("../shared/util.js");
32
32
 
33
- var _dom_utils = require('./dom_utils');
33
+ class AnnotationElementFactory {
34
+ static create(parameters) {
35
+ const subtype = parameters.data.annotationType;
34
36
 
35
- var _util = require('../shared/util');
37
+ switch (subtype) {
38
+ case _util.AnnotationType.LINK:
39
+ return new LinkAnnotationElement(parameters);
36
40
 
37
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
41
+ case _util.AnnotationType.TEXT:
42
+ return new TextAnnotationElement(parameters);
38
43
 
39
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
44
+ case _util.AnnotationType.WIDGET:
45
+ const fieldType = parameters.data.fieldType;
40
46
 
41
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
47
+ switch (fieldType) {
48
+ case "Tx":
49
+ return new TextWidgetAnnotationElement(parameters);
42
50
 
43
- var AnnotationElementFactory = function () {
44
- function AnnotationElementFactory() {
45
- _classCallCheck(this, AnnotationElementFactory);
46
- }
51
+ case "Btn":
52
+ if (parameters.data.radioButton) {
53
+ return new RadioButtonWidgetAnnotationElement(parameters);
54
+ } else if (parameters.data.checkBox) {
55
+ return new CheckboxWidgetAnnotationElement(parameters);
56
+ }
47
57
 
48
- _createClass(AnnotationElementFactory, null, [{
49
- key: 'create',
50
- value: function create(parameters) {
51
- var subtype = parameters.data.annotationType;
52
- switch (subtype) {
53
- case _util.AnnotationType.LINK:
54
- return new LinkAnnotationElement(parameters);
55
- case _util.AnnotationType.TEXT:
56
- return new TextAnnotationElement(parameters);
57
- case _util.AnnotationType.WIDGET:
58
- var fieldType = parameters.data.fieldType;
59
- switch (fieldType) {
60
- case 'Tx':
61
- return new TextWidgetAnnotationElement(parameters);
62
- case 'Btn':
63
- if (parameters.data.radioButton) {
64
- return new RadioButtonWidgetAnnotationElement(parameters);
65
- } else if (parameters.data.checkBox) {
66
- return new CheckboxWidgetAnnotationElement(parameters);
67
- }
68
- return new PushButtonWidgetAnnotationElement(parameters);
69
- case 'Ch':
70
- return new ChoiceWidgetAnnotationElement(parameters);
71
- }
72
- return new WidgetAnnotationElement(parameters);
73
- case _util.AnnotationType.POPUP:
74
- return new PopupAnnotationElement(parameters);
75
- case _util.AnnotationType.LINE:
76
- return new LineAnnotationElement(parameters);
77
- case _util.AnnotationType.SQUARE:
78
- return new SquareAnnotationElement(parameters);
79
- case _util.AnnotationType.CIRCLE:
80
- return new CircleAnnotationElement(parameters);
81
- case _util.AnnotationType.POLYLINE:
82
- return new PolylineAnnotationElement(parameters);
83
- case _util.AnnotationType.INK:
84
- return new InkAnnotationElement(parameters);
85
- case _util.AnnotationType.POLYGON:
86
- return new PolygonAnnotationElement(parameters);
87
- case _util.AnnotationType.HIGHLIGHT:
88
- return new HighlightAnnotationElement(parameters);
89
- case _util.AnnotationType.UNDERLINE:
90
- return new UnderlineAnnotationElement(parameters);
91
- case _util.AnnotationType.SQUIGGLY:
92
- return new SquigglyAnnotationElement(parameters);
93
- case _util.AnnotationType.STRIKEOUT:
94
- return new StrikeOutAnnotationElement(parameters);
95
- case _util.AnnotationType.STAMP:
96
- return new StampAnnotationElement(parameters);
97
- case _util.AnnotationType.FILEATTACHMENT:
98
- return new FileAttachmentAnnotationElement(parameters);
99
- default:
100
- return new AnnotationElement(parameters);
101
- }
102
- }
103
- }]);
58
+ return new PushButtonWidgetAnnotationElement(parameters);
59
+
60
+ case "Ch":
61
+ return new ChoiceWidgetAnnotationElement(parameters);
62
+ }
63
+
64
+ return new WidgetAnnotationElement(parameters);
65
+
66
+ case _util.AnnotationType.POPUP:
67
+ return new PopupAnnotationElement(parameters);
68
+
69
+ case _util.AnnotationType.FREETEXT:
70
+ return new FreeTextAnnotationElement(parameters);
71
+
72
+ case _util.AnnotationType.LINE:
73
+ return new LineAnnotationElement(parameters);
74
+
75
+ case _util.AnnotationType.SQUARE:
76
+ return new SquareAnnotationElement(parameters);
77
+
78
+ case _util.AnnotationType.CIRCLE:
79
+ return new CircleAnnotationElement(parameters);
80
+
81
+ case _util.AnnotationType.POLYLINE:
82
+ return new PolylineAnnotationElement(parameters);
83
+
84
+ case _util.AnnotationType.CARET:
85
+ return new CaretAnnotationElement(parameters);
86
+
87
+ case _util.AnnotationType.INK:
88
+ return new InkAnnotationElement(parameters);
104
89
 
105
- return AnnotationElementFactory;
106
- }();
90
+ case _util.AnnotationType.POLYGON:
91
+ return new PolygonAnnotationElement(parameters);
107
92
 
108
- var AnnotationElement = function () {
109
- function AnnotationElement(parameters) {
110
- var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
111
- var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
93
+ case _util.AnnotationType.HIGHLIGHT:
94
+ return new HighlightAnnotationElement(parameters);
112
95
 
113
- _classCallCheck(this, AnnotationElement);
96
+ case _util.AnnotationType.UNDERLINE:
97
+ return new UnderlineAnnotationElement(parameters);
114
98
 
99
+ case _util.AnnotationType.SQUIGGLY:
100
+ return new SquigglyAnnotationElement(parameters);
101
+
102
+ case _util.AnnotationType.STRIKEOUT:
103
+ return new StrikeOutAnnotationElement(parameters);
104
+
105
+ case _util.AnnotationType.STAMP:
106
+ return new StampAnnotationElement(parameters);
107
+
108
+ case _util.AnnotationType.FILEATTACHMENT:
109
+ return new FileAttachmentAnnotationElement(parameters);
110
+
111
+ default:
112
+ return new AnnotationElement(parameters);
113
+ }
114
+ }
115
+
116
+ }
117
+
118
+ class AnnotationElement {
119
+ constructor(parameters, isRenderable = false, ignoreBorder = false) {
115
120
  this.isRenderable = isRenderable;
116
121
  this.data = parameters.data;
117
122
  this.layer = parameters.layer;
@@ -122,981 +127,922 @@ var AnnotationElement = function () {
122
127
  this.imageResourcesPath = parameters.imageResourcesPath;
123
128
  this.renderInteractiveForms = parameters.renderInteractiveForms;
124
129
  this.svgFactory = parameters.svgFactory;
130
+
125
131
  if (isRenderable) {
126
132
  this.container = this._createContainer(ignoreBorder);
127
133
  }
128
134
  }
129
135
 
130
- _createClass(AnnotationElement, [{
131
- key: '_createContainer',
132
- value: function _createContainer() {
133
- var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
134
-
135
- var data = this.data,
136
+ _createContainer(ignoreBorder = false) {
137
+ const data = this.data,
136
138
  page = this.page,
137
139
  viewport = this.viewport;
138
- var container = document.createElement('section');
139
- var width = data.rect[2] - data.rect[0];
140
- var height = data.rect[3] - data.rect[1];
141
- container.setAttribute('data-annotation-id', data.id);
142
- var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
143
- container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';
144
- container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';
145
- if (!ignoreBorder && data.borderStyle.width > 0) {
146
- container.style.borderWidth = data.borderStyle.width + 'px';
147
- if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
148
- width = width - 2 * data.borderStyle.width;
149
- height = height - 2 * data.borderStyle.width;
150
- }
151
- var horizontalRadius = data.borderStyle.horizontalCornerRadius;
152
- var verticalRadius = data.borderStyle.verticalCornerRadius;
153
- if (horizontalRadius > 0 || verticalRadius > 0) {
154
- var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
155
- container.style.borderRadius = radius;
156
- }
157
- switch (data.borderStyle.style) {
158
- case _util.AnnotationBorderStyleType.SOLID:
159
- container.style.borderStyle = 'solid';
160
- break;
161
- case _util.AnnotationBorderStyleType.DASHED:
162
- container.style.borderStyle = 'dashed';
163
- break;
164
- case _util.AnnotationBorderStyleType.BEVELED:
165
- (0, _util.warn)('Unimplemented border style: beveled');
166
- break;
167
- case _util.AnnotationBorderStyleType.INSET:
168
- (0, _util.warn)('Unimplemented border style: inset');
169
- break;
170
- case _util.AnnotationBorderStyleType.UNDERLINE:
171
- container.style.borderBottomStyle = 'solid';
172
- break;
173
- default:
174
- break;
175
- }
176
- if (data.color) {
177
- container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
178
- } else {
179
- container.style.borderWidth = 0;
180
- }
140
+ const container = document.createElement("section");
141
+ let width = data.rect[2] - data.rect[0];
142
+ let height = data.rect[3] - data.rect[1];
143
+ container.setAttribute("data-annotation-id", data.id);
144
+
145
+ const rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
146
+
147
+ container.style.transform = `matrix(${viewport.transform.join(",")})`;
148
+ container.style.transformOrigin = `-${rect[0]}px -${rect[1]}px`;
149
+
150
+ if (!ignoreBorder && data.borderStyle.width > 0) {
151
+ container.style.borderWidth = `${data.borderStyle.width}px`;
152
+
153
+ if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
154
+ width = width - 2 * data.borderStyle.width;
155
+ height = height - 2 * data.borderStyle.width;
181
156
  }
182
- container.style.left = rect[0] + 'px';
183
- container.style.top = rect[1] + 'px';
184
- container.style.width = width + 'px';
185
- container.style.height = height + 'px';
186
- return container;
187
- }
188
- }, {
189
- key: '_createPopup',
190
- value: function _createPopup(container, trigger, data) {
191
- if (!trigger) {
192
- trigger = document.createElement('div');
193
- trigger.style.height = container.style.height;
194
- trigger.style.width = container.style.width;
195
- container.appendChild(trigger);
157
+
158
+ const horizontalRadius = data.borderStyle.horizontalCornerRadius;
159
+ const verticalRadius = data.borderStyle.verticalCornerRadius;
160
+
161
+ if (horizontalRadius > 0 || verticalRadius > 0) {
162
+ const radius = `${horizontalRadius}px / ${verticalRadius}px`;
163
+ container.style.borderRadius = radius;
196
164
  }
197
- var popupElement = new PopupElement({
198
- container: container,
199
- trigger: trigger,
200
- color: data.color,
201
- title: data.title,
202
- contents: data.contents,
203
- hideWrapper: true
204
- });
205
- var popup = popupElement.render();
206
- popup.style.left = container.style.width;
207
- container.appendChild(popup);
208
- }
209
- }, {
210
- key: 'render',
211
- value: function render() {
212
- (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
213
- }
214
- }]);
215
165
 
216
- return AnnotationElement;
217
- }();
166
+ switch (data.borderStyle.style) {
167
+ case _util.AnnotationBorderStyleType.SOLID:
168
+ container.style.borderStyle = "solid";
169
+ break;
218
170
 
219
- var LinkAnnotationElement = function (_AnnotationElement) {
220
- _inherits(LinkAnnotationElement, _AnnotationElement);
171
+ case _util.AnnotationBorderStyleType.DASHED:
172
+ container.style.borderStyle = "dashed";
173
+ break;
221
174
 
222
- function LinkAnnotationElement(parameters) {
223
- _classCallCheck(this, LinkAnnotationElement);
175
+ case _util.AnnotationBorderStyleType.BEVELED:
176
+ (0, _util.warn)("Unimplemented border style: beveled");
177
+ break;
224
178
 
225
- var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
226
- return _possibleConstructorReturn(this, (LinkAnnotationElement.__proto__ || Object.getPrototypeOf(LinkAnnotationElement)).call(this, parameters, isRenderable));
227
- }
179
+ case _util.AnnotationBorderStyleType.INSET:
180
+ (0, _util.warn)("Unimplemented border style: inset");
181
+ break;
228
182
 
229
- _createClass(LinkAnnotationElement, [{
230
- key: 'render',
231
- value: function render() {
232
- this.container.className = 'linkAnnotation';
233
- var data = this.data,
234
- linkService = this.linkService;
183
+ case _util.AnnotationBorderStyleType.UNDERLINE:
184
+ container.style.borderBottomStyle = "solid";
185
+ break;
235
186
 
236
- var link = document.createElement('a');
237
- (0, _dom_utils.addLinkAttributes)(link, {
238
- url: data.url,
239
- target: data.newWindow ? _dom_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
240
- rel: linkService.externalLinkRel
241
- });
242
- if (!data.url) {
243
- if (data.action) {
244
- this._bindNamedAction(link, data.action);
245
- } else {
246
- this._bindLink(link, data.dest);
247
- }
187
+ default:
188
+ break;
248
189
  }
249
- this.container.appendChild(link);
250
- return this.container;
251
- }
252
- }, {
253
- key: '_bindLink',
254
- value: function _bindLink(link, destination) {
255
- var _this2 = this;
256
-
257
- link.href = this.linkService.getDestinationHash(destination);
258
- link.onclick = function () {
259
- if (destination) {
260
- _this2.linkService.navigateTo(destination);
261
- }
262
- return false;
263
- };
264
- if (destination) {
265
- link.className = 'internalLink';
190
+
191
+ if (data.color) {
192
+ container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
193
+ } else {
194
+ container.style.borderWidth = 0;
266
195
  }
267
196
  }
268
- }, {
269
- key: '_bindNamedAction',
270
- value: function _bindNamedAction(link, action) {
271
- var _this3 = this;
272
-
273
- link.href = this.linkService.getAnchorUrl('');
274
- link.onclick = function () {
275
- _this3.linkService.executeNamedAction(action);
276
- return false;
277
- };
278
- link.className = 'internalLink';
197
+
198
+ container.style.left = `${rect[0]}px`;
199
+ container.style.top = `${rect[1]}px`;
200
+ container.style.width = `${width}px`;
201
+ container.style.height = `${height}px`;
202
+ return container;
203
+ }
204
+
205
+ _createPopup(container, trigger, data) {
206
+ if (!trigger) {
207
+ trigger = document.createElement("div");
208
+ trigger.style.height = container.style.height;
209
+ trigger.style.width = container.style.width;
210
+ container.appendChild(trigger);
279
211
  }
280
- }]);
281
212
 
282
- return LinkAnnotationElement;
283
- }(AnnotationElement);
213
+ const popupElement = new PopupElement({
214
+ container,
215
+ trigger,
216
+ color: data.color,
217
+ title: data.title,
218
+ modificationDate: data.modificationDate,
219
+ contents: data.contents,
220
+ hideWrapper: true
221
+ });
222
+ const popup = popupElement.render();
223
+ popup.style.left = container.style.width;
224
+ container.appendChild(popup);
225
+ }
284
226
 
285
- var TextAnnotationElement = function (_AnnotationElement2) {
286
- _inherits(TextAnnotationElement, _AnnotationElement2);
227
+ render() {
228
+ (0, _util.unreachable)("Abstract method `AnnotationElement.render` called");
229
+ }
287
230
 
288
- function TextAnnotationElement(parameters) {
289
- _classCallCheck(this, TextAnnotationElement);
231
+ }
290
232
 
291
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
292
- return _possibleConstructorReturn(this, (TextAnnotationElement.__proto__ || Object.getPrototypeOf(TextAnnotationElement)).call(this, parameters, isRenderable));
233
+ class LinkAnnotationElement extends AnnotationElement {
234
+ constructor(parameters) {
235
+ const isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
236
+ super(parameters, isRenderable);
293
237
  }
294
238
 
295
- _createClass(TextAnnotationElement, [{
296
- key: 'render',
297
- value: function render() {
298
- this.container.className = 'textAnnotation';
299
- var image = document.createElement('img');
300
- image.style.height = this.container.style.height;
301
- image.style.width = this.container.style.width;
302
- image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
303
- image.alt = '[{{type}} Annotation]';
304
- image.dataset.l10nId = 'text_annotation_type';
305
- image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
306
- if (!this.data.hasPopup) {
307
- this._createPopup(this.container, image, this.data);
239
+ render() {
240
+ this.container.className = "linkAnnotation";
241
+ const {
242
+ data,
243
+ linkService
244
+ } = this;
245
+ const link = document.createElement("a");
246
+
247
+ if (data.url) {
248
+ (0, _display_utils.addLinkAttributes)(link, {
249
+ url: data.url,
250
+ target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
251
+ rel: linkService.externalLinkRel,
252
+ enabled: linkService.externalLinkEnabled
253
+ });
254
+ } else if (data.action) {
255
+ this._bindNamedAction(link, data.action);
256
+ } else {
257
+ this._bindLink(link, data.dest);
258
+ }
259
+
260
+ this.container.appendChild(link);
261
+ return this.container;
262
+ }
263
+
264
+ _bindLink(link, destination) {
265
+ link.href = this.linkService.getDestinationHash(destination);
266
+
267
+ link.onclick = () => {
268
+ if (destination) {
269
+ this.linkService.navigateTo(destination);
308
270
  }
309
- this.container.appendChild(image);
310
- return this.container;
271
+
272
+ return false;
273
+ };
274
+
275
+ if (destination) {
276
+ link.className = "internalLink";
311
277
  }
312
- }]);
278
+ }
313
279
 
314
- return TextAnnotationElement;
315
- }(AnnotationElement);
280
+ _bindNamedAction(link, action) {
281
+ link.href = this.linkService.getAnchorUrl("");
316
282
 
317
- var WidgetAnnotationElement = function (_AnnotationElement3) {
318
- _inherits(WidgetAnnotationElement, _AnnotationElement3);
283
+ link.onclick = () => {
284
+ this.linkService.executeNamedAction(action);
285
+ return false;
286
+ };
319
287
 
320
- function WidgetAnnotationElement() {
321
- _classCallCheck(this, WidgetAnnotationElement);
288
+ link.className = "internalLink";
289
+ }
290
+
291
+ }
322
292
 
323
- return _possibleConstructorReturn(this, (WidgetAnnotationElement.__proto__ || Object.getPrototypeOf(WidgetAnnotationElement)).apply(this, arguments));
293
+ class TextAnnotationElement extends AnnotationElement {
294
+ constructor(parameters) {
295
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
296
+ super(parameters, isRenderable);
324
297
  }
325
298
 
326
- _createClass(WidgetAnnotationElement, [{
327
- key: 'render',
328
- value: function render() {
329
- return this.container;
299
+ render() {
300
+ this.container.className = "textAnnotation";
301
+ const image = document.createElement("img");
302
+ image.style.height = this.container.style.height;
303
+ image.style.width = this.container.style.width;
304
+ image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
305
+ image.alt = "[{{type}} Annotation]";
306
+ image.dataset.l10nId = "text_annotation_type";
307
+ image.dataset.l10nArgs = JSON.stringify({
308
+ type: this.data.name
309
+ });
310
+
311
+ if (!this.data.hasPopup) {
312
+ this._createPopup(this.container, image, this.data);
330
313
  }
331
- }]);
332
314
 
333
- return WidgetAnnotationElement;
334
- }(AnnotationElement);
315
+ this.container.appendChild(image);
316
+ return this.container;
317
+ }
335
318
 
336
- var TextWidgetAnnotationElement = function (_WidgetAnnotationElem) {
337
- _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
319
+ }
338
320
 
339
- function TextWidgetAnnotationElement(parameters) {
340
- _classCallCheck(this, TextWidgetAnnotationElement);
321
+ class WidgetAnnotationElement extends AnnotationElement {
322
+ render() {
323
+ return this.container;
324
+ }
325
+
326
+ }
341
327
 
342
- var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
343
- return _possibleConstructorReturn(this, (TextWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(TextWidgetAnnotationElement)).call(this, parameters, isRenderable));
328
+ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
329
+ constructor(parameters) {
330
+ const isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
331
+ super(parameters, isRenderable);
344
332
  }
345
333
 
346
- _createClass(TextWidgetAnnotationElement, [{
347
- key: 'render',
348
- value: function render() {
349
- var TEXT_ALIGNMENT = ['left', 'center', 'right'];
350
- this.container.className = 'textWidgetAnnotation';
351
- var element = null;
352
- if (this.renderInteractiveForms) {
353
- if (this.data.multiLine) {
354
- element = document.createElement('textarea');
355
- element.textContent = this.data.fieldValue;
356
- } else {
357
- element = document.createElement('input');
358
- element.type = 'text';
359
- element.setAttribute('value', this.data.fieldValue);
360
- }
361
- element.disabled = this.data.readOnly;
362
- if (this.data.maxLen !== null) {
363
- element.maxLength = this.data.maxLen;
364
- }
365
- if (this.data.comb) {
366
- var fieldWidth = this.data.rect[2] - this.data.rect[0];
367
- var combWidth = fieldWidth / this.data.maxLen;
368
- element.classList.add('comb');
369
- element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
370
- }
371
- } else {
372
- element = document.createElement('div');
334
+ render() {
335
+ const TEXT_ALIGNMENT = ["left", "center", "right"];
336
+ this.container.className = "textWidgetAnnotation";
337
+ let element = null;
338
+
339
+ if (this.renderInteractiveForms) {
340
+ if (this.data.multiLine) {
341
+ element = document.createElement("textarea");
373
342
  element.textContent = this.data.fieldValue;
374
- element.style.verticalAlign = 'middle';
375
- element.style.display = 'table-cell';
376
- var font = null;
377
- if (this.data.fontRefName) {
378
- font = this.page.commonObjs.getData(this.data.fontRefName);
379
- }
380
- this._setTextStyle(element, font);
381
- }
382
- if (this.data.textAlignment !== null) {
383
- element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
343
+ } else {
344
+ element = document.createElement("input");
345
+ element.type = "text";
346
+ element.setAttribute("value", this.data.fieldValue);
384
347
  }
385
- this.container.appendChild(element);
386
- return this.container;
387
- }
388
- }, {
389
- key: '_setTextStyle',
390
- value: function _setTextStyle(element, font) {
391
- var style = element.style;
392
- style.fontSize = this.data.fontSize + 'px';
393
- style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
394
- if (!font) {
395
- return;
348
+
349
+ element.disabled = this.data.readOnly;
350
+
351
+ if (this.data.maxLen !== null) {
352
+ element.maxLength = this.data.maxLen;
396
353
  }
397
- style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
398
- style.fontStyle = font.italic ? 'italic' : 'normal';
399
- var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
400
- var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
401
- style.fontFamily = fontFamily + fallbackName;
402
- }
403
- }]);
404
354
 
405
- return TextWidgetAnnotationElement;
406
- }(WidgetAnnotationElement);
355
+ if (this.data.comb) {
356
+ const fieldWidth = this.data.rect[2] - this.data.rect[0];
357
+ const combWidth = fieldWidth / this.data.maxLen;
358
+ element.classList.add("comb");
359
+ element.style.letterSpacing = `calc(${combWidth}px - 1ch)`;
360
+ }
361
+ } else {
362
+ element = document.createElement("div");
363
+ element.textContent = this.data.fieldValue;
364
+ element.style.verticalAlign = "middle";
365
+ element.style.display = "table-cell";
366
+ let font = null;
367
+
368
+ if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
369
+ font = this.page.commonObjs.get(this.data.fontRefName);
370
+ }
407
371
 
408
- var CheckboxWidgetAnnotationElement = function (_WidgetAnnotationElem2) {
409
- _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
372
+ this._setTextStyle(element, font);
373
+ }
410
374
 
411
- function CheckboxWidgetAnnotationElement(parameters) {
412
- _classCallCheck(this, CheckboxWidgetAnnotationElement);
375
+ if (this.data.textAlignment !== null) {
376
+ element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
377
+ }
413
378
 
414
- return _possibleConstructorReturn(this, (CheckboxWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(CheckboxWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
379
+ this.container.appendChild(element);
380
+ return this.container;
415
381
  }
416
382
 
417
- _createClass(CheckboxWidgetAnnotationElement, [{
418
- key: 'render',
419
- value: function render() {
420
- this.container.className = 'buttonWidgetAnnotation checkBox';
421
- var element = document.createElement('input');
422
- element.disabled = this.data.readOnly;
423
- element.type = 'checkbox';
424
- if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
425
- element.setAttribute('checked', true);
426
- }
427
- this.container.appendChild(element);
428
- return this.container;
383
+ _setTextStyle(element, font) {
384
+ const style = element.style;
385
+ style.fontSize = `${this.data.fontSize}px`;
386
+ style.direction = this.data.fontDirection < 0 ? "rtl" : "ltr";
387
+
388
+ if (!font) {
389
+ return;
429
390
  }
430
- }]);
431
391
 
432
- return CheckboxWidgetAnnotationElement;
433
- }(WidgetAnnotationElement);
392
+ let bold = "normal";
434
393
 
435
- var RadioButtonWidgetAnnotationElement = function (_WidgetAnnotationElem3) {
436
- _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
394
+ if (font.black) {
395
+ bold = "900";
396
+ } else if (font.bold) {
397
+ bold = "bold";
398
+ }
437
399
 
438
- function RadioButtonWidgetAnnotationElement(parameters) {
439
- _classCallCheck(this, RadioButtonWidgetAnnotationElement);
400
+ style.fontWeight = bold;
401
+ style.fontStyle = font.italic ? "italic" : "normal";
402
+ const fontFamily = font.loadedName ? `"${font.loadedName}", ` : "";
403
+ const fallbackName = font.fallbackName || "Helvetica, sans-serif";
404
+ style.fontFamily = fontFamily + fallbackName;
405
+ }
440
406
 
441
- return _possibleConstructorReturn(this, (RadioButtonWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(RadioButtonWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
407
+ }
408
+
409
+ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
410
+ constructor(parameters) {
411
+ super(parameters, parameters.renderInteractiveForms);
442
412
  }
443
413
 
444
- _createClass(RadioButtonWidgetAnnotationElement, [{
445
- key: 'render',
446
- value: function render() {
447
- this.container.className = 'buttonWidgetAnnotation radioButton';
448
- var element = document.createElement('input');
449
- element.disabled = this.data.readOnly;
450
- element.type = 'radio';
451
- element.name = this.data.fieldName;
452
- if (this.data.fieldValue === this.data.buttonValue) {
453
- element.setAttribute('checked', true);
454
- }
455
- this.container.appendChild(element);
456
- return this.container;
457
- }
458
- }]);
414
+ render() {
415
+ this.container.className = "buttonWidgetAnnotation checkBox";
416
+ const element = document.createElement("input");
417
+ element.disabled = this.data.readOnly;
418
+ element.type = "checkbox";
459
419
 
460
- return RadioButtonWidgetAnnotationElement;
461
- }(WidgetAnnotationElement);
420
+ if (this.data.fieldValue && this.data.fieldValue !== "Off") {
421
+ element.setAttribute("checked", true);
422
+ }
462
423
 
463
- var PushButtonWidgetAnnotationElement = function (_LinkAnnotationElemen) {
464
- _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
424
+ this.container.appendChild(element);
425
+ return this.container;
426
+ }
465
427
 
466
- function PushButtonWidgetAnnotationElement() {
467
- _classCallCheck(this, PushButtonWidgetAnnotationElement);
428
+ }
468
429
 
469
- return _possibleConstructorReturn(this, (PushButtonWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(PushButtonWidgetAnnotationElement)).apply(this, arguments));
430
+ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
431
+ constructor(parameters) {
432
+ super(parameters, parameters.renderInteractiveForms);
470
433
  }
471
434
 
472
- _createClass(PushButtonWidgetAnnotationElement, [{
473
- key: 'render',
474
- value: function render() {
475
- var container = _get(PushButtonWidgetAnnotationElement.prototype.__proto__ || Object.getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), 'render', this).call(this);
476
- container.className = 'buttonWidgetAnnotation pushButton';
477
- return container;
435
+ render() {
436
+ this.container.className = "buttonWidgetAnnotation radioButton";
437
+ const element = document.createElement("input");
438
+ element.disabled = this.data.readOnly;
439
+ element.type = "radio";
440
+ element.name = this.data.fieldName;
441
+
442
+ if (this.data.fieldValue === this.data.buttonValue) {
443
+ element.setAttribute("checked", true);
478
444
  }
479
- }]);
480
445
 
481
- return PushButtonWidgetAnnotationElement;
482
- }(LinkAnnotationElement);
446
+ this.container.appendChild(element);
447
+ return this.container;
448
+ }
449
+
450
+ }
483
451
 
484
- var ChoiceWidgetAnnotationElement = function (_WidgetAnnotationElem4) {
485
- _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
452
+ class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
453
+ render() {
454
+ const container = super.render();
455
+ container.className = "buttonWidgetAnnotation pushButton";
456
+ return container;
457
+ }
486
458
 
487
- function ChoiceWidgetAnnotationElement(parameters) {
488
- _classCallCheck(this, ChoiceWidgetAnnotationElement);
459
+ }
489
460
 
490
- return _possibleConstructorReturn(this, (ChoiceWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
461
+ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
462
+ constructor(parameters) {
463
+ super(parameters, parameters.renderInteractiveForms);
491
464
  }
492
465
 
493
- _createClass(ChoiceWidgetAnnotationElement, [{
494
- key: 'render',
495
- value: function render() {
496
- this.container.className = 'choiceWidgetAnnotation';
497
- var selectElement = document.createElement('select');
498
- selectElement.disabled = this.data.readOnly;
499
- if (!this.data.combo) {
500
- selectElement.size = this.data.options.length;
501
- if (this.data.multiSelect) {
502
- selectElement.multiple = true;
503
- }
504
- }
505
- for (var i = 0, ii = this.data.options.length; i < ii; i++) {
506
- var option = this.data.options[i];
507
- var optionElement = document.createElement('option');
508
- optionElement.textContent = option.displayValue;
509
- optionElement.value = option.exportValue;
510
- if (this.data.fieldValue.includes(option.displayValue)) {
511
- optionElement.setAttribute('selected', true);
512
- }
513
- selectElement.appendChild(optionElement);
466
+ render() {
467
+ this.container.className = "choiceWidgetAnnotation";
468
+ const selectElement = document.createElement("select");
469
+ selectElement.disabled = this.data.readOnly;
470
+
471
+ if (!this.data.combo) {
472
+ selectElement.size = this.data.options.length;
473
+
474
+ if (this.data.multiSelect) {
475
+ selectElement.multiple = true;
514
476
  }
515
- this.container.appendChild(selectElement);
516
- return this.container;
517
477
  }
518
- }]);
519
478
 
520
- return ChoiceWidgetAnnotationElement;
521
- }(WidgetAnnotationElement);
479
+ for (const option of this.data.options) {
480
+ const optionElement = document.createElement("option");
481
+ optionElement.textContent = option.displayValue;
482
+ optionElement.value = option.exportValue;
522
483
 
523
- var PopupAnnotationElement = function (_AnnotationElement4) {
524
- _inherits(PopupAnnotationElement, _AnnotationElement4);
484
+ if (this.data.fieldValue.includes(option.displayValue)) {
485
+ optionElement.setAttribute("selected", true);
486
+ }
525
487
 
526
- function PopupAnnotationElement(parameters) {
527
- _classCallCheck(this, PopupAnnotationElement);
488
+ selectElement.appendChild(optionElement);
489
+ }
528
490
 
529
- var isRenderable = !!(parameters.data.title || parameters.data.contents);
530
- return _possibleConstructorReturn(this, (PopupAnnotationElement.__proto__ || Object.getPrototypeOf(PopupAnnotationElement)).call(this, parameters, isRenderable));
491
+ this.container.appendChild(selectElement);
492
+ return this.container;
531
493
  }
532
494
 
533
- _createClass(PopupAnnotationElement, [{
534
- key: 'render',
535
- value: function render() {
536
- var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
537
- this.container.className = 'popupAnnotation';
538
- if (IGNORE_TYPES.includes(this.data.parentType)) {
539
- return this.container;
540
- }
541
- var selector = '[data-annotation-id="' + this.data.parentId + '"]';
542
- var parentElement = this.layer.querySelector(selector);
543
- if (!parentElement) {
544
- return this.container;
545
- }
546
- var popup = new PopupElement({
547
- container: this.container,
548
- trigger: parentElement,
549
- color: this.data.color,
550
- title: this.data.title,
551
- contents: this.data.contents
552
- });
553
- var parentLeft = parseFloat(parentElement.style.left);
554
- var parentWidth = parseFloat(parentElement.style.width);
555
- this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;
556
- this.container.style.left = parentLeft + parentWidth + 'px';
557
- this.container.appendChild(popup.render());
495
+ }
496
+
497
+ class PopupAnnotationElement extends AnnotationElement {
498
+ constructor(parameters) {
499
+ const isRenderable = !!(parameters.data.title || parameters.data.contents);
500
+ super(parameters, isRenderable);
501
+ }
502
+
503
+ render() {
504
+ const IGNORE_TYPES = ["Line", "Square", "Circle", "PolyLine", "Polygon", "Ink"];
505
+ this.container.className = "popupAnnotation";
506
+
507
+ if (IGNORE_TYPES.includes(this.data.parentType)) {
558
508
  return this.container;
559
509
  }
560
- }]);
561
510
 
562
- return PopupAnnotationElement;
563
- }(AnnotationElement);
511
+ const selector = `[data-annotation-id="${this.data.parentId}"]`;
512
+ const parentElement = this.layer.querySelector(selector);
564
513
 
565
- var PopupElement = function () {
566
- function PopupElement(parameters) {
567
- _classCallCheck(this, PopupElement);
514
+ if (!parentElement) {
515
+ return this.container;
516
+ }
568
517
 
518
+ const popup = new PopupElement({
519
+ container: this.container,
520
+ trigger: parentElement,
521
+ color: this.data.color,
522
+ title: this.data.title,
523
+ modificationDate: this.data.modificationDate,
524
+ contents: this.data.contents
525
+ });
526
+ const parentLeft = parseFloat(parentElement.style.left);
527
+ const parentWidth = parseFloat(parentElement.style.width);
528
+ this.container.style.transformOrigin = `-${parentLeft + parentWidth}px -${parentElement.style.top}`;
529
+ this.container.style.left = `${parentLeft + parentWidth}px`;
530
+ this.container.appendChild(popup.render());
531
+ return this.container;
532
+ }
533
+
534
+ }
535
+
536
+ class PopupElement {
537
+ constructor(parameters) {
569
538
  this.container = parameters.container;
570
539
  this.trigger = parameters.trigger;
571
540
  this.color = parameters.color;
572
541
  this.title = parameters.title;
542
+ this.modificationDate = parameters.modificationDate;
573
543
  this.contents = parameters.contents;
574
544
  this.hideWrapper = parameters.hideWrapper || false;
575
545
  this.pinned = false;
576
546
  }
577
547
 
578
- _createClass(PopupElement, [{
579
- key: 'render',
580
- value: function render() {
581
- var BACKGROUND_ENLIGHT = 0.7;
582
- var wrapper = document.createElement('div');
583
- wrapper.className = 'popupWrapper';
584
- this.hideElement = this.hideWrapper ? wrapper : this.container;
585
- this.hideElement.setAttribute('hidden', true);
586
- var popup = document.createElement('div');
587
- popup.className = 'popup';
588
- var color = this.color;
589
- if (color) {
590
- var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
591
- var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
592
- var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
593
- popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
594
- }
595
- var contents = this._formatContents(this.contents);
596
- var title = document.createElement('h1');
597
- title.textContent = this.title;
598
- this.trigger.addEventListener('click', this._toggle.bind(this));
599
- this.trigger.addEventListener('mouseover', this._show.bind(this, false));
600
- this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
601
- popup.addEventListener('click', this._hide.bind(this, true));
602
- popup.appendChild(title);
603
- popup.appendChild(contents);
604
- wrapper.appendChild(popup);
605
- return wrapper;
606
- }
607
- }, {
608
- key: '_formatContents',
609
- value: function _formatContents(contents) {
610
- var p = document.createElement('p');
611
- var lines = contents.split(/(?:\r\n?|\n)/);
612
- for (var i = 0, ii = lines.length; i < ii; ++i) {
613
- var line = lines[i];
614
- p.appendChild(document.createTextNode(line));
615
- if (i < ii - 1) {
616
- p.appendChild(document.createElement('br'));
617
- }
618
- }
619
- return p;
620
- }
621
- }, {
622
- key: '_toggle',
623
- value: function _toggle() {
624
- if (this.pinned) {
625
- this._hide(true);
626
- } else {
627
- this._show(true);
628
- }
548
+ render() {
549
+ const BACKGROUND_ENLIGHT = 0.7;
550
+ const wrapper = document.createElement("div");
551
+ wrapper.className = "popupWrapper";
552
+ this.hideElement = this.hideWrapper ? wrapper : this.container;
553
+ this.hideElement.setAttribute("hidden", true);
554
+ const popup = document.createElement("div");
555
+ popup.className = "popup";
556
+ const color = this.color;
557
+
558
+ if (color) {
559
+ const r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
560
+ const g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
561
+ const b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
562
+ popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
629
563
  }
630
- }, {
631
- key: '_show',
632
- value: function _show() {
633
- var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
634
564
 
635
- if (pin) {
636
- this.pinned = true;
637
- }
638
- if (this.hideElement.hasAttribute('hidden')) {
639
- this.hideElement.removeAttribute('hidden');
640
- this.container.style.zIndex += 1;
641
- }
565
+ const title = document.createElement("h1");
566
+ title.textContent = this.title;
567
+ popup.appendChild(title);
568
+
569
+ const dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
570
+
571
+ if (dateObject) {
572
+ const modificationDate = document.createElement("span");
573
+ modificationDate.textContent = "{{date}}, {{time}}";
574
+ modificationDate.dataset.l10nId = "annotation_date_string";
575
+ modificationDate.dataset.l10nArgs = JSON.stringify({
576
+ date: dateObject.toLocaleDateString(),
577
+ time: dateObject.toLocaleTimeString()
578
+ });
579
+ popup.appendChild(modificationDate);
642
580
  }
643
- }, {
644
- key: '_hide',
645
- value: function _hide() {
646
- var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
647
581
 
648
- if (unpin) {
649
- this.pinned = false;
650
- }
651
- if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
652
- this.hideElement.setAttribute('hidden', true);
653
- this.container.style.zIndex -= 1;
582
+ const contents = this._formatContents(this.contents);
583
+
584
+ popup.appendChild(contents);
585
+ this.trigger.addEventListener("click", this._toggle.bind(this));
586
+ this.trigger.addEventListener("mouseover", this._show.bind(this, false));
587
+ this.trigger.addEventListener("mouseout", this._hide.bind(this, false));
588
+ popup.addEventListener("click", this._hide.bind(this, true));
589
+ wrapper.appendChild(popup);
590
+ return wrapper;
591
+ }
592
+
593
+ _formatContents(contents) {
594
+ const p = document.createElement("p");
595
+ const lines = contents.split(/(?:\r\n?|\n)/);
596
+
597
+ for (let i = 0, ii = lines.length; i < ii; ++i) {
598
+ const line = lines[i];
599
+ p.appendChild(document.createTextNode(line));
600
+
601
+ if (i < ii - 1) {
602
+ p.appendChild(document.createElement("br"));
654
603
  }
655
604
  }
656
- }]);
657
605
 
658
- return PopupElement;
659
- }();
606
+ return p;
607
+ }
660
608
 
661
- var LineAnnotationElement = function (_AnnotationElement5) {
662
- _inherits(LineAnnotationElement, _AnnotationElement5);
609
+ _toggle() {
610
+ if (this.pinned) {
611
+ this._hide(true);
612
+ } else {
613
+ this._show(true);
614
+ }
615
+ }
663
616
 
664
- function LineAnnotationElement(parameters) {
665
- _classCallCheck(this, LineAnnotationElement);
617
+ _show(pin = false) {
618
+ if (pin) {
619
+ this.pinned = true;
620
+ }
666
621
 
667
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
668
- return _possibleConstructorReturn(this, (LineAnnotationElement.__proto__ || Object.getPrototypeOf(LineAnnotationElement)).call(this, parameters, isRenderable, true));
622
+ if (this.hideElement.hasAttribute("hidden")) {
623
+ this.hideElement.removeAttribute("hidden");
624
+ this.container.style.zIndex += 1;
625
+ }
669
626
  }
670
627
 
671
- _createClass(LineAnnotationElement, [{
672
- key: 'render',
673
- value: function render() {
674
- this.container.className = 'lineAnnotation';
675
- var data = this.data;
676
- var width = data.rect[2] - data.rect[0];
677
- var height = data.rect[3] - data.rect[1];
678
- var svg = this.svgFactory.create(width, height);
679
- var line = this.svgFactory.createElement('svg:line');
680
- line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
681
- line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
682
- line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
683
- line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
684
- line.setAttribute('stroke-width', data.borderStyle.width);
685
- line.setAttribute('stroke', 'transparent');
686
- svg.appendChild(line);
687
- this.container.append(svg);
688
- this._createPopup(this.container, line, data);
689
- return this.container;
628
+ _hide(unpin = true) {
629
+ if (unpin) {
630
+ this.pinned = false;
690
631
  }
691
- }]);
692
632
 
693
- return LineAnnotationElement;
694
- }(AnnotationElement);
695
-
696
- var SquareAnnotationElement = function (_AnnotationElement6) {
697
- _inherits(SquareAnnotationElement, _AnnotationElement6);
633
+ if (!this.hideElement.hasAttribute("hidden") && !this.pinned) {
634
+ this.hideElement.setAttribute("hidden", true);
635
+ this.container.style.zIndex -= 1;
636
+ }
637
+ }
698
638
 
699
- function SquareAnnotationElement(parameters) {
700
- _classCallCheck(this, SquareAnnotationElement);
639
+ }
701
640
 
702
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
703
- return _possibleConstructorReturn(this, (SquareAnnotationElement.__proto__ || Object.getPrototypeOf(SquareAnnotationElement)).call(this, parameters, isRenderable, true));
641
+ class FreeTextAnnotationElement extends AnnotationElement {
642
+ constructor(parameters) {
643
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
644
+ super(parameters, isRenderable, true);
704
645
  }
705
646
 
706
- _createClass(SquareAnnotationElement, [{
707
- key: 'render',
708
- value: function render() {
709
- this.container.className = 'squareAnnotation';
710
- var data = this.data;
711
- var width = data.rect[2] - data.rect[0];
712
- var height = data.rect[3] - data.rect[1];
713
- var svg = this.svgFactory.create(width, height);
714
- var borderWidth = data.borderStyle.width;
715
- var square = this.svgFactory.createElement('svg:rect');
716
- square.setAttribute('x', borderWidth / 2);
717
- square.setAttribute('y', borderWidth / 2);
718
- square.setAttribute('width', width - borderWidth);
719
- square.setAttribute('height', height - borderWidth);
720
- square.setAttribute('stroke-width', borderWidth);
721
- square.setAttribute('stroke', 'transparent');
722
- square.setAttribute('fill', 'none');
723
- svg.appendChild(square);
724
- this.container.append(svg);
725
- this._createPopup(this.container, square, data);
726
- return this.container;
647
+ render() {
648
+ this.container.className = "freeTextAnnotation";
649
+
650
+ if (!this.data.hasPopup) {
651
+ this._createPopup(this.container, null, this.data);
727
652
  }
728
- }]);
729
653
 
730
- return SquareAnnotationElement;
731
- }(AnnotationElement);
654
+ return this.container;
655
+ }
732
656
 
733
- var CircleAnnotationElement = function (_AnnotationElement7) {
734
- _inherits(CircleAnnotationElement, _AnnotationElement7);
657
+ }
735
658
 
736
- function CircleAnnotationElement(parameters) {
737
- _classCallCheck(this, CircleAnnotationElement);
659
+ class LineAnnotationElement extends AnnotationElement {
660
+ constructor(parameters) {
661
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
662
+ super(parameters, isRenderable, true);
663
+ }
738
664
 
739
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
740
- return _possibleConstructorReturn(this, (CircleAnnotationElement.__proto__ || Object.getPrototypeOf(CircleAnnotationElement)).call(this, parameters, isRenderable, true));
665
+ render() {
666
+ this.container.className = "lineAnnotation";
667
+ const data = this.data;
668
+ const width = data.rect[2] - data.rect[0];
669
+ const height = data.rect[3] - data.rect[1];
670
+ const svg = this.svgFactory.create(width, height);
671
+ const line = this.svgFactory.createElement("svg:line");
672
+ line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
673
+ line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
674
+ line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
675
+ line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
676
+ line.setAttribute("stroke-width", data.borderStyle.width || 1);
677
+ line.setAttribute("stroke", "transparent");
678
+ svg.appendChild(line);
679
+ this.container.append(svg);
680
+
681
+ this._createPopup(this.container, line, data);
682
+
683
+ return this.container;
741
684
  }
742
685
 
743
- _createClass(CircleAnnotationElement, [{
744
- key: 'render',
745
- value: function render() {
746
- this.container.className = 'circleAnnotation';
747
- var data = this.data;
748
- var width = data.rect[2] - data.rect[0];
749
- var height = data.rect[3] - data.rect[1];
750
- var svg = this.svgFactory.create(width, height);
751
- var borderWidth = data.borderStyle.width;
752
- var circle = this.svgFactory.createElement('svg:ellipse');
753
- circle.setAttribute('cx', width / 2);
754
- circle.setAttribute('cy', height / 2);
755
- circle.setAttribute('rx', width / 2 - borderWidth / 2);
756
- circle.setAttribute('ry', height / 2 - borderWidth / 2);
757
- circle.setAttribute('stroke-width', borderWidth);
758
- circle.setAttribute('stroke', 'transparent');
759
- circle.setAttribute('fill', 'none');
760
- svg.appendChild(circle);
761
- this.container.append(svg);
762
- this._createPopup(this.container, circle, data);
763
- return this.container;
764
- }
765
- }]);
686
+ }
766
687
 
767
- return CircleAnnotationElement;
768
- }(AnnotationElement);
688
+ class SquareAnnotationElement extends AnnotationElement {
689
+ constructor(parameters) {
690
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
691
+ super(parameters, isRenderable, true);
692
+ }
769
693
 
770
- var PolylineAnnotationElement = function (_AnnotationElement8) {
771
- _inherits(PolylineAnnotationElement, _AnnotationElement8);
694
+ render() {
695
+ this.container.className = "squareAnnotation";
696
+ const data = this.data;
697
+ const width = data.rect[2] - data.rect[0];
698
+ const height = data.rect[3] - data.rect[1];
699
+ const svg = this.svgFactory.create(width, height);
700
+ const borderWidth = data.borderStyle.width;
701
+ const square = this.svgFactory.createElement("svg:rect");
702
+ square.setAttribute("x", borderWidth / 2);
703
+ square.setAttribute("y", borderWidth / 2);
704
+ square.setAttribute("width", width - borderWidth);
705
+ square.setAttribute("height", height - borderWidth);
706
+ square.setAttribute("stroke-width", borderWidth || 1);
707
+ square.setAttribute("stroke", "transparent");
708
+ square.setAttribute("fill", "none");
709
+ svg.appendChild(square);
710
+ this.container.append(svg);
711
+
712
+ this._createPopup(this.container, square, data);
713
+
714
+ return this.container;
715
+ }
772
716
 
773
- function PolylineAnnotationElement(parameters) {
774
- _classCallCheck(this, PolylineAnnotationElement);
717
+ }
775
718
 
776
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
719
+ class CircleAnnotationElement extends AnnotationElement {
720
+ constructor(parameters) {
721
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
722
+ super(parameters, isRenderable, true);
723
+ }
724
+
725
+ render() {
726
+ this.container.className = "circleAnnotation";
727
+ const data = this.data;
728
+ const width = data.rect[2] - data.rect[0];
729
+ const height = data.rect[3] - data.rect[1];
730
+ const svg = this.svgFactory.create(width, height);
731
+ const borderWidth = data.borderStyle.width;
732
+ const circle = this.svgFactory.createElement("svg:ellipse");
733
+ circle.setAttribute("cx", width / 2);
734
+ circle.setAttribute("cy", height / 2);
735
+ circle.setAttribute("rx", width / 2 - borderWidth / 2);
736
+ circle.setAttribute("ry", height / 2 - borderWidth / 2);
737
+ circle.setAttribute("stroke-width", borderWidth || 1);
738
+ circle.setAttribute("stroke", "transparent");
739
+ circle.setAttribute("fill", "none");
740
+ svg.appendChild(circle);
741
+ this.container.append(svg);
742
+
743
+ this._createPopup(this.container, circle, data);
744
+
745
+ return this.container;
746
+ }
777
747
 
778
- var _this15 = _possibleConstructorReturn(this, (PolylineAnnotationElement.__proto__ || Object.getPrototypeOf(PolylineAnnotationElement)).call(this, parameters, isRenderable, true));
748
+ }
779
749
 
780
- _this15.containerClassName = 'polylineAnnotation';
781
- _this15.svgElementName = 'svg:polyline';
782
- return _this15;
750
+ class PolylineAnnotationElement extends AnnotationElement {
751
+ constructor(parameters) {
752
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
753
+ super(parameters, isRenderable, true);
754
+ this.containerClassName = "polylineAnnotation";
755
+ this.svgElementName = "svg:polyline";
783
756
  }
784
757
 
785
- _createClass(PolylineAnnotationElement, [{
786
- key: 'render',
787
- value: function render() {
788
- this.container.className = this.containerClassName;
789
- var data = this.data;
790
- var width = data.rect[2] - data.rect[0];
791
- var height = data.rect[3] - data.rect[1];
792
- var svg = this.svgFactory.create(width, height);
793
- var vertices = data.vertices;
794
- var points = [];
795
- for (var i = 0, ii = vertices.length; i < ii; i++) {
796
- var x = vertices[i].x - data.rect[0];
797
- var y = data.rect[3] - vertices[i].y;
798
- points.push(x + ',' + y);
799
- }
800
- points = points.join(' ');
801
- var borderWidth = data.borderStyle.width;
802
- var polyline = this.svgFactory.createElement(this.svgElementName);
803
- polyline.setAttribute('points', points);
804
- polyline.setAttribute('stroke-width', borderWidth);
805
- polyline.setAttribute('stroke', 'transparent');
806
- polyline.setAttribute('fill', 'none');
807
- svg.appendChild(polyline);
808
- this.container.append(svg);
809
- this._createPopup(this.container, polyline, data);
810
- return this.container;
758
+ render() {
759
+ this.container.className = this.containerClassName;
760
+ const data = this.data;
761
+ const width = data.rect[2] - data.rect[0];
762
+ const height = data.rect[3] - data.rect[1];
763
+ const svg = this.svgFactory.create(width, height);
764
+ let points = [];
765
+
766
+ for (const coordinate of data.vertices) {
767
+ const x = coordinate.x - data.rect[0];
768
+ const y = data.rect[3] - coordinate.y;
769
+ points.push(x + "," + y);
811
770
  }
812
- }]);
813
771
 
814
- return PolylineAnnotationElement;
815
- }(AnnotationElement);
772
+ points = points.join(" ");
773
+ const polyline = this.svgFactory.createElement(this.svgElementName);
774
+ polyline.setAttribute("points", points);
775
+ polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
776
+ polyline.setAttribute("stroke", "transparent");
777
+ polyline.setAttribute("fill", "none");
778
+ svg.appendChild(polyline);
779
+ this.container.append(svg);
816
780
 
817
- var PolygonAnnotationElement = function (_PolylineAnnotationEl) {
818
- _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
781
+ this._createPopup(this.container, polyline, data);
819
782
 
820
- function PolygonAnnotationElement(parameters) {
821
- _classCallCheck(this, PolygonAnnotationElement);
783
+ return this.container;
784
+ }
822
785
 
823
- var _this16 = _possibleConstructorReturn(this, (PolygonAnnotationElement.__proto__ || Object.getPrototypeOf(PolygonAnnotationElement)).call(this, parameters));
786
+ }
824
787
 
825
- _this16.containerClassName = 'polygonAnnotation';
826
- _this16.svgElementName = 'svg:polygon';
827
- return _this16;
788
+ class PolygonAnnotationElement extends PolylineAnnotationElement {
789
+ constructor(parameters) {
790
+ super(parameters);
791
+ this.containerClassName = "polygonAnnotation";
792
+ this.svgElementName = "svg:polygon";
828
793
  }
829
794
 
830
- return PolygonAnnotationElement;
831
- }(PolylineAnnotationElement);
795
+ }
832
796
 
833
- var InkAnnotationElement = function (_AnnotationElement9) {
834
- _inherits(InkAnnotationElement, _AnnotationElement9);
797
+ class CaretAnnotationElement extends AnnotationElement {
798
+ constructor(parameters) {
799
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
800
+ super(parameters, isRenderable, true);
801
+ }
835
802
 
836
- function InkAnnotationElement(parameters) {
837
- _classCallCheck(this, InkAnnotationElement);
803
+ render() {
804
+ this.container.className = "caretAnnotation";
838
805
 
839
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
806
+ if (!this.data.hasPopup) {
807
+ this._createPopup(this.container, null, this.data);
808
+ }
840
809
 
841
- var _this17 = _possibleConstructorReturn(this, (InkAnnotationElement.__proto__ || Object.getPrototypeOf(InkAnnotationElement)).call(this, parameters, isRenderable, true));
810
+ return this.container;
811
+ }
842
812
 
843
- _this17.containerClassName = 'inkAnnotation';
844
- _this17.svgElementName = 'svg:polyline';
845
- return _this17;
813
+ }
814
+
815
+ class InkAnnotationElement extends AnnotationElement {
816
+ constructor(parameters) {
817
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
818
+ super(parameters, isRenderable, true);
819
+ this.containerClassName = "inkAnnotation";
820
+ this.svgElementName = "svg:polyline";
846
821
  }
847
822
 
848
- _createClass(InkAnnotationElement, [{
849
- key: 'render',
850
- value: function render() {
851
- this.container.className = this.containerClassName;
852
- var data = this.data;
853
- var width = data.rect[2] - data.rect[0];
854
- var height = data.rect[3] - data.rect[1];
855
- var svg = this.svgFactory.create(width, height);
856
- var inkLists = data.inkLists;
857
- for (var i = 0, ii = inkLists.length; i < ii; i++) {
858
- var inkList = inkLists[i];
859
- var points = [];
860
- for (var j = 0, jj = inkList.length; j < jj; j++) {
861
- var x = inkList[j].x - data.rect[0];
862
- var y = data.rect[3] - inkList[j].y;
863
- points.push(x + ',' + y);
864
- }
865
- points = points.join(' ');
866
- var borderWidth = data.borderStyle.width;
867
- var polyline = this.svgFactory.createElement(this.svgElementName);
868
- polyline.setAttribute('points', points);
869
- polyline.setAttribute('stroke-width', borderWidth);
870
- polyline.setAttribute('stroke', 'transparent');
871
- polyline.setAttribute('fill', 'none');
872
- this._createPopup(this.container, polyline, data);
873
- svg.appendChild(polyline);
874
- }
875
- this.container.append(svg);
876
- return this.container;
877
- }
878
- }]);
823
+ render() {
824
+ this.container.className = this.containerClassName;
825
+ const data = this.data;
826
+ const width = data.rect[2] - data.rect[0];
827
+ const height = data.rect[3] - data.rect[1];
828
+ const svg = this.svgFactory.create(width, height);
879
829
 
880
- return InkAnnotationElement;
881
- }(AnnotationElement);
830
+ for (const inkList of data.inkLists) {
831
+ let points = [];
882
832
 
883
- var HighlightAnnotationElement = function (_AnnotationElement10) {
884
- _inherits(HighlightAnnotationElement, _AnnotationElement10);
833
+ for (const coordinate of inkList) {
834
+ const x = coordinate.x - data.rect[0];
835
+ const y = data.rect[3] - coordinate.y;
836
+ points.push(`${x},${y}`);
837
+ }
885
838
 
886
- function HighlightAnnotationElement(parameters) {
887
- _classCallCheck(this, HighlightAnnotationElement);
839
+ points = points.join(" ");
840
+ const polyline = this.svgFactory.createElement(this.svgElementName);
841
+ polyline.setAttribute("points", points);
842
+ polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
843
+ polyline.setAttribute("stroke", "transparent");
844
+ polyline.setAttribute("fill", "none");
888
845
 
889
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
890
- return _possibleConstructorReturn(this, (HighlightAnnotationElement.__proto__ || Object.getPrototypeOf(HighlightAnnotationElement)).call(this, parameters, isRenderable, true));
891
- }
846
+ this._createPopup(this.container, polyline, data);
892
847
 
893
- _createClass(HighlightAnnotationElement, [{
894
- key: 'render',
895
- value: function render() {
896
- this.container.className = 'highlightAnnotation';
897
- if (!this.data.hasPopup) {
898
- this._createPopup(this.container, null, this.data);
899
- }
900
- return this.container;
848
+ svg.appendChild(polyline);
901
849
  }
902
- }]);
903
850
 
904
- return HighlightAnnotationElement;
905
- }(AnnotationElement);
906
-
907
- var UnderlineAnnotationElement = function (_AnnotationElement11) {
908
- _inherits(UnderlineAnnotationElement, _AnnotationElement11);
851
+ this.container.append(svg);
852
+ return this.container;
853
+ }
909
854
 
910
- function UnderlineAnnotationElement(parameters) {
911
- _classCallCheck(this, UnderlineAnnotationElement);
855
+ }
912
856
 
913
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
914
- return _possibleConstructorReturn(this, (UnderlineAnnotationElement.__proto__ || Object.getPrototypeOf(UnderlineAnnotationElement)).call(this, parameters, isRenderable, true));
857
+ class HighlightAnnotationElement extends AnnotationElement {
858
+ constructor(parameters) {
859
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
860
+ super(parameters, isRenderable, true);
915
861
  }
916
862
 
917
- _createClass(UnderlineAnnotationElement, [{
918
- key: 'render',
919
- value: function render() {
920
- this.container.className = 'underlineAnnotation';
921
- if (!this.data.hasPopup) {
922
- this._createPopup(this.container, null, this.data);
923
- }
924
- return this.container;
925
- }
926
- }]);
863
+ render() {
864
+ this.container.className = "highlightAnnotation";
927
865
 
928
- return UnderlineAnnotationElement;
929
- }(AnnotationElement);
866
+ if (!this.data.hasPopup) {
867
+ this._createPopup(this.container, null, this.data);
868
+ }
930
869
 
931
- var SquigglyAnnotationElement = function (_AnnotationElement12) {
932
- _inherits(SquigglyAnnotationElement, _AnnotationElement12);
870
+ return this.container;
871
+ }
933
872
 
934
- function SquigglyAnnotationElement(parameters) {
935
- _classCallCheck(this, SquigglyAnnotationElement);
873
+ }
936
874
 
937
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
938
- return _possibleConstructorReturn(this, (SquigglyAnnotationElement.__proto__ || Object.getPrototypeOf(SquigglyAnnotationElement)).call(this, parameters, isRenderable, true));
875
+ class UnderlineAnnotationElement extends AnnotationElement {
876
+ constructor(parameters) {
877
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
878
+ super(parameters, isRenderable, true);
939
879
  }
940
880
 
941
- _createClass(SquigglyAnnotationElement, [{
942
- key: 'render',
943
- value: function render() {
944
- this.container.className = 'squigglyAnnotation';
945
- if (!this.data.hasPopup) {
946
- this._createPopup(this.container, null, this.data);
947
- }
948
- return this.container;
949
- }
950
- }]);
881
+ render() {
882
+ this.container.className = "underlineAnnotation";
951
883
 
952
- return SquigglyAnnotationElement;
953
- }(AnnotationElement);
884
+ if (!this.data.hasPopup) {
885
+ this._createPopup(this.container, null, this.data);
886
+ }
954
887
 
955
- var StrikeOutAnnotationElement = function (_AnnotationElement13) {
956
- _inherits(StrikeOutAnnotationElement, _AnnotationElement13);
888
+ return this.container;
889
+ }
957
890
 
958
- function StrikeOutAnnotationElement(parameters) {
959
- _classCallCheck(this, StrikeOutAnnotationElement);
891
+ }
960
892
 
961
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
962
- return _possibleConstructorReturn(this, (StrikeOutAnnotationElement.__proto__ || Object.getPrototypeOf(StrikeOutAnnotationElement)).call(this, parameters, isRenderable, true));
893
+ class SquigglyAnnotationElement extends AnnotationElement {
894
+ constructor(parameters) {
895
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
896
+ super(parameters, isRenderable, true);
963
897
  }
964
898
 
965
- _createClass(StrikeOutAnnotationElement, [{
966
- key: 'render',
967
- value: function render() {
968
- this.container.className = 'strikeoutAnnotation';
969
- if (!this.data.hasPopup) {
970
- this._createPopup(this.container, null, this.data);
971
- }
972
- return this.container;
973
- }
974
- }]);
899
+ render() {
900
+ this.container.className = "squigglyAnnotation";
975
901
 
976
- return StrikeOutAnnotationElement;
977
- }(AnnotationElement);
902
+ if (!this.data.hasPopup) {
903
+ this._createPopup(this.container, null, this.data);
904
+ }
978
905
 
979
- var StampAnnotationElement = function (_AnnotationElement14) {
980
- _inherits(StampAnnotationElement, _AnnotationElement14);
906
+ return this.container;
907
+ }
981
908
 
982
- function StampAnnotationElement(parameters) {
983
- _classCallCheck(this, StampAnnotationElement);
909
+ }
984
910
 
985
- var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
986
- return _possibleConstructorReturn(this, (StampAnnotationElement.__proto__ || Object.getPrototypeOf(StampAnnotationElement)).call(this, parameters, isRenderable, true));
911
+ class StrikeOutAnnotationElement extends AnnotationElement {
912
+ constructor(parameters) {
913
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
914
+ super(parameters, isRenderable, true);
987
915
  }
988
916
 
989
- _createClass(StampAnnotationElement, [{
990
- key: 'render',
991
- value: function render() {
992
- this.container.className = 'stampAnnotation';
993
- if (!this.data.hasPopup) {
994
- this._createPopup(this.container, null, this.data);
995
- }
996
- return this.container;
917
+ render() {
918
+ this.container.className = "strikeoutAnnotation";
919
+
920
+ if (!this.data.hasPopup) {
921
+ this._createPopup(this.container, null, this.data);
997
922
  }
998
- }]);
999
923
 
1000
- return StampAnnotationElement;
1001
- }(AnnotationElement);
924
+ return this.container;
925
+ }
1002
926
 
1003
- var FileAttachmentAnnotationElement = function (_AnnotationElement15) {
1004
- _inherits(FileAttachmentAnnotationElement, _AnnotationElement15);
927
+ }
1005
928
 
1006
- function FileAttachmentAnnotationElement(parameters) {
1007
- _classCallCheck(this, FileAttachmentAnnotationElement);
929
+ class StampAnnotationElement extends AnnotationElement {
930
+ constructor(parameters) {
931
+ const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
932
+ super(parameters, isRenderable, true);
933
+ }
1008
934
 
1009
- var _this23 = _possibleConstructorReturn(this, (FileAttachmentAnnotationElement.__proto__ || Object.getPrototypeOf(FileAttachmentAnnotationElement)).call(this, parameters, true));
935
+ render() {
936
+ this.container.className = "stampAnnotation";
1010
937
 
1011
- var _this23$data$file = _this23.data.file,
1012
- filename = _this23$data$file.filename,
1013
- content = _this23$data$file.content;
938
+ if (!this.data.hasPopup) {
939
+ this._createPopup(this.container, null, this.data);
940
+ }
941
+
942
+ return this.container;
943
+ }
1014
944
 
1015
- _this23.filename = (0, _dom_utils.getFilenameFromUrl)(filename);
1016
- _this23.content = content;
1017
- if (_this23.linkService.eventBus) {
1018
- _this23.linkService.eventBus.dispatch('fileattachmentannotation', {
1019
- source: _this23,
945
+ }
946
+
947
+ class FileAttachmentAnnotationElement extends AnnotationElement {
948
+ constructor(parameters) {
949
+ super(parameters, true);
950
+ const {
951
+ filename,
952
+ content
953
+ } = this.data.file;
954
+ this.filename = (0, _display_utils.getFilenameFromUrl)(filename);
955
+ this.content = content;
956
+
957
+ if (this.linkService.eventBus) {
958
+ this.linkService.eventBus.dispatch("fileattachmentannotation", {
959
+ source: this,
1020
960
  id: (0, _util.stringToPDFString)(filename),
1021
- filename: filename,
1022
- content: content
961
+ filename,
962
+ content
1023
963
  });
1024
964
  }
1025
- return _this23;
1026
965
  }
1027
966
 
1028
- _createClass(FileAttachmentAnnotationElement, [{
1029
- key: 'render',
1030
- value: function render() {
1031
- this.container.className = 'fileAttachmentAnnotation';
1032
- var trigger = document.createElement('div');
1033
- trigger.style.height = this.container.style.height;
1034
- trigger.style.width = this.container.style.width;
1035
- trigger.addEventListener('dblclick', this._download.bind(this));
1036
- if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
1037
- this._createPopup(this.container, trigger, this.data);
1038
- }
1039
- this.container.appendChild(trigger);
1040
- return this.container;
967
+ render() {
968
+ this.container.className = "fileAttachmentAnnotation";
969
+ const trigger = document.createElement("div");
970
+ trigger.style.height = this.container.style.height;
971
+ trigger.style.width = this.container.style.width;
972
+ trigger.addEventListener("dblclick", this._download.bind(this));
973
+
974
+ if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
975
+ this._createPopup(this.container, trigger, this.data);
1041
976
  }
1042
- }, {
1043
- key: '_download',
1044
- value: function _download() {
1045
- if (!this.downloadManager) {
1046
- (0, _util.warn)('Download cannot be started due to unavailable download manager');
1047
- return;
977
+
978
+ this.container.appendChild(trigger);
979
+ return this.container;
980
+ }
981
+
982
+ _download() {
983
+ if (!this.downloadManager) {
984
+ (0, _util.warn)("Download cannot be started due to unavailable download manager");
985
+ return;
986
+ }
987
+
988
+ this.downloadManager.downloadData(this.content, this.filename, "");
989
+ }
990
+
991
+ }
992
+
993
+ class AnnotationLayer {
994
+ static render(parameters) {
995
+ const sortedAnnotations = [],
996
+ popupAnnotations = [];
997
+
998
+ for (const data of parameters.annotations) {
999
+ if (!data) {
1000
+ continue;
1048
1001
  }
1049
- this.downloadManager.downloadData(this.content, this.filename, '');
1002
+
1003
+ if (data.annotationType === _util.AnnotationType.POPUP) {
1004
+ popupAnnotations.push(data);
1005
+ continue;
1006
+ }
1007
+
1008
+ sortedAnnotations.push(data);
1050
1009
  }
1051
- }]);
1052
1010
 
1053
- return FileAttachmentAnnotationElement;
1054
- }(AnnotationElement);
1011
+ if (popupAnnotations.length) {
1012
+ sortedAnnotations.push(...popupAnnotations);
1013
+ }
1055
1014
 
1056
- var AnnotationLayer = function () {
1057
- function AnnotationLayer() {
1058
- _classCallCheck(this, AnnotationLayer);
1059
- }
1015
+ for (const data of sortedAnnotations) {
1016
+ const element = AnnotationElementFactory.create({
1017
+ data,
1018
+ layer: parameters.div,
1019
+ page: parameters.page,
1020
+ viewport: parameters.viewport,
1021
+ linkService: parameters.linkService,
1022
+ downloadManager: parameters.downloadManager,
1023
+ imageResourcesPath: parameters.imageResourcesPath || "",
1024
+ renderInteractiveForms: parameters.renderInteractiveForms || false,
1025
+ svgFactory: new _display_utils.DOMSVGFactory()
1026
+ });
1060
1027
 
1061
- _createClass(AnnotationLayer, null, [{
1062
- key: 'render',
1063
- value: function render(parameters) {
1064
- for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
1065
- var data = parameters.annotations[i];
1066
- if (!data) {
1067
- continue;
1068
- }
1069
- var element = AnnotationElementFactory.create({
1070
- data: data,
1071
- layer: parameters.div,
1072
- page: parameters.page,
1073
- viewport: parameters.viewport,
1074
- linkService: parameters.linkService,
1075
- downloadManager: parameters.downloadManager,
1076
- imageResourcesPath: parameters.imageResourcesPath || '',
1077
- renderInteractiveForms: parameters.renderInteractiveForms || false,
1078
- svgFactory: new _dom_utils.DOMSVGFactory()
1079
- });
1080
- if (element.isRenderable) {
1081
- parameters.div.appendChild(element.render());
1082
- }
1028
+ if (element.isRenderable) {
1029
+ parameters.div.appendChild(element.render());
1083
1030
  }
1084
1031
  }
1085
- }, {
1086
- key: 'update',
1087
- value: function update(parameters) {
1088
- for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
1089
- var data = parameters.annotations[i];
1090
- var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
1091
- if (element) {
1092
- element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')';
1093
- }
1032
+ }
1033
+
1034
+ static update(parameters) {
1035
+ for (const data of parameters.annotations) {
1036
+ const element = parameters.div.querySelector(`[data-annotation-id="${data.id}"]`);
1037
+
1038
+ if (element) {
1039
+ element.style.transform = `matrix(${parameters.viewport.transform.join(",")})`;
1094
1040
  }
1095
- parameters.div.removeAttribute('hidden');
1096
1041
  }
1097
- }]);
1098
1042
 
1099
- return AnnotationLayer;
1100
- }();
1043
+ parameters.div.removeAttribute("hidden");
1044
+ }
1045
+
1046
+ }
1101
1047
 
1102
1048
  exports.AnnotationLayer = AnnotationLayer;