Prevent a "TypeError: pdfViewer is null" when the viewer loads (PR 5413 followup)

Currently if you manage to e.g. open the console (with <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>K</kbd>) before the viewer is initialized, the following will be printed in the console: `TypeError: pdfViewer is null`.
This doesn't cause any actual errors, but nevertheless it seems like something we should avoid.

Followup to PR 5413.
This commit is contained in:
Jonas Jenwald 2014-11-15 11:38:43 +01:00
parent de9838018e
commit 6078901962

View File

@ -2024,9 +2024,9 @@ window.addEventListener('keydown', function keydown(evt) {
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
// either CTRL or META key with optional SHIFT.
var pdfViewer = PDFViewerApplication.pdfViewer;
var inPresentationMode =
pdfViewer.presentationModeState === PresentationModeState.CHANGING ||
pdfViewer.presentationModeState === PresentationModeState.FULLSCREEN;
var inPresentationMode = pdfViewer &&
(pdfViewer.presentationModeState === PresentationModeState.CHANGING ||
pdfViewer.presentationModeState === PresentationModeState.FULLSCREEN);
switch (evt.keyCode) {
case 70: // f