Renames and refactors PDFView to PDFViewerApplication.
This commit is contained in:
parent
a89bba35b2
commit
44779f14b0
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* globals chrome, PDFJS, PDFView */
|
/* globals chrome, PDFJS, PDFViewerApplication */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ChromeCom = (function ChromeComClosure() {
|
var ChromeCom = (function ChromeComClosure() {
|
||||||
@ -64,10 +64,10 @@ var ChromeCom = (function ChromeComClosure() {
|
|||||||
var streamUrl = response.streamUrl;
|
var streamUrl = response.streamUrl;
|
||||||
if (streamUrl) {
|
if (streamUrl) {
|
||||||
console.log('Found data stream for ' + file);
|
console.log('Found data stream for ' + file);
|
||||||
PDFView.open(streamUrl, 0, undefined, undefined, {
|
PDFViewerApplication.open(streamUrl, 0, undefined, undefined, {
|
||||||
length: response.contentLength
|
length: response.contentLength
|
||||||
});
|
});
|
||||||
PDFView.setTitleUsingUrl(file);
|
PDFViewerApplication.setTitleUsingUrl(file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isFTPFile && !response.extensionSupportsFTP) {
|
if (isFTPFile && !response.extensionSupportsFTP) {
|
||||||
@ -91,7 +91,7 @@ var ChromeCom = (function ChromeComClosure() {
|
|||||||
resolveLocalFileSystemURL(file, function onResolvedFSURL(fileEntry) {
|
resolveLocalFileSystemURL(file, function onResolvedFSURL(fileEntry) {
|
||||||
fileEntry.file(function(fileObject) {
|
fileEntry.file(function(fileObject) {
|
||||||
var blobUrl = URL.createObjectURL(fileObject);
|
var blobUrl = URL.createObjectURL(fileObject);
|
||||||
PDFView.open(blobUrl, 0, undefined, undefined, {
|
PDFViewerApplication.open(blobUrl, 0, undefined, undefined, {
|
||||||
length: fileObject.size
|
length: fileObject.size
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -100,11 +100,11 @@ var ChromeCom = (function ChromeComClosure() {
|
|||||||
// usual way of getting the File's data (via the Web worker).
|
// usual way of getting the File's data (via the Web worker).
|
||||||
console.warn('Cannot resolve file ' + file + ', ' + error.name + ' ' +
|
console.warn('Cannot resolve file ' + file + ', ' + error.name + ' ' +
|
||||||
error.message);
|
error.message);
|
||||||
PDFView.open(file, 0);
|
PDFViewerApplication.open(file, 0);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFView.open(file, 0);
|
PDFViewerApplication.open(file, 0);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return ChromeCom;
|
return ChromeCom;
|
||||||
|
@ -14,20 +14,18 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFView, DownloadManager, getFileName */
|
/* globals DownloadManager, getFileName */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var DocumentAttachmentsView = function documentAttachmentsView(attachments) {
|
var DocumentAttachmentsView = function documentAttachmentsView(options) {
|
||||||
var attachmentsView = document.getElementById('attachmentsView');
|
var attachments = options.attachments;
|
||||||
|
var attachmentsView = options.attachmentsView;
|
||||||
while (attachmentsView.firstChild) {
|
while (attachmentsView.firstChild) {
|
||||||
attachmentsView.removeChild(attachmentsView.firstChild);
|
attachmentsView.removeChild(attachmentsView.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attachments) {
|
if (!attachments) {
|
||||||
if (!attachmentsView.classList.contains('hidden')) {
|
|
||||||
PDFView.switchSidebarView('thumbs');
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,27 +14,26 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFView */
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var DocumentOutlineView = function documentOutlineView(outline) {
|
var DocumentOutlineView = function documentOutlineView(options) {
|
||||||
var outlineView = document.getElementById('outlineView');
|
var outline = options.outline;
|
||||||
|
var outlineView = options.outlineView;
|
||||||
while (outlineView.firstChild) {
|
while (outlineView.firstChild) {
|
||||||
outlineView.removeChild(outlineView.firstChild);
|
outlineView.removeChild(outlineView.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!outline) {
|
if (!outline) {
|
||||||
if (!outlineView.classList.contains('hidden')) {
|
|
||||||
PDFView.switchSidebarView('thumbs');
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var linkService = options.linkService;
|
||||||
|
|
||||||
function bindItemLink(domObj, item) {
|
function bindItemLink(domObj, item) {
|
||||||
domObj.href = PDFView.getDestinationHash(item.dest);
|
domObj.href = linkService.getDestinationHash(item.dest);
|
||||||
domObj.onclick = function documentOutlineViewOnclick(e) {
|
domObj.onclick = function documentOutlineViewOnclick(e) {
|
||||||
PDFView.navigateTo(item.dest);
|
linkService.navigateTo(item.dest);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFView, Promise, mozL10n, getPDFFileNameFromURL, OverlayManager */
|
/* globals Promise, mozL10n, getPDFFileNameFromURL, OverlayManager */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -35,6 +35,8 @@ var DocumentProperties = {
|
|||||||
producerField: null,
|
producerField: null,
|
||||||
versionField: null,
|
versionField: null,
|
||||||
pageCountField: null,
|
pageCountField: null,
|
||||||
|
url: null,
|
||||||
|
pdfDocument: null,
|
||||||
|
|
||||||
initialize: function documentPropertiesInitialize(options) {
|
initialize: function documentPropertiesInitialize(options) {
|
||||||
this.overlayName = options.overlayName;
|
this.overlayName = options.overlayName;
|
||||||
@ -72,7 +74,7 @@ var DocumentProperties = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get the file size (if it hasn't already been set).
|
// Get the file size (if it hasn't already been set).
|
||||||
PDFView.pdfDocument.getDownloadInfo().then(function(data) {
|
this.pdfDocument.getDownloadInfo().then(function(data) {
|
||||||
if (data.length === this.rawFileSize) {
|
if (data.length === this.rawFileSize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -81,10 +83,10 @@ var DocumentProperties = {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
// Get the document properties.
|
// Get the document properties.
|
||||||
PDFView.pdfDocument.getMetadata().then(function(data) {
|
this.pdfDocument.getMetadata().then(function(data) {
|
||||||
var fields = [
|
var fields = [
|
||||||
{ field: this.fileNameField,
|
{ field: this.fileNameField,
|
||||||
content: getPDFFileNameFromURL(PDFView.url) },
|
content: getPDFFileNameFromURL(this.url) },
|
||||||
{ field: this.fileSizeField, content: this.parseFileSize() },
|
{ field: this.fileSizeField, content: this.parseFileSize() },
|
||||||
{ field: this.titleField, content: data.info.Title },
|
{ field: this.titleField, content: data.info.Title },
|
||||||
{ field: this.authorField, content: data.info.Author },
|
{ field: this.authorField, content: data.info.Author },
|
||||||
@ -97,7 +99,7 @@ var DocumentProperties = {
|
|||||||
{ field: this.creatorField, content: data.info.Creator },
|
{ field: this.creatorField, content: data.info.Creator },
|
||||||
{ field: this.producerField, content: data.info.Producer },
|
{ field: this.producerField, content: data.info.Producer },
|
||||||
{ field: this.versionField, content: data.info.PDFFormatVersion },
|
{ field: this.versionField, content: data.info.PDFFormatVersion },
|
||||||
{ field: this.pageCountField, content: PDFView.pdfDocument.numPages }
|
{ field: this.pageCountField, content: this.pdfDocument.numPages }
|
||||||
];
|
];
|
||||||
|
|
||||||
// Show the properties in the dialog.
|
// Show the properties in the dialog.
|
||||||
|
@ -43,6 +43,10 @@ IPDFLinkService.prototype = {
|
|||||||
* @returns {string} The hyperlink to the PDF object.
|
* @returns {string} The hyperlink to the PDF object.
|
||||||
*/
|
*/
|
||||||
getAnchorUrl: function (hash) {},
|
getAnchorUrl: function (hash) {},
|
||||||
|
/**
|
||||||
|
* @param {string} hash
|
||||||
|
*/
|
||||||
|
setHash: function (hash) {},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFJS, PDFView, PresentationMode */
|
/* globals PDFJS, PresentationMode */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -22,12 +22,11 @@ var PDFHistory = {
|
|||||||
initialized: false,
|
initialized: false,
|
||||||
initialDestination: null,
|
initialDestination: null,
|
||||||
|
|
||||||
initialize: function pdfHistoryInitialize(fingerprint) {
|
/**
|
||||||
if (PDFJS.disableHistory || PDFView.isViewerEmbedded) {
|
* @param {string} fingerprint
|
||||||
// The browsing history is only enabled when the viewer is standalone,
|
* @param {IPDFLinkService} linkService
|
||||||
// i.e. not when it is embedded in a web page.
|
*/
|
||||||
return;
|
initialize: function pdfHistoryInitialize(fingerprint, linkService) {
|
||||||
}
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
this.reInitialized = false;
|
this.reInitialized = false;
|
||||||
this.allowHashChange = true;
|
this.allowHashChange = true;
|
||||||
@ -42,6 +41,7 @@ var PDFHistory = {
|
|||||||
this.nextHashParam = '';
|
this.nextHashParam = '';
|
||||||
|
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
|
this.linkService = linkService;
|
||||||
this.currentUid = this.uid = 0;
|
this.currentUid = this.uid = 0;
|
||||||
this.current = {};
|
this.current = {};
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ var PDFHistory = {
|
|||||||
if (state.target.dest) {
|
if (state.target.dest) {
|
||||||
this.initialDestination = state.target.dest;
|
this.initialDestination = state.target.dest;
|
||||||
} else {
|
} else {
|
||||||
PDFView.initialBookmark = state.target.hash;
|
linkService.setHash(state.target.hash);
|
||||||
}
|
}
|
||||||
this.currentUid = state.uid;
|
this.currentUid = state.uid;
|
||||||
this.uid = state.uid + 1;
|
this.uid = state.uid + 1;
|
||||||
@ -203,7 +203,7 @@ var PDFHistory = {
|
|||||||
params.hash = (this.current.hash && this.current.dest &&
|
params.hash = (this.current.hash && this.current.dest &&
|
||||||
this.current.dest === params.dest) ?
|
this.current.dest === params.dest) ?
|
||||||
this.current.hash :
|
this.current.hash :
|
||||||
PDFView.getDestinationHash(params.dest).split('#')[1];
|
this.linkService.getDestinationHash(params.dest).split('#')[1];
|
||||||
}
|
}
|
||||||
if (params.page) {
|
if (params.page) {
|
||||||
params.page |= 0;
|
params.page |= 0;
|
||||||
@ -212,7 +212,7 @@ var PDFHistory = {
|
|||||||
var target = window.history.state.target;
|
var target = window.history.state.target;
|
||||||
if (!target) {
|
if (!target) {
|
||||||
// Invoked when the user specifies an initial bookmark,
|
// Invoked when the user specifies an initial bookmark,
|
||||||
// thus setting PDFView.initialBookmark, when the document is loaded.
|
// thus setting initialBookmark, when the document is loaded.
|
||||||
this._pushToHistory(params, false);
|
this._pushToHistory(params, false);
|
||||||
this.previousHash = window.location.hash.substring(1);
|
this.previousHash = window.location.hash.substring(1);
|
||||||
}
|
}
|
||||||
@ -337,9 +337,9 @@ var PDFHistory = {
|
|||||||
this.historyUnlocked = false;
|
this.historyUnlocked = false;
|
||||||
|
|
||||||
if (state.target.dest) {
|
if (state.target.dest) {
|
||||||
PDFView.navigateTo(state.target.dest);
|
this.linkService.navigateTo(state.target.dest);
|
||||||
} else {
|
} else {
|
||||||
PDFView.setHash(state.target.hash);
|
this.linkService.setHash(state.target.hash);
|
||||||
}
|
}
|
||||||
this.currentUid = state.uid;
|
this.currentUid = state.uid;
|
||||||
if (state.uid > this.uid) {
|
if (state.uid > this.uid) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFView, scrollIntoView, HandTool */
|
/* globals scrollIntoView, HandTool, PDFViewerApplication */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ var PresentationMode = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
request: function presentationModeRequest() {
|
request: function presentationModeRequest() {
|
||||||
if (!PDFView.supportsFullscreen || this.isFullscreen ||
|
if (!PDFViewerApplication.supportsFullscreen || this.isFullscreen ||
|
||||||
!this.viewer.hasChildNodes()) {
|
!this.viewer.hasChildNodes()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -113,8 +113,8 @@ var PresentationMode = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.args = {
|
this.args = {
|
||||||
page: PDFView.page,
|
page: PDFViewerApplication.page,
|
||||||
previousScale: PDFView.currentScaleValue
|
previousScale: PDFViewerApplication.currentScaleValue
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -138,8 +138,8 @@ var PresentationMode = {
|
|||||||
// Presentation Mode, by waiting until fullscreen mode in enabled.
|
// Presentation Mode, by waiting until fullscreen mode in enabled.
|
||||||
// Note: This is only necessary in non-Mozilla browsers.
|
// Note: This is only necessary in non-Mozilla browsers.
|
||||||
setTimeout(function enterPresentationModeTimeout() {
|
setTimeout(function enterPresentationModeTimeout() {
|
||||||
PDFView.page = this.args.page;
|
PDFViewerApplication.page = this.args.page;
|
||||||
PDFView.setScale('page-fit', true);
|
PDFViewerApplication.setScale('page-fit', true);
|
||||||
}.bind(this), 0);
|
}.bind(this), 0);
|
||||||
|
|
||||||
window.addEventListener('mousemove', this.mouseMove, false);
|
window.addEventListener('mousemove', this.mouseMove, false);
|
||||||
@ -153,7 +153,7 @@ var PresentationMode = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
exit: function presentationModeExit() {
|
exit: function presentationModeExit() {
|
||||||
var page = PDFView.page;
|
var page = PDFViewerApplication.page;
|
||||||
|
|
||||||
// Ensure that the correct page is scrolled into view when exiting
|
// Ensure that the correct page is scrolled into view when exiting
|
||||||
// Presentation Mode, by waiting until fullscreen mode is disabled.
|
// Presentation Mode, by waiting until fullscreen mode is disabled.
|
||||||
@ -162,8 +162,8 @@ var PresentationMode = {
|
|||||||
this.active = false;
|
this.active = false;
|
||||||
this._notifyStateChange();
|
this._notifyStateChange();
|
||||||
|
|
||||||
PDFView.setScale(this.args.previousScale, true);
|
PDFViewerApplication.setScale(this.args.previousScale, true);
|
||||||
PDFView.page = page;
|
PDFViewerApplication.page = page;
|
||||||
this.args = null;
|
this.args = null;
|
||||||
}.bind(this), 0);
|
}.bind(this), 0);
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ var PresentationMode = {
|
|||||||
window.removeEventListener('contextmenu', this.contextMenu, false);
|
window.removeEventListener('contextmenu', this.contextMenu, false);
|
||||||
|
|
||||||
this.hideControls();
|
this.hideControls();
|
||||||
PDFView.clearMouseScrollState();
|
PDFViewerApplication.clearMouseScrollState();
|
||||||
HandTool.exitPresentationMode();
|
HandTool.exitPresentationMode();
|
||||||
this.container.removeAttribute('contextmenu');
|
this.container.removeAttribute('contextmenu');
|
||||||
this.contextMenuOpen = false;
|
this.contextMenuOpen = false;
|
||||||
@ -236,7 +236,7 @@ var PresentationMode = {
|
|||||||
if (!isInternalLink) {
|
if (!isInternalLink) {
|
||||||
// Unless an internal link was clicked, advance one page.
|
// Unless an internal link was clicked, advance one page.
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
PDFView.page += (evt.shiftKey ? -1 : 1);
|
PDFViewerApplication.page += (evt.shiftKey ? -1 : 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFView, SCROLLBAR_PADDING */
|
/* globals PDFViewerApplication, SCROLLBAR_PADDING */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ var SecondaryToolbar = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
downloadClick: function secondaryToolbarDownloadClick(evt) {
|
downloadClick: function secondaryToolbarDownloadClick(evt) {
|
||||||
PDFView.download();
|
PDFViewerApplication.download();
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -96,23 +96,23 @@ var SecondaryToolbar = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
firstPageClick: function secondaryToolbarFirstPageClick(evt) {
|
firstPageClick: function secondaryToolbarFirstPageClick(evt) {
|
||||||
PDFView.page = 1;
|
PDFViewerApplication.page = 1;
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
lastPageClick: function secondaryToolbarLastPageClick(evt) {
|
lastPageClick: function secondaryToolbarLastPageClick(evt) {
|
||||||
if (PDFView.pdfDocument) {
|
if (PDFViewerApplication.pdfDocument) {
|
||||||
PDFView.page = PDFView.pdfDocument.numPages;
|
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
||||||
}
|
}
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
pageRotateCwClick: function secondaryToolbarPageRotateCwClick(evt) {
|
pageRotateCwClick: function secondaryToolbarPageRotateCwClick(evt) {
|
||||||
PDFView.rotatePages(90);
|
PDFViewerApplication.rotatePages(90);
|
||||||
},
|
},
|
||||||
|
|
||||||
pageRotateCcwClick: function secondaryToolbarPageRotateCcwClick(evt) {
|
pageRotateCcwClick: function secondaryToolbarPageRotateCcwClick(evt) {
|
||||||
PDFView.rotatePages(-90);
|
PDFViewerApplication.rotatePages(-90);
|
||||||
},
|
},
|
||||||
|
|
||||||
documentPropertiesClick: function secondaryToolbarDocumentPropsClick(evt) {
|
documentPropertiesClick: function secondaryToolbarDocumentPropsClick(evt) {
|
||||||
|
305
web/viewer.js
305
web/viewer.js
@ -85,7 +85,7 @@ var mozL10n = document.mozL10n || document.webL10n;
|
|||||||
//#include document_properties.js
|
//#include document_properties.js
|
||||||
//#include pdf_viewer.js
|
//#include pdf_viewer.js
|
||||||
|
|
||||||
var PDFView = {
|
var PDFViewerApplication = {
|
||||||
initialBookmark: document.location.hash.substring(1),
|
initialBookmark: document.location.hash.substring(1),
|
||||||
initialized: false,
|
initialized: false,
|
||||||
fellback: false,
|
fellback: false,
|
||||||
@ -100,6 +100,8 @@ var PDFView = {
|
|||||||
pdfRenderingQueue: null,
|
pdfRenderingQueue: null,
|
||||||
pageRotation: 0,
|
pageRotation: 0,
|
||||||
updateScaleControls: true,
|
updateScaleControls: true,
|
||||||
|
isInitialViewSet: false,
|
||||||
|
animationStartedPromise: null,
|
||||||
mouseScrollTimeStamp: 0,
|
mouseScrollTimeStamp: 0,
|
||||||
mouseScrollDelta: 0,
|
mouseScrollDelta: 0,
|
||||||
isViewerEmbedded: (window.parent !== window),
|
isViewerEmbedded: (window.parent !== window),
|
||||||
@ -247,7 +249,7 @@ var PDFView = {
|
|||||||
]).catch(function (reason) { });
|
]).catch(function (reason) { });
|
||||||
|
|
||||||
return initializedPromise.then(function () {
|
return initializedPromise.then(function () {
|
||||||
PDFView.initialized = true;
|
PDFViewerApplication.initialized = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -418,7 +420,8 @@ var PDFView = {
|
|||||||
}
|
}
|
||||||
switch (args.pdfjsLoadAction) {
|
switch (args.pdfjsLoadAction) {
|
||||||
case 'supportsRangedLoading':
|
case 'supportsRangedLoading':
|
||||||
PDFView.open(args.pdfUrl, 0, undefined, pdfDataRangeTransport, {
|
PDFViewerApplication.open(args.pdfUrl, 0, undefined,
|
||||||
|
pdfDataRangeTransport, {
|
||||||
length: args.length,
|
length: args.length,
|
||||||
initialData: args.data
|
initialData: args.data
|
||||||
});
|
});
|
||||||
@ -430,15 +433,15 @@ var PDFView = {
|
|||||||
pdfDataRangeTransport.onDataProgress(args.loaded);
|
pdfDataRangeTransport.onDataProgress(args.loaded);
|
||||||
break;
|
break;
|
||||||
case 'progress':
|
case 'progress':
|
||||||
PDFView.progress(args.loaded / args.total);
|
PDFViewerApplication.progress(args.loaded / args.total);
|
||||||
break;
|
break;
|
||||||
case 'complete':
|
case 'complete':
|
||||||
if (!args.data) {
|
if (!args.data) {
|
||||||
PDFView.error(mozL10n.get('loading_error', null,
|
PDFViewerApplication.error(mozL10n.get('loading_error', null,
|
||||||
'An error occurred while loading the PDF.'), e);
|
'An error occurred while loading the PDF.'), e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PDFView.open(args.data, 0);
|
PDFViewerApplication.open(args.data, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -574,7 +577,7 @@ var PDFView = {
|
|||||||
downloadManager.onerror = function (err) {
|
downloadManager.onerror = function (err) {
|
||||||
// This error won't really be helpful because it's likely the
|
// This error won't really be helpful because it's likely the
|
||||||
// fallback won't work either (or is already open).
|
// fallback won't work either (or is already open).
|
||||||
PDFView.error('PDF failed to download.');
|
PDFViewerApplication.error('PDF failed to download.');
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.pdfDocument) { // the PDF is not ready yet
|
if (!this.pdfDocument) { // the PDF is not ready yet
|
||||||
@ -611,7 +614,7 @@ var PDFView = {
|
|||||||
// if (!download) {
|
// if (!download) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// PDFView.download();
|
// PDFViewerApplication.download();
|
||||||
// });
|
// });
|
||||||
//#endif
|
//#endif
|
||||||
},
|
},
|
||||||
@ -672,25 +675,25 @@ var PDFView = {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Find':
|
case 'Find':
|
||||||
if (!PDFView.supportsIntegratedFind) {
|
if (!this.supportsIntegratedFind) {
|
||||||
PDFView.findBar.toggle();
|
this.findBar.toggle();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'NextPage':
|
case 'NextPage':
|
||||||
PDFView.page++;
|
this.page++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PrevPage':
|
case 'PrevPage':
|
||||||
PDFView.page--;
|
this.page--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'LastPage':
|
case 'LastPage':
|
||||||
PDFView.page = PDFView.pagesCount;
|
this.page = this.pagesCount;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'FirstPage':
|
case 'FirstPage':
|
||||||
PDFView.page = 1;
|
this.page = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -700,7 +703,7 @@ var PDFView = {
|
|||||||
|
|
||||||
getDestinationHash: function pdfViewGetDestinationHash(dest) {
|
getDestinationHash: function pdfViewGetDestinationHash(dest) {
|
||||||
if (typeof dest === 'string') {
|
if (typeof dest === 'string') {
|
||||||
return PDFView.getAnchorUrl('#' + escape(dest));
|
return this.getAnchorUrl('#' + escape(dest));
|
||||||
}
|
}
|
||||||
if (dest instanceof Array) {
|
if (dest instanceof Array) {
|
||||||
var destRef = dest[0]; // see navigateTo method for dest format
|
var destRef = dest[0]; // see navigateTo method for dest format
|
||||||
@ -708,7 +711,7 @@ var PDFView = {
|
|||||||
this.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'] :
|
this.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'] :
|
||||||
(destRef + 1);
|
(destRef + 1);
|
||||||
if (pageNumber) {
|
if (pageNumber) {
|
||||||
var pdfOpenParams = PDFView.getAnchorUrl('#page=' + pageNumber);
|
var pdfOpenParams = this.getAnchorUrl('#page=' + pageNumber);
|
||||||
var destKind = dest[1];
|
var destKind = dest[1];
|
||||||
if (typeof destKind === 'object' && 'name' in destKind &&
|
if (typeof destKind === 'object' && 'name' in destKind &&
|
||||||
destKind.name === 'XYZ') {
|
destKind.name === 'XYZ') {
|
||||||
@ -822,8 +825,8 @@ var PDFView = {
|
|||||||
// that we discard some of the loaded data. This can cause the loading
|
// that we discard some of the loaded data. This can cause the loading
|
||||||
// bar to move backwards. So prevent this by only updating the bar if it
|
// bar to move backwards. So prevent this by only updating the bar if it
|
||||||
// increases.
|
// increases.
|
||||||
if (percent > PDFView.loadingBar.percent || isNaN(percent)) {
|
if (percent > this.loadingBar.percent || isNaN(percent)) {
|
||||||
PDFView.loadingBar.percent = percent;
|
this.loadingBar.percent = percent;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -831,15 +834,17 @@ var PDFView = {
|
|||||||
var self = this;
|
var self = this;
|
||||||
scale = scale || UNKNOWN_SCALE;
|
scale = scale || UNKNOWN_SCALE;
|
||||||
|
|
||||||
PDFView.findController.reset();
|
this.findController.reset();
|
||||||
|
|
||||||
this.pdfDocument = pdfDocument;
|
this.pdfDocument = pdfDocument;
|
||||||
|
|
||||||
|
DocumentProperties.url = this.url;
|
||||||
|
DocumentProperties.pdfDocument = pdfDocument;
|
||||||
DocumentProperties.resolveDataAvailable();
|
DocumentProperties.resolveDataAvailable();
|
||||||
|
|
||||||
var downloadedPromise = pdfDocument.getDownloadInfo().then(function() {
|
var downloadedPromise = pdfDocument.getDownloadInfo().then(function() {
|
||||||
self.downloadComplete = true;
|
self.downloadComplete = true;
|
||||||
PDFView.loadingBar.hide();
|
self.loadingBar.hide();
|
||||||
var outerContainer = document.getElementById('outerContainer');
|
var outerContainer = document.getElementById('outerContainer');
|
||||||
outerContainer.classList.remove('loadingInProgress');
|
outerContainer.classList.remove('loadingInProgress');
|
||||||
});
|
});
|
||||||
@ -851,8 +856,8 @@ var PDFView = {
|
|||||||
mozL10n.get('page_of', {pageCount: pagesCount}, 'of {{pageCount}}');
|
mozL10n.get('page_of', {pageCount: pagesCount}, 'of {{pageCount}}');
|
||||||
document.getElementById('pageNumber').max = pagesCount;
|
document.getElementById('pageNumber').max = pagesCount;
|
||||||
|
|
||||||
PDFView.documentFingerprint = id;
|
this.documentFingerprint = id;
|
||||||
var store = PDFView.store = new ViewHistory(id);
|
var store = this.store = new ViewHistory(id);
|
||||||
|
|
||||||
var pdfViewer = this.pdfViewer;
|
var pdfViewer = this.pdfViewer;
|
||||||
pdfViewer.currentScale = scale;
|
pdfViewer.currentScale = scale;
|
||||||
@ -862,6 +867,7 @@ var PDFView = {
|
|||||||
var onePageRendered = pdfViewer.onePageRendered;
|
var onePageRendered = pdfViewer.onePageRendered;
|
||||||
|
|
||||||
this.pageRotation = 0;
|
this.pageRotation = 0;
|
||||||
|
this.isInitialViewSet = false;
|
||||||
this.pagesRefMap = pdfViewer.pagesRefMap;
|
this.pagesRefMap = pdfViewer.pagesRefMap;
|
||||||
|
|
||||||
this.pdfThumbnailViewer.setDocument(pdfDocument);
|
this.pdfThumbnailViewer.setDocument(pdfDocument);
|
||||||
@ -873,12 +879,15 @@ var PDFView = {
|
|||||||
window.dispatchEvent(event);
|
window.dispatchEvent(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
PDFView.loadingBar.setWidth(document.getElementById('viewer'));
|
self.loadingBar.setWidth(document.getElementById('viewer'));
|
||||||
|
|
||||||
PDFView.findController.resolveFirstPage();
|
self.findController.resolveFirstPage();
|
||||||
|
|
||||||
// Initialize the browsing history.
|
if (!PDFJS.disableHistory && !self.isViewerEmbedded) {
|
||||||
PDFHistory.initialize(self.documentFingerprint);
|
// The browsing history is only enabled when the viewer is standalone,
|
||||||
|
// i.e. not when it is embedded in a web page.
|
||||||
|
PDFHistory.initialize(self.documentFingerprint, self);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch the necessary preference values.
|
// Fetch the necessary preference values.
|
||||||
@ -900,7 +909,7 @@ var PDFView = {
|
|||||||
if (showPreviousViewOnLoad && store.get('exists', false)) {
|
if (showPreviousViewOnLoad && store.get('exists', false)) {
|
||||||
var pageNum = store.get('page', '1');
|
var pageNum = store.get('page', '1');
|
||||||
var zoom = defaultZoomValue ||
|
var zoom = defaultZoomValue ||
|
||||||
store.get('zoom', PDFView.pdfViewer.currentScale);
|
store.get('zoom', self.pdfViewer.currentScale);
|
||||||
var left = store.get('scrollLeft', '0');
|
var left = store.get('scrollLeft', '0');
|
||||||
var top = store.get('scrollTop', '0');
|
var top = store.get('scrollTop', '0');
|
||||||
|
|
||||||
@ -928,11 +937,11 @@ var PDFView = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
pagesPromise.then(function() {
|
pagesPromise.then(function() {
|
||||||
if (PDFView.supportsPrinting) {
|
if (self.supportsPrinting) {
|
||||||
pdfDocument.getJavaScript().then(function(javaScript) {
|
pdfDocument.getJavaScript().then(function(javaScript) {
|
||||||
if (javaScript.length) {
|
if (javaScript.length) {
|
||||||
console.warn('Warning: JavaScript is not supported');
|
console.warn('Warning: JavaScript is not supported');
|
||||||
PDFView.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript);
|
self.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript);
|
||||||
}
|
}
|
||||||
// Hack to support auto printing.
|
// Hack to support auto printing.
|
||||||
var regex = /\bprint\s*\(/g;
|
var regex = /\bprint\s*\(/g;
|
||||||
@ -957,21 +966,36 @@ var PDFView = {
|
|||||||
|
|
||||||
// outline depends on destinations and pagesRefMap
|
// outline depends on destinations and pagesRefMap
|
||||||
var promises = [pagesPromise, destinationsPromise,
|
var promises = [pagesPromise, destinationsPromise,
|
||||||
PDFView.animationStartedPromise];
|
this.animationStartedPromise];
|
||||||
Promise.all(promises).then(function() {
|
Promise.all(promises).then(function() {
|
||||||
pdfDocument.getOutline().then(function(outline) {
|
pdfDocument.getOutline().then(function(outline) {
|
||||||
self.outline = new DocumentOutlineView(outline);
|
var outlineView = document.getElementById('outlineView');
|
||||||
|
self.outline = new DocumentOutlineView({
|
||||||
|
outline: outline,
|
||||||
|
outlineView: outlineView,
|
||||||
|
linkService: self
|
||||||
|
});
|
||||||
document.getElementById('viewOutline').disabled = !outline;
|
document.getElementById('viewOutline').disabled = !outline;
|
||||||
|
|
||||||
|
if (!outline && !outlineView.classList.contains('hidden')) {
|
||||||
|
self.switchSidebarView('thumbs');
|
||||||
|
}
|
||||||
if (outline &&
|
if (outline &&
|
||||||
self.preferenceSidebarViewOnLoad === SidebarView.OUTLINE) {
|
self.preferenceSidebarViewOnLoad === SidebarView.OUTLINE) {
|
||||||
self.switchSidebarView('outline', true);
|
self.switchSidebarView('outline', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pdfDocument.getAttachments().then(function(attachments) {
|
pdfDocument.getAttachments().then(function(attachments) {
|
||||||
self.attachments = new DocumentAttachmentsView(attachments);
|
var attachmentsView = document.getElementById('attachmentsView');
|
||||||
|
self.attachments = new DocumentAttachmentsView({
|
||||||
|
attachments: attachments,
|
||||||
|
attachmentsView: attachmentsView
|
||||||
|
});
|
||||||
document.getElementById('viewAttachments').disabled = !attachments;
|
document.getElementById('viewAttachments').disabled = !attachments;
|
||||||
|
|
||||||
|
if (!attachments && !attachmentsView.classList.contains('hidden')) {
|
||||||
|
self.switchSidebarView('thumbs');
|
||||||
|
}
|
||||||
if (attachments &&
|
if (attachments &&
|
||||||
self.preferenceSidebarViewOnLoad === SidebarView.ATTACHMENTS) {
|
self.preferenceSidebarViewOnLoad === SidebarView.ATTACHMENTS) {
|
||||||
self.switchSidebarView('attachments', true);
|
self.switchSidebarView('attachments', true);
|
||||||
@ -1016,7 +1040,7 @@ var PDFView = {
|
|||||||
|
|
||||||
if (info.IsAcroFormPresent) {
|
if (info.IsAcroFormPresent) {
|
||||||
console.warn('Warning: AcroForm/XFA is not supported');
|
console.warn('Warning: AcroForm/XFA is not supported');
|
||||||
PDFView.fallback(PDFJS.UNSUPPORTED_FEATURES.forms);
|
self.fallback(PDFJS.UNSUPPORTED_FEATURES.forms);
|
||||||
}
|
}
|
||||||
|
|
||||||
//#if (FIREFOX || MOZCENTRAL)
|
//#if (FIREFOX || MOZCENTRAL)
|
||||||
@ -1050,6 +1074,8 @@ var PDFView = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setInitialView: function pdfViewSetInitialView(storedHash, scale) {
|
setInitialView: function pdfViewSetInitialView(storedHash, scale) {
|
||||||
|
this.isInitialViewSet = true;
|
||||||
|
|
||||||
// When opening a new file (when one is already loaded in the viewer):
|
// When opening a new file (when one is already loaded in the viewer):
|
||||||
// Reset 'currentPageNumber', since otherwise the page's scale will be wrong
|
// Reset 'currentPageNumber', since otherwise the page's scale will be wrong
|
||||||
// if 'currentPageNumber' is larger than the number of pages in the file.
|
// if 'currentPageNumber' is larger than the number of pages in the file.
|
||||||
@ -1070,7 +1096,7 @@ var PDFView = {
|
|||||||
this.page = 1;
|
this.page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDFView.pdfViewer.currentScale === UNKNOWN_SCALE) {
|
if (this.pdfViewer.currentScale === UNKNOWN_SCALE) {
|
||||||
// Scale was not initialized: invalid bookmark or scale was not specified.
|
// Scale was not initialized: invalid bookmark or scale was not specified.
|
||||||
// Setting the default one.
|
// Setting the default one.
|
||||||
this.setScale(DEFAULT_SCALE, true);
|
this.setScale(DEFAULT_SCALE, true);
|
||||||
@ -1090,6 +1116,11 @@ var PDFView = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setHash: function pdfViewSetHash(hash) {
|
setHash: function pdfViewSetHash(hash) {
|
||||||
|
if (!this.isInitialViewSet) {
|
||||||
|
this.initialBookmark = hash;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var validFitZoomValues = ['Fit','FitB','FitH','FitBH',
|
var validFitZoomValues = ['Fit','FitB','FitH','FitBH',
|
||||||
'FitV','FitBV','FitR'];
|
'FitV','FitBV','FitR'];
|
||||||
|
|
||||||
@ -1098,11 +1129,11 @@ var PDFView = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hash.indexOf('=') >= 0) {
|
if (hash.indexOf('=') >= 0) {
|
||||||
var params = PDFView.parseQueryString(hash);
|
var params = this.parseQueryString(hash);
|
||||||
// borrowing syntax from "Parameters for Opening PDF Files"
|
// borrowing syntax from "Parameters for Opening PDF Files"
|
||||||
if ('nameddest' in params) {
|
if ('nameddest' in params) {
|
||||||
PDFHistory.updateNextHashParam(params.nameddest);
|
PDFHistory.updateNextHashParam(params.nameddest);
|
||||||
PDFView.navigateTo(params.nameddest);
|
this.navigateTo(params.nameddest);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pageNumber, dest;
|
var pageNumber, dest;
|
||||||
@ -1147,7 +1178,7 @@ var PDFView = {
|
|||||||
this.page = hash;
|
this.page = hash;
|
||||||
} else { // named destination
|
} else { // named destination
|
||||||
PDFHistory.updateNextHashParam(unescape(hash));
|
PDFHistory.updateNextHashParam(unescape(hash));
|
||||||
PDFView.navigateTo(unescape(hash));
|
this.navigateTo(unescape(hash));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1174,7 +1205,7 @@ var PDFView = {
|
|||||||
outlineView.classList.add('hidden');
|
outlineView.classList.add('hidden');
|
||||||
attachmentsView.classList.add('hidden');
|
attachmentsView.classList.add('hidden');
|
||||||
|
|
||||||
PDFView.forceRendering();
|
this.forceRendering();
|
||||||
|
|
||||||
if (wasAnotherViewVisible) {
|
if (wasAnotherViewVisible) {
|
||||||
this.pdfThumbnailViewer.ensureThumbnailVisible(this.page);
|
this.pdfThumbnailViewer.ensureThumbnailVisible(this.page);
|
||||||
@ -1363,6 +1394,9 @@ var PDFView = {
|
|||||||
this.mouseScrollDelta = 0;
|
this.mouseScrollDelta = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
//#if GENERIC
|
||||||
|
window.PDFView = PDFViewerApplication; // obsolete name, using it as an alias
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#include thumbnail_view.js
|
//#include thumbnail_view.js
|
||||||
//#include document_outline_view.js
|
//#include document_outline_view.js
|
||||||
@ -1372,7 +1406,8 @@ var PDFView = {
|
|||||||
//(function rewriteUrlClosure() {
|
//(function rewriteUrlClosure() {
|
||||||
// // Run this code outside DOMContentLoaded to make sure that the URL
|
// // Run this code outside DOMContentLoaded to make sure that the URL
|
||||||
// // is rewritten as soon as possible.
|
// // is rewritten as soon as possible.
|
||||||
// var params = PDFView.parseQueryString(document.location.search.slice(1));
|
// var queryString = document.location.search.slice(1);
|
||||||
|
// var params = PDFViewerApplication.parseQueryString(queryString);
|
||||||
// DEFAULT_URL = params.file || '';
|
// DEFAULT_URL = params.file || '';
|
||||||
//
|
//
|
||||||
// // Example: chrome-extension://.../http://example.com/file.pdf
|
// // Example: chrome-extension://.../http://example.com/file.pdf
|
||||||
@ -1385,12 +1420,13 @@ var PDFView = {
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
function webViewerLoad(evt) {
|
function webViewerLoad(evt) {
|
||||||
PDFView.initialize().then(webViewerInitialized);
|
PDFViewerApplication.initialize().then(webViewerInitialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerInitialized() {
|
function webViewerInitialized() {
|
||||||
//#if (GENERIC || B2G)
|
//#if (GENERIC || B2G)
|
||||||
var params = PDFView.parseQueryString(document.location.search.substring(1));
|
var queryString = document.location.search.substring(1);
|
||||||
|
var params = PDFViewerApplication.parseQueryString(queryString);
|
||||||
var file = 'file' in params ? params.file : DEFAULT_URL;
|
var file = 'file' in params ? params.file : DEFAULT_URL;
|
||||||
//#endif
|
//#endif
|
||||||
//#if (FIREFOX || MOZCENTRAL)
|
//#if (FIREFOX || MOZCENTRAL)
|
||||||
@ -1426,11 +1462,11 @@ function webViewerInitialized() {
|
|||||||
//#if !PRODUCTION
|
//#if !PRODUCTION
|
||||||
if (true) {
|
if (true) {
|
||||||
//#else
|
//#else
|
||||||
//if (PDFView.preferencesPdfBugEnabled) {
|
//if (PDFViewerApplication.preferencesPdfBugEnabled) {
|
||||||
//#endif
|
//#endif
|
||||||
// Special debugging flags in the hash section of the URL.
|
// Special debugging flags in the hash section of the URL.
|
||||||
var hash = document.location.hash.substring(1);
|
var hash = document.location.hash.substring(1);
|
||||||
var hashParams = PDFView.parseQueryString(hash);
|
var hashParams = PDFViewerApplication.parseQueryString(hash);
|
||||||
|
|
||||||
if ('disableworker' in hashParams) {
|
if ('disableworker' in hashParams) {
|
||||||
PDFJS.disableWorker = (hashParams['disableworker'] === 'true');
|
PDFJS.disableWorker = (hashParams['disableworker'] === 'true');
|
||||||
@ -1497,30 +1533,31 @@ function webViewerInitialized() {
|
|||||||
mozL10n.setLanguage(locale);
|
mozL10n.setLanguage(locale);
|
||||||
//#endif
|
//#endif
|
||||||
//#if (FIREFOX || MOZCENTRAL)
|
//#if (FIREFOX || MOZCENTRAL)
|
||||||
//if (!PDFView.supportsDocumentFonts) {
|
//if (!PDFViewerApplication.supportsDocumentFonts) {
|
||||||
// PDFJS.disableFontFace = true;
|
// PDFJS.disableFontFace = true;
|
||||||
// console.warn(mozL10n.get('web_fonts_disabled', null,
|
// console.warn(mozL10n.get('web_fonts_disabled', null,
|
||||||
// 'Web fonts are disabled: unable to use embedded PDF fonts.'));
|
// 'Web fonts are disabled: unable to use embedded PDF fonts.'));
|
||||||
//}
|
//}
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
if (!PDFView.supportsPrinting) {
|
if (!PDFViewerApplication.supportsPrinting) {
|
||||||
document.getElementById('print').classList.add('hidden');
|
document.getElementById('print').classList.add('hidden');
|
||||||
document.getElementById('secondaryPrint').classList.add('hidden');
|
document.getElementById('secondaryPrint').classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PDFView.supportsFullscreen) {
|
if (!PDFViewerApplication.supportsFullscreen) {
|
||||||
document.getElementById('presentationMode').classList.add('hidden');
|
document.getElementById('presentationMode').classList.add('hidden');
|
||||||
document.getElementById('secondaryPresentationMode').
|
document.getElementById('secondaryPresentationMode').
|
||||||
classList.add('hidden');
|
classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDFView.supportsIntegratedFind) {
|
if (PDFViewerApplication.supportsIntegratedFind) {
|
||||||
document.getElementById('viewFind').classList.add('hidden');
|
document.getElementById('viewFind').classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen for unsupported features to trigger the fallback UI.
|
// Listen for unsupported features to trigger the fallback UI.
|
||||||
PDFJS.UnsupportedManager.listen(PDFView.fallback.bind(PDFView));
|
PDFJS.UnsupportedManager.listen(
|
||||||
|
PDFViewerApplication.fallback.bind(PDFViewerApplication));
|
||||||
|
|
||||||
// Suppress context menus for some controls
|
// Suppress context menus for some controls
|
||||||
document.getElementById('scaleSelect').oncontextmenu = noContextMenuHandler;
|
document.getElementById('scaleSelect').oncontextmenu = noContextMenuHandler;
|
||||||
@ -1541,43 +1578,44 @@ function webViewerInitialized() {
|
|||||||
this.classList.toggle('toggled');
|
this.classList.toggle('toggled');
|
||||||
outerContainer.classList.add('sidebarMoving');
|
outerContainer.classList.add('sidebarMoving');
|
||||||
outerContainer.classList.toggle('sidebarOpen');
|
outerContainer.classList.toggle('sidebarOpen');
|
||||||
PDFView.sidebarOpen = outerContainer.classList.contains('sidebarOpen');
|
PDFViewerApplication.sidebarOpen =
|
||||||
PDFView.forceRendering();
|
outerContainer.classList.contains('sidebarOpen');
|
||||||
|
PDFViewerApplication.forceRendering();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('viewThumbnail').addEventListener('click',
|
document.getElementById('viewThumbnail').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.switchSidebarView('thumbs');
|
PDFViewerApplication.switchSidebarView('thumbs');
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('viewOutline').addEventListener('click',
|
document.getElementById('viewOutline').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.switchSidebarView('outline');
|
PDFViewerApplication.switchSidebarView('outline');
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('viewAttachments').addEventListener('click',
|
document.getElementById('viewAttachments').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.switchSidebarView('attachments');
|
PDFViewerApplication.switchSidebarView('attachments');
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('previous').addEventListener('click',
|
document.getElementById('previous').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.page--;
|
PDFViewerApplication.page--;
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('next').addEventListener('click',
|
document.getElementById('next').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.page++;
|
PDFViewerApplication.page++;
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('zoomIn').addEventListener('click',
|
document.getElementById('zoomIn').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.zoomIn();
|
PDFViewerApplication.zoomIn();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('zoomOut').addEventListener('click',
|
document.getElementById('zoomOut').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.zoomOut();
|
PDFViewerApplication.zoomOut();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('pageNumber').addEventListener('click',
|
document.getElementById('pageNumber').addEventListener('click',
|
||||||
@ -1588,16 +1626,16 @@ function webViewerInitialized() {
|
|||||||
document.getElementById('pageNumber').addEventListener('change',
|
document.getElementById('pageNumber').addEventListener('change',
|
||||||
function() {
|
function() {
|
||||||
// Handle the user inputting a floating point number.
|
// Handle the user inputting a floating point number.
|
||||||
PDFView.page = (this.value | 0);
|
PDFViewerApplication.page = (this.value | 0);
|
||||||
|
|
||||||
if (this.value !== (this.value | 0).toString()) {
|
if (this.value !== (this.value | 0).toString()) {
|
||||||
this.value = PDFView.page;
|
this.value = PDFViewerApplication.page;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('scaleSelect').addEventListener('change',
|
document.getElementById('scaleSelect').addEventListener('change',
|
||||||
function() {
|
function() {
|
||||||
PDFView.setScale(this.value, false);
|
PDFViewerApplication.setScale(this.value, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('presentationMode').addEventListener('click',
|
document.getElementById('presentationMode').addEventListener('click',
|
||||||
@ -1613,8 +1651,8 @@ function webViewerInitialized() {
|
|||||||
SecondaryToolbar.downloadClick.bind(SecondaryToolbar));
|
SecondaryToolbar.downloadClick.bind(SecondaryToolbar));
|
||||||
|
|
||||||
//#if (FIREFOX || MOZCENTRAL)
|
//#if (FIREFOX || MOZCENTRAL)
|
||||||
//PDFView.setTitleUsingUrl(file);
|
//PDFViewerApplication.setTitleUsingUrl(file);
|
||||||
//PDFView.initPassiveLoading();
|
//PDFViewerApplication.initPassiveLoading();
|
||||||
//return;
|
//return;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
@ -1623,18 +1661,18 @@ function webViewerInitialized() {
|
|||||||
// file:-scheme. Load the contents in the main thread because QtWebKit
|
// file:-scheme. Load the contents in the main thread because QtWebKit
|
||||||
// cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded
|
// cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded
|
||||||
// very quickly, so there is no need to set up progress event listeners.
|
// very quickly, so there is no need to set up progress event listeners.
|
||||||
PDFView.setTitleUsingUrl(file);
|
PDFViewerApplication.setTitleUsingUrl(file);
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
PDFView.open(new Uint8Array(xhr.response), 0);
|
PDFViewerApplication.open(new Uint8Array(xhr.response), 0);
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
xhr.open('GET', file);
|
xhr.open('GET', file);
|
||||||
xhr.responseType = 'arraybuffer';
|
xhr.responseType = 'arraybuffer';
|
||||||
xhr.send();
|
xhr.send();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
PDFView.error(mozL10n.get('loading_error', null,
|
PDFViewerApplication.error(mozL10n.get('loading_error', null,
|
||||||
'An error occurred while loading the PDF.'), e);
|
'An error occurred while loading the PDF.'), e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1642,7 +1680,7 @@ function webViewerInitialized() {
|
|||||||
|
|
||||||
//#if !B2G && !CHROME
|
//#if !B2G && !CHROME
|
||||||
if (file) {
|
if (file) {
|
||||||
PDFView.open(file, 0);
|
PDFViewerApplication.open(file, 0);
|
||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
//#if CHROME
|
//#if CHROME
|
||||||
@ -1656,24 +1694,25 @@ document.addEventListener('DOMContentLoaded', webViewerLoad, true);
|
|||||||
|
|
||||||
document.addEventListener('pagerendered', function (e) {
|
document.addEventListener('pagerendered', function (e) {
|
||||||
var pageIndex = e.detail.pageNumber - 1;
|
var pageIndex = e.detail.pageNumber - 1;
|
||||||
var pageView = PDFView.pdfViewer.getPageView(pageIndex);
|
var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
|
||||||
var thumbnailView = PDFView.pdfThumbnailViewer.getThumbnail(pageIndex);
|
var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.
|
||||||
|
getThumbnail(pageIndex);
|
||||||
thumbnailView.setImage(pageView.canvas);
|
thumbnailView.setImage(pageView.canvas);
|
||||||
|
|
||||||
//#if (FIREFOX || MOZCENTRAL)
|
//#if (FIREFOX || MOZCENTRAL)
|
||||||
//if (pageView.textLayer && pageView.textLayer.textDivs &&
|
//if (pageView.textLayer && pageView.textLayer.textDivs &&
|
||||||
// pageView.textLayer.textDivs.length > 0 &&
|
// pageView.textLayer.textDivs.length > 0 &&
|
||||||
// !PDFView.supportsDocumentColors) {
|
// !PDFViewerApplication.supportsDocumentColors) {
|
||||||
// console.error(mozL10n.get('document_colors_disabled', null,
|
// console.error(mozL10n.get('document_colors_disabled', null,
|
||||||
// 'PDF documents are not allowed to use their own colors: ' +
|
// 'PDF documents are not allowed to use their own colors: ' +
|
||||||
// '\'Allow pages to choose their own colors\' ' +
|
// '\'Allow pages to choose their own colors\' ' +
|
||||||
// 'is deactivated in the browser.'));
|
// 'is deactivated in the browser.'));
|
||||||
// PDFView.fallback();
|
// PDFViewerApplication.fallback();
|
||||||
//}
|
//}
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
if (pageView.error) {
|
if (pageView.error) {
|
||||||
PDFView.error(mozL10n.get('rendering_error', null,
|
PDFViewerApplication.error(mozL10n.get('rendering_error', null,
|
||||||
'An error occurred while rendering the page.'), pageView.error);
|
'An error occurred while rendering the page.'), pageView.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1682,7 +1721,7 @@ document.addEventListener('pagerendered', function (e) {
|
|||||||
// type: 'pageInfo'
|
// type: 'pageInfo'
|
||||||
//}));
|
//}));
|
||||||
//// It is a good time to report stream and font types
|
//// It is a good time to report stream and font types
|
||||||
//PDFView.pdfDocument.getStats().then(function (stats) {
|
//PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
|
||||||
// FirefoxCom.request('reportTelemetry', JSON.stringify({
|
// FirefoxCom.request('reportTelemetry', JSON.stringify({
|
||||||
// type: 'documentStats',
|
// type: 'documentStats',
|
||||||
// stats: stats
|
// stats: stats
|
||||||
@ -1694,27 +1733,27 @@ document.addEventListener('pagerendered', function (e) {
|
|||||||
window.addEventListener('presentationmodechanged', function (e) {
|
window.addEventListener('presentationmodechanged', function (e) {
|
||||||
var active = e.detail.active;
|
var active = e.detail.active;
|
||||||
var switchInProgress = e.detail.switchInProgress;
|
var switchInProgress = e.detail.switchInProgress;
|
||||||
PDFView.pdfViewer.presentationModeState =
|
PDFViewerApplication.pdfViewer.presentationModeState =
|
||||||
switchInProgress ? PresentationModeState.CHANGING :
|
switchInProgress ? PresentationModeState.CHANGING :
|
||||||
active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL;
|
active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL;
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateViewarea() {
|
function updateViewarea() {
|
||||||
if (!PDFView.initialized) {
|
if (!PDFViewerApplication.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFView.pdfViewer.update();
|
PDFViewerApplication.pdfViewer.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('updateviewarea', function () {
|
window.addEventListener('updateviewarea', function () {
|
||||||
if (!PDFView.initialized) {
|
if (!PDFViewerApplication.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var location = PDFView.pdfViewer.location;
|
var location = PDFViewerApplication.pdfViewer.location;
|
||||||
|
|
||||||
PDFView.store.initializedPromise.then(function() {
|
PDFViewerApplication.store.initializedPromise.then(function() {
|
||||||
PDFView.store.setMultiple({
|
PDFViewerApplication.store.setMultiple({
|
||||||
'exists': true,
|
'exists': true,
|
||||||
'page': location.pageNumber,
|
'page': location.pageNumber,
|
||||||
'zoom': location.scale,
|
'zoom': location.scale,
|
||||||
@ -1724,7 +1763,7 @@ window.addEventListener('updateviewarea', function () {
|
|||||||
// unable to write to storage
|
// unable to write to storage
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
var href = PDFView.getAnchorUrl(location.pdfOpenParams);
|
var href = PDFViewerApplication.getAnchorUrl(location.pdfOpenParams);
|
||||||
document.getElementById('viewBookmark').href = href;
|
document.getElementById('viewBookmark').href = href;
|
||||||
document.getElementById('secondaryViewBookmark').href = href;
|
document.getElementById('secondaryViewBookmark').href = href;
|
||||||
|
|
||||||
@ -1733,11 +1772,12 @@ window.addEventListener('updateviewarea', function () {
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
window.addEventListener('resize', function webViewerResize(evt) {
|
window.addEventListener('resize', function webViewerResize(evt) {
|
||||||
if (PDFView.initialized &&
|
if (PDFViewerApplication.initialized &&
|
||||||
(document.getElementById('pageWidthOption').selected ||
|
(document.getElementById('pageWidthOption').selected ||
|
||||||
document.getElementById('pageFitOption').selected ||
|
document.getElementById('pageFitOption').selected ||
|
||||||
document.getElementById('pageAutoOption').selected)) {
|
document.getElementById('pageAutoOption').selected)) {
|
||||||
PDFView.setScale(document.getElementById('scaleSelect').value, false);
|
var selectedScale = document.getElementById('scaleSelect').value;
|
||||||
|
PDFViewerApplication.setScale(selectedScale, false);
|
||||||
}
|
}
|
||||||
updateViewarea();
|
updateViewarea();
|
||||||
|
|
||||||
@ -1747,7 +1787,7 @@ window.addEventListener('resize', function webViewerResize(evt) {
|
|||||||
|
|
||||||
window.addEventListener('hashchange', function webViewerHashchange(evt) {
|
window.addEventListener('hashchange', function webViewerHashchange(evt) {
|
||||||
if (PDFHistory.isHashChangeUnlocked) {
|
if (PDFHistory.isHashChangeUnlocked) {
|
||||||
PDFView.setHash(document.location.hash.substring(1));
|
PDFViewerApplication.setHash(document.location.hash.substring(1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1761,19 +1801,19 @@ window.addEventListener('change', function webViewerChange(evt) {
|
|||||||
|
|
||||||
if (!PDFJS.disableCreateObjectURL &&
|
if (!PDFJS.disableCreateObjectURL &&
|
||||||
typeof URL !== 'undefined' && URL.createObjectURL) {
|
typeof URL !== 'undefined' && URL.createObjectURL) {
|
||||||
PDFView.open(URL.createObjectURL(file), 0);
|
PDFViewerApplication.open(URL.createObjectURL(file), 0);
|
||||||
} else {
|
} else {
|
||||||
// Read the local file into a Uint8Array.
|
// Read the local file into a Uint8Array.
|
||||||
var fileReader = new FileReader();
|
var fileReader = new FileReader();
|
||||||
fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
|
fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
|
||||||
var buffer = evt.target.result;
|
var buffer = evt.target.result;
|
||||||
var uint8Array = new Uint8Array(buffer);
|
var uint8Array = new Uint8Array(buffer);
|
||||||
PDFView.open(uint8Array, 0);
|
PDFViewerApplication.open(uint8Array, 0);
|
||||||
};
|
};
|
||||||
fileReader.readAsArrayBuffer(file);
|
fileReader.readAsArrayBuffer(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFView.setTitleUsingUrl(file.name);
|
PDFViewerApplication.setTitleUsingUrl(file.name);
|
||||||
|
|
||||||
// URL does not reflect proper document location - hiding some icons.
|
// URL does not reflect proper document location - hiding some icons.
|
||||||
document.getElementById('viewBookmark').setAttribute('hidden', 'true');
|
document.getElementById('viewBookmark').setAttribute('hidden', 'true');
|
||||||
@ -1802,7 +1842,7 @@ function selectScaleOption(value) {
|
|||||||
window.addEventListener('localized', function localized(evt) {
|
window.addEventListener('localized', function localized(evt) {
|
||||||
document.getElementsByTagName('html')[0].dir = mozL10n.getDirection();
|
document.getElementsByTagName('html')[0].dir = mozL10n.getDirection();
|
||||||
|
|
||||||
PDFView.animationStartedPromise.then(function() {
|
PDFViewerApplication.animationStartedPromise.then(function() {
|
||||||
// Adjust the width of the zoom box to fit the content.
|
// Adjust the width of the zoom box to fit the content.
|
||||||
// Note: If the window is narrow enough that the zoom box is not visible,
|
// Note: If the window is narrow enough that the zoom box is not visible,
|
||||||
// we temporarily show it to be able to adjust its width.
|
// we temporarily show it to be able to adjust its width.
|
||||||
@ -1832,7 +1872,7 @@ window.addEventListener('scalechange', function scalechange(evt) {
|
|||||||
var customScaleOption = document.getElementById('customScaleOption');
|
var customScaleOption = document.getElementById('customScaleOption');
|
||||||
customScaleOption.selected = false;
|
customScaleOption.selected = false;
|
||||||
|
|
||||||
if (!PDFView.updateScaleControls &&
|
if (!PDFViewerApplication.updateScaleControls &&
|
||||||
(document.getElementById('pageWidthOption').selected ||
|
(document.getElementById('pageWidthOption').selected ||
|
||||||
document.getElementById('pageFitOption').selected ||
|
document.getElementById('pageFitOption').selected ||
|
||||||
document.getElementById('pageAutoOption').selected)) {
|
document.getElementById('pageAutoOption').selected)) {
|
||||||
@ -1858,9 +1898,9 @@ window.addEventListener('pagechange', function pagechange(evt) {
|
|||||||
var page = evt.pageNumber;
|
var page = evt.pageNumber;
|
||||||
if (evt.previousPageNumber !== page) {
|
if (evt.previousPageNumber !== page) {
|
||||||
document.getElementById('pageNumber').value = page;
|
document.getElementById('pageNumber').value = page;
|
||||||
PDFView.pdfThumbnailViewer.scrollThumbnailIntoView(page);
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
|
||||||
}
|
}
|
||||||
var numPages = PDFView.pagesCount;
|
var numPages = PDFViewerApplication.pagesCount;
|
||||||
|
|
||||||
document.getElementById('previous').disabled = (page <= 1);
|
document.getElementById('previous').disabled = (page <= 1);
|
||||||
document.getElementById('next').disabled = (page >= numPages);
|
document.getElementById('next').disabled = (page >= numPages);
|
||||||
@ -1876,7 +1916,7 @@ window.addEventListener('pagechange', function pagechange(evt) {
|
|||||||
if (this.loading && page === 1) {
|
if (this.loading && page === 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFView.getPageView(page - 1).scrollIntoView();
|
PDFViewerApplication.getPageView(page - 1).scrollIntoView();
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
function handleMouseWheel(evt) {
|
function handleMouseWheel(evt) {
|
||||||
@ -1887,9 +1927,9 @@ function handleMouseWheel(evt) {
|
|||||||
|
|
||||||
if (evt.ctrlKey) { // Only zoom the pages, not the entire viewer
|
if (evt.ctrlKey) { // Only zoom the pages, not the entire viewer
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
PDFView[direction](Math.abs(ticks));
|
PDFViewerApplication[direction](Math.abs(ticks));
|
||||||
} else if (PresentationMode.active) {
|
} else if (PresentationMode.active) {
|
||||||
PDFView.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR);
|
PDFViewerApplication.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1899,7 +1939,7 @@ window.addEventListener('mousewheel', handleMouseWheel);
|
|||||||
window.addEventListener('click', function click(evt) {
|
window.addEventListener('click', function click(evt) {
|
||||||
if (!PresentationMode.active) {
|
if (!PresentationMode.active) {
|
||||||
if (SecondaryToolbar.opened &&
|
if (SecondaryToolbar.opened &&
|
||||||
PDFView.pdfViewer.containsElement(evt.target)) {
|
PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
|
||||||
SecondaryToolbar.close();
|
SecondaryToolbar.close();
|
||||||
}
|
}
|
||||||
} else if (evt.button === 0) {
|
} else if (evt.button === 0) {
|
||||||
@ -1926,14 +1966,15 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
// either CTRL or META key with optional SHIFT.
|
// either CTRL or META key with optional SHIFT.
|
||||||
switch (evt.keyCode) {
|
switch (evt.keyCode) {
|
||||||
case 70: // f
|
case 70: // f
|
||||||
if (!PDFView.supportsIntegratedFind) {
|
if (!PDFViewerApplication.supportsIntegratedFind) {
|
||||||
PDFView.findBar.open();
|
PDFViewerApplication.findBar.open();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 71: // g
|
case 71: // g
|
||||||
if (!PDFView.supportsIntegratedFind) {
|
if (!PDFViewerApplication.supportsIntegratedFind) {
|
||||||
PDFView.findBar.dispatchEvent('again', cmd === 5 || cmd === 12);
|
PDFViewerApplication.findBar.dispatchEvent('again',
|
||||||
|
cmd === 5 || cmd === 12);
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1941,13 +1982,13 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
case 107: // FF '+' and '='
|
case 107: // FF '+' and '='
|
||||||
case 187: // Chrome '+'
|
case 187: // Chrome '+'
|
||||||
case 171: // FF with German keyboard
|
case 171: // FF with German keyboard
|
||||||
PDFView.zoomIn();
|
PDFViewerApplication.zoomIn();
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case 173: // FF/Mac '-'
|
case 173: // FF/Mac '-'
|
||||||
case 109: // FF '-'
|
case 109: // FF '-'
|
||||||
case 189: // Chrome '-'
|
case 189: // Chrome '-'
|
||||||
PDFView.zoomOut();
|
PDFViewerApplication.zoomOut();
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case 48: // '0'
|
case 48: // '0'
|
||||||
@ -1955,7 +1996,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
// keeping it unhandled (to restore page zoom to 100%)
|
// keeping it unhandled (to restore page zoom to 100%)
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
// ... and resetting the scale after browser adjusts its scale
|
// ... and resetting the scale after browser adjusts its scale
|
||||||
PDFView.setScale(DEFAULT_SCALE, true);
|
PDFViewerApplication.setScale(DEFAULT_SCALE, true);
|
||||||
});
|
});
|
||||||
handled = false;
|
handled = false;
|
||||||
break;
|
break;
|
||||||
@ -1967,7 +2008,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
if (cmd === 1 || cmd === 8) {
|
if (cmd === 1 || cmd === 8) {
|
||||||
switch (evt.keyCode) {
|
switch (evt.keyCode) {
|
||||||
case 83: // s
|
case 83: // s
|
||||||
PDFView.download();
|
PDFViewerApplication.download();
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2013,20 +2054,20 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
case 33: // pg up
|
case 33: // pg up
|
||||||
case 8: // backspace
|
case 8: // backspace
|
||||||
if (!PresentationMode.active &&
|
if (!PresentationMode.active &&
|
||||||
PDFView.currentScaleValue !== 'page-fit') {
|
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* in presentation mode */
|
/* in presentation mode */
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 37: // left arrow
|
case 37: // left arrow
|
||||||
// horizontal scrolling using arrow keys
|
// horizontal scrolling using arrow keys
|
||||||
if (PDFView.pdfViewer.isHorizontalScrollbarEnabled) {
|
if (PDFViewerApplication.pdfViewer.isHorizontalScrollbarEnabled) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 75: // 'k'
|
case 75: // 'k'
|
||||||
case 80: // 'p'
|
case 80: // 'p'
|
||||||
PDFView.page--;
|
PDFViewerApplication.page--;
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case 27: // esc key
|
case 27: // esc key
|
||||||
@ -2034,8 +2075,9 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
SecondaryToolbar.close();
|
SecondaryToolbar.close();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
if (!PDFView.supportsIntegratedFind && PDFView.findBar.opened) {
|
if (!PDFViewerApplication.supportsIntegratedFind &&
|
||||||
PDFView.findBar.close();
|
PDFViewerApplication.findBar.opened) {
|
||||||
|
PDFViewerApplication.findBar.close();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2043,32 +2085,32 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
case 34: // pg down
|
case 34: // pg down
|
||||||
case 32: // spacebar
|
case 32: // spacebar
|
||||||
if (!PresentationMode.active &&
|
if (!PresentationMode.active &&
|
||||||
PDFView.currentScaleValue !== 'page-fit') {
|
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 39: // right arrow
|
case 39: // right arrow
|
||||||
// horizontal scrolling using arrow keys
|
// horizontal scrolling using arrow keys
|
||||||
if (PDFView.pdfViewer.isHorizontalScrollbarEnabled) {
|
if (PDFViewerApplication.pdfViewer.isHorizontalScrollbarEnabled) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 74: // 'j'
|
case 74: // 'j'
|
||||||
case 78: // 'n'
|
case 78: // 'n'
|
||||||
PDFView.page++;
|
PDFViewerApplication.page++;
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 36: // home
|
case 36: // home
|
||||||
if (PresentationMode.active || PDFView.page > 1) {
|
if (PresentationMode.active || PDFViewerApplication.page > 1) {
|
||||||
PDFView.page = 1;
|
PDFViewerApplication.page = 1;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 35: // end
|
case 35: // end
|
||||||
if (PresentationMode.active || (PDFView.pdfDocument &&
|
if (PresentationMode.active || (PDFViewerApplication.pdfDocument &&
|
||||||
PDFView.page < PDFView.pagesCount)) {
|
PDFViewerApplication.page < PDFViewerApplication.pagesCount)) {
|
||||||
PDFView.page = PDFView.pagesCount;
|
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2079,7 +2121,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 82: // 'r'
|
case 82: // 'r'
|
||||||
PDFView.rotatePages(90);
|
PDFViewerApplication.rotatePages(90);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2088,15 +2130,15 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
switch (evt.keyCode) {
|
switch (evt.keyCode) {
|
||||||
case 32: // spacebar
|
case 32: // spacebar
|
||||||
if (!PresentationMode.active &&
|
if (!PresentationMode.active &&
|
||||||
PDFView.currentScaleValue !== 'page-fit') {
|
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PDFView.page--;
|
PDFViewerApplication.page--;
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 82: // 'r'
|
case 82: // 'r'
|
||||||
PDFView.rotatePages(-90);
|
PDFViewerApplication.rotatePages(-90);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2105,21 +2147,21 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
// 33=Page Up 34=Page Down 35=End 36=Home
|
// 33=Page Up 34=Page Down 35=End 36=Home
|
||||||
// 37=Left 38=Up 39=Right 40=Down
|
// 37=Left 38=Up 39=Right 40=Down
|
||||||
if (evt.keyCode >= 33 && evt.keyCode <= 40 &&
|
if (evt.keyCode >= 33 && evt.keyCode <= 40 &&
|
||||||
!PDFView.pdfViewer.containsElement(curElement)) {
|
!PDFViewerApplication.pdfViewer.containsElement(curElement)) {
|
||||||
// The page container is not focused, but a page navigation key has been
|
// The page container is not focused, but a page navigation key has been
|
||||||
// pressed. Change the focus to the viewer container to make sure that
|
// pressed. Change the focus to the viewer container to make sure that
|
||||||
// navigation by keyboard works as expected.
|
// navigation by keyboard works as expected.
|
||||||
PDFView.pdfViewer.focus();
|
PDFViewerApplication.pdfViewer.focus();
|
||||||
}
|
}
|
||||||
// 32=Spacebar
|
// 32=Spacebar
|
||||||
if (evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
|
if (evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
|
||||||
//#if (FIREFOX || MOZCENTRAL)
|
//#if (FIREFOX || MOZCENTRAL)
|
||||||
// // Workaround for issue in Firefox, that prevents scroll keys from
|
// // Workaround for issue in Firefox, that prevents scroll keys from
|
||||||
// // working when elements with 'tabindex' are focused. (#3498)
|
// // working when elements with 'tabindex' are focused. (#3498)
|
||||||
// PDFView.pdfViewer.blur();
|
// PDFViewerApplication.pdfViewer.blur();
|
||||||
//#else
|
//#else
|
||||||
if (!PDFView.pdfViewer.containsElement(curElement)) {
|
if (!PDFViewerApplication.pdfViewer.containsElement(curElement)) {
|
||||||
PDFView.pdfViewer.focus();
|
PDFViewerApplication.pdfViewer.focus();
|
||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
@ -2144,22 +2186,23 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
|
|
||||||
if (handled) {
|
if (handled) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
PDFView.clearMouseScrollState();
|
PDFViewerApplication.clearMouseScrollState();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('beforeprint', function beforePrint(evt) {
|
window.addEventListener('beforeprint', function beforePrint(evt) {
|
||||||
PDFView.beforePrint();
|
PDFViewerApplication.beforePrint();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('afterprint', function afterPrint(evt) {
|
window.addEventListener('afterprint', function afterPrint(evt) {
|
||||||
PDFView.afterPrint();
|
PDFViewerApplication.afterPrint();
|
||||||
});
|
});
|
||||||
|
|
||||||
(function animationStartedClosure() {
|
(function animationStartedClosure() {
|
||||||
// The offsetParent is not set until the pdf.js iframe or object is visible.
|
// The offsetParent is not set until the pdf.js iframe or object is visible.
|
||||||
// Waiting for first animation.
|
// Waiting for first animation.
|
||||||
PDFView.animationStartedPromise = new Promise(function (resolve) {
|
PDFViewerApplication.animationStartedPromise = new Promise(
|
||||||
|
function (resolve) {
|
||||||
window.requestAnimationFrame(resolve);
|
window.requestAnimationFrame(resolve);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
@ -2171,7 +2214,7 @@ window.addEventListener('afterprint', function afterPrint(evt) {
|
|||||||
// var fileURL = activity.source.data.url;
|
// var fileURL = activity.source.data.url;
|
||||||
//
|
//
|
||||||
// var url = URL.createObjectURL(blob);
|
// var url = URL.createObjectURL(blob);
|
||||||
// PDFView.open({url : url, originalUrl: fileURL});
|
// PDFViewerApplication.open({url : url, originalUrl: fileURL});
|
||||||
//
|
//
|
||||||
// var header = document.getElementById('header');
|
// var header = document.getElementById('header');
|
||||||
// header.addEventListener('action', function() {
|
// header.addEventListener('action', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user