1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 07:37:57 +02:00

Enabling clicking to close the context menu in Presentation Mode, without going to the next page

This commit is contained in:
Jonas Jenwald 2013-10-08 20:11:04 +02:00
parent 6d1533293e
commit dfb8e62079
2 changed files with 46 additions and 13 deletions

View file

@ -24,9 +24,34 @@ var SELECTOR = 'presentationControls';
var PresentationMode = {
active: false,
args: null,
contextMenuOpen: false,
initialize: function presentationModeInitialize(options) {
this.container = options.container;
this.secondaryToolbar = options.secondaryToolbar;
this.firstPage = options.firstPage;
this.lastPage = options.lastPage;
this.pageRotateCw = options.pageRotateCw;
this.pageRotateCcw = options.pageRotateCcw;
this.firstPage.addEventListener('click', function() {
this.contextMenuOpen = false;
this.secondaryToolbar.firstPageClick();
}.bind(this));
this.lastPage.addEventListener('click', function() {
this.contextMenuOpen = false;
this.secondaryToolbar.lastPageClick();
}.bind(this));
this.pageRotateCw.addEventListener('click', function() {
this.contextMenuOpen = false;
this.secondaryToolbar.pageRotateCwClick();
}.bind(this));
this.pageRotateCcw.addEventListener('click', function() {
this.contextMenuOpen = false;
this.secondaryToolbar.pageRotateCcwClick();
}.bind(this));
},
get isFullscreen() {
@ -69,8 +94,10 @@ var PresentationMode = {
window.addEventListener('mousemove', this.mouseMove, false);
window.addEventListener('mousedown', this.mouseDown, false);
window.addEventListener('contextmenu', this.contextMenu, false);
this.showControls();
this.contextMenuOpen = false;
this.container.setAttribute('contextmenu', 'viewerContextMenu');
},
@ -83,11 +110,13 @@ var PresentationMode = {
window.removeEventListener('mousemove', this.mouseMove, false);
window.removeEventListener('mousedown', this.mouseDown, false);
window.removeEventListener('contextmenu', this.contextMenu, false);
this.hideControls();
this.args = null;
PDFView.clearMouseScrollState();
this.container.removeAttribute('contextmenu');
this.contextMenuOpen = false;
// Ensure that the thumbnail of the current page is visible
// when exiting presentation mode.
@ -120,6 +149,13 @@ var PresentationMode = {
},
mouseDown: function presentationModeMouseDown(evt) {
var self = PresentationMode;
if (self.contextMenuOpen) {
self.contextMenuOpen = false;
evt.preventDefault();
return;
}
if (evt.button === 0) {
// Enable clicking of links in presentation mode. Please note:
// Only links pointing to destinations in the current PDF document work.
@ -131,6 +167,10 @@ var PresentationMode = {
PDFView.page += (evt.shiftKey ? -1 : 1);
}
}
},
contextMenu: function presentationModeContextMenu(evt) {
PresentationMode.contextMenuOpen = true;
}
};