2016-04-02 00:29:44 +09:00
|
|
|
/* Copyright 2016 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2016-12-16 02:10:43 +09:00
|
|
|
/* globals chrome */
|
2016-04-02 00:29:44 +09:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2016-10-15 00:57:53 +09:00
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
2018-02-18 07:25:23 +09:00
|
|
|
var defaultUrl; // eslint-disable-line no-var
|
|
|
|
|
2016-10-15 00:57:53 +09:00
|
|
|
(function rewriteUrlClosure() {
|
|
|
|
// Run this code outside DOMContentLoaded to make sure that the URL
|
|
|
|
// is rewritten as soon as possible.
|
2017-06-29 19:14:26 +09:00
|
|
|
let queryString = document.location.search.slice(1);
|
|
|
|
let m = /(^|&)file=([^&]*)/.exec(queryString);
|
2018-02-18 07:25:23 +09:00
|
|
|
defaultUrl = m ? decodeURIComponent(m[2]) : '';
|
2016-04-02 00:29:44 +09:00
|
|
|
|
2016-10-15 00:57:53 +09:00
|
|
|
// Example: chrome-extension://.../http://example.com/file.pdf
|
2018-02-18 07:25:23 +09:00
|
|
|
let humanReadableUrl = '/' + defaultUrl + location.hash;
|
2016-10-15 00:57:53 +09:00
|
|
|
history.replaceState(history.state, '', humanReadableUrl);
|
|
|
|
if (top === window) {
|
|
|
|
chrome.runtime.sendMessage('showPageAction');
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
|
2018-02-17 21:22:26 +09:00
|
|
|
let pdfjsWebApp, pdfjsWebAppOptions;
|
2016-10-15 00:57:53 +09:00
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
|
2017-02-09 07:32:15 +09:00
|
|
|
pdfjsWebApp = require('./app.js');
|
2018-02-17 21:22:26 +09:00
|
|
|
pdfjsWebAppOptions = require('./app_options.js');
|
2016-10-15 00:57:53 +09:00
|
|
|
}
|
2016-06-24 07:57:30 +09:00
|
|
|
|
2016-10-15 00:57:53 +09:00
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
|
2017-04-21 00:15:02 +09:00
|
|
|
require('./firefoxcom.js');
|
2017-02-09 07:32:15 +09:00
|
|
|
require('./firefox_print_service.js');
|
|
|
|
}
|
2017-04-17 08:55:45 +09:00
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
|
|
|
|
require('./genericcom.js');
|
|
|
|
}
|
2017-02-09 07:32:15 +09:00
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
|
|
|
require('./chromecom.js');
|
|
|
|
}
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME || GENERIC')) {
|
|
|
|
require('./pdf_print_service.js');
|
2016-10-15 00:57:53 +09:00
|
|
|
}
|
2016-06-24 07:57:30 +09:00
|
|
|
|
2016-04-22 01:39:11 +09:00
|
|
|
function getViewerConfiguration() {
|
|
|
|
return {
|
|
|
|
appContainer: document.body,
|
|
|
|
mainContainer: document.getElementById('viewerContainer'),
|
2016-12-11 05:17:11 +09:00
|
|
|
viewerContainer: document.getElementById('viewer'),
|
2018-09-21 03:51:50 +09:00
|
|
|
eventBus: null, // Using global event bus with (optional) DOM events.
|
2016-04-22 01:39:11 +09:00
|
|
|
toolbar: {
|
2016-04-29 05:04:09 +09:00
|
|
|
container: document.getElementById('toolbarViewer'),
|
2016-04-22 01:39:11 +09:00
|
|
|
numPages: document.getElementById('numPages'),
|
|
|
|
pageNumber: document.getElementById('pageNumber'),
|
|
|
|
scaleSelectContainer: document.getElementById('scaleSelectContainer'),
|
|
|
|
scaleSelect: document.getElementById('scaleSelect'),
|
|
|
|
customScaleOption: document.getElementById('customScaleOption'),
|
|
|
|
previous: document.getElementById('previous'),
|
|
|
|
next: document.getElementById('next'),
|
|
|
|
zoomIn: document.getElementById('zoomIn'),
|
|
|
|
zoomOut: document.getElementById('zoomOut'),
|
|
|
|
viewFind: document.getElementById('viewFind'),
|
|
|
|
openFile: document.getElementById('openFile'),
|
|
|
|
print: document.getElementById('print'),
|
|
|
|
presentationModeButton: document.getElementById('presentationMode'),
|
|
|
|
download: document.getElementById('download'),
|
|
|
|
viewBookmark: document.getElementById('viewBookmark'),
|
|
|
|
},
|
|
|
|
secondaryToolbar: {
|
|
|
|
toolbar: document.getElementById('secondaryToolbar'),
|
|
|
|
toggleButton: document.getElementById('secondaryToolbarToggle'),
|
2016-09-08 19:35:49 +09:00
|
|
|
toolbarButtonContainer:
|
|
|
|
document.getElementById('secondaryToolbarButtonContainer'),
|
2016-04-22 01:39:11 +09:00
|
|
|
presentationModeButton:
|
|
|
|
document.getElementById('secondaryPresentationMode'),
|
2016-05-11 08:31:03 +09:00
|
|
|
openFileButton: document.getElementById('secondaryOpenFile'),
|
|
|
|
printButton: document.getElementById('secondaryPrint'),
|
|
|
|
downloadButton: document.getElementById('secondaryDownload'),
|
|
|
|
viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
|
|
|
|
firstPageButton: document.getElementById('firstPage'),
|
|
|
|
lastPageButton: document.getElementById('lastPage'),
|
|
|
|
pageRotateCwButton: document.getElementById('pageRotateCw'),
|
|
|
|
pageRotateCcwButton: document.getElementById('pageRotateCcw'),
|
2016-09-07 20:30:26 +09:00
|
|
|
cursorSelectToolButton: document.getElementById('cursorSelectTool'),
|
|
|
|
cursorHandToolButton: document.getElementById('cursorHandTool'),
|
2018-05-15 12:10:32 +09:00
|
|
|
scrollVerticalButton: document.getElementById('scrollVertical'),
|
|
|
|
scrollHorizontalButton: document.getElementById('scrollHorizontal'),
|
|
|
|
scrollWrappedButton: document.getElementById('scrollWrapped'),
|
2018-05-15 12:10:32 +09:00
|
|
|
spreadNoneButton: document.getElementById('spreadNone'),
|
|
|
|
spreadOddButton: document.getElementById('spreadOdd'),
|
|
|
|
spreadEvenButton: document.getElementById('spreadEven'),
|
2016-04-22 01:39:11 +09:00
|
|
|
documentPropertiesButton: document.getElementById('documentProperties'),
|
|
|
|
},
|
|
|
|
fullscreen: {
|
|
|
|
contextFirstPage: document.getElementById('contextFirstPage'),
|
|
|
|
contextLastPage: document.getElementById('contextLastPage'),
|
|
|
|
contextPageRotateCw: document.getElementById('contextPageRotateCw'),
|
|
|
|
contextPageRotateCcw: document.getElementById('contextPageRotateCcw'),
|
|
|
|
},
|
|
|
|
sidebar: {
|
|
|
|
// Divs (and sidebar button)
|
|
|
|
outerContainer: document.getElementById('outerContainer'),
|
2017-09-30 23:41:46 +09:00
|
|
|
viewerContainer: document.getElementById('viewerContainer'),
|
2016-04-22 01:39:11 +09:00
|
|
|
toggleButton: document.getElementById('sidebarToggle'),
|
|
|
|
// Buttons
|
|
|
|
thumbnailButton: document.getElementById('viewThumbnail'),
|
|
|
|
outlineButton: document.getElementById('viewOutline'),
|
|
|
|
attachmentsButton: document.getElementById('viewAttachments'),
|
|
|
|
// Views
|
|
|
|
thumbnailView: document.getElementById('thumbnailView'),
|
|
|
|
outlineView: document.getElementById('outlineView'),
|
|
|
|
attachmentsView: document.getElementById('attachmentsView'),
|
|
|
|
},
|
Implement sidebar resizing for modern browsers, by utilizing CSS variables (issue 2072)
By making use of modern CSS features, in this case [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables), implementing sidebar resizing is actually quite simple. Not only will the amount of added code be fairly small, but it should also be easy to maintain since there's no need for complicated JavaScript hacks in order to update the CSS. Another benefit is that the JavaScript code doesn't need to make detailed assumptions about the exact structure of the HTML/CSS code.
Obviously this will not work in older browsers, such as IE, that lack support for CSS variables. In those cases sidebar resizing is simply disabled (via feature detection), and the resizing DOM element hidden, and the behaviour is thus *identical* to the current (fixed-width) sidebar.
However, considering the simplicity of the implementation, I really don't see why limiting this feature to "modern" browsers is a problem.
Finally, note that a few edge-cases meant that the patch is a bit larger than what the basic functionality would dictate. Among those is first of all proper RTL support, and secondly (automatic) resizing of the sidebar when the width of the *entire* viewer changes. Another, pre-existing, issue fixed here is the incomplete interface of `NullL10n`.
*Please note:* This patch has been successfully tested in both LTR and RTL viewer locales, in recent versions of Firefox and Chrome.
Fixes 2072.
2017-10-10 23:16:05 +09:00
|
|
|
sidebarResizer: {
|
|
|
|
outerContainer: document.getElementById('outerContainer'),
|
|
|
|
resizer: document.getElementById('sidebarResizer'),
|
|
|
|
},
|
2016-04-22 01:39:11 +09:00
|
|
|
findBar: {
|
|
|
|
bar: document.getElementById('findbar'),
|
|
|
|
toggleButton: document.getElementById('viewFind'),
|
|
|
|
findField: document.getElementById('findInput'),
|
|
|
|
highlightAllCheckbox: document.getElementById('findHighlightAll'),
|
|
|
|
caseSensitiveCheckbox: document.getElementById('findMatchCase'),
|
2018-09-01 08:28:19 +09:00
|
|
|
entireWordCheckbox: document.getElementById('findEntireWord'),
|
2016-04-22 01:39:11 +09:00
|
|
|
findMsg: document.getElementById('findMsg'),
|
|
|
|
findResultsCount: document.getElementById('findResultsCount'),
|
|
|
|
findPreviousButton: document.getElementById('findPrevious'),
|
Fix inconsistent spacing and trailing commas in objects in `web/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 002dbf29..1de4e530 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -420,8 +420,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
setPageLabel: function PDFThumbnailView_setPageLabel(label) {
this.pageLabel = (typeof label === 'string' ? label : null);
- this.l10n.get('thumb_page_title', { page: this.pageId, }, 'Page {{page}}').
- then((msg) => {
+ this.l10n.get('thumb_page_title', { page: this.pageId, },
+ 'Page {{page}}').then((msg) => {
this.anchor.title = msg;
});
diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js
index 160e0410..6495fc5e 100644
--- a/web/secondary_toolbar.js
+++ b/web/secondary_toolbar.js
@@ -65,7 +65,8 @@ class SecondaryToolbar {
{ element: options.printButton, eventName: 'print', close: true, },
{ element: options.downloadButton, eventName: 'download', close: true, },
{ element: options.viewBookmarkButton, eventName: null, close: true, },
- { element: options.firstPageButton, eventName: 'firstpage', close: true, },
+ { element: options.firstPageButton, eventName: 'firstpage',
+ close: true, },
{ element: options.lastPageButton, eventName: 'lastpage', close: true, },
{ element: options.pageRotateCwButton, eventName: 'rotatecw',
close: false, },
@@ -76,7 +77,7 @@ class SecondaryToolbar {
{ element: options.cursorHandToolButton, eventName: 'switchcursortool',
eventDetails: { tool: CursorTool.HAND, }, close: true, },
{ element: options.documentPropertiesButton,
- eventName: 'documentproperties', close: true, }
+ eventName: 'documentproperties', close: true, },
];
this.items = {
firstPage: options.firstPageButton,
```
2017-06-01 19:46:12 +09:00
|
|
|
findNextButton: document.getElementById('findNext'),
|
2016-04-22 01:39:11 +09:00
|
|
|
},
|
|
|
|
passwordOverlay: {
|
|
|
|
overlayName: 'passwordOverlay',
|
|
|
|
container: document.getElementById('passwordOverlay'),
|
|
|
|
label: document.getElementById('passwordText'),
|
|
|
|
input: document.getElementById('password'),
|
|
|
|
submitButton: document.getElementById('passwordSubmit'),
|
Fix inconsistent spacing and trailing commas in objects in `web/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 002dbf29..1de4e530 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -420,8 +420,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
setPageLabel: function PDFThumbnailView_setPageLabel(label) {
this.pageLabel = (typeof label === 'string' ? label : null);
- this.l10n.get('thumb_page_title', { page: this.pageId, }, 'Page {{page}}').
- then((msg) => {
+ this.l10n.get('thumb_page_title', { page: this.pageId, },
+ 'Page {{page}}').then((msg) => {
this.anchor.title = msg;
});
diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js
index 160e0410..6495fc5e 100644
--- a/web/secondary_toolbar.js
+++ b/web/secondary_toolbar.js
@@ -65,7 +65,8 @@ class SecondaryToolbar {
{ element: options.printButton, eventName: 'print', close: true, },
{ element: options.downloadButton, eventName: 'download', close: true, },
{ element: options.viewBookmarkButton, eventName: null, close: true, },
- { element: options.firstPageButton, eventName: 'firstpage', close: true, },
+ { element: options.firstPageButton, eventName: 'firstpage',
+ close: true, },
{ element: options.lastPageButton, eventName: 'lastpage', close: true, },
{ element: options.pageRotateCwButton, eventName: 'rotatecw',
close: false, },
@@ -76,7 +77,7 @@ class SecondaryToolbar {
{ element: options.cursorHandToolButton, eventName: 'switchcursortool',
eventDetails: { tool: CursorTool.HAND, }, close: true, },
{ element: options.documentPropertiesButton,
- eventName: 'documentproperties', close: true, }
+ eventName: 'documentproperties', close: true, },
];
this.items = {
firstPage: options.firstPageButton,
```
2017-06-01 19:46:12 +09:00
|
|
|
cancelButton: document.getElementById('passwordCancel'),
|
2016-04-22 01:39:11 +09:00
|
|
|
},
|
|
|
|
documentProperties: {
|
|
|
|
overlayName: 'documentPropertiesOverlay',
|
|
|
|
container: document.getElementById('documentPropertiesOverlay'),
|
|
|
|
closeButton: document.getElementById('documentPropertiesClose'),
|
|
|
|
fields: {
|
|
|
|
'fileName': document.getElementById('fileNameField'),
|
|
|
|
'fileSize': document.getElementById('fileSizeField'),
|
|
|
|
'title': document.getElementById('titleField'),
|
|
|
|
'author': document.getElementById('authorField'),
|
|
|
|
'subject': document.getElementById('subjectField'),
|
|
|
|
'keywords': document.getElementById('keywordsField'),
|
|
|
|
'creationDate': document.getElementById('creationDateField'),
|
|
|
|
'modificationDate': document.getElementById('modificationDateField'),
|
|
|
|
'creator': document.getElementById('creatorField'),
|
|
|
|
'producer': document.getElementById('producerField'),
|
|
|
|
'version': document.getElementById('versionField'),
|
Fix inconsistent spacing and trailing commas in objects in `web/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 002dbf29..1de4e530 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -420,8 +420,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
setPageLabel: function PDFThumbnailView_setPageLabel(label) {
this.pageLabel = (typeof label === 'string' ? label : null);
- this.l10n.get('thumb_page_title', { page: this.pageId, }, 'Page {{page}}').
- then((msg) => {
+ this.l10n.get('thumb_page_title', { page: this.pageId, },
+ 'Page {{page}}').then((msg) => {
this.anchor.title = msg;
});
diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js
index 160e0410..6495fc5e 100644
--- a/web/secondary_toolbar.js
+++ b/web/secondary_toolbar.js
@@ -65,7 +65,8 @@ class SecondaryToolbar {
{ element: options.printButton, eventName: 'print', close: true, },
{ element: options.downloadButton, eventName: 'download', close: true, },
{ element: options.viewBookmarkButton, eventName: null, close: true, },
- { element: options.firstPageButton, eventName: 'firstpage', close: true, },
+ { element: options.firstPageButton, eventName: 'firstpage',
+ close: true, },
{ element: options.lastPageButton, eventName: 'lastpage', close: true, },
{ element: options.pageRotateCwButton, eventName: 'rotatecw',
close: false, },
@@ -76,7 +77,7 @@ class SecondaryToolbar {
{ element: options.cursorHandToolButton, eventName: 'switchcursortool',
eventDetails: { tool: CursorTool.HAND, }, close: true, },
{ element: options.documentPropertiesButton,
- eventName: 'documentproperties', close: true, }
+ eventName: 'documentproperties', close: true, },
];
this.items = {
firstPage: options.firstPageButton,
```
2017-06-01 19:46:12 +09:00
|
|
|
'pageCount': document.getElementById('pageCountField'),
|
2018-03-20 21:51:56 +09:00
|
|
|
'pageSize': document.getElementById('pageSizeField'),
|
2018-07-24 23:24:30 +09:00
|
|
|
'linearized': document.getElementById('linearizedField'),
|
Fix inconsistent spacing and trailing commas in objects in `web/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 002dbf29..1de4e530 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -420,8 +420,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
setPageLabel: function PDFThumbnailView_setPageLabel(label) {
this.pageLabel = (typeof label === 'string' ? label : null);
- this.l10n.get('thumb_page_title', { page: this.pageId, }, 'Page {{page}}').
- then((msg) => {
+ this.l10n.get('thumb_page_title', { page: this.pageId, },
+ 'Page {{page}}').then((msg) => {
this.anchor.title = msg;
});
diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js
index 160e0410..6495fc5e 100644
--- a/web/secondary_toolbar.js
+++ b/web/secondary_toolbar.js
@@ -65,7 +65,8 @@ class SecondaryToolbar {
{ element: options.printButton, eventName: 'print', close: true, },
{ element: options.downloadButton, eventName: 'download', close: true, },
{ element: options.viewBookmarkButton, eventName: null, close: true, },
- { element: options.firstPageButton, eventName: 'firstpage', close: true, },
+ { element: options.firstPageButton, eventName: 'firstpage',
+ close: true, },
{ element: options.lastPageButton, eventName: 'lastpage', close: true, },
{ element: options.pageRotateCwButton, eventName: 'rotatecw',
close: false, },
@@ -76,7 +77,7 @@ class SecondaryToolbar {
{ element: options.cursorHandToolButton, eventName: 'switchcursortool',
eventDetails: { tool: CursorTool.HAND, }, close: true, },
{ element: options.documentPropertiesButton,
- eventName: 'documentproperties', close: true, }
+ eventName: 'documentproperties', close: true, },
];
this.items = {
firstPage: options.firstPageButton,
```
2017-06-01 19:46:12 +09:00
|
|
|
},
|
2016-04-22 01:39:11 +09:00
|
|
|
},
|
|
|
|
errorWrapper: {
|
|
|
|
container: document.getElementById('errorWrapper'),
|
|
|
|
errorMessage: document.getElementById('errorMessage'),
|
|
|
|
closeButton: document.getElementById('errorClose'),
|
|
|
|
errorMoreInfo: document.getElementById('errorMoreInfo'),
|
|
|
|
moreInfoButton: document.getElementById('errorShowMore'),
|
|
|
|
lessInfoButton: document.getElementById('errorShowLess'),
|
|
|
|
},
|
|
|
|
printContainer: document.getElementById('printContainer'),
|
|
|
|
openFileInputName: 'fileInput',
|
2016-05-10 08:18:43 +09:00
|
|
|
debuggerScriptPath: './debugger.js',
|
2016-04-22 01:39:11 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-04-02 00:29:44 +09:00
|
|
|
function webViewerLoad() {
|
2017-06-29 19:14:26 +09:00
|
|
|
let config = getViewerConfiguration();
|
2016-10-15 00:57:53 +09:00
|
|
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
2017-04-17 08:55:45 +09:00
|
|
|
Promise.all([
|
|
|
|
SystemJS.import('pdfjs-web/app'),
|
2018-02-17 21:22:26 +09:00
|
|
|
SystemJS.import('pdfjs-web/app_options'),
|
2017-04-17 08:55:45 +09:00
|
|
|
SystemJS.import('pdfjs-web/genericcom'),
|
|
|
|
SystemJS.import('pdfjs-web/pdf_print_service'),
|
2018-02-17 21:22:26 +09:00
|
|
|
]).then(function([app, appOptions, ...otherModules]) {
|
2017-02-10 00:53:52 +09:00
|
|
|
window.PDFViewerApplication = app.PDFViewerApplication;
|
2018-02-17 21:22:26 +09:00
|
|
|
window.PDFViewerApplicationOptions = appOptions.AppOptions;
|
2017-02-10 00:53:52 +09:00
|
|
|
app.PDFViewerApplication.run(config);
|
2016-06-29 22:18:12 +09:00
|
|
|
});
|
2016-10-15 00:57:53 +09:00
|
|
|
} else {
|
2018-02-18 07:25:23 +09:00
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
|
|
|
pdfjsWebAppOptions.AppOptions.set('defaultUrl', defaultUrl);
|
|
|
|
}
|
|
|
|
|
2017-02-09 07:32:15 +09:00
|
|
|
window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
|
2018-02-17 21:22:26 +09:00
|
|
|
window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
|
2018-11-29 19:32:48 +09:00
|
|
|
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
|
|
|
|
// Give custom implementations of the default viewer a simpler way to
|
|
|
|
// set various `AppOptions`, by dispatching an event once all viewer
|
|
|
|
// files are loaded but *before* the viewer initialization has run.
|
|
|
|
const event = document.createEvent('CustomEvent');
|
|
|
|
event.initCustomEvent('webviewerloaded', true, true, {});
|
|
|
|
document.dispatchEvent(event);
|
|
|
|
}
|
|
|
|
|
2017-02-09 07:32:15 +09:00
|
|
|
pdfjsWebApp.PDFViewerApplication.run(config);
|
2016-10-15 00:57:53 +09:00
|
|
|
}
|
2016-04-02 00:29:44 +09:00
|
|
|
}
|
|
|
|
|
2017-01-10 23:49:08 +09:00
|
|
|
if (document.readyState === 'interactive' ||
|
|
|
|
document.readyState === 'complete') {
|
|
|
|
webViewerLoad();
|
|
|
|
} else {
|
|
|
|
document.addEventListener('DOMContentLoaded', webViewerLoad, true);
|
|
|
|
}
|