1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | 'use strict';
|
23 |
|
24 | Object.defineProperty(exports, "__esModule", {
|
25 | value: true
|
26 | });
|
27 | exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
|
28 |
|
29 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
30 |
|
31 | var _pdf = require('../pdf');
|
32 |
|
33 | var _ui_utils = require('./ui_utils');
|
34 |
|
35 | var _pdf_link_service = require('./pdf_link_service');
|
36 |
|
37 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
38 |
|
39 | var AnnotationLayerBuilder = function () {
|
40 | function AnnotationLayerBuilder(_ref) {
|
41 | var pageDiv = _ref.pageDiv,
|
42 | pdfPage = _ref.pdfPage,
|
43 | linkService = _ref.linkService,
|
44 | downloadManager = _ref.downloadManager,
|
45 | _ref$imageResourcesPa = _ref.imageResourcesPath,
|
46 | imageResourcesPath = _ref$imageResourcesPa === undefined ? '' : _ref$imageResourcesPa,
|
47 | _ref$renderInteractiv = _ref.renderInteractiveForms,
|
48 | renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
|
49 | _ref$l10n = _ref.l10n,
|
50 | l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
|
51 |
|
52 | _classCallCheck(this, AnnotationLayerBuilder);
|
53 |
|
54 | this.pageDiv = pageDiv;
|
55 | this.pdfPage = pdfPage;
|
56 | this.linkService = linkService;
|
57 | this.downloadManager = downloadManager;
|
58 | this.imageResourcesPath = imageResourcesPath;
|
59 | this.renderInteractiveForms = renderInteractiveForms;
|
60 | this.l10n = l10n;
|
61 | this.div = null;
|
62 | this._cancelled = false;
|
63 | }
|
64 |
|
65 | _createClass(AnnotationLayerBuilder, [{
|
66 | key: 'render',
|
67 | value: function render(viewport) {
|
68 | var _this = this;
|
69 |
|
70 | var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
|
71 |
|
72 | this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
|
73 | if (_this._cancelled) {
|
74 | return;
|
75 | }
|
76 | var parameters = {
|
77 | viewport: viewport.clone({ dontFlip: true }),
|
78 | div: _this.div,
|
79 | annotations: annotations,
|
80 | page: _this.pdfPage,
|
81 | imageResourcesPath: _this.imageResourcesPath,
|
82 | renderInteractiveForms: _this.renderInteractiveForms,
|
83 | linkService: _this.linkService,
|
84 | downloadManager: _this.downloadManager
|
85 | };
|
86 | if (_this.div) {
|
87 | _pdf.AnnotationLayer.update(parameters);
|
88 | } else {
|
89 | if (annotations.length === 0) {
|
90 | return;
|
91 | }
|
92 | _this.div = document.createElement('div');
|
93 | _this.div.className = 'annotationLayer';
|
94 | _this.pageDiv.appendChild(_this.div);
|
95 | parameters.div = _this.div;
|
96 | _pdf.AnnotationLayer.render(parameters);
|
97 | _this.l10n.translate(_this.div);
|
98 | }
|
99 | });
|
100 | }
|
101 | }, {
|
102 | key: 'cancel',
|
103 | value: function cancel() {
|
104 | this._cancelled = true;
|
105 | }
|
106 | }, {
|
107 | key: 'hide',
|
108 | value: function hide() {
|
109 | if (!this.div) {
|
110 | return;
|
111 | }
|
112 | this.div.setAttribute('hidden', 'true');
|
113 | }
|
114 | }]);
|
115 |
|
116 | return AnnotationLayerBuilder;
|
117 | }();
|
118 |
|
119 | var DefaultAnnotationLayerFactory = function () {
|
120 | function DefaultAnnotationLayerFactory() {
|
121 | _classCallCheck(this, DefaultAnnotationLayerFactory);
|
122 | }
|
123 |
|
124 | _createClass(DefaultAnnotationLayerFactory, [{
|
125 | key: 'createAnnotationLayerBuilder',
|
126 | value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
|
127 | var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
128 | var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
129 | var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
|
130 |
|
131 | return new AnnotationLayerBuilder({
|
132 | pageDiv: pageDiv,
|
133 | pdfPage: pdfPage,
|
134 | imageResourcesPath: imageResourcesPath,
|
135 | renderInteractiveForms: renderInteractiveForms,
|
136 | linkService: new _pdf_link_service.SimpleLinkService(),
|
137 | l10n: l10n
|
138 | });
|
139 | }
|
140 | }]);
|
141 |
|
142 | return DefaultAnnotationLayerFactory;
|
143 | }();
|
144 |
|
145 | exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
|
146 | exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory; |
\ | No newline at end of file |