Move Presentation Mode related code from viewer.js to its own file
This commit is contained in:
parent
17a953c7b3
commit
bfc66626a0
@ -15,9 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals RenderingStates, PDFView, PDFHistory, PDFFindBar, PDFJS, mozL10n,
|
/* globals RenderingStates, PDFView, PDFHistory, PDFFindBar, PDFJS, mozL10n,
|
||||||
CustomStyle, scrollIntoView, SCROLLBAR_PADDING, CSS_UNITS,
|
CustomStyle, PresentationMode, scrollIntoView, SCROLLBAR_PADDING,
|
||||||
UNKNOWN_SCALE, DEFAULT_SCALE, getOutputScale, TextLayerBuilder,
|
CSS_UNITS, UNKNOWN_SCALE, DEFAULT_SCALE, getOutputScale,
|
||||||
cache, Stats */
|
TextLayerBuilder, cache, Stats */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ var PageView = function pageView(container, id, scale,
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.scrollIntoView = function pageViewScrollIntoView(dest) {
|
this.scrollIntoView = function pageViewScrollIntoView(dest) {
|
||||||
if (PDFView.isPresentationMode) { // Avoid breaking presentation mode.
|
if (PresentationMode.active) { // Avoid breaking presentation mode.
|
||||||
dest = null;
|
dest = null;
|
||||||
}
|
}
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
@ -379,7 +379,7 @@ var PageView = function pageView(container, id, scale,
|
|||||||
pageIndex: this.id - 1,
|
pageIndex: this.id - 1,
|
||||||
lastScrollSource: PDFView,
|
lastScrollSource: PDFView,
|
||||||
viewport: this.viewport,
|
viewport: this.viewport,
|
||||||
isViewerInPresentationMode: PDFView.isPresentationMode
|
isViewerInPresentationMode: PresentationMode.active
|
||||||
}) : null;
|
}) : null;
|
||||||
// TODO(mack): use data attributes to store these
|
// TODO(mack): use data attributes to store these
|
||||||
ctx._scaleX = outputScale.sx;
|
ctx._scaleX = outputScale.sx;
|
||||||
|
@ -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 */
|
/* globals PDFJS, PDFView, PresentationMode */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ var PDFHistory = {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var params = { hash: this.currentBookmark, page: this.currentPage };
|
var params = { hash: this.currentBookmark, page: this.currentPage };
|
||||||
if (PDFView.isPresentationMode) {
|
if (PresentationMode.active) {
|
||||||
params.hash = null;
|
params.hash = null;
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
|
157
web/presentation_mode.js
Normal file
157
web/presentation_mode.js
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/* Copyright 2012 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.
|
||||||
|
*/
|
||||||
|
/* globals PDFView, scrollIntoView */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var PresentationMode = {
|
||||||
|
active: false,
|
||||||
|
args: null,
|
||||||
|
|
||||||
|
request: function presentationModeRequest() {
|
||||||
|
if (!PDFView.supportsFullscreen) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var isPresentationMode = document.fullscreenElement ||
|
||||||
|
document.mozFullScreen ||
|
||||||
|
document.webkitIsFullScreen ||
|
||||||
|
document.msFullscreenElement;
|
||||||
|
|
||||||
|
if (isPresentationMode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var wrapper = document.getElementById('viewerContainer');
|
||||||
|
if (document.documentElement.requestFullscreen) {
|
||||||
|
wrapper.requestFullscreen();
|
||||||
|
} else if (document.documentElement.mozRequestFullScreen) {
|
||||||
|
wrapper.mozRequestFullScreen();
|
||||||
|
} else if (document.documentElement.webkitRequestFullScreen) {
|
||||||
|
wrapper.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||||
|
} else if (document.documentElement.msRequestFullscreen) {
|
||||||
|
wrapper.msRequestFullscreen();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.args = {
|
||||||
|
page: PDFView.page,
|
||||||
|
previousScale: PDFView.currentScaleValue
|
||||||
|
};
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
enter: function presentationModeEnter() {
|
||||||
|
this.active = true;
|
||||||
|
|
||||||
|
PDFView.page = this.args.page;
|
||||||
|
PDFView.parseScale('page-fit', true);
|
||||||
|
|
||||||
|
this.showControls();
|
||||||
|
|
||||||
|
var viewer = document.getElementById('viewer');
|
||||||
|
viewer.setAttribute('contextmenu', 'viewerContextMenu');
|
||||||
|
},
|
||||||
|
|
||||||
|
exit: function presentationModeExit() {
|
||||||
|
this.active = false;
|
||||||
|
|
||||||
|
var page = PDFView.page;
|
||||||
|
PDFView.parseScale(this.args.previousScale);
|
||||||
|
PDFView.page = page;
|
||||||
|
|
||||||
|
this.hideControls();
|
||||||
|
this.args = null;
|
||||||
|
PDFView.clearMouseScrollState();
|
||||||
|
|
||||||
|
var viewer = document.getElementById('viewer');
|
||||||
|
viewer.removeAttribute('contextmenu');
|
||||||
|
|
||||||
|
// Ensure that the thumbnail of the current page is visible
|
||||||
|
// when exiting presentation mode.
|
||||||
|
scrollIntoView(document.getElementById('thumbnailContainer' + page));
|
||||||
|
},
|
||||||
|
|
||||||
|
showControls: function presentationModeShowControls() {
|
||||||
|
var DELAY_BEFORE_HIDING_CONTROLS = 3000;
|
||||||
|
var wrapper = document.getElementById('viewerContainer');
|
||||||
|
if (this.controlsTimeout) {
|
||||||
|
clearTimeout(this.controlsTimeout);
|
||||||
|
} else {
|
||||||
|
wrapper.classList.add('presentationControls');
|
||||||
|
}
|
||||||
|
this.controlsTimeout = setTimeout(function hideControlsTimeout() {
|
||||||
|
wrapper.classList.remove('presentationControls');
|
||||||
|
delete this.controlsTimeout;
|
||||||
|
}.bind(this), DELAY_BEFORE_HIDING_CONTROLS);
|
||||||
|
},
|
||||||
|
|
||||||
|
hideControls: function presentationModeHideControls() {
|
||||||
|
if (!this.controlsTimeout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearTimeout(this.controlsTimeout);
|
||||||
|
delete this.controlsTimeout;
|
||||||
|
|
||||||
|
var wrapper = document.getElementById('viewerContainer');
|
||||||
|
wrapper.classList.remove('presentationControls');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('mousemove', function mousemove(evt) {
|
||||||
|
if (PresentationMode.active) {
|
||||||
|
PresentationMode.showControls();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
window.addEventListener('mousedown', function mousedown(evt) {
|
||||||
|
if (PresentationMode.active && evt.button === 0) {
|
||||||
|
// Enable clicking of links in presentation mode.
|
||||||
|
// Note: Only links that point to the currently loaded PDF document works.
|
||||||
|
var targetHref = evt.target.href;
|
||||||
|
var internalLink = targetHref && (targetHref.replace(/#.*$/, '') ===
|
||||||
|
window.location.href.replace(/#.*$/, ''));
|
||||||
|
if (!internalLink) {
|
||||||
|
// Unless an internal link was clicked, advance a page in presentation
|
||||||
|
// mode.
|
||||||
|
evt.preventDefault();
|
||||||
|
PDFView.page++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
(function presentationModeClosure() {
|
||||||
|
function presentationModeChange(e) {
|
||||||
|
var isPresentationMode = document.fullscreenElement ||
|
||||||
|
document.mozFullScreen ||
|
||||||
|
document.webkitIsFullScreen ||
|
||||||
|
document.msFullscreenElement;
|
||||||
|
|
||||||
|
if (isPresentationMode) {
|
||||||
|
PresentationMode.enter();
|
||||||
|
} else {
|
||||||
|
PresentationMode.exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('fullscreenchange', presentationModeChange, false);
|
||||||
|
window.addEventListener('mozfullscreenchange', presentationModeChange, false);
|
||||||
|
window.addEventListener('webkitfullscreenchange', presentationModeChange,
|
||||||
|
false);
|
||||||
|
window.addEventListener('MSFullscreenChange', presentationModeChange, 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, SCROLLBAR_PADDING */
|
/* globals PDFView, PresentationMode, SCROLLBAR_PADDING */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ var SecondaryToolbar = {
|
|||||||
|
|
||||||
// Event handling functions.
|
// Event handling functions.
|
||||||
presentationModeClick: function secondaryToolbarPresentationModeClick(evt) {
|
presentationModeClick: function secondaryToolbarPresentationModeClick(evt) {
|
||||||
PDFView.presentationMode();
|
PresentationMode.request();
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ limitations under the License.
|
|||||||
<script type="text/javascript" src="pdf_history.js"></script>
|
<script type="text/javascript" src="pdf_history.js"></script>
|
||||||
<script type="text/javascript" src="secondary_toolbar.js"></script>
|
<script type="text/javascript" src="secondary_toolbar.js"></script>
|
||||||
<script type="text/javascript" src="password_prompt.js"></script>
|
<script type="text/javascript" src="password_prompt.js"></script>
|
||||||
|
<script type="text/javascript" src="presentation_mode.js"></script>
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
<script type="text/javascript" src="debugger.js"></script>
|
<script type="text/javascript" src="debugger.js"></script>
|
||||||
|
192
web/viewer.js
192
web/viewer.js
@ -18,7 +18,7 @@
|
|||||||
PDFFindController, ProgressBar, TextLayerBuilder, DownloadManager,
|
PDFFindController, ProgressBar, TextLayerBuilder, DownloadManager,
|
||||||
getFileName, getOutputScale, scrollIntoView, getPDFFileNameFromURL,
|
getFileName, getOutputScale, scrollIntoView, getPDFFileNameFromURL,
|
||||||
PDFHistory, PageView, ThumbnailView, noContextMenuHandler,
|
PDFHistory, PageView, ThumbnailView, noContextMenuHandler,
|
||||||
SecondaryToolbar, PasswordPrompt */
|
SecondaryToolbar, PasswordPrompt, PresentationMode */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -168,6 +168,7 @@ var currentPageNumber = 1;
|
|||||||
//#include pdf_history.js
|
//#include pdf_history.js
|
||||||
//#include secondary_toolbar.js
|
//#include secondary_toolbar.js
|
||||||
//#include password_prompt.js
|
//#include password_prompt.js
|
||||||
|
//#include presentation_mode.js
|
||||||
|
|
||||||
var PDFView = {
|
var PDFView = {
|
||||||
pages: [],
|
pages: [],
|
||||||
@ -183,8 +184,6 @@ var PDFView = {
|
|||||||
sidebarOpen: false,
|
sidebarOpen: false,
|
||||||
pageViewScroll: null,
|
pageViewScroll: null,
|
||||||
thumbnailViewScroll: null,
|
thumbnailViewScroll: null,
|
||||||
isPresentationMode: false,
|
|
||||||
presentationModeArgs: null,
|
|
||||||
pageRotation: 0,
|
pageRotation: 0,
|
||||||
mouseScrollTimeStamp: 0,
|
mouseScrollTimeStamp: 0,
|
||||||
mouseScrollDelta: 0,
|
mouseScrollDelta: 0,
|
||||||
@ -205,6 +204,23 @@ var PDFView = {
|
|||||||
this.watchScroll(thumbnailContainer, this.thumbnailViewScroll,
|
this.watchScroll(thumbnailContainer, this.thumbnailViewScroll,
|
||||||
this.renderHighestPriority.bind(this));
|
this.renderHighestPriority.bind(this));
|
||||||
|
|
||||||
|
PDFFindBar.initialize({
|
||||||
|
bar: document.getElementById('findbar'),
|
||||||
|
toggleButton: document.getElementById('viewFind'),
|
||||||
|
findField: document.getElementById('findInput'),
|
||||||
|
highlightAllCheckbox: document.getElementById('findHighlightAll'),
|
||||||
|
caseSensitiveCheckbox: document.getElementById('findMatchCase'),
|
||||||
|
findMsg: document.getElementById('findMsg'),
|
||||||
|
findStatusIcon: document.getElementById('findStatusIcon'),
|
||||||
|
findPreviousButton: document.getElementById('findPrevious'),
|
||||||
|
findNextButton: document.getElementById('findNext')
|
||||||
|
});
|
||||||
|
|
||||||
|
PDFFindController.initialize({
|
||||||
|
pdfPageSource: this,
|
||||||
|
integratedFind: this.supportsIntegratedFind
|
||||||
|
});
|
||||||
|
|
||||||
SecondaryToolbar.initialize({
|
SecondaryToolbar.initialize({
|
||||||
toolbar: document.getElementById('secondaryToolbar'),
|
toolbar: document.getElementById('secondaryToolbar'),
|
||||||
toggleButton: document.getElementById('secondaryToolbarToggle'),
|
toggleButton: document.getElementById('secondaryToolbarToggle'),
|
||||||
@ -226,23 +242,6 @@ var PDFView = {
|
|||||||
passwordCancel: document.getElementById('passwordCancel')
|
passwordCancel: document.getElementById('passwordCancel')
|
||||||
});
|
});
|
||||||
|
|
||||||
PDFFindBar.initialize({
|
|
||||||
bar: document.getElementById('findbar'),
|
|
||||||
toggleButton: document.getElementById('viewFind'),
|
|
||||||
findField: document.getElementById('findInput'),
|
|
||||||
highlightAllCheckbox: document.getElementById('findHighlightAll'),
|
|
||||||
caseSensitiveCheckbox: document.getElementById('findMatchCase'),
|
|
||||||
findMsg: document.getElementById('findMsg'),
|
|
||||||
findStatusIcon: document.getElementById('findStatusIcon'),
|
|
||||||
findPreviousButton: document.getElementById('findPrevious'),
|
|
||||||
findNextButton: document.getElementById('findNext')
|
|
||||||
});
|
|
||||||
|
|
||||||
PDFFindController.initialize({
|
|
||||||
pdfPageSource: this,
|
|
||||||
integratedFind: this.supportsIntegratedFind
|
|
||||||
});
|
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
container.addEventListener('scroll', function() {
|
container.addEventListener('scroll', function() {
|
||||||
self.lastScroll = Date.now();
|
self.lastScroll = Date.now();
|
||||||
@ -1283,7 +1282,7 @@ var PDFView = {
|
|||||||
|
|
||||||
getVisiblePages: function pdfViewGetVisiblePages() {
|
getVisiblePages: function pdfViewGetVisiblePages() {
|
||||||
return this.getVisibleElements(this.container, this.pages,
|
return this.getVisibleElements(this.container, this.pages,
|
||||||
!this.isPresentationMode);
|
!PresentationMode.active);
|
||||||
},
|
},
|
||||||
|
|
||||||
getVisibleThumbs: function pdfViewGetVisibleThumbs() {
|
getVisibleThumbs: function pdfViewGetVisibleThumbs() {
|
||||||
@ -1389,91 +1388,6 @@ var PDFView = {
|
|||||||
div.removeChild(div.lastChild);
|
div.removeChild(div.lastChild);
|
||||||
},
|
},
|
||||||
|
|
||||||
presentationMode: function pdfViewPresentationMode() {
|
|
||||||
if (!this.supportsFullscreen) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var isPresentationMode = document.fullscreenElement ||
|
|
||||||
document.mozFullScreen ||
|
|
||||||
document.webkitIsFullScreen ||
|
|
||||||
document.msFullscreenElement;
|
|
||||||
|
|
||||||
if (isPresentationMode) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var wrapper = document.getElementById('viewerContainer');
|
|
||||||
if (document.documentElement.requestFullscreen) {
|
|
||||||
wrapper.requestFullscreen();
|
|
||||||
} else if (document.documentElement.mozRequestFullScreen) {
|
|
||||||
wrapper.mozRequestFullScreen();
|
|
||||||
} else if (document.documentElement.webkitRequestFullScreen) {
|
|
||||||
wrapper.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
|
||||||
} else if (document.documentElement.msRequestFullscreen) {
|
|
||||||
wrapper.msRequestFullscreen();
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.presentationModeArgs = {
|
|
||||||
page: this.page,
|
|
||||||
previousScale: this.currentScaleValue
|
|
||||||
};
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
enterPresentationMode: function pdfViewEnterPresentationMode() {
|
|
||||||
this.isPresentationMode = true;
|
|
||||||
this.page = this.presentationModeArgs.page;
|
|
||||||
this.parseScale('page-fit', true);
|
|
||||||
this.showPresentationControls();
|
|
||||||
|
|
||||||
var viewer = document.getElementById('viewer');
|
|
||||||
viewer.setAttribute('contextmenu', 'viewerContextMenu');
|
|
||||||
},
|
|
||||||
|
|
||||||
exitPresentationMode: function pdfViewExitPresentationMode() {
|
|
||||||
this.isPresentationMode = false;
|
|
||||||
this.parseScale(this.presentationModeArgs.previousScale);
|
|
||||||
this.page = this.page;
|
|
||||||
this.clearMouseScrollState();
|
|
||||||
this.hidePresentationControls();
|
|
||||||
this.presentationModeArgs = null;
|
|
||||||
|
|
||||||
var viewer = document.getElementById('viewer');
|
|
||||||
viewer.removeAttribute('contextmenu');
|
|
||||||
|
|
||||||
// Ensure that the thumbnail of the current page is visible
|
|
||||||
// when exiting presentation mode.
|
|
||||||
scrollIntoView(document.getElementById('thumbnailContainer' + this.page));
|
|
||||||
},
|
|
||||||
|
|
||||||
showPresentationControls: function pdfViewShowPresentationControls() {
|
|
||||||
var DELAY_BEFORE_HIDING_CONTROLS = 3000;
|
|
||||||
var wrapper = document.getElementById('viewerContainer');
|
|
||||||
if (this.presentationControlsTimeout) {
|
|
||||||
clearTimeout(this.presentationControlsTimeout);
|
|
||||||
} else {
|
|
||||||
wrapper.classList.add('presentationControls');
|
|
||||||
}
|
|
||||||
this.presentationControlsTimeout = setTimeout(function hideControls() {
|
|
||||||
wrapper.classList.remove('presentationControls');
|
|
||||||
delete PDFView.presentationControlsTimeout;
|
|
||||||
}, DELAY_BEFORE_HIDING_CONTROLS);
|
|
||||||
},
|
|
||||||
|
|
||||||
hidePresentationControls: function pdfViewShowPresentationControls() {
|
|
||||||
if (!this.presentationControlsTimeout) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
clearTimeout(this.presentationControlsTimeout);
|
|
||||||
delete this.presentationControlsTimeout;
|
|
||||||
|
|
||||||
var wrapper = document.getElementById('viewerContainer');
|
|
||||||
wrapper.classList.remove('presentationControls');
|
|
||||||
},
|
|
||||||
|
|
||||||
rotatePages: function pdfViewPageRotation(delta) {
|
rotatePages: function pdfViewPageRotation(delta) {
|
||||||
|
|
||||||
this.pageRotation = (this.pageRotation + 360 + delta) % 360;
|
this.pageRotation = (this.pageRotation + 360 + delta) % 360;
|
||||||
@ -2051,36 +1965,14 @@ window.addEventListener('DOMMouseScroll', function(evt) {
|
|||||||
var ticks = evt.detail;
|
var ticks = evt.detail;
|
||||||
var direction = (ticks > 0) ? 'zoomOut' : 'zoomIn';
|
var direction = (ticks > 0) ? 'zoomOut' : 'zoomIn';
|
||||||
PDFView[direction](Math.abs(ticks));
|
PDFView[direction](Math.abs(ticks));
|
||||||
} else if (PDFView.isPresentationMode) {
|
} else if (PresentationMode.active) {
|
||||||
var FIREFOX_DELTA_FACTOR = -40;
|
var FIREFOX_DELTA_FACTOR = -40;
|
||||||
PDFView.mouseScroll(evt.detail * FIREFOX_DELTA_FACTOR);
|
PDFView.mouseScroll(evt.detail * FIREFOX_DELTA_FACTOR);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
window.addEventListener('mousemove', function mousemove(evt) {
|
|
||||||
if (PDFView.isPresentationMode) {
|
|
||||||
PDFView.showPresentationControls();
|
|
||||||
}
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
window.addEventListener('mousedown', function mousedown(evt) {
|
|
||||||
if (PDFView.isPresentationMode && evt.button === 0) {
|
|
||||||
// Enable clicking of links in presentation mode.
|
|
||||||
// Note: Only links that point to the currently loaded PDF document works.
|
|
||||||
var targetHref = evt.target.href;
|
|
||||||
var internalLink = targetHref && (targetHref.replace(/#.*$/, '') ===
|
|
||||||
window.location.href.replace(/#.*$/, ''));
|
|
||||||
if (!internalLink) {
|
|
||||||
// Unless an internal link was clicked, advance a page in presentation
|
|
||||||
// mode.
|
|
||||||
evt.preventDefault();
|
|
||||||
PDFView.page++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
window.addEventListener('click', function click(evt) {
|
window.addEventListener('click', function click(evt) {
|
||||||
if (!PDFView.isPresentationMode) {
|
if (!PresentationMode.active) {
|
||||||
if (SecondaryToolbar.isOpen && PDFView.container.contains(evt.target)) {
|
if (SecondaryToolbar.isOpen && PDFView.container.contains(evt.target)) {
|
||||||
SecondaryToolbar.close();
|
SecondaryToolbar.close();
|
||||||
}
|
}
|
||||||
@ -2148,8 +2040,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
if (cmd === 3 || cmd === 10) {
|
if (cmd === 3 || cmd === 10) {
|
||||||
switch (evt.keyCode) {
|
switch (evt.keyCode) {
|
||||||
case 80: // p
|
case 80: // p
|
||||||
PDFView.presentationMode();
|
SecondaryToolbar.presentationModeClick();
|
||||||
SecondaryToolbar.close();
|
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2173,7 +2064,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
}
|
}
|
||||||
var controlsElement = document.getElementById('toolbar');
|
var controlsElement = document.getElementById('toolbar');
|
||||||
while (curElement) {
|
while (curElement) {
|
||||||
if (curElement === controlsElement && !PDFView.isPresentationMode)
|
if (curElement === controlsElement && !PresentationMode.active)
|
||||||
return; // ignoring if the 'toolbar' element is focused
|
return; // ignoring if the 'toolbar' element is focused
|
||||||
curElement = curElement.parentNode;
|
curElement = curElement.parentNode;
|
||||||
}
|
}
|
||||||
@ -2183,7 +2074,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
case 38: // up arrow
|
case 38: // up arrow
|
||||||
case 33: // pg up
|
case 33: // pg up
|
||||||
case 8: // backspace
|
case 8: // backspace
|
||||||
if (!PDFView.isPresentationMode &&
|
if (!PresentationMode.active &&
|
||||||
PDFView.currentScaleValue !== 'page-fit') {
|
PDFView.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2213,7 +2104,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
case 40: // down arrow
|
case 40: // down arrow
|
||||||
case 34: // pg down
|
case 34: // pg down
|
||||||
case 32: // spacebar
|
case 32: // spacebar
|
||||||
if (!PDFView.isPresentationMode &&
|
if (!PresentationMode.active &&
|
||||||
PDFView.currentScaleValue !== 'page-fit') {
|
PDFView.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2231,13 +2122,13 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 36: // home
|
case 36: // home
|
||||||
if (PDFView.isPresentationMode) {
|
if (PresentationMode.active) {
|
||||||
PDFView.page = 1;
|
PDFView.page = 1;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 35: // end
|
case 35: // end
|
||||||
if (PDFView.isPresentationMode) {
|
if (PresentationMode.active) {
|
||||||
PDFView.page = PDFView.pdfDocument.numPages;
|
PDFView.page = PDFView.pdfDocument.numPages;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
@ -2252,7 +2143,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
if (cmd === 4) { // shift-key
|
if (cmd === 4) { // shift-key
|
||||||
switch (evt.keyCode) {
|
switch (evt.keyCode) {
|
||||||
case 32: // spacebar
|
case 32: // spacebar
|
||||||
if (!PDFView.isPresentationMode &&
|
if (!PresentationMode.active &&
|
||||||
PDFView.currentScaleValue !== 'page-fit') {
|
PDFView.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2269,13 +2160,13 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
if (cmd === 2) { // alt-key
|
if (cmd === 2) { // alt-key
|
||||||
switch (evt.keyCode) {
|
switch (evt.keyCode) {
|
||||||
case 37: // left arrow
|
case 37: // left arrow
|
||||||
if (PDFView.isPresentationMode) {
|
if (PresentationMode.active) {
|
||||||
PDFHistory.back();
|
PDFHistory.back();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 39: // right arrow
|
case 39: // right arrow
|
||||||
if (PDFView.isPresentationMode) {
|
if (PresentationMode.active) {
|
||||||
PDFHistory.forward();
|
PDFHistory.forward();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
@ -2297,27 +2188,6 @@ window.addEventListener('afterprint', function afterPrint(evt) {
|
|||||||
PDFView.afterPrint();
|
PDFView.afterPrint();
|
||||||
});
|
});
|
||||||
|
|
||||||
(function presentationModeClosure() {
|
|
||||||
function presentationModeChange(e) {
|
|
||||||
var isPresentationMode = document.fullscreenElement ||
|
|
||||||
document.mozFullScreen ||
|
|
||||||
document.webkitIsFullScreen ||
|
|
||||||
document.msFullscreenElement;
|
|
||||||
|
|
||||||
if (isPresentationMode) {
|
|
||||||
PDFView.enterPresentationMode();
|
|
||||||
} else {
|
|
||||||
PDFView.exitPresentationMode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('fullscreenchange', presentationModeChange, false);
|
|
||||||
window.addEventListener('mozfullscreenchange', presentationModeChange, false);
|
|
||||||
window.addEventListener('webkitfullscreenchange', presentationModeChange,
|
|
||||||
false);
|
|
||||||
window.addEventListener('MSFullscreenChange', presentationModeChange, false);
|
|
||||||
})();
|
|
||||||
|
|
||||||
(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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user