2
0

annotation_layer.js 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2018 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 _dom_utils = require("./dom_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.LINE:
  74. return new LineAnnotationElement(parameters);
  75. case _util.AnnotationType.SQUARE:
  76. return new SquareAnnotationElement(parameters);
  77. case _util.AnnotationType.CIRCLE:
  78. return new CircleAnnotationElement(parameters);
  79. case _util.AnnotationType.POLYLINE:
  80. return new PolylineAnnotationElement(parameters);
  81. case _util.AnnotationType.INK:
  82. return new InkAnnotationElement(parameters);
  83. case _util.AnnotationType.POLYGON:
  84. return new PolygonAnnotationElement(parameters);
  85. case _util.AnnotationType.HIGHLIGHT:
  86. return new HighlightAnnotationElement(parameters);
  87. case _util.AnnotationType.UNDERLINE:
  88. return new UnderlineAnnotationElement(parameters);
  89. case _util.AnnotationType.SQUIGGLY:
  90. return new SquigglyAnnotationElement(parameters);
  91. case _util.AnnotationType.STRIKEOUT:
  92. return new StrikeOutAnnotationElement(parameters);
  93. case _util.AnnotationType.STAMP:
  94. return new StampAnnotationElement(parameters);
  95. case _util.AnnotationType.FILEATTACHMENT:
  96. return new FileAttachmentAnnotationElement(parameters);
  97. default:
  98. return new AnnotationElement(parameters);
  99. }
  100. }
  101. }]);
  102. return AnnotationElementFactory;
  103. }();
  104. var AnnotationElement =
  105. /*#__PURE__*/
  106. function () {
  107. function AnnotationElement(parameters) {
  108. var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  109. var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  110. _classCallCheck(this, AnnotationElement);
  111. this.isRenderable = isRenderable;
  112. this.data = parameters.data;
  113. this.layer = parameters.layer;
  114. this.page = parameters.page;
  115. this.viewport = parameters.viewport;
  116. this.linkService = parameters.linkService;
  117. this.downloadManager = parameters.downloadManager;
  118. this.imageResourcesPath = parameters.imageResourcesPath;
  119. this.renderInteractiveForms = parameters.renderInteractiveForms;
  120. this.svgFactory = parameters.svgFactory;
  121. if (isRenderable) {
  122. this.container = this._createContainer(ignoreBorder);
  123. }
  124. }
  125. _createClass(AnnotationElement, [{
  126. key: "_createContainer",
  127. value: function _createContainer() {
  128. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  129. var data = this.data,
  130. page = this.page,
  131. viewport = this.viewport;
  132. var container = document.createElement('section');
  133. var width = data.rect[2] - data.rect[0];
  134. var height = data.rect[3] - data.rect[1];
  135. container.setAttribute('data-annotation-id', data.id);
  136. 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]]);
  137. container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';
  138. container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';
  139. if (!ignoreBorder && data.borderStyle.width > 0) {
  140. container.style.borderWidth = data.borderStyle.width + 'px';
  141. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  142. width = width - 2 * data.borderStyle.width;
  143. height = height - 2 * data.borderStyle.width;
  144. }
  145. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  146. var verticalRadius = data.borderStyle.verticalCornerRadius;
  147. if (horizontalRadius > 0 || verticalRadius > 0) {
  148. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  149. container.style.borderRadius = radius;
  150. }
  151. switch (data.borderStyle.style) {
  152. case _util.AnnotationBorderStyleType.SOLID:
  153. container.style.borderStyle = 'solid';
  154. break;
  155. case _util.AnnotationBorderStyleType.DASHED:
  156. container.style.borderStyle = 'dashed';
  157. break;
  158. case _util.AnnotationBorderStyleType.BEVELED:
  159. (0, _util.warn)('Unimplemented border style: beveled');
  160. break;
  161. case _util.AnnotationBorderStyleType.INSET:
  162. (0, _util.warn)('Unimplemented border style: inset');
  163. break;
  164. case _util.AnnotationBorderStyleType.UNDERLINE:
  165. container.style.borderBottomStyle = 'solid';
  166. break;
  167. default:
  168. break;
  169. }
  170. if (data.color) {
  171. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  172. } else {
  173. container.style.borderWidth = 0;
  174. }
  175. }
  176. container.style.left = rect[0] + 'px';
  177. container.style.top = rect[1] + 'px';
  178. container.style.width = width + 'px';
  179. container.style.height = height + 'px';
  180. return container;
  181. }
  182. }, {
  183. key: "_createPopup",
  184. value: function _createPopup(container, trigger, data) {
  185. if (!trigger) {
  186. trigger = document.createElement('div');
  187. trigger.style.height = container.style.height;
  188. trigger.style.width = container.style.width;
  189. container.appendChild(trigger);
  190. }
  191. var popupElement = new PopupElement({
  192. container: container,
  193. trigger: trigger,
  194. color: data.color,
  195. title: data.title,
  196. contents: data.contents,
  197. hideWrapper: true
  198. });
  199. var popup = popupElement.render();
  200. popup.style.left = container.style.width;
  201. container.appendChild(popup);
  202. }
  203. }, {
  204. key: "render",
  205. value: function render() {
  206. (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
  207. }
  208. }]);
  209. return AnnotationElement;
  210. }();
  211. var LinkAnnotationElement =
  212. /*#__PURE__*/
  213. function (_AnnotationElement) {
  214. _inherits(LinkAnnotationElement, _AnnotationElement);
  215. function LinkAnnotationElement(parameters) {
  216. _classCallCheck(this, LinkAnnotationElement);
  217. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
  218. return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));
  219. }
  220. _createClass(LinkAnnotationElement, [{
  221. key: "render",
  222. value: function render() {
  223. this.container.className = 'linkAnnotation';
  224. var data = this.data,
  225. linkService = this.linkService;
  226. var link = document.createElement('a');
  227. (0, _dom_utils.addLinkAttributes)(link, {
  228. url: data.url,
  229. target: data.newWindow ? _dom_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
  230. rel: linkService.externalLinkRel
  231. });
  232. if (!data.url) {
  233. if (data.action) {
  234. this._bindNamedAction(link, data.action);
  235. } else {
  236. this._bindLink(link, data.dest);
  237. }
  238. }
  239. this.container.appendChild(link);
  240. return this.container;
  241. }
  242. }, {
  243. key: "_bindLink",
  244. value: function _bindLink(link, destination) {
  245. var _this = this;
  246. link.href = this.linkService.getDestinationHash(destination);
  247. link.onclick = function () {
  248. if (destination) {
  249. _this.linkService.navigateTo(destination);
  250. }
  251. return false;
  252. };
  253. if (destination) {
  254. link.className = 'internalLink';
  255. }
  256. }
  257. }, {
  258. key: "_bindNamedAction",
  259. value: function _bindNamedAction(link, action) {
  260. var _this2 = this;
  261. link.href = this.linkService.getAnchorUrl('');
  262. link.onclick = function () {
  263. _this2.linkService.executeNamedAction(action);
  264. return false;
  265. };
  266. link.className = 'internalLink';
  267. }
  268. }]);
  269. return LinkAnnotationElement;
  270. }(AnnotationElement);
  271. var TextAnnotationElement =
  272. /*#__PURE__*/
  273. function (_AnnotationElement2) {
  274. _inherits(TextAnnotationElement, _AnnotationElement2);
  275. function TextAnnotationElement(parameters) {
  276. _classCallCheck(this, TextAnnotationElement);
  277. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  278. return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));
  279. }
  280. _createClass(TextAnnotationElement, [{
  281. key: "render",
  282. value: function render() {
  283. this.container.className = 'textAnnotation';
  284. var image = document.createElement('img');
  285. image.style.height = this.container.style.height;
  286. image.style.width = this.container.style.width;
  287. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  288. image.alt = '[{{type}} Annotation]';
  289. image.dataset.l10nId = 'text_annotation_type';
  290. image.dataset.l10nArgs = JSON.stringify({
  291. type: this.data.name
  292. });
  293. if (!this.data.hasPopup) {
  294. this._createPopup(this.container, image, this.data);
  295. }
  296. this.container.appendChild(image);
  297. return this.container;
  298. }
  299. }]);
  300. return TextAnnotationElement;
  301. }(AnnotationElement);
  302. var WidgetAnnotationElement =
  303. /*#__PURE__*/
  304. function (_AnnotationElement3) {
  305. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  306. function WidgetAnnotationElement() {
  307. _classCallCheck(this, WidgetAnnotationElement);
  308. return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));
  309. }
  310. _createClass(WidgetAnnotationElement, [{
  311. key: "render",
  312. value: function render() {
  313. return this.container;
  314. }
  315. }]);
  316. return WidgetAnnotationElement;
  317. }(AnnotationElement);
  318. var TextWidgetAnnotationElement =
  319. /*#__PURE__*/
  320. function (_WidgetAnnotationElem) {
  321. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  322. function TextWidgetAnnotationElement(parameters) {
  323. _classCallCheck(this, TextWidgetAnnotationElement);
  324. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  325. return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));
  326. }
  327. _createClass(TextWidgetAnnotationElement, [{
  328. key: "render",
  329. value: function render() {
  330. var TEXT_ALIGNMENT = ['left', 'center', 'right'];
  331. this.container.className = 'textWidgetAnnotation';
  332. var element = null;
  333. if (this.renderInteractiveForms) {
  334. if (this.data.multiLine) {
  335. element = document.createElement('textarea');
  336. element.textContent = this.data.fieldValue;
  337. } else {
  338. element = document.createElement('input');
  339. element.type = 'text';
  340. element.setAttribute('value', this.data.fieldValue);
  341. }
  342. element.disabled = this.data.readOnly;
  343. if (this.data.maxLen !== null) {
  344. element.maxLength = this.data.maxLen;
  345. }
  346. if (this.data.comb) {
  347. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  348. var combWidth = fieldWidth / this.data.maxLen;
  349. element.classList.add('comb');
  350. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  351. }
  352. } else {
  353. element = document.createElement('div');
  354. element.textContent = this.data.fieldValue;
  355. element.style.verticalAlign = 'middle';
  356. element.style.display = 'table-cell';
  357. var font = null;
  358. if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
  359. font = this.page.commonObjs.get(this.data.fontRefName);
  360. }
  361. this._setTextStyle(element, font);
  362. }
  363. if (this.data.textAlignment !== null) {
  364. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  365. }
  366. this.container.appendChild(element);
  367. return this.container;
  368. }
  369. }, {
  370. key: "_setTextStyle",
  371. value: function _setTextStyle(element, font) {
  372. var style = element.style;
  373. style.fontSize = this.data.fontSize + 'px';
  374. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  375. if (!font) {
  376. return;
  377. }
  378. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  379. style.fontStyle = font.italic ? 'italic' : 'normal';
  380. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  381. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  382. style.fontFamily = fontFamily + fallbackName;
  383. }
  384. }]);
  385. return TextWidgetAnnotationElement;
  386. }(WidgetAnnotationElement);
  387. var CheckboxWidgetAnnotationElement =
  388. /*#__PURE__*/
  389. function (_WidgetAnnotationElem2) {
  390. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  391. function CheckboxWidgetAnnotationElement(parameters) {
  392. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  393. return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  394. }
  395. _createClass(CheckboxWidgetAnnotationElement, [{
  396. key: "render",
  397. value: function render() {
  398. this.container.className = 'buttonWidgetAnnotation checkBox';
  399. var element = document.createElement('input');
  400. element.disabled = this.data.readOnly;
  401. element.type = 'checkbox';
  402. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  403. element.setAttribute('checked', true);
  404. }
  405. this.container.appendChild(element);
  406. return this.container;
  407. }
  408. }]);
  409. return CheckboxWidgetAnnotationElement;
  410. }(WidgetAnnotationElement);
  411. var RadioButtonWidgetAnnotationElement =
  412. /*#__PURE__*/
  413. function (_WidgetAnnotationElem3) {
  414. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  415. function RadioButtonWidgetAnnotationElement(parameters) {
  416. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  417. return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  418. }
  419. _createClass(RadioButtonWidgetAnnotationElement, [{
  420. key: "render",
  421. value: function render() {
  422. this.container.className = 'buttonWidgetAnnotation radioButton';
  423. var element = document.createElement('input');
  424. element.disabled = this.data.readOnly;
  425. element.type = 'radio';
  426. element.name = this.data.fieldName;
  427. if (this.data.fieldValue === this.data.buttonValue) {
  428. element.setAttribute('checked', true);
  429. }
  430. this.container.appendChild(element);
  431. return this.container;
  432. }
  433. }]);
  434. return RadioButtonWidgetAnnotationElement;
  435. }(WidgetAnnotationElement);
  436. var PushButtonWidgetAnnotationElement =
  437. /*#__PURE__*/
  438. function (_LinkAnnotationElemen) {
  439. _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
  440. function PushButtonWidgetAnnotationElement() {
  441. _classCallCheck(this, PushButtonWidgetAnnotationElement);
  442. return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));
  443. }
  444. _createClass(PushButtonWidgetAnnotationElement, [{
  445. key: "render",
  446. value: function render() {
  447. var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
  448. container.className = 'buttonWidgetAnnotation pushButton';
  449. return container;
  450. }
  451. }]);
  452. return PushButtonWidgetAnnotationElement;
  453. }(LinkAnnotationElement);
  454. var ChoiceWidgetAnnotationElement =
  455. /*#__PURE__*/
  456. function (_WidgetAnnotationElem4) {
  457. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  458. function ChoiceWidgetAnnotationElement(parameters) {
  459. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  460. return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  461. }
  462. _createClass(ChoiceWidgetAnnotationElement, [{
  463. key: "render",
  464. value: function render() {
  465. this.container.className = 'choiceWidgetAnnotation';
  466. var selectElement = document.createElement('select');
  467. selectElement.disabled = this.data.readOnly;
  468. if (!this.data.combo) {
  469. selectElement.size = this.data.options.length;
  470. if (this.data.multiSelect) {
  471. selectElement.multiple = true;
  472. }
  473. }
  474. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  475. var option = this.data.options[i];
  476. var optionElement = document.createElement('option');
  477. optionElement.textContent = option.displayValue;
  478. optionElement.value = option.exportValue;
  479. if (this.data.fieldValue.includes(option.displayValue)) {
  480. optionElement.setAttribute('selected', true);
  481. }
  482. selectElement.appendChild(optionElement);
  483. }
  484. this.container.appendChild(selectElement);
  485. return this.container;
  486. }
  487. }]);
  488. return ChoiceWidgetAnnotationElement;
  489. }(WidgetAnnotationElement);
  490. var PopupAnnotationElement =
  491. /*#__PURE__*/
  492. function (_AnnotationElement4) {
  493. _inherits(PopupAnnotationElement, _AnnotationElement4);
  494. function PopupAnnotationElement(parameters) {
  495. _classCallCheck(this, PopupAnnotationElement);
  496. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  497. return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));
  498. }
  499. _createClass(PopupAnnotationElement, [{
  500. key: "render",
  501. value: function render() {
  502. var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
  503. this.container.className = 'popupAnnotation';
  504. if (IGNORE_TYPES.includes(this.data.parentType)) {
  505. return this.container;
  506. }
  507. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  508. var parentElement = this.layer.querySelector(selector);
  509. if (!parentElement) {
  510. return this.container;
  511. }
  512. var popup = new PopupElement({
  513. container: this.container,
  514. trigger: parentElement,
  515. color: this.data.color,
  516. title: this.data.title,
  517. contents: this.data.contents
  518. });
  519. var parentLeft = parseFloat(parentElement.style.left);
  520. var parentWidth = parseFloat(parentElement.style.width);
  521. this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;
  522. this.container.style.left = parentLeft + parentWidth + 'px';
  523. this.container.appendChild(popup.render());
  524. return this.container;
  525. }
  526. }]);
  527. return PopupAnnotationElement;
  528. }(AnnotationElement);
  529. var PopupElement =
  530. /*#__PURE__*/
  531. function () {
  532. function PopupElement(parameters) {
  533. _classCallCheck(this, PopupElement);
  534. this.container = parameters.container;
  535. this.trigger = parameters.trigger;
  536. this.color = parameters.color;
  537. this.title = parameters.title;
  538. this.contents = parameters.contents;
  539. this.hideWrapper = parameters.hideWrapper || false;
  540. this.pinned = false;
  541. }
  542. _createClass(PopupElement, [{
  543. key: "render",
  544. value: function render() {
  545. var BACKGROUND_ENLIGHT = 0.7;
  546. var wrapper = document.createElement('div');
  547. wrapper.className = 'popupWrapper';
  548. this.hideElement = this.hideWrapper ? wrapper : this.container;
  549. this.hideElement.setAttribute('hidden', true);
  550. var popup = document.createElement('div');
  551. popup.className = 'popup';
  552. var color = this.color;
  553. if (color) {
  554. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  555. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  556. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  557. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  558. }
  559. var contents = this._formatContents(this.contents);
  560. var title = document.createElement('h1');
  561. title.textContent = this.title;
  562. this.trigger.addEventListener('click', this._toggle.bind(this));
  563. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  564. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  565. popup.addEventListener('click', this._hide.bind(this, true));
  566. popup.appendChild(title);
  567. popup.appendChild(contents);
  568. wrapper.appendChild(popup);
  569. return wrapper;
  570. }
  571. }, {
  572. key: "_formatContents",
  573. value: function _formatContents(contents) {
  574. var p = document.createElement('p');
  575. var lines = contents.split(/(?:\r\n?|\n)/);
  576. for (var i = 0, ii = lines.length; i < ii; ++i) {
  577. var line = lines[i];
  578. p.appendChild(document.createTextNode(line));
  579. if (i < ii - 1) {
  580. p.appendChild(document.createElement('br'));
  581. }
  582. }
  583. return p;
  584. }
  585. }, {
  586. key: "_toggle",
  587. value: function _toggle() {
  588. if (this.pinned) {
  589. this._hide(true);
  590. } else {
  591. this._show(true);
  592. }
  593. }
  594. }, {
  595. key: "_show",
  596. value: function _show() {
  597. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  598. if (pin) {
  599. this.pinned = true;
  600. }
  601. if (this.hideElement.hasAttribute('hidden')) {
  602. this.hideElement.removeAttribute('hidden');
  603. this.container.style.zIndex += 1;
  604. }
  605. }
  606. }, {
  607. key: "_hide",
  608. value: function _hide() {
  609. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  610. if (unpin) {
  611. this.pinned = false;
  612. }
  613. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  614. this.hideElement.setAttribute('hidden', true);
  615. this.container.style.zIndex -= 1;
  616. }
  617. }
  618. }]);
  619. return PopupElement;
  620. }();
  621. var LineAnnotationElement =
  622. /*#__PURE__*/
  623. function (_AnnotationElement5) {
  624. _inherits(LineAnnotationElement, _AnnotationElement5);
  625. function LineAnnotationElement(parameters) {
  626. _classCallCheck(this, LineAnnotationElement);
  627. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  628. return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));
  629. }
  630. _createClass(LineAnnotationElement, [{
  631. key: "render",
  632. value: function render() {
  633. this.container.className = 'lineAnnotation';
  634. var data = this.data;
  635. var width = data.rect[2] - data.rect[0];
  636. var height = data.rect[3] - data.rect[1];
  637. var svg = this.svgFactory.create(width, height);
  638. var line = this.svgFactory.createElement('svg:line');
  639. line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
  640. line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
  641. line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
  642. line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
  643. line.setAttribute('stroke-width', data.borderStyle.width);
  644. line.setAttribute('stroke', 'transparent');
  645. svg.appendChild(line);
  646. this.container.append(svg);
  647. this._createPopup(this.container, line, data);
  648. return this.container;
  649. }
  650. }]);
  651. return LineAnnotationElement;
  652. }(AnnotationElement);
  653. var SquareAnnotationElement =
  654. /*#__PURE__*/
  655. function (_AnnotationElement6) {
  656. _inherits(SquareAnnotationElement, _AnnotationElement6);
  657. function SquareAnnotationElement(parameters) {
  658. _classCallCheck(this, SquareAnnotationElement);
  659. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  660. return _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotationElement).call(this, parameters, isRenderable, true));
  661. }
  662. _createClass(SquareAnnotationElement, [{
  663. key: "render",
  664. value: function render() {
  665. this.container.className = 'squareAnnotation';
  666. var data = this.data;
  667. var width = data.rect[2] - data.rect[0];
  668. var height = data.rect[3] - data.rect[1];
  669. var svg = this.svgFactory.create(width, height);
  670. var borderWidth = data.borderStyle.width;
  671. var square = this.svgFactory.createElement('svg:rect');
  672. square.setAttribute('x', borderWidth / 2);
  673. square.setAttribute('y', borderWidth / 2);
  674. square.setAttribute('width', width - borderWidth);
  675. square.setAttribute('height', height - borderWidth);
  676. square.setAttribute('stroke-width', borderWidth);
  677. square.setAttribute('stroke', 'transparent');
  678. square.setAttribute('fill', 'none');
  679. svg.appendChild(square);
  680. this.container.append(svg);
  681. this._createPopup(this.container, square, data);
  682. return this.container;
  683. }
  684. }]);
  685. return SquareAnnotationElement;
  686. }(AnnotationElement);
  687. var CircleAnnotationElement =
  688. /*#__PURE__*/
  689. function (_AnnotationElement7) {
  690. _inherits(CircleAnnotationElement, _AnnotationElement7);
  691. function CircleAnnotationElement(parameters) {
  692. _classCallCheck(this, CircleAnnotationElement);
  693. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  694. return _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotationElement).call(this, parameters, isRenderable, true));
  695. }
  696. _createClass(CircleAnnotationElement, [{
  697. key: "render",
  698. value: function render() {
  699. this.container.className = 'circleAnnotation';
  700. var data = this.data;
  701. var width = data.rect[2] - data.rect[0];
  702. var height = data.rect[3] - data.rect[1];
  703. var svg = this.svgFactory.create(width, height);
  704. var borderWidth = data.borderStyle.width;
  705. var circle = this.svgFactory.createElement('svg:ellipse');
  706. circle.setAttribute('cx', width / 2);
  707. circle.setAttribute('cy', height / 2);
  708. circle.setAttribute('rx', width / 2 - borderWidth / 2);
  709. circle.setAttribute('ry', height / 2 - borderWidth / 2);
  710. circle.setAttribute('stroke-width', borderWidth);
  711. circle.setAttribute('stroke', 'transparent');
  712. circle.setAttribute('fill', 'none');
  713. svg.appendChild(circle);
  714. this.container.append(svg);
  715. this._createPopup(this.container, circle, data);
  716. return this.container;
  717. }
  718. }]);
  719. return CircleAnnotationElement;
  720. }(AnnotationElement);
  721. var PolylineAnnotationElement =
  722. /*#__PURE__*/
  723. function (_AnnotationElement8) {
  724. _inherits(PolylineAnnotationElement, _AnnotationElement8);
  725. function PolylineAnnotationElement(parameters) {
  726. var _this3;
  727. _classCallCheck(this, PolylineAnnotationElement);
  728. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  729. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotationElement).call(this, parameters, isRenderable, true));
  730. _this3.containerClassName = 'polylineAnnotation';
  731. _this3.svgElementName = 'svg:polyline';
  732. return _this3;
  733. }
  734. _createClass(PolylineAnnotationElement, [{
  735. key: "render",
  736. value: function render() {
  737. this.container.className = this.containerClassName;
  738. var data = this.data;
  739. var width = data.rect[2] - data.rect[0];
  740. var height = data.rect[3] - data.rect[1];
  741. var svg = this.svgFactory.create(width, height);
  742. var vertices = data.vertices;
  743. var points = [];
  744. for (var i = 0, ii = vertices.length; i < ii; i++) {
  745. var x = vertices[i].x - data.rect[0];
  746. var y = data.rect[3] - vertices[i].y;
  747. points.push(x + ',' + y);
  748. }
  749. points = points.join(' ');
  750. var borderWidth = data.borderStyle.width;
  751. var polyline = this.svgFactory.createElement(this.svgElementName);
  752. polyline.setAttribute('points', points);
  753. polyline.setAttribute('stroke-width', borderWidth);
  754. polyline.setAttribute('stroke', 'transparent');
  755. polyline.setAttribute('fill', 'none');
  756. svg.appendChild(polyline);
  757. this.container.append(svg);
  758. this._createPopup(this.container, polyline, data);
  759. return this.container;
  760. }
  761. }]);
  762. return PolylineAnnotationElement;
  763. }(AnnotationElement);
  764. var PolygonAnnotationElement =
  765. /*#__PURE__*/
  766. function (_PolylineAnnotationEl) {
  767. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  768. function PolygonAnnotationElement(parameters) {
  769. var _this4;
  770. _classCallCheck(this, PolygonAnnotationElement);
  771. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotationElement).call(this, parameters));
  772. _this4.containerClassName = 'polygonAnnotation';
  773. _this4.svgElementName = 'svg:polygon';
  774. return _this4;
  775. }
  776. return PolygonAnnotationElement;
  777. }(PolylineAnnotationElement);
  778. var InkAnnotationElement =
  779. /*#__PURE__*/
  780. function (_AnnotationElement9) {
  781. _inherits(InkAnnotationElement, _AnnotationElement9);
  782. function InkAnnotationElement(parameters) {
  783. var _this5;
  784. _classCallCheck(this, InkAnnotationElement);
  785. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  786. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotationElement).call(this, parameters, isRenderable, true));
  787. _this5.containerClassName = 'inkAnnotation';
  788. _this5.svgElementName = 'svg:polyline';
  789. return _this5;
  790. }
  791. _createClass(InkAnnotationElement, [{
  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 inkLists = data.inkLists;
  800. for (var i = 0, ii = inkLists.length; i < ii; i++) {
  801. var inkList = inkLists[i];
  802. var points = [];
  803. for (var j = 0, jj = inkList.length; j < jj; j++) {
  804. var x = inkList[j].x - data.rect[0];
  805. var y = data.rect[3] - inkList[j].y;
  806. points.push(x + ',' + y);
  807. }
  808. points = points.join(' ');
  809. var borderWidth = data.borderStyle.width;
  810. var polyline = this.svgFactory.createElement(this.svgElementName);
  811. polyline.setAttribute('points', points);
  812. polyline.setAttribute('stroke-width', borderWidth);
  813. polyline.setAttribute('stroke', 'transparent');
  814. polyline.setAttribute('fill', 'none');
  815. this._createPopup(this.container, polyline, data);
  816. svg.appendChild(polyline);
  817. }
  818. this.container.append(svg);
  819. return this.container;
  820. }
  821. }]);
  822. return InkAnnotationElement;
  823. }(AnnotationElement);
  824. var HighlightAnnotationElement =
  825. /*#__PURE__*/
  826. function (_AnnotationElement10) {
  827. _inherits(HighlightAnnotationElement, _AnnotationElement10);
  828. function HighlightAnnotationElement(parameters) {
  829. _classCallCheck(this, HighlightAnnotationElement);
  830. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  831. return _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotationElement).call(this, parameters, isRenderable, true));
  832. }
  833. _createClass(HighlightAnnotationElement, [{
  834. key: "render",
  835. value: function render() {
  836. this.container.className = 'highlightAnnotation';
  837. if (!this.data.hasPopup) {
  838. this._createPopup(this.container, null, this.data);
  839. }
  840. return this.container;
  841. }
  842. }]);
  843. return HighlightAnnotationElement;
  844. }(AnnotationElement);
  845. var UnderlineAnnotationElement =
  846. /*#__PURE__*/
  847. function (_AnnotationElement11) {
  848. _inherits(UnderlineAnnotationElement, _AnnotationElement11);
  849. function UnderlineAnnotationElement(parameters) {
  850. _classCallCheck(this, UnderlineAnnotationElement);
  851. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  852. return _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotationElement).call(this, parameters, isRenderable, true));
  853. }
  854. _createClass(UnderlineAnnotationElement, [{
  855. key: "render",
  856. value: function render() {
  857. this.container.className = 'underlineAnnotation';
  858. if (!this.data.hasPopup) {
  859. this._createPopup(this.container, null, this.data);
  860. }
  861. return this.container;
  862. }
  863. }]);
  864. return UnderlineAnnotationElement;
  865. }(AnnotationElement);
  866. var SquigglyAnnotationElement =
  867. /*#__PURE__*/
  868. function (_AnnotationElement12) {
  869. _inherits(SquigglyAnnotationElement, _AnnotationElement12);
  870. function SquigglyAnnotationElement(parameters) {
  871. _classCallCheck(this, SquigglyAnnotationElement);
  872. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  873. return _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotationElement).call(this, parameters, isRenderable, true));
  874. }
  875. _createClass(SquigglyAnnotationElement, [{
  876. key: "render",
  877. value: function render() {
  878. this.container.className = 'squigglyAnnotation';
  879. if (!this.data.hasPopup) {
  880. this._createPopup(this.container, null, this.data);
  881. }
  882. return this.container;
  883. }
  884. }]);
  885. return SquigglyAnnotationElement;
  886. }(AnnotationElement);
  887. var StrikeOutAnnotationElement =
  888. /*#__PURE__*/
  889. function (_AnnotationElement13) {
  890. _inherits(StrikeOutAnnotationElement, _AnnotationElement13);
  891. function StrikeOutAnnotationElement(parameters) {
  892. _classCallCheck(this, StrikeOutAnnotationElement);
  893. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  894. return _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotationElement).call(this, parameters, isRenderable, true));
  895. }
  896. _createClass(StrikeOutAnnotationElement, [{
  897. key: "render",
  898. value: function render() {
  899. this.container.className = 'strikeoutAnnotation';
  900. if (!this.data.hasPopup) {
  901. this._createPopup(this.container, null, this.data);
  902. }
  903. return this.container;
  904. }
  905. }]);
  906. return StrikeOutAnnotationElement;
  907. }(AnnotationElement);
  908. var StampAnnotationElement =
  909. /*#__PURE__*/
  910. function (_AnnotationElement14) {
  911. _inherits(StampAnnotationElement, _AnnotationElement14);
  912. function StampAnnotationElement(parameters) {
  913. _classCallCheck(this, StampAnnotationElement);
  914. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  915. return _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotationElement).call(this, parameters, isRenderable, true));
  916. }
  917. _createClass(StampAnnotationElement, [{
  918. key: "render",
  919. value: function render() {
  920. this.container.className = 'stampAnnotation';
  921. if (!this.data.hasPopup) {
  922. this._createPopup(this.container, null, this.data);
  923. }
  924. return this.container;
  925. }
  926. }]);
  927. return StampAnnotationElement;
  928. }(AnnotationElement);
  929. var FileAttachmentAnnotationElement =
  930. /*#__PURE__*/
  931. function (_AnnotationElement15) {
  932. _inherits(FileAttachmentAnnotationElement, _AnnotationElement15);
  933. function FileAttachmentAnnotationElement(parameters) {
  934. var _this6;
  935. _classCallCheck(this, FileAttachmentAnnotationElement);
  936. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotationElement).call(this, parameters, true));
  937. var _this6$data$file = _this6.data.file,
  938. filename = _this6$data$file.filename,
  939. content = _this6$data$file.content;
  940. _this6.filename = (0, _dom_utils.getFilenameFromUrl)(filename);
  941. _this6.content = content;
  942. if (_this6.linkService.eventBus) {
  943. _this6.linkService.eventBus.dispatch('fileattachmentannotation', {
  944. source: _assertThisInitialized(_assertThisInitialized(_this6)),
  945. id: (0, _util.stringToPDFString)(filename),
  946. filename: filename,
  947. content: content
  948. });
  949. }
  950. return _this6;
  951. }
  952. _createClass(FileAttachmentAnnotationElement, [{
  953. key: "render",
  954. value: function render() {
  955. this.container.className = 'fileAttachmentAnnotation';
  956. var trigger = document.createElement('div');
  957. trigger.style.height = this.container.style.height;
  958. trigger.style.width = this.container.style.width;
  959. trigger.addEventListener('dblclick', this._download.bind(this));
  960. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  961. this._createPopup(this.container, trigger, this.data);
  962. }
  963. this.container.appendChild(trigger);
  964. return this.container;
  965. }
  966. }, {
  967. key: "_download",
  968. value: function _download() {
  969. if (!this.downloadManager) {
  970. (0, _util.warn)('Download cannot be started due to unavailable download manager');
  971. return;
  972. }
  973. this.downloadManager.downloadData(this.content, this.filename, '');
  974. }
  975. }]);
  976. return FileAttachmentAnnotationElement;
  977. }(AnnotationElement);
  978. var AnnotationLayer =
  979. /*#__PURE__*/
  980. function () {
  981. function AnnotationLayer() {
  982. _classCallCheck(this, AnnotationLayer);
  983. }
  984. _createClass(AnnotationLayer, null, [{
  985. key: "render",
  986. value: function render(parameters) {
  987. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  988. var data = parameters.annotations[i];
  989. if (!data) {
  990. continue;
  991. }
  992. var element = AnnotationElementFactory.create({
  993. data: data,
  994. layer: parameters.div,
  995. page: parameters.page,
  996. viewport: parameters.viewport,
  997. linkService: parameters.linkService,
  998. downloadManager: parameters.downloadManager,
  999. imageResourcesPath: parameters.imageResourcesPath || '',
  1000. renderInteractiveForms: parameters.renderInteractiveForms || false,
  1001. svgFactory: new _dom_utils.DOMSVGFactory()
  1002. });
  1003. if (element.isRenderable) {
  1004. parameters.div.appendChild(element.render());
  1005. }
  1006. }
  1007. }
  1008. }, {
  1009. key: "update",
  1010. value: function update(parameters) {
  1011. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  1012. var data = parameters.annotations[i];
  1013. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  1014. if (element) {
  1015. element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')';
  1016. }
  1017. }
  1018. parameters.div.removeAttribute('hidden');
  1019. }
  1020. }]);
  1021. return AnnotationLayer;
  1022. }();
  1023. exports.AnnotationLayer = AnnotationLayer;