2
0

annotation_layer.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.AnnotationLayer = void 0;
  27. var _display_utils = require("./display_utils");
  28. var _util = require("../shared/util");
  29. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  30. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  31. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  32. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  33. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  34. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  35. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  36. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38. 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); } }
  39. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  40. var AnnotationElementFactory =
  41. /*#__PURE__*/
  42. function () {
  43. function AnnotationElementFactory() {
  44. _classCallCheck(this, AnnotationElementFactory);
  45. }
  46. _createClass(AnnotationElementFactory, null, [{
  47. key: "create",
  48. value: function create(parameters) {
  49. var subtype = parameters.data.annotationType;
  50. switch (subtype) {
  51. case _util.AnnotationType.LINK:
  52. return new LinkAnnotationElement(parameters);
  53. case _util.AnnotationType.TEXT:
  54. return new TextAnnotationElement(parameters);
  55. case _util.AnnotationType.WIDGET:
  56. var fieldType = parameters.data.fieldType;
  57. switch (fieldType) {
  58. case 'Tx':
  59. return new TextWidgetAnnotationElement(parameters);
  60. case 'Btn':
  61. if (parameters.data.radioButton) {
  62. return new RadioButtonWidgetAnnotationElement(parameters);
  63. } else if (parameters.data.checkBox) {
  64. return new CheckboxWidgetAnnotationElement(parameters);
  65. }
  66. return new PushButtonWidgetAnnotationElement(parameters);
  67. case 'Ch':
  68. return new ChoiceWidgetAnnotationElement(parameters);
  69. }
  70. return new WidgetAnnotationElement(parameters);
  71. case _util.AnnotationType.POPUP:
  72. return new PopupAnnotationElement(parameters);
  73. case _util.AnnotationType.FREETEXT:
  74. return new FreeTextAnnotationElement(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.CARET:
  84. return new CaretAnnotationElement(parameters);
  85. case _util.AnnotationType.INK:
  86. return new InkAnnotationElement(parameters);
  87. case _util.AnnotationType.POLYGON:
  88. return new PolygonAnnotationElement(parameters);
  89. case _util.AnnotationType.HIGHLIGHT:
  90. return new HighlightAnnotationElement(parameters);
  91. case _util.AnnotationType.UNDERLINE:
  92. return new UnderlineAnnotationElement(parameters);
  93. case _util.AnnotationType.SQUIGGLY:
  94. return new SquigglyAnnotationElement(parameters);
  95. case _util.AnnotationType.STRIKEOUT:
  96. return new StrikeOutAnnotationElement(parameters);
  97. case _util.AnnotationType.STAMP:
  98. return new StampAnnotationElement(parameters);
  99. case _util.AnnotationType.FILEATTACHMENT:
  100. return new FileAttachmentAnnotationElement(parameters);
  101. default:
  102. return new AnnotationElement(parameters);
  103. }
  104. }
  105. }]);
  106. return AnnotationElementFactory;
  107. }();
  108. var AnnotationElement =
  109. /*#__PURE__*/
  110. function () {
  111. function AnnotationElement(parameters) {
  112. var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  113. var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  114. _classCallCheck(this, AnnotationElement);
  115. this.isRenderable = isRenderable;
  116. this.data = parameters.data;
  117. this.layer = parameters.layer;
  118. this.page = parameters.page;
  119. this.viewport = parameters.viewport;
  120. this.linkService = parameters.linkService;
  121. this.downloadManager = parameters.downloadManager;
  122. this.imageResourcesPath = parameters.imageResourcesPath;
  123. this.renderInteractiveForms = parameters.renderInteractiveForms;
  124. this.svgFactory = parameters.svgFactory;
  125. if (isRenderable) {
  126. this.container = this._createContainer(ignoreBorder);
  127. }
  128. }
  129. _createClass(AnnotationElement, [{
  130. key: "_createContainer",
  131. value: function _createContainer() {
  132. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  133. var data = this.data,
  134. page = this.page,
  135. viewport = this.viewport;
  136. var container = document.createElement('section');
  137. var width = data.rect[2] - data.rect[0];
  138. var height = data.rect[3] - data.rect[1];
  139. container.setAttribute('data-annotation-id', data.id);
  140. 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]]);
  141. container.style.transform = "matrix(".concat(viewport.transform.join(','), ")");
  142. container.style.transformOrigin = "-".concat(rect[0], "px -").concat(rect[1], "px");
  143. if (!ignoreBorder && data.borderStyle.width > 0) {
  144. container.style.borderWidth = "".concat(data.borderStyle.width, "px");
  145. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  146. width = width - 2 * data.borderStyle.width;
  147. height = height - 2 * data.borderStyle.width;
  148. }
  149. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  150. var verticalRadius = data.borderStyle.verticalCornerRadius;
  151. if (horizontalRadius > 0 || verticalRadius > 0) {
  152. var radius = "".concat(horizontalRadius, "px / ").concat(verticalRadius, "px");
  153. container.style.borderRadius = radius;
  154. }
  155. switch (data.borderStyle.style) {
  156. case _util.AnnotationBorderStyleType.SOLID:
  157. container.style.borderStyle = 'solid';
  158. break;
  159. case _util.AnnotationBorderStyleType.DASHED:
  160. container.style.borderStyle = 'dashed';
  161. break;
  162. case _util.AnnotationBorderStyleType.BEVELED:
  163. (0, _util.warn)('Unimplemented border style: beveled');
  164. break;
  165. case _util.AnnotationBorderStyleType.INSET:
  166. (0, _util.warn)('Unimplemented border style: inset');
  167. break;
  168. case _util.AnnotationBorderStyleType.UNDERLINE:
  169. container.style.borderBottomStyle = 'solid';
  170. break;
  171. default:
  172. break;
  173. }
  174. if (data.color) {
  175. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  176. } else {
  177. container.style.borderWidth = 0;
  178. }
  179. }
  180. container.style.left = "".concat(rect[0], "px");
  181. container.style.top = "".concat(rect[1], "px");
  182. container.style.width = "".concat(width, "px");
  183. container.style.height = "".concat(height, "px");
  184. return container;
  185. }
  186. }, {
  187. key: "_createPopup",
  188. value: function _createPopup(container, trigger, data) {
  189. if (!trigger) {
  190. trigger = document.createElement('div');
  191. trigger.style.height = container.style.height;
  192. trigger.style.width = container.style.width;
  193. container.appendChild(trigger);
  194. }
  195. var popupElement = new PopupElement({
  196. container: container,
  197. trigger: trigger,
  198. color: data.color,
  199. title: data.title,
  200. modificationDate: data.modificationDate,
  201. contents: data.contents,
  202. hideWrapper: true
  203. });
  204. var popup = popupElement.render();
  205. popup.style.left = container.style.width;
  206. container.appendChild(popup);
  207. }
  208. }, {
  209. key: "render",
  210. value: function render() {
  211. (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
  212. }
  213. }]);
  214. return AnnotationElement;
  215. }();
  216. var LinkAnnotationElement =
  217. /*#__PURE__*/
  218. function (_AnnotationElement) {
  219. _inherits(LinkAnnotationElement, _AnnotationElement);
  220. function LinkAnnotationElement(parameters) {
  221. _classCallCheck(this, LinkAnnotationElement);
  222. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
  223. return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));
  224. }
  225. _createClass(LinkAnnotationElement, [{
  226. key: "render",
  227. value: function render() {
  228. this.container.className = 'linkAnnotation';
  229. var data = this.data,
  230. linkService = this.linkService;
  231. var link = document.createElement('a');
  232. if (data.url) {
  233. (0, _display_utils.addLinkAttributes)(link, {
  234. url: data.url,
  235. target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
  236. rel: linkService.externalLinkRel,
  237. enabled: linkService.externalLinkEnabled
  238. });
  239. } else if (data.action) {
  240. this._bindNamedAction(link, data.action);
  241. } else {
  242. this._bindLink(link, data.dest);
  243. }
  244. this.container.appendChild(link);
  245. return this.container;
  246. }
  247. }, {
  248. key: "_bindLink",
  249. value: function _bindLink(link, destination) {
  250. var _this = this;
  251. link.href = this.linkService.getDestinationHash(destination);
  252. link.onclick = function () {
  253. if (destination) {
  254. _this.linkService.navigateTo(destination);
  255. }
  256. return false;
  257. };
  258. if (destination) {
  259. link.className = 'internalLink';
  260. }
  261. }
  262. }, {
  263. key: "_bindNamedAction",
  264. value: function _bindNamedAction(link, action) {
  265. var _this2 = this;
  266. link.href = this.linkService.getAnchorUrl('');
  267. link.onclick = function () {
  268. _this2.linkService.executeNamedAction(action);
  269. return false;
  270. };
  271. link.className = 'internalLink';
  272. }
  273. }]);
  274. return LinkAnnotationElement;
  275. }(AnnotationElement);
  276. var TextAnnotationElement =
  277. /*#__PURE__*/
  278. function (_AnnotationElement2) {
  279. _inherits(TextAnnotationElement, _AnnotationElement2);
  280. function TextAnnotationElement(parameters) {
  281. _classCallCheck(this, TextAnnotationElement);
  282. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  283. return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));
  284. }
  285. _createClass(TextAnnotationElement, [{
  286. key: "render",
  287. value: function render() {
  288. this.container.className = 'textAnnotation';
  289. var image = document.createElement('img');
  290. image.style.height = this.container.style.height;
  291. image.style.width = this.container.style.width;
  292. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  293. image.alt = '[{{type}} Annotation]';
  294. image.dataset.l10nId = 'text_annotation_type';
  295. image.dataset.l10nArgs = JSON.stringify({
  296. type: this.data.name
  297. });
  298. if (!this.data.hasPopup) {
  299. this._createPopup(this.container, image, this.data);
  300. }
  301. this.container.appendChild(image);
  302. return this.container;
  303. }
  304. }]);
  305. return TextAnnotationElement;
  306. }(AnnotationElement);
  307. var WidgetAnnotationElement =
  308. /*#__PURE__*/
  309. function (_AnnotationElement3) {
  310. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  311. function WidgetAnnotationElement() {
  312. _classCallCheck(this, WidgetAnnotationElement);
  313. return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));
  314. }
  315. _createClass(WidgetAnnotationElement, [{
  316. key: "render",
  317. value: function render() {
  318. return this.container;
  319. }
  320. }]);
  321. return WidgetAnnotationElement;
  322. }(AnnotationElement);
  323. var TextWidgetAnnotationElement =
  324. /*#__PURE__*/
  325. function (_WidgetAnnotationElem) {
  326. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  327. function TextWidgetAnnotationElement(parameters) {
  328. _classCallCheck(this, TextWidgetAnnotationElement);
  329. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  330. return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));
  331. }
  332. _createClass(TextWidgetAnnotationElement, [{
  333. key: "render",
  334. value: function render() {
  335. var TEXT_ALIGNMENT = ['left', 'center', 'right'];
  336. this.container.className = 'textWidgetAnnotation';
  337. var element = null;
  338. if (this.renderInteractiveForms) {
  339. if (this.data.multiLine) {
  340. element = document.createElement('textarea');
  341. element.textContent = this.data.fieldValue;
  342. } else {
  343. element = document.createElement('input');
  344. element.type = 'text';
  345. element.setAttribute('value', this.data.fieldValue);
  346. }
  347. element.disabled = this.data.readOnly;
  348. if (this.data.maxLen !== null) {
  349. element.maxLength = this.data.maxLen;
  350. }
  351. if (this.data.comb) {
  352. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  353. var combWidth = fieldWidth / this.data.maxLen;
  354. element.classList.add('comb');
  355. element.style.letterSpacing = "calc(".concat(combWidth, "px - 1ch)");
  356. }
  357. } else {
  358. element = document.createElement('div');
  359. element.textContent = this.data.fieldValue;
  360. element.style.verticalAlign = 'middle';
  361. element.style.display = 'table-cell';
  362. var font = null;
  363. if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
  364. font = this.page.commonObjs.get(this.data.fontRefName);
  365. }
  366. this._setTextStyle(element, font);
  367. }
  368. if (this.data.textAlignment !== null) {
  369. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  370. }
  371. this.container.appendChild(element);
  372. return this.container;
  373. }
  374. }, {
  375. key: "_setTextStyle",
  376. value: function _setTextStyle(element, font) {
  377. var style = element.style;
  378. style.fontSize = "".concat(this.data.fontSize, "px");
  379. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  380. if (!font) {
  381. return;
  382. }
  383. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  384. style.fontStyle = font.italic ? 'italic' : 'normal';
  385. var fontFamily = font.loadedName ? "\"".concat(font.loadedName, "\", ") : '';
  386. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  387. style.fontFamily = fontFamily + fallbackName;
  388. }
  389. }]);
  390. return TextWidgetAnnotationElement;
  391. }(WidgetAnnotationElement);
  392. var CheckboxWidgetAnnotationElement =
  393. /*#__PURE__*/
  394. function (_WidgetAnnotationElem2) {
  395. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  396. function CheckboxWidgetAnnotationElement(parameters) {
  397. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  398. return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  399. }
  400. _createClass(CheckboxWidgetAnnotationElement, [{
  401. key: "render",
  402. value: function render() {
  403. this.container.className = 'buttonWidgetAnnotation checkBox';
  404. var element = document.createElement('input');
  405. element.disabled = this.data.readOnly;
  406. element.type = 'checkbox';
  407. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  408. element.setAttribute('checked', true);
  409. }
  410. this.container.appendChild(element);
  411. return this.container;
  412. }
  413. }]);
  414. return CheckboxWidgetAnnotationElement;
  415. }(WidgetAnnotationElement);
  416. var RadioButtonWidgetAnnotationElement =
  417. /*#__PURE__*/
  418. function (_WidgetAnnotationElem3) {
  419. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  420. function RadioButtonWidgetAnnotationElement(parameters) {
  421. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  422. return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  423. }
  424. _createClass(RadioButtonWidgetAnnotationElement, [{
  425. key: "render",
  426. value: function render() {
  427. this.container.className = 'buttonWidgetAnnotation radioButton';
  428. var element = document.createElement('input');
  429. element.disabled = this.data.readOnly;
  430. element.type = 'radio';
  431. element.name = this.data.fieldName;
  432. if (this.data.fieldValue === this.data.buttonValue) {
  433. element.setAttribute('checked', true);
  434. }
  435. this.container.appendChild(element);
  436. return this.container;
  437. }
  438. }]);
  439. return RadioButtonWidgetAnnotationElement;
  440. }(WidgetAnnotationElement);
  441. var PushButtonWidgetAnnotationElement =
  442. /*#__PURE__*/
  443. function (_LinkAnnotationElemen) {
  444. _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
  445. function PushButtonWidgetAnnotationElement() {
  446. _classCallCheck(this, PushButtonWidgetAnnotationElement);
  447. return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));
  448. }
  449. _createClass(PushButtonWidgetAnnotationElement, [{
  450. key: "render",
  451. value: function render() {
  452. var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
  453. container.className = 'buttonWidgetAnnotation pushButton';
  454. return container;
  455. }
  456. }]);
  457. return PushButtonWidgetAnnotationElement;
  458. }(LinkAnnotationElement);
  459. var ChoiceWidgetAnnotationElement =
  460. /*#__PURE__*/
  461. function (_WidgetAnnotationElem4) {
  462. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  463. function ChoiceWidgetAnnotationElement(parameters) {
  464. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  465. return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  466. }
  467. _createClass(ChoiceWidgetAnnotationElement, [{
  468. key: "render",
  469. value: function render() {
  470. this.container.className = 'choiceWidgetAnnotation';
  471. var selectElement = document.createElement('select');
  472. selectElement.disabled = this.data.readOnly;
  473. if (!this.data.combo) {
  474. selectElement.size = this.data.options.length;
  475. if (this.data.multiSelect) {
  476. selectElement.multiple = true;
  477. }
  478. }
  479. var _iteratorNormalCompletion = true;
  480. var _didIteratorError = false;
  481. var _iteratorError = undefined;
  482. try {
  483. for (var _iterator = this.data.options[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  484. var option = _step.value;
  485. var optionElement = document.createElement('option');
  486. optionElement.textContent = option.displayValue;
  487. optionElement.value = option.exportValue;
  488. if (this.data.fieldValue.includes(option.displayValue)) {
  489. optionElement.setAttribute('selected', true);
  490. }
  491. selectElement.appendChild(optionElement);
  492. }
  493. } catch (err) {
  494. _didIteratorError = true;
  495. _iteratorError = err;
  496. } finally {
  497. try {
  498. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  499. _iterator["return"]();
  500. }
  501. } finally {
  502. if (_didIteratorError) {
  503. throw _iteratorError;
  504. }
  505. }
  506. }
  507. this.container.appendChild(selectElement);
  508. return this.container;
  509. }
  510. }]);
  511. return ChoiceWidgetAnnotationElement;
  512. }(WidgetAnnotationElement);
  513. var PopupAnnotationElement =
  514. /*#__PURE__*/
  515. function (_AnnotationElement4) {
  516. _inherits(PopupAnnotationElement, _AnnotationElement4);
  517. function PopupAnnotationElement(parameters) {
  518. _classCallCheck(this, PopupAnnotationElement);
  519. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  520. return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));
  521. }
  522. _createClass(PopupAnnotationElement, [{
  523. key: "render",
  524. value: function render() {
  525. var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
  526. this.container.className = 'popupAnnotation';
  527. if (IGNORE_TYPES.includes(this.data.parentType)) {
  528. return this.container;
  529. }
  530. var selector = "[data-annotation-id=\"".concat(this.data.parentId, "\"]");
  531. var parentElement = this.layer.querySelector(selector);
  532. if (!parentElement) {
  533. return this.container;
  534. }
  535. var popup = new PopupElement({
  536. container: this.container,
  537. trigger: parentElement,
  538. color: this.data.color,
  539. title: this.data.title,
  540. modificationDate: this.data.modificationDate,
  541. contents: this.data.contents
  542. });
  543. var parentLeft = parseFloat(parentElement.style.left);
  544. var parentWidth = parseFloat(parentElement.style.width);
  545. this.container.style.transformOrigin = "-".concat(parentLeft + parentWidth, "px -").concat(parentElement.style.top);
  546. this.container.style.left = "".concat(parentLeft + parentWidth, "px");
  547. this.container.appendChild(popup.render());
  548. return this.container;
  549. }
  550. }]);
  551. return PopupAnnotationElement;
  552. }(AnnotationElement);
  553. var PopupElement =
  554. /*#__PURE__*/
  555. function () {
  556. function PopupElement(parameters) {
  557. _classCallCheck(this, PopupElement);
  558. this.container = parameters.container;
  559. this.trigger = parameters.trigger;
  560. this.color = parameters.color;
  561. this.title = parameters.title;
  562. this.modificationDate = parameters.modificationDate;
  563. this.contents = parameters.contents;
  564. this.hideWrapper = parameters.hideWrapper || false;
  565. this.pinned = false;
  566. }
  567. _createClass(PopupElement, [{
  568. key: "render",
  569. value: function render() {
  570. var BACKGROUND_ENLIGHT = 0.7;
  571. var wrapper = document.createElement('div');
  572. wrapper.className = 'popupWrapper';
  573. this.hideElement = this.hideWrapper ? wrapper : this.container;
  574. this.hideElement.setAttribute('hidden', true);
  575. var popup = document.createElement('div');
  576. popup.className = 'popup';
  577. var color = this.color;
  578. if (color) {
  579. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  580. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  581. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  582. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  583. }
  584. var title = document.createElement('h1');
  585. title.textContent = this.title;
  586. popup.appendChild(title);
  587. var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
  588. if (dateObject) {
  589. var modificationDate = document.createElement('span');
  590. modificationDate.textContent = '{{date}}, {{time}}';
  591. modificationDate.dataset.l10nId = 'annotation_date_string';
  592. modificationDate.dataset.l10nArgs = JSON.stringify({
  593. date: dateObject.toLocaleDateString(),
  594. time: dateObject.toLocaleTimeString()
  595. });
  596. popup.appendChild(modificationDate);
  597. }
  598. var contents = this._formatContents(this.contents);
  599. popup.appendChild(contents);
  600. this.trigger.addEventListener('click', this._toggle.bind(this));
  601. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  602. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  603. popup.addEventListener('click', this._hide.bind(this, true));
  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. }
  629. }
  630. }, {
  631. key: "_show",
  632. value: function _show() {
  633. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  634. if (pin) {
  635. this.pinned = true;
  636. }
  637. if (this.hideElement.hasAttribute('hidden')) {
  638. this.hideElement.removeAttribute('hidden');
  639. this.container.style.zIndex += 1;
  640. }
  641. }
  642. }, {
  643. key: "_hide",
  644. value: function _hide() {
  645. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  646. if (unpin) {
  647. this.pinned = false;
  648. }
  649. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  650. this.hideElement.setAttribute('hidden', true);
  651. this.container.style.zIndex -= 1;
  652. }
  653. }
  654. }]);
  655. return PopupElement;
  656. }();
  657. var FreeTextAnnotationElement =
  658. /*#__PURE__*/
  659. function (_AnnotationElement5) {
  660. _inherits(FreeTextAnnotationElement, _AnnotationElement5);
  661. function FreeTextAnnotationElement(parameters) {
  662. _classCallCheck(this, FreeTextAnnotationElement);
  663. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  664. return _possibleConstructorReturn(this, _getPrototypeOf(FreeTextAnnotationElement).call(this, parameters, isRenderable, true));
  665. }
  666. _createClass(FreeTextAnnotationElement, [{
  667. key: "render",
  668. value: function render() {
  669. this.container.className = 'freeTextAnnotation';
  670. if (!this.data.hasPopup) {
  671. this._createPopup(this.container, null, this.data);
  672. }
  673. return this.container;
  674. }
  675. }]);
  676. return FreeTextAnnotationElement;
  677. }(AnnotationElement);
  678. var LineAnnotationElement =
  679. /*#__PURE__*/
  680. function (_AnnotationElement6) {
  681. _inherits(LineAnnotationElement, _AnnotationElement6);
  682. function LineAnnotationElement(parameters) {
  683. _classCallCheck(this, LineAnnotationElement);
  684. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  685. return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));
  686. }
  687. _createClass(LineAnnotationElement, [{
  688. key: "render",
  689. value: function render() {
  690. this.container.className = 'lineAnnotation';
  691. var data = this.data;
  692. var width = data.rect[2] - data.rect[0];
  693. var height = data.rect[3] - data.rect[1];
  694. var svg = this.svgFactory.create(width, height);
  695. var line = this.svgFactory.createElement('svg:line');
  696. line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
  697. line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
  698. line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
  699. line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
  700. line.setAttribute('stroke-width', data.borderStyle.width);
  701. line.setAttribute('stroke', 'transparent');
  702. svg.appendChild(line);
  703. this.container.append(svg);
  704. this._createPopup(this.container, line, data);
  705. return this.container;
  706. }
  707. }]);
  708. return LineAnnotationElement;
  709. }(AnnotationElement);
  710. var SquareAnnotationElement =
  711. /*#__PURE__*/
  712. function (_AnnotationElement7) {
  713. _inherits(SquareAnnotationElement, _AnnotationElement7);
  714. function SquareAnnotationElement(parameters) {
  715. _classCallCheck(this, SquareAnnotationElement);
  716. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  717. return _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotationElement).call(this, parameters, isRenderable, true));
  718. }
  719. _createClass(SquareAnnotationElement, [{
  720. key: "render",
  721. value: function render() {
  722. this.container.className = 'squareAnnotation';
  723. var data = this.data;
  724. var width = data.rect[2] - data.rect[0];
  725. var height = data.rect[3] - data.rect[1];
  726. var svg = this.svgFactory.create(width, height);
  727. var borderWidth = data.borderStyle.width;
  728. var square = this.svgFactory.createElement('svg:rect');
  729. square.setAttribute('x', borderWidth / 2);
  730. square.setAttribute('y', borderWidth / 2);
  731. square.setAttribute('width', width - borderWidth);
  732. square.setAttribute('height', height - borderWidth);
  733. square.setAttribute('stroke-width', borderWidth);
  734. square.setAttribute('stroke', 'transparent');
  735. square.setAttribute('fill', 'none');
  736. svg.appendChild(square);
  737. this.container.append(svg);
  738. this._createPopup(this.container, square, data);
  739. return this.container;
  740. }
  741. }]);
  742. return SquareAnnotationElement;
  743. }(AnnotationElement);
  744. var CircleAnnotationElement =
  745. /*#__PURE__*/
  746. function (_AnnotationElement8) {
  747. _inherits(CircleAnnotationElement, _AnnotationElement8);
  748. function CircleAnnotationElement(parameters) {
  749. _classCallCheck(this, CircleAnnotationElement);
  750. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  751. return _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotationElement).call(this, parameters, isRenderable, true));
  752. }
  753. _createClass(CircleAnnotationElement, [{
  754. key: "render",
  755. value: function render() {
  756. this.container.className = 'circleAnnotation';
  757. var data = this.data;
  758. var width = data.rect[2] - data.rect[0];
  759. var height = data.rect[3] - data.rect[1];
  760. var svg = this.svgFactory.create(width, height);
  761. var borderWidth = data.borderStyle.width;
  762. var circle = this.svgFactory.createElement('svg:ellipse');
  763. circle.setAttribute('cx', width / 2);
  764. circle.setAttribute('cy', height / 2);
  765. circle.setAttribute('rx', width / 2 - borderWidth / 2);
  766. circle.setAttribute('ry', height / 2 - borderWidth / 2);
  767. circle.setAttribute('stroke-width', borderWidth);
  768. circle.setAttribute('stroke', 'transparent');
  769. circle.setAttribute('fill', 'none');
  770. svg.appendChild(circle);
  771. this.container.append(svg);
  772. this._createPopup(this.container, circle, data);
  773. return this.container;
  774. }
  775. }]);
  776. return CircleAnnotationElement;
  777. }(AnnotationElement);
  778. var PolylineAnnotationElement =
  779. /*#__PURE__*/
  780. function (_AnnotationElement9) {
  781. _inherits(PolylineAnnotationElement, _AnnotationElement9);
  782. function PolylineAnnotationElement(parameters) {
  783. var _this3;
  784. _classCallCheck(this, PolylineAnnotationElement);
  785. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  786. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotationElement).call(this, parameters, isRenderable, true));
  787. _this3.containerClassName = 'polylineAnnotation';
  788. _this3.svgElementName = 'svg:polyline';
  789. return _this3;
  790. }
  791. _createClass(PolylineAnnotationElement, [{
  792. key: "render",
  793. value: function render() {
  794. this.container.className = this.containerClassName;
  795. var data = this.data;
  796. var width = data.rect[2] - data.rect[0];
  797. var height = data.rect[3] - data.rect[1];
  798. var svg = this.svgFactory.create(width, height);
  799. var points = [];
  800. var _iteratorNormalCompletion2 = true;
  801. var _didIteratorError2 = false;
  802. var _iteratorError2 = undefined;
  803. try {
  804. for (var _iterator2 = data.vertices[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  805. var coordinate = _step2.value;
  806. var x = coordinate.x - data.rect[0];
  807. var y = data.rect[3] - coordinate.y;
  808. points.push(x + ',' + y);
  809. }
  810. } catch (err) {
  811. _didIteratorError2 = true;
  812. _iteratorError2 = err;
  813. } finally {
  814. try {
  815. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  816. _iterator2["return"]();
  817. }
  818. } finally {
  819. if (_didIteratorError2) {
  820. throw _iteratorError2;
  821. }
  822. }
  823. }
  824. points = points.join(' ');
  825. var polyline = this.svgFactory.createElement(this.svgElementName);
  826. polyline.setAttribute('points', points);
  827. polyline.setAttribute('stroke-width', data.borderStyle.width);
  828. polyline.setAttribute('stroke', 'transparent');
  829. polyline.setAttribute('fill', 'none');
  830. svg.appendChild(polyline);
  831. this.container.append(svg);
  832. this._createPopup(this.container, polyline, data);
  833. return this.container;
  834. }
  835. }]);
  836. return PolylineAnnotationElement;
  837. }(AnnotationElement);
  838. var PolygonAnnotationElement =
  839. /*#__PURE__*/
  840. function (_PolylineAnnotationEl) {
  841. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  842. function PolygonAnnotationElement(parameters) {
  843. var _this4;
  844. _classCallCheck(this, PolygonAnnotationElement);
  845. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotationElement).call(this, parameters));
  846. _this4.containerClassName = 'polygonAnnotation';
  847. _this4.svgElementName = 'svg:polygon';
  848. return _this4;
  849. }
  850. return PolygonAnnotationElement;
  851. }(PolylineAnnotationElement);
  852. var CaretAnnotationElement =
  853. /*#__PURE__*/
  854. function (_AnnotationElement10) {
  855. _inherits(CaretAnnotationElement, _AnnotationElement10);
  856. function CaretAnnotationElement(parameters) {
  857. _classCallCheck(this, CaretAnnotationElement);
  858. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  859. return _possibleConstructorReturn(this, _getPrototypeOf(CaretAnnotationElement).call(this, parameters, isRenderable, true));
  860. }
  861. _createClass(CaretAnnotationElement, [{
  862. key: "render",
  863. value: function render() {
  864. this.container.className = 'caretAnnotation';
  865. if (!this.data.hasPopup) {
  866. this._createPopup(this.container, null, this.data);
  867. }
  868. return this.container;
  869. }
  870. }]);
  871. return CaretAnnotationElement;
  872. }(AnnotationElement);
  873. var InkAnnotationElement =
  874. /*#__PURE__*/
  875. function (_AnnotationElement11) {
  876. _inherits(InkAnnotationElement, _AnnotationElement11);
  877. function InkAnnotationElement(parameters) {
  878. var _this5;
  879. _classCallCheck(this, InkAnnotationElement);
  880. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  881. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotationElement).call(this, parameters, isRenderable, true));
  882. _this5.containerClassName = 'inkAnnotation';
  883. _this5.svgElementName = 'svg:polyline';
  884. return _this5;
  885. }
  886. _createClass(InkAnnotationElement, [{
  887. key: "render",
  888. value: function render() {
  889. this.container.className = this.containerClassName;
  890. var data = this.data;
  891. var width = data.rect[2] - data.rect[0];
  892. var height = data.rect[3] - data.rect[1];
  893. var svg = this.svgFactory.create(width, height);
  894. var _iteratorNormalCompletion3 = true;
  895. var _didIteratorError3 = false;
  896. var _iteratorError3 = undefined;
  897. try {
  898. for (var _iterator3 = data.inkLists[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  899. var inkList = _step3.value;
  900. var points = [];
  901. var _iteratorNormalCompletion4 = true;
  902. var _didIteratorError4 = false;
  903. var _iteratorError4 = undefined;
  904. try {
  905. for (var _iterator4 = inkList[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  906. var coordinate = _step4.value;
  907. var x = coordinate.x - data.rect[0];
  908. var y = data.rect[3] - coordinate.y;
  909. points.push("".concat(x, ",").concat(y));
  910. }
  911. } catch (err) {
  912. _didIteratorError4 = true;
  913. _iteratorError4 = err;
  914. } finally {
  915. try {
  916. if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
  917. _iterator4["return"]();
  918. }
  919. } finally {
  920. if (_didIteratorError4) {
  921. throw _iteratorError4;
  922. }
  923. }
  924. }
  925. points = points.join(' ');
  926. var polyline = this.svgFactory.createElement(this.svgElementName);
  927. polyline.setAttribute('points', points);
  928. polyline.setAttribute('stroke-width', data.borderStyle.width);
  929. polyline.setAttribute('stroke', 'transparent');
  930. polyline.setAttribute('fill', 'none');
  931. this._createPopup(this.container, polyline, data);
  932. svg.appendChild(polyline);
  933. }
  934. } catch (err) {
  935. _didIteratorError3 = true;
  936. _iteratorError3 = err;
  937. } finally {
  938. try {
  939. if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
  940. _iterator3["return"]();
  941. }
  942. } finally {
  943. if (_didIteratorError3) {
  944. throw _iteratorError3;
  945. }
  946. }
  947. }
  948. this.container.append(svg);
  949. return this.container;
  950. }
  951. }]);
  952. return InkAnnotationElement;
  953. }(AnnotationElement);
  954. var HighlightAnnotationElement =
  955. /*#__PURE__*/
  956. function (_AnnotationElement12) {
  957. _inherits(HighlightAnnotationElement, _AnnotationElement12);
  958. function HighlightAnnotationElement(parameters) {
  959. _classCallCheck(this, HighlightAnnotationElement);
  960. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  961. return _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotationElement).call(this, parameters, isRenderable, true));
  962. }
  963. _createClass(HighlightAnnotationElement, [{
  964. key: "render",
  965. value: function render() {
  966. this.container.className = 'highlightAnnotation';
  967. if (!this.data.hasPopup) {
  968. this._createPopup(this.container, null, this.data);
  969. }
  970. return this.container;
  971. }
  972. }]);
  973. return HighlightAnnotationElement;
  974. }(AnnotationElement);
  975. var UnderlineAnnotationElement =
  976. /*#__PURE__*/
  977. function (_AnnotationElement13) {
  978. _inherits(UnderlineAnnotationElement, _AnnotationElement13);
  979. function UnderlineAnnotationElement(parameters) {
  980. _classCallCheck(this, UnderlineAnnotationElement);
  981. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  982. return _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotationElement).call(this, parameters, isRenderable, true));
  983. }
  984. _createClass(UnderlineAnnotationElement, [{
  985. key: "render",
  986. value: function render() {
  987. this.container.className = 'underlineAnnotation';
  988. if (!this.data.hasPopup) {
  989. this._createPopup(this.container, null, this.data);
  990. }
  991. return this.container;
  992. }
  993. }]);
  994. return UnderlineAnnotationElement;
  995. }(AnnotationElement);
  996. var SquigglyAnnotationElement =
  997. /*#__PURE__*/
  998. function (_AnnotationElement14) {
  999. _inherits(SquigglyAnnotationElement, _AnnotationElement14);
  1000. function SquigglyAnnotationElement(parameters) {
  1001. _classCallCheck(this, SquigglyAnnotationElement);
  1002. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  1003. return _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotationElement).call(this, parameters, isRenderable, true));
  1004. }
  1005. _createClass(SquigglyAnnotationElement, [{
  1006. key: "render",
  1007. value: function render() {
  1008. this.container.className = 'squigglyAnnotation';
  1009. if (!this.data.hasPopup) {
  1010. this._createPopup(this.container, null, this.data);
  1011. }
  1012. return this.container;
  1013. }
  1014. }]);
  1015. return SquigglyAnnotationElement;
  1016. }(AnnotationElement);
  1017. var StrikeOutAnnotationElement =
  1018. /*#__PURE__*/
  1019. function (_AnnotationElement15) {
  1020. _inherits(StrikeOutAnnotationElement, _AnnotationElement15);
  1021. function StrikeOutAnnotationElement(parameters) {
  1022. _classCallCheck(this, StrikeOutAnnotationElement);
  1023. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  1024. return _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotationElement).call(this, parameters, isRenderable, true));
  1025. }
  1026. _createClass(StrikeOutAnnotationElement, [{
  1027. key: "render",
  1028. value: function render() {
  1029. this.container.className = 'strikeoutAnnotation';
  1030. if (!this.data.hasPopup) {
  1031. this._createPopup(this.container, null, this.data);
  1032. }
  1033. return this.container;
  1034. }
  1035. }]);
  1036. return StrikeOutAnnotationElement;
  1037. }(AnnotationElement);
  1038. var StampAnnotationElement =
  1039. /*#__PURE__*/
  1040. function (_AnnotationElement16) {
  1041. _inherits(StampAnnotationElement, _AnnotationElement16);
  1042. function StampAnnotationElement(parameters) {
  1043. _classCallCheck(this, StampAnnotationElement);
  1044. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  1045. return _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotationElement).call(this, parameters, isRenderable, true));
  1046. }
  1047. _createClass(StampAnnotationElement, [{
  1048. key: "render",
  1049. value: function render() {
  1050. this.container.className = 'stampAnnotation';
  1051. if (!this.data.hasPopup) {
  1052. this._createPopup(this.container, null, this.data);
  1053. }
  1054. return this.container;
  1055. }
  1056. }]);
  1057. return StampAnnotationElement;
  1058. }(AnnotationElement);
  1059. var FileAttachmentAnnotationElement =
  1060. /*#__PURE__*/
  1061. function (_AnnotationElement17) {
  1062. _inherits(FileAttachmentAnnotationElement, _AnnotationElement17);
  1063. function FileAttachmentAnnotationElement(parameters) {
  1064. var _this6;
  1065. _classCallCheck(this, FileAttachmentAnnotationElement);
  1066. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotationElement).call(this, parameters, true));
  1067. var _this6$data$file = _this6.data.file,
  1068. filename = _this6$data$file.filename,
  1069. content = _this6$data$file.content;
  1070. _this6.filename = (0, _display_utils.getFilenameFromUrl)(filename);
  1071. _this6.content = content;
  1072. if (_this6.linkService.eventBus) {
  1073. _this6.linkService.eventBus.dispatch('fileattachmentannotation', {
  1074. source: _assertThisInitialized(_this6),
  1075. id: (0, _util.stringToPDFString)(filename),
  1076. filename: filename,
  1077. content: content
  1078. });
  1079. }
  1080. return _this6;
  1081. }
  1082. _createClass(FileAttachmentAnnotationElement, [{
  1083. key: "render",
  1084. value: function render() {
  1085. this.container.className = 'fileAttachmentAnnotation';
  1086. var trigger = document.createElement('div');
  1087. trigger.style.height = this.container.style.height;
  1088. trigger.style.width = this.container.style.width;
  1089. trigger.addEventListener('dblclick', this._download.bind(this));
  1090. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  1091. this._createPopup(this.container, trigger, this.data);
  1092. }
  1093. this.container.appendChild(trigger);
  1094. return this.container;
  1095. }
  1096. }, {
  1097. key: "_download",
  1098. value: function _download() {
  1099. if (!this.downloadManager) {
  1100. (0, _util.warn)('Download cannot be started due to unavailable download manager');
  1101. return;
  1102. }
  1103. this.downloadManager.downloadData(this.content, this.filename, '');
  1104. }
  1105. }]);
  1106. return FileAttachmentAnnotationElement;
  1107. }(AnnotationElement);
  1108. var AnnotationLayer =
  1109. /*#__PURE__*/
  1110. function () {
  1111. function AnnotationLayer() {
  1112. _classCallCheck(this, AnnotationLayer);
  1113. }
  1114. _createClass(AnnotationLayer, null, [{
  1115. key: "render",
  1116. value: function render(parameters) {
  1117. var _iteratorNormalCompletion5 = true;
  1118. var _didIteratorError5 = false;
  1119. var _iteratorError5 = undefined;
  1120. try {
  1121. for (var _iterator5 = parameters.annotations[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  1122. var data = _step5.value;
  1123. if (!data) {
  1124. continue;
  1125. }
  1126. var element = AnnotationElementFactory.create({
  1127. data: data,
  1128. layer: parameters.div,
  1129. page: parameters.page,
  1130. viewport: parameters.viewport,
  1131. linkService: parameters.linkService,
  1132. downloadManager: parameters.downloadManager,
  1133. imageResourcesPath: parameters.imageResourcesPath || '',
  1134. renderInteractiveForms: parameters.renderInteractiveForms || false,
  1135. svgFactory: new _display_utils.DOMSVGFactory()
  1136. });
  1137. if (element.isRenderable) {
  1138. parameters.div.appendChild(element.render());
  1139. }
  1140. }
  1141. } catch (err) {
  1142. _didIteratorError5 = true;
  1143. _iteratorError5 = err;
  1144. } finally {
  1145. try {
  1146. if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
  1147. _iterator5["return"]();
  1148. }
  1149. } finally {
  1150. if (_didIteratorError5) {
  1151. throw _iteratorError5;
  1152. }
  1153. }
  1154. }
  1155. }
  1156. }, {
  1157. key: "update",
  1158. value: function update(parameters) {
  1159. var _iteratorNormalCompletion6 = true;
  1160. var _didIteratorError6 = false;
  1161. var _iteratorError6 = undefined;
  1162. try {
  1163. for (var _iterator6 = parameters.annotations[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  1164. var data = _step6.value;
  1165. var element = parameters.div.querySelector("[data-annotation-id=\"".concat(data.id, "\"]"));
  1166. if (element) {
  1167. element.style.transform = "matrix(".concat(parameters.viewport.transform.join(','), ")");
  1168. }
  1169. }
  1170. } catch (err) {
  1171. _didIteratorError6 = true;
  1172. _iteratorError6 = err;
  1173. } finally {
  1174. try {
  1175. if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) {
  1176. _iterator6["return"]();
  1177. }
  1178. } finally {
  1179. if (_didIteratorError6) {
  1180. throw _iteratorError6;
  1181. }
  1182. }
  1183. }
  1184. parameters.div.removeAttribute('hidden');
  1185. }
  1186. }]);
  1187. return AnnotationLayer;
  1188. }();
  1189. exports.AnnotationLayer = AnnotationLayer;