@fto-consult/expo-ui 8.73.0 → 8.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-app/App.js +29 -0
- package/package.json +3 -2
- package/src/components/BottomSheet/Sheet.js +0 -6
- package/src/components/Datagrid/Accordion/index.js +2 -2
- package/src/components/Icon/Font.js +1 -0
- package/src/context/Provider.js +1 -0
- package/src/layouts/ProfilAvatar/index.js +87 -35
- package/src/layouts/Screen/Screen.js +16 -6
- package/src/layouts/Screen/ScreenWithoutAuthContainer.js +4 -2
- package/src/pdf/Reader/index.js +6 -0
- package/src/pdf/Reader/index.web.js +16 -173
- package/src/pdf/Reader/index.web.old.js +178 -0
- package/src/pdf/Reader/web/Viewer.js +20 -0
- package/src/pdf/Reader/web/script.js +334 -0
- package/src/screens/Help/openLibraries.js +125 -82
@@ -0,0 +1,178 @@
|
|
1
|
+
/**@see : https://github.com/pipwerks/PDFObject#readme */
|
2
|
+
let {Dialog} = require("$ecomponents/Dialog")
|
3
|
+
let Icon = require("$ecomponents/Icon")
|
4
|
+
require("./styles.css")
|
5
|
+
let PDFObject = require("pdfobject")
|
6
|
+
let {MenuButton} = require("$ui")
|
7
|
+
let isMSE = //checkEdge ? false :
|
8
|
+
window.navigator && typeof window.navigator.msSaveOrOpenBlob == "function" ? true : false;
|
9
|
+
class PDFViewer extends APP.Component {
|
10
|
+
constructor(props){
|
11
|
+
super(props);
|
12
|
+
APP.extend(this._events,{
|
13
|
+
resize : this.resetPos.bind(this)
|
14
|
+
})
|
15
|
+
this.autobind();
|
16
|
+
}
|
17
|
+
|
18
|
+
componentDidMount(){
|
19
|
+
super.componentDidMount();
|
20
|
+
this.updatePdfContent();
|
21
|
+
window.addEventListener('resize',this._events.resize, true)
|
22
|
+
this.resetPos();
|
23
|
+
}
|
24
|
+
resetPos (){
|
25
|
+
if(!this._isMounted()) return;
|
26
|
+
let pdfWrap = document.getElementById(this.pdfViewerWrapperDomId);
|
27
|
+
if(isDOMElement(pdfWrap)){
|
28
|
+
let parent = pdfWrap.parentNode;
|
29
|
+
let mP = pdfWrap.closest(".dialog.md-dialog-container");
|
30
|
+
if(isDOMElement(parent) && isDOMElement(mP)){
|
31
|
+
let maxHeight = mezr.height(parent);
|
32
|
+
let maxH2 = mezr.height(mP);
|
33
|
+
let min = Math.min(maxHeight,maxH2);
|
34
|
+
if(min == 0){
|
35
|
+
min = "100%";
|
36
|
+
} else min = min+"px";
|
37
|
+
pdfWrap.style.height = min;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
componentDidUpdate(){
|
43
|
+
super.componentDidUpdate();
|
44
|
+
if(this.dialogRef && this.dialogRef.open){
|
45
|
+
this.dialogRef.open();
|
46
|
+
}
|
47
|
+
this.updatePdfContent()
|
48
|
+
this.resetPos();
|
49
|
+
}
|
50
|
+
componentWillUnmount(){
|
51
|
+
super.componentWillUnmount();
|
52
|
+
this.dialogRef = undefined;
|
53
|
+
window.removeEventListener('resize',this._events.resize, true)
|
54
|
+
this.clearEvents();
|
55
|
+
}
|
56
|
+
viewCapacitor (){
|
57
|
+
let f = window.PreviewAnyFile || (cordova && cordova.plugins.PreviewAnyFile);
|
58
|
+
if(f && f.preview){
|
59
|
+
f = f.preview;
|
60
|
+
let {file} = this.props;
|
61
|
+
APP.FILE.getCapacitorPDFromDataURL({content:file,fileName:this.props.fileName,success:({path})=>{
|
62
|
+
if(isFunction(f)){
|
63
|
+
f(
|
64
|
+
path,
|
65
|
+
function(win){},
|
66
|
+
function(err){
|
67
|
+
console.log(err," pdf viewer in cap android ios")
|
68
|
+
}
|
69
|
+
)
|
70
|
+
}
|
71
|
+
}})
|
72
|
+
}
|
73
|
+
}
|
74
|
+
updatePdfContent(){
|
75
|
+
let file = this.props.file;
|
76
|
+
if (isMSE) {
|
77
|
+
let b64 = dataURLToBase64(file);
|
78
|
+
if(b64){
|
79
|
+
var byteCharacters = atob(b64);
|
80
|
+
var byteNumbers = new Array(byteCharacters.length);
|
81
|
+
for (var i = 0; i < byteCharacters.length; i++) {
|
82
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
83
|
+
}
|
84
|
+
var byteArray = new Uint8Array(byteNumbers);
|
85
|
+
var blob = new Blob([byteArray], {
|
86
|
+
type: 'application/pdf'
|
87
|
+
});
|
88
|
+
return window.navigator.msSaveOrOpenBlob(blob, defaultStr(this.props.title,'données-impr')+".pdf");
|
89
|
+
}
|
90
|
+
return null;
|
91
|
+
}
|
92
|
+
if(isElectron()){
|
93
|
+
return ELECTRON.PRINTER.preview({
|
94
|
+
content:this.props.file,
|
95
|
+
fileName : this.props.fileName,
|
96
|
+
fileExtension : 'pdf',
|
97
|
+
});
|
98
|
+
}
|
99
|
+
if(isCapacitor(true)){
|
100
|
+
return this.viewCapacitor();
|
101
|
+
}
|
102
|
+
let dom = document.getElementById(this.pdfViewerWrapperDomId);
|
103
|
+
if(isDOMElement(dom)){
|
104
|
+
try {
|
105
|
+
this.pdfInstance = PDFObject.embed(file,dom);
|
106
|
+
} catch (e){
|
107
|
+
console.log(e,' error on loading pdf file')
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
UNSAFE_componentWillReceiveProps(nexProps,prevProps){
|
112
|
+
if(nexProps.file && nexProps.file != this.state.file){
|
113
|
+
this._pageNumber = 1;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
onPrint (args){
|
117
|
+
console.log(args,' was printed');
|
118
|
+
}
|
119
|
+
getPrintSettings(){
|
120
|
+
return defaultObj(this.props.printProps,this.props.printOptions);
|
121
|
+
}
|
122
|
+
render (){
|
123
|
+
if(isMSE || isElectron() || isCapacitor(true)) return null;
|
124
|
+
let {file,dialogProps,title,onPrint,printProps,printOptions,fileName,...rest} = this.props;
|
125
|
+
dialogProps = defaultObj(dialogProps);
|
126
|
+
dialogProps.contentProps = defaultObj(dialogProps.contentProps)
|
127
|
+
dialogProps.contentProps.id = defaultStr(dialogProps.contentProps.id,this.dialogWrapperParentId,uniqid('dialog-content-wrp-par'))
|
128
|
+
this.dialogWrapperParentId = dialogProps.contentProps.id;
|
129
|
+
dialogProps.contentProps.className = classNames(dialogProps.contentProps.className,'no-padding pdf-viewer-dialog-content')
|
130
|
+
dialogProps.className = classNames(dialogProps.className,'pdf-viewer-dialog')
|
131
|
+
dialogProps.title = defaultStr(dialogProps.title,title)
|
132
|
+
rest = defaultObj(rest)
|
133
|
+
let {actions} = dialogProps;
|
134
|
+
let acts = []
|
135
|
+
let mIts = []
|
136
|
+
if(mIts.length > 0){
|
137
|
+
acts.push(
|
138
|
+
<MenuButton
|
139
|
+
menuItems = {mIts}
|
140
|
+
flat
|
141
|
+
id = {uniqid("view-page-id-butt")}
|
142
|
+
>
|
143
|
+
{<Icon name="material-more_vert" title={"pages"}/>}
|
144
|
+
</MenuButton>
|
145
|
+
)
|
146
|
+
}
|
147
|
+
Object.map(actions,(a,i)=>{
|
148
|
+
if(!a) return;
|
149
|
+
acts.push(a);
|
150
|
+
})
|
151
|
+
this.pdfViewerWrapperDomId = defaultStr(this.pdfViewerWrapperDomId,uniqid("pdf-viewer-wrapper-id"))
|
152
|
+
return (
|
153
|
+
<Dialog
|
154
|
+
key = {_uniqid("dialog-pdf-viewer-key-id")}
|
155
|
+
{...dialogProps}
|
156
|
+
ref = {(el)=>{
|
157
|
+
if(el){
|
158
|
+
this.dialogRef = el;
|
159
|
+
}
|
160
|
+
}}
|
161
|
+
fullPage
|
162
|
+
visible
|
163
|
+
actions = {acts}
|
164
|
+
>
|
165
|
+
<div className="pdf-viewer-wrapper w100 h100" id={this.pdfViewerWrapperDomId}></div>
|
166
|
+
</Dialog>
|
167
|
+
);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
module.exports = PDFViewer;
|
172
|
+
PDFViewer.PDFObject = PDFObject;
|
173
|
+
|
174
|
+
PDFViewer.propTypes = {
|
175
|
+
...Document.propTypes,
|
176
|
+
/*** méthode appelée lorsque le document est imprimé */
|
177
|
+
onPrint : PropTypes.func,
|
178
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from "$react";
|
2
|
+
import View from "$ecomponents/View";
|
3
|
+
export default function PdfViewerWeb(){
|
4
|
+
return <View testID="RN_PDF_WEBVIEW_COMPONENT">
|
5
|
+
<div id="viewerContainer">
|
6
|
+
<div id="viewer" class="pdfViewer"></div>
|
7
|
+
</div>
|
8
|
+
<div id="loadingBar">
|
9
|
+
<div class="progress"></div>
|
10
|
+
<div class="glimmer"></div>
|
11
|
+
</div>
|
12
|
+
<footer>
|
13
|
+
<button class="toolbarButton pageUp" title="Previous Page" id="previous"></button>
|
14
|
+
<button class="toolbarButton pageDown" title="Next Page" id="next"></button>
|
15
|
+
<input type="number" id="pageNumber" class="toolbarField pageNumber" value="1" size="4" min="1"/>
|
16
|
+
<button class="toolbarButton zoomOut" title="Zoom Out" id="zoomOut"></button>
|
17
|
+
<button class="toolbarButton zoomIn" title="Zoom In" id="zoomIn"></button>
|
18
|
+
</footer>
|
19
|
+
</View>
|
20
|
+
}
|
@@ -0,0 +1,334 @@
|
|
1
|
+
const pdfjsLib = require("pdfjs-dist/build/pdf.min.mjs");
|
2
|
+
|
3
|
+
const MAX_CANVAS_PIXELS = 0; // CSS-only zooming.
|
4
|
+
const TEXT_LAYER_MODE = 0; // DISABLE
|
5
|
+
const MAX_IMAGE_SIZE = 1024 * 1024;
|
6
|
+
const CMAP_URL = "../../node_modules/pdfjs-dist/cmaps/";
|
7
|
+
const CMAP_PACKED = true;
|
8
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = "../../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
|
9
|
+
const DEFAULT_SCALE_DELTA = 1.1;
|
10
|
+
const MIN_SCALE = 0.25;
|
11
|
+
const MAX_SCALE = 10.0;
|
12
|
+
const DEFAULT_SCALE_VALUE = "auto";
|
13
|
+
|
14
|
+
const PDFViewerApplication = {
|
15
|
+
pdfLoadingTask: null,
|
16
|
+
pdfDocument: null,
|
17
|
+
pdfViewer: null,
|
18
|
+
pdfHistory: null,
|
19
|
+
pdfLinkService: null,
|
20
|
+
eventBus: null,
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Opens PDF document specified by URL.
|
24
|
+
* @returns {Promise} - Returns the promise, which is resolved when document
|
25
|
+
* is opened.
|
26
|
+
*/
|
27
|
+
open(params) {
|
28
|
+
if (this.pdfLoadingTask) {
|
29
|
+
// We need to destroy already opened document
|
30
|
+
return this.close().then(
|
31
|
+
function () {
|
32
|
+
// ... and repeat the open() call.
|
33
|
+
return this.open(params);
|
34
|
+
}.bind(this)
|
35
|
+
);
|
36
|
+
}
|
37
|
+
const url = params.url;
|
38
|
+
const self = this;
|
39
|
+
this.setTitleUsingUrl(url);
|
40
|
+
|
41
|
+
// Loading document.
|
42
|
+
const loadingTask = pdfjsLib.getDocument({
|
43
|
+
url,
|
44
|
+
maxImageSize: MAX_IMAGE_SIZE,
|
45
|
+
cMapUrl: CMAP_URL,
|
46
|
+
cMapPacked: CMAP_PACKED,
|
47
|
+
});
|
48
|
+
this.pdfLoadingTask = loadingTask;
|
49
|
+
|
50
|
+
loadingTask.onProgress = function (progressData) {
|
51
|
+
self.progress(progressData.loaded / progressData.total);
|
52
|
+
};
|
53
|
+
|
54
|
+
return loadingTask.promise.then(
|
55
|
+
function (pdfDocument) {
|
56
|
+
// Document loaded, specifying document for the viewer.
|
57
|
+
self.pdfDocument = pdfDocument;
|
58
|
+
self.pdfViewer.setDocument(pdfDocument);
|
59
|
+
self.pdfLinkService.setDocument(pdfDocument);
|
60
|
+
self.pdfHistory.initialize({
|
61
|
+
fingerprint: pdfDocument.fingerprints[0],
|
62
|
+
});
|
63
|
+
|
64
|
+
self.loadingBar.hide();
|
65
|
+
self.setTitleUsingMetadata(pdfDocument);
|
66
|
+
},
|
67
|
+
function (reason) {
|
68
|
+
let key = "pdfjs-loading-error";
|
69
|
+
if (reason instanceof pdfjsLib.InvalidPDFException) {
|
70
|
+
key = "pdfjs-invalid-file-error";
|
71
|
+
} else if (reason instanceof pdfjsLib.MissingPDFException) {
|
72
|
+
key = "pdfjs-missing-file-error";
|
73
|
+
} else if (reason instanceof pdfjsLib.UnexpectedResponseException) {
|
74
|
+
key = "pdfjs-unexpected-response-error";
|
75
|
+
}
|
76
|
+
self.l10n.get(key).then(msg => {
|
77
|
+
self.error(msg, { message: reason?.message });
|
78
|
+
});
|
79
|
+
self.loadingBar.hide();
|
80
|
+
}
|
81
|
+
);
|
82
|
+
},
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Closes opened PDF document.
|
86
|
+
* @returns {Promise} - Returns the promise, which is resolved when all
|
87
|
+
* destruction is completed.
|
88
|
+
*/
|
89
|
+
close() {
|
90
|
+
if (!this.pdfLoadingTask) {
|
91
|
+
return Promise.resolve();
|
92
|
+
}
|
93
|
+
|
94
|
+
const promise = this.pdfLoadingTask.destroy();
|
95
|
+
this.pdfLoadingTask = null;
|
96
|
+
|
97
|
+
if (this.pdfDocument) {
|
98
|
+
this.pdfDocument = null;
|
99
|
+
|
100
|
+
this.pdfViewer.setDocument(null);
|
101
|
+
this.pdfLinkService.setDocument(null, null);
|
102
|
+
|
103
|
+
if (this.pdfHistory) {
|
104
|
+
this.pdfHistory.reset();
|
105
|
+
}
|
106
|
+
}
|
107
|
+
return promise;
|
108
|
+
},
|
109
|
+
|
110
|
+
get loadingBar() {
|
111
|
+
const bar = document.getElementById("loadingBar");
|
112
|
+
return pdfjsLib.shadow(
|
113
|
+
this,
|
114
|
+
"loadingBar",
|
115
|
+
new pdfjsViewer.ProgressBar(bar)
|
116
|
+
);
|
117
|
+
},
|
118
|
+
|
119
|
+
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
120
|
+
this.url = url;
|
121
|
+
let title = pdfjsLib.getFilenameFromUrl(url) || url;
|
122
|
+
try {
|
123
|
+
title = decodeURIComponent(title);
|
124
|
+
} catch {
|
125
|
+
// decodeURIComponent may throw URIError,
|
126
|
+
// fall back to using the unprocessed url in that case
|
127
|
+
}
|
128
|
+
this.setTitle(title);
|
129
|
+
},
|
130
|
+
|
131
|
+
setTitleUsingMetadata(pdfDocument) {
|
132
|
+
const self = this;
|
133
|
+
pdfDocument.getMetadata().then(function (data) {
|
134
|
+
const info = data.info,
|
135
|
+
metadata = data.metadata;
|
136
|
+
self.documentInfo = info;
|
137
|
+
self.metadata = metadata;
|
138
|
+
|
139
|
+
// Provides some basic debug information
|
140
|
+
console.log(
|
141
|
+
"PDF " +
|
142
|
+
pdfDocument.fingerprints[0] +
|
143
|
+
" [" +
|
144
|
+
info.PDFFormatVersion +
|
145
|
+
" " +
|
146
|
+
(info.Producer || "-").trim() +
|
147
|
+
" / " +
|
148
|
+
(info.Creator || "-").trim() +
|
149
|
+
"]" +
|
150
|
+
" (PDF.js: " +
|
151
|
+
(pdfjsLib.version || "-") +
|
152
|
+
")"
|
153
|
+
);
|
154
|
+
|
155
|
+
let pdfTitle;
|
156
|
+
if (metadata && metadata.has("dc:title")) {
|
157
|
+
const title = metadata.get("dc:title");
|
158
|
+
// Ghostscript sometimes returns 'Untitled', so prevent setting the
|
159
|
+
// title to 'Untitled.
|
160
|
+
if (title !== "Untitled") {
|
161
|
+
pdfTitle = title;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
if (!pdfTitle && info && info.Title) {
|
166
|
+
pdfTitle = info.Title;
|
167
|
+
}
|
168
|
+
|
169
|
+
if (pdfTitle) {
|
170
|
+
self.setTitle(pdfTitle + " - " + document.title);
|
171
|
+
}
|
172
|
+
});
|
173
|
+
},
|
174
|
+
|
175
|
+
setTitle: function pdfViewSetTitle(title) {
|
176
|
+
document.title = title;
|
177
|
+
document.getElementById("title").textContent = title;
|
178
|
+
},
|
179
|
+
|
180
|
+
error: function pdfViewError(message, moreInfo) {
|
181
|
+
const moreInfoText = [
|
182
|
+
`PDF.js v${pdfjsLib.version || "?"} (build: ${pdfjsLib.build || "?"})`,
|
183
|
+
];
|
184
|
+
if (moreInfo) {
|
185
|
+
moreInfoText.push(`Message: ${moreInfo.message}`);
|
186
|
+
|
187
|
+
if (moreInfo.stack) {
|
188
|
+
moreInfoText.push(`Stack: ${moreInfo.stack}`);
|
189
|
+
} else {
|
190
|
+
if (moreInfo.filename) {
|
191
|
+
moreInfoText.push(`File: ${moreInfo.filename}`);
|
192
|
+
}
|
193
|
+
if (moreInfo.lineNumber) {
|
194
|
+
moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
console.error(`${message}\n\n${moreInfoText.join("\n")}`);
|
200
|
+
},
|
201
|
+
|
202
|
+
progress: function pdfViewProgress(level) {
|
203
|
+
const percent = Math.round(level * 100);
|
204
|
+
// Updating the bar if value increases.
|
205
|
+
if (percent > this.loadingBar.percent || isNaN(percent)) {
|
206
|
+
this.loadingBar.percent = percent;
|
207
|
+
}
|
208
|
+
},
|
209
|
+
|
210
|
+
get pagesCount() {
|
211
|
+
return this.pdfDocument.numPages;
|
212
|
+
},
|
213
|
+
|
214
|
+
get page() {
|
215
|
+
return this.pdfViewer.currentPageNumber;
|
216
|
+
},
|
217
|
+
|
218
|
+
set page(val) {
|
219
|
+
this.pdfViewer.currentPageNumber = val;
|
220
|
+
},
|
221
|
+
|
222
|
+
zoomIn: function pdfViewZoomIn(ticks) {
|
223
|
+
let newScale = this.pdfViewer.currentScale;
|
224
|
+
do {
|
225
|
+
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
|
226
|
+
newScale = Math.ceil(newScale * 10) / 10;
|
227
|
+
newScale = Math.min(MAX_SCALE, newScale);
|
228
|
+
} while (--ticks && newScale < MAX_SCALE);
|
229
|
+
this.pdfViewer.currentScaleValue = newScale;
|
230
|
+
},
|
231
|
+
|
232
|
+
zoomOut: function pdfViewZoomOut(ticks) {
|
233
|
+
let newScale = this.pdfViewer.currentScale;
|
234
|
+
do {
|
235
|
+
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
|
236
|
+
newScale = Math.floor(newScale * 10) / 10;
|
237
|
+
newScale = Math.max(MIN_SCALE, newScale);
|
238
|
+
} while (--ticks && newScale > MIN_SCALE);
|
239
|
+
this.pdfViewer.currentScaleValue = newScale;
|
240
|
+
},
|
241
|
+
|
242
|
+
initUI: function pdfViewInitUI() {
|
243
|
+
const eventBus = new pdfjsViewer.EventBus();
|
244
|
+
this.eventBus = eventBus;
|
245
|
+
|
246
|
+
const linkService = new pdfjsViewer.PDFLinkService({
|
247
|
+
eventBus,
|
248
|
+
});
|
249
|
+
this.pdfLinkService = linkService;
|
250
|
+
|
251
|
+
this.l10n = new pdfjsViewer.GenericL10n();
|
252
|
+
|
253
|
+
const container = document.getElementById("viewerContainer");
|
254
|
+
const pdfViewer = new pdfjsViewer.PDFViewer({
|
255
|
+
container,
|
256
|
+
eventBus,
|
257
|
+
linkService,
|
258
|
+
l10n: this.l10n,
|
259
|
+
maxCanvasPixels: MAX_CANVAS_PIXELS,
|
260
|
+
textLayerMode: TEXT_LAYER_MODE,
|
261
|
+
});
|
262
|
+
this.pdfViewer = pdfViewer;
|
263
|
+
linkService.setViewer(pdfViewer);
|
264
|
+
|
265
|
+
this.pdfHistory = new pdfjsViewer.PDFHistory({
|
266
|
+
eventBus,
|
267
|
+
linkService,
|
268
|
+
});
|
269
|
+
linkService.setHistory(this.pdfHistory);
|
270
|
+
|
271
|
+
document.getElementById("previous").addEventListener("click", function () {
|
272
|
+
PDFViewerApplication.page--;
|
273
|
+
});
|
274
|
+
|
275
|
+
document.getElementById("next").addEventListener("click", function () {
|
276
|
+
PDFViewerApplication.page++;
|
277
|
+
});
|
278
|
+
|
279
|
+
document.getElementById("zoomIn").addEventListener("click", function () {
|
280
|
+
PDFViewerApplication.zoomIn();
|
281
|
+
});
|
282
|
+
|
283
|
+
document.getElementById("zoomOut").addEventListener("click", function () {
|
284
|
+
PDFViewerApplication.zoomOut();
|
285
|
+
});
|
286
|
+
|
287
|
+
document
|
288
|
+
.getElementById("pageNumber")
|
289
|
+
.addEventListener("click", function () {
|
290
|
+
this.select();
|
291
|
+
});
|
292
|
+
|
293
|
+
document
|
294
|
+
.getElementById("pageNumber")
|
295
|
+
.addEventListener("change", function () {
|
296
|
+
PDFViewerApplication.page = this.value | 0;
|
297
|
+
|
298
|
+
// Ensure that the page number input displays the correct value,
|
299
|
+
// even if the value entered by the user was invalid
|
300
|
+
// (e.g. a floating point number).
|
301
|
+
if (this.value !== PDFViewerApplication.page.toString()) {
|
302
|
+
this.value = PDFViewerApplication.page;
|
303
|
+
}
|
304
|
+
});
|
305
|
+
|
306
|
+
eventBus.on("pagesinit", function () {
|
307
|
+
// We can use pdfViewer now, e.g. let's change default scale.
|
308
|
+
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
309
|
+
});
|
310
|
+
|
311
|
+
eventBus.on(
|
312
|
+
"pagechanging",
|
313
|
+
function (evt) {
|
314
|
+
const page = evt.pageNumber;
|
315
|
+
const numPages = PDFViewerApplication.pagesCount;
|
316
|
+
|
317
|
+
document.getElementById("pageNumber").value = page;
|
318
|
+
document.getElementById("previous").disabled = page <= 1;
|
319
|
+
document.getElementById("next").disabled = page >= numPages;
|
320
|
+
},
|
321
|
+
true
|
322
|
+
);
|
323
|
+
},
|
324
|
+
};
|
325
|
+
|
326
|
+
window.PDFViewerApplication = PDFViewerApplication;
|
327
|
+
|
328
|
+
document.addEventListener(
|
329
|
+
"DOMContentLoaded",
|
330
|
+
function () {
|
331
|
+
PDFViewerApplication.initUI();
|
332
|
+
},
|
333
|
+
true
|
334
|
+
);
|