@@ -2085,7 +2085,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
2085
2085
"https://mozilla.github.io" ,
2086
2086
] ;
2087
2087
validateFileURL = function ( file ) {
2088
- if ( file === undefined ) {
2088
+ if ( ! file ) {
2089
2089
return ;
2090
2090
}
2091
2091
try {
@@ -2142,7 +2142,7 @@ function reportPageStatsPDFBug({ pageNumber }) {
2142
2142
}
2143
2143
2144
2144
function webViewerInitialized ( ) {
2145
- const appConfig = PDFViewerApplication . appConfig ;
2145
+ const { appConfig, eventBus } = PDFViewerApplication ;
2146
2146
let file ;
2147
2147
if ( typeof PDFJSDev === "undefined" || PDFJSDev . test ( "GENERIC" ) ) {
2148
2148
const queryString = document . location . search . substring ( 1 ) ;
@@ -2156,31 +2156,15 @@ function webViewerInitialized() {
2156
2156
}
2157
2157
2158
2158
if ( typeof PDFJSDev === "undefined" || PDFJSDev . test ( "GENERIC" ) ) {
2159
- const fileInput = document . createElement ( "input" ) ;
2160
- fileInput . id = appConfig . openFileInputName ;
2161
- fileInput . className = "fileInput" ;
2162
- fileInput . setAttribute ( "type" , "file" ) ;
2163
- fileInput . oncontextmenu = noContextMenuHandler ;
2164
- document . body . appendChild ( fileInput ) ;
2165
-
2166
- if (
2167
- ! window . File ||
2168
- ! window . FileReader ||
2169
- ! window . FileList ||
2170
- ! window . Blob
2171
- ) {
2172
- appConfig . toolbar . openFile . hidden = true ;
2173
- appConfig . secondaryToolbar . openFileButton . hidden = true ;
2174
- } else {
2175
- fileInput . value = null ;
2176
- }
2159
+ const fileInput = appConfig . openFileInput ;
2160
+ fileInput . value = null ;
2177
2161
2178
2162
fileInput . addEventListener ( "change" , function ( evt ) {
2179
- const files = evt . target . files ;
2163
+ const { files } = evt . target ;
2180
2164
if ( ! files || files . length === 0 ) {
2181
2165
return ;
2182
2166
}
2183
- PDFViewerApplication . eventBus . dispatch ( "fileinputchange" , {
2167
+ eventBus . dispatch ( "fileinputchange" , {
2184
2168
source : this ,
2185
2169
fileInput : evt . target ,
2186
2170
} ) ;
@@ -2195,11 +2179,11 @@ function webViewerInitialized() {
2195
2179
appConfig . mainContainer . addEventListener ( "drop" , function ( evt ) {
2196
2180
evt . preventDefault ( ) ;
2197
2181
2198
- const files = evt . dataTransfer . files ;
2182
+ const { files } = evt . dataTransfer ;
2199
2183
if ( ! files || files . length === 0 ) {
2200
2184
return ;
2201
2185
}
2202
- PDFViewerApplication . eventBus . dispatch ( "fileinputchange" , {
2186
+ eventBus . dispatch ( "fileinputchange" , {
2203
2187
source : this ,
2204
2188
fileInput : evt . dataTransfer ,
2205
2189
} ) ;
@@ -2234,7 +2218,7 @@ function webViewerInitialized() {
2234
2218
"transitionend" ,
2235
2219
function ( evt ) {
2236
2220
if ( evt . target === /* mainContainer */ this ) {
2237
- PDFViewerApplication . eventBus . dispatch ( "resize" , { source : this } ) ;
2221
+ eventBus . dispatch ( "resize" , { source : this } ) ;
2238
2222
}
2239
2223
} ,
2240
2224
true
@@ -2460,8 +2444,8 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
2460
2444
} ;
2461
2445
2462
2446
webViewerOpenFile = function ( evt ) {
2463
- const openFileInputName = PDFViewerApplication . appConfig . openFileInputName ;
2464
- document . getElementById ( openFileInputName ) . click ( ) ;
2447
+ const fileInput = PDFViewerApplication . appConfig . openFileInput ;
2448
+ fileInput . click ( ) ;
2465
2449
} ;
2466
2450
}
2467
2451
0 commit comments