Rename the presentation_mode.js file and adjust the function names
Also moves the |fullscreenchange| event listeners into PDFPresentationMode.
This commit is contained in:
parent
e7fd5b4d4d
commit
f15d5c8cfe
@ -22,7 +22,7 @@ var DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms
|
|||||||
var SELECTOR = 'presentationControls';
|
var SELECTOR = 'presentationControls';
|
||||||
var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1000; // in ms
|
var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1000; // in ms
|
||||||
|
|
||||||
var PresentationMode = {
|
var PDFPresentationMode = {
|
||||||
initialized: false,
|
initialized: false,
|
||||||
active: false,
|
active: false,
|
||||||
args: null,
|
args: null,
|
||||||
@ -30,7 +30,7 @@ var PresentationMode = {
|
|||||||
mouseScrollTimeStamp: 0,
|
mouseScrollTimeStamp: 0,
|
||||||
mouseScrollDelta: 0,
|
mouseScrollDelta: 0,
|
||||||
|
|
||||||
initialize: function presentationModeInitialize(options) {
|
initialize: function pdfPresentationModeInitialize(options) {
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
this.container = options.container;
|
this.container = options.container;
|
||||||
this.pdfThumbnailViewer = options.pdfThumbnailViewer || null;
|
this.pdfThumbnailViewer = options.pdfThumbnailViewer || null;
|
||||||
@ -38,6 +38,13 @@ var PresentationMode = {
|
|||||||
|
|
||||||
this.viewer = this.container.firstElementChild;
|
this.viewer = this.container.firstElementChild;
|
||||||
|
|
||||||
|
window.addEventListener('fullscreenchange', this._fullscreenChange);
|
||||||
|
window.addEventListener('mozfullscreenchange', this._fullscreenChange);
|
||||||
|
//#if !(FIREFOX || MOZCENTRAL)
|
||||||
|
window.addEventListener('webkitfullscreenchange', this._fullscreenChange);
|
||||||
|
window.addEventListener('MSFullscreenChange', this._fullscreenChange);
|
||||||
|
//#endif
|
||||||
|
|
||||||
if (contextMenuItems) {
|
if (contextMenuItems) {
|
||||||
for (var i = 0, ii = contextMenuItems.length; i < ii; i++) {
|
for (var i = 0, ii = contextMenuItems.length; i < ii; i++) {
|
||||||
var item = contextMenuItems[i];
|
var item = contextMenuItems[i];
|
||||||
@ -56,6 +63,15 @@ var PresentationMode = {
|
|||||||
document.msFullscreenElement);
|
document.msFullscreenElement);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_fullscreenChange: function pdfPresentationModeFullscreenChange() {
|
||||||
|
var self = PDFPresentationMode;
|
||||||
|
if (self.isFullscreen) {
|
||||||
|
self._enter();
|
||||||
|
} else {
|
||||||
|
self._exit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a timeout that is used to specify switchInProgress when the
|
* Initialize a timeout that is used to specify switchInProgress when the
|
||||||
* browser transitions to fullscreen mode. Since resize events are triggered
|
* browser transitions to fullscreen mode. Since resize events are triggered
|
||||||
@ -64,7 +80,7 @@ var PresentationMode = {
|
|||||||
* out of view when Presentation Mode is enabled.
|
* out of view when Presentation Mode is enabled.
|
||||||
* Note: This is only an issue at certain zoom levels, e.g. 'page-width'.
|
* Note: This is only an issue at certain zoom levels, e.g. 'page-width'.
|
||||||
*/
|
*/
|
||||||
_setSwitchInProgress: function presentationMode_setSwitchInProgress() {
|
_setSwitchInProgress: function pdfPresentationMode_setSwitchInProgress() {
|
||||||
if (this.switchInProgress) {
|
if (this.switchInProgress) {
|
||||||
clearTimeout(this.switchInProgress);
|
clearTimeout(this.switchInProgress);
|
||||||
}
|
}
|
||||||
@ -74,14 +90,14 @@ var PresentationMode = {
|
|||||||
}.bind(this), DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
|
}.bind(this), DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
|
||||||
},
|
},
|
||||||
|
|
||||||
_resetSwitchInProgress: function presentationMode_resetSwitchInProgress() {
|
_resetSwitchInProgress: function pdfPresentationMode_resetSwitchInProgress() {
|
||||||
if (this.switchInProgress) {
|
if (this.switchInProgress) {
|
||||||
clearTimeout(this.switchInProgress);
|
clearTimeout(this.switchInProgress);
|
||||||
delete this.switchInProgress;
|
delete this.switchInProgress;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
request: function presentationModeRequest() {
|
request: function pdfPresentationModeRequest() {
|
||||||
if (!this.initialized || this.isFullscreen ||
|
if (!this.initialized || this.isFullscreen ||
|
||||||
!this.viewer.hasChildNodes()) {
|
!this.viewer.hasChildNodes()) {
|
||||||
return false;
|
return false;
|
||||||
@ -109,16 +125,17 @@ var PresentationMode = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
_notifyStateChange: function presentationModeNotifyStateChange() {
|
_notifyStateChange: function pdfPresentationModeNotifyStateChange() {
|
||||||
|
var self = PDFPresentationMode;
|
||||||
var event = document.createEvent('CustomEvent');
|
var event = document.createEvent('CustomEvent');
|
||||||
event.initCustomEvent('presentationmodechanged', true, true, {
|
event.initCustomEvent('presentationmodechanged', true, true, {
|
||||||
active: PresentationMode.active,
|
active: self.active,
|
||||||
switchInProgress: !!PresentationMode.switchInProgress
|
switchInProgress: !!self.switchInProgress
|
||||||
});
|
});
|
||||||
window.dispatchEvent(event);
|
window.dispatchEvent(event);
|
||||||
},
|
},
|
||||||
|
|
||||||
enter: function presentationModeEnter() {
|
_enter: function pdfPresentationModeEnter() {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
this._resetSwitchInProgress();
|
this._resetSwitchInProgress();
|
||||||
this._notifyStateChange();
|
this._notifyStateChange();
|
||||||
@ -131,12 +148,12 @@ var PresentationMode = {
|
|||||||
PDFViewerApplication.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);
|
||||||
window.addEventListener('mousedown', this.mouseDown, false);
|
window.addEventListener('mousedown', this._mouseDown, false);
|
||||||
window.addEventListener('keydown', this.keyDown, false);
|
window.addEventListener('keydown', this._keyDown, false);
|
||||||
window.addEventListener('contextmenu', this.contextMenu, false);
|
window.addEventListener('contextmenu', this._contextMenu, false);
|
||||||
|
|
||||||
this.showControls();
|
this._showControls();
|
||||||
this.contextMenuOpen = false;
|
this.contextMenuOpen = false;
|
||||||
this.container.setAttribute('contextmenu', 'viewerContextMenu');
|
this.container.setAttribute('contextmenu', 'viewerContextMenu');
|
||||||
|
|
||||||
@ -146,7 +163,7 @@ var PresentationMode = {
|
|||||||
window.getSelection().removeAllRanges();
|
window.getSelection().removeAllRanges();
|
||||||
},
|
},
|
||||||
|
|
||||||
exit: function presentationModeExit() {
|
_exit: function pdfPresentationModeExit() {
|
||||||
var page = PDFViewerApplication.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
|
||||||
@ -161,13 +178,13 @@ var PresentationMode = {
|
|||||||
this.args = null;
|
this.args = null;
|
||||||
}.bind(this), 0);
|
}.bind(this), 0);
|
||||||
|
|
||||||
window.removeEventListener('mousemove', this.mouseMove, false);
|
window.removeEventListener('mousemove', this._mouseMove, false);
|
||||||
window.removeEventListener('mousedown', this.mouseDown, false);
|
window.removeEventListener('mousedown', this._mouseDown, false);
|
||||||
window.removeEventListener('keydown', this.keyDown, false);
|
window.removeEventListener('keydown', this._keyDown, false);
|
||||||
window.removeEventListener('contextmenu', this.contextMenu, false);
|
window.removeEventListener('contextmenu', this._contextMenu, false);
|
||||||
|
|
||||||
this.hideControls();
|
this._hideControls();
|
||||||
this.clearMouseScrollState();
|
this._clearMouseScrollState();
|
||||||
this.container.removeAttribute('contextmenu');
|
this.container.removeAttribute('contextmenu');
|
||||||
this.contextMenuOpen = false;
|
this.contextMenuOpen = false;
|
||||||
|
|
||||||
@ -178,19 +195,19 @@ var PresentationMode = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showControls: function presentationModeShowControls() {
|
_showControls: function pdfPresentationModeShowControls() {
|
||||||
if (this.controlsTimeout) {
|
if (this.controlsTimeout) {
|
||||||
clearTimeout(this.controlsTimeout);
|
clearTimeout(this.controlsTimeout);
|
||||||
} else {
|
} else {
|
||||||
this.container.classList.add(SELECTOR);
|
this.container.classList.add(SELECTOR);
|
||||||
}
|
}
|
||||||
this.controlsTimeout = setTimeout(function hideControlsTimeout() {
|
this.controlsTimeout = setTimeout(function showControlsTimeout() {
|
||||||
this.container.classList.remove(SELECTOR);
|
this.container.classList.remove(SELECTOR);
|
||||||
delete this.controlsTimeout;
|
delete this.controlsTimeout;
|
||||||
}.bind(this), DELAY_BEFORE_HIDING_CONTROLS);
|
}.bind(this), DELAY_BEFORE_HIDING_CONTROLS);
|
||||||
},
|
},
|
||||||
|
|
||||||
hideControls: function presentationModeHideControls() {
|
_hideControls: function pdfPresentationModeHideControls() {
|
||||||
if (!this.controlsTimeout) {
|
if (!this.controlsTimeout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -199,12 +216,12 @@ var PresentationMode = {
|
|||||||
delete this.controlsTimeout;
|
delete this.controlsTimeout;
|
||||||
},
|
},
|
||||||
|
|
||||||
mouseMove: function presentationModeMouseMove(evt) {
|
_mouseMove: function pdfPresentationModeMouseMove(evt) {
|
||||||
PresentationMode.showControls();
|
PDFPresentationMode._showControls();
|
||||||
},
|
},
|
||||||
|
|
||||||
mouseDown: function presentationModeMouseDown(evt) {
|
_mouseDown: function pdfPresentationModeMouseDown(evt) {
|
||||||
var self = PresentationMode;
|
var self = PDFPresentationMode;
|
||||||
if (self.contextMenuOpen) {
|
if (self.contextMenuOpen) {
|
||||||
self.contextMenuOpen = false;
|
self.contextMenuOpen = false;
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
@ -224,12 +241,12 @@ var PresentationMode = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
keyDown: function presentationModeKeyDown(evt) {
|
_keyDown: function pdfPresentationModeKeyDown(evt) {
|
||||||
PresentationMode.clearMouseScrollState();
|
PDFPresentationMode._clearMouseScrollState();
|
||||||
},
|
},
|
||||||
|
|
||||||
contextMenu: function presentationModeContextMenu(evt) {
|
_contextMenu: function pdfPresentationModeContextMenu(evt) {
|
||||||
PresentationMode.contextMenuOpen = true;
|
PDFPresentationMode.contextMenuOpen = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -237,7 +254,7 @@ var PresentationMode = {
|
|||||||
* or down with large enough motion and prevents page flipping too often.
|
* or down with large enough motion and prevents page flipping too often.
|
||||||
* @param {number} mouseScrollDelta The delta value from the mouse event.
|
* @param {number} mouseScrollDelta The delta value from the mouse event.
|
||||||
*/
|
*/
|
||||||
mouseScroll: function presentationModeMouseScroll(mouseScrollDelta) {
|
mouseScroll: function pdfPresentationModeMouseScroll(mouseScrollDelta) {
|
||||||
if (!this.initialized) {
|
if (!this.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -257,7 +274,7 @@ var PresentationMode = {
|
|||||||
// clear the accumulated delta.
|
// clear the accumulated delta.
|
||||||
if ((this.mouseScrollDelta > 0 && mouseScrollDelta < 0) ||
|
if ((this.mouseScrollDelta > 0 && mouseScrollDelta < 0) ||
|
||||||
(this.mouseScrollDelta < 0 && mouseScrollDelta > 0)) {
|
(this.mouseScrollDelta < 0 && mouseScrollDelta > 0)) {
|
||||||
this.clearMouseScrollState();
|
this._clearMouseScrollState();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mouseScrollDelta += mouseScrollDelta;
|
this.mouseScrollDelta += mouseScrollDelta;
|
||||||
@ -274,7 +291,7 @@ var PresentationMode = {
|
|||||||
var pageFlipDirection = (this.mouseScrollDelta > 0) ?
|
var pageFlipDirection = (this.mouseScrollDelta > 0) ?
|
||||||
PageFlipDirection.UP :
|
PageFlipDirection.UP :
|
||||||
PageFlipDirection.DOWN;
|
PageFlipDirection.DOWN;
|
||||||
this.clearMouseScrollState();
|
this._clearMouseScrollState();
|
||||||
var currentPage = PDFViewerApplication.page;
|
var currentPage = PDFViewerApplication.page;
|
||||||
|
|
||||||
// In case we are already on the first or the last page there is no need
|
// In case we are already on the first or the last page there is no need
|
||||||
@ -294,24 +311,8 @@ var PresentationMode = {
|
|||||||
* This function clears the member attributes used with mouse scrolling in
|
* This function clears the member attributes used with mouse scrolling in
|
||||||
* presentation mode.
|
* presentation mode.
|
||||||
*/
|
*/
|
||||||
clearMouseScrollState: function presentationModeClearMouseScrollState() {
|
_clearMouseScrollState: function pdfPresentationModeClearMouseScrollState() {
|
||||||
this.mouseScrollTimeStamp = 0;
|
this.mouseScrollTimeStamp = 0;
|
||||||
this.mouseScrollDelta = 0;
|
this.mouseScrollDelta = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(function presentationModeClosure() {
|
|
||||||
function presentationModeChange(e) {
|
|
||||||
if (PresentationMode.isFullscreen) {
|
|
||||||
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);
|
|
||||||
})();
|
|
@ -81,7 +81,7 @@ http://sourceforge.net/adobe/cmap/wiki/License/
|
|||||||
<script src="pdf_find_controller.js"></script>
|
<script src="pdf_find_controller.js"></script>
|
||||||
<script src="pdf_history.js"></script>
|
<script src="pdf_history.js"></script>
|
||||||
<script src="secondary_toolbar.js"></script>
|
<script src="secondary_toolbar.js"></script>
|
||||||
<script src="presentation_mode.js"></script>
|
<script src="pdf_presentation_mode.js"></script>
|
||||||
<script src="grab_to_pan.js"></script>
|
<script src="grab_to_pan.js"></script>
|
||||||
<script src="hand_tool.js"></script>
|
<script src="hand_tool.js"></script>
|
||||||
<script src="overlay_manager.js"></script>
|
<script src="overlay_manager.js"></script>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
DownloadManager, getFileName, getPDFFileNameFromURL,
|
DownloadManager, getFileName, getPDFFileNameFromURL,
|
||||||
PDFHistory, Preferences, SidebarView, ViewHistory, Stats,
|
PDFHistory, Preferences, SidebarView, ViewHistory, Stats,
|
||||||
PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar,
|
PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar,
|
||||||
PasswordPrompt, PresentationMode, HandTool, Promise,
|
PasswordPrompt, PDFPresentationMode, HandTool, Promise,
|
||||||
DocumentProperties, PDFOutlineView, PDFAttachmentView,
|
DocumentProperties, PDFOutlineView, PDFAttachmentView,
|
||||||
OverlayManager, PDFFindController, PDFFindBar, getVisibleElements,
|
OverlayManager, PDFFindController, PDFFindBar, getVisibleElements,
|
||||||
watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState,
|
watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState,
|
||||||
@ -84,7 +84,7 @@ var mozL10n = document.mozL10n || document.webL10n;
|
|||||||
//#include pdf_find_controller.js
|
//#include pdf_find_controller.js
|
||||||
//#include pdf_history.js
|
//#include pdf_history.js
|
||||||
//#include secondary_toolbar.js
|
//#include secondary_toolbar.js
|
||||||
//#include presentation_mode.js
|
//#include pdf_presentation_mode.js
|
||||||
//#include hand_tool.js
|
//#include hand_tool.js
|
||||||
//#include overlay_manager.js
|
//#include overlay_manager.js
|
||||||
//#include password_prompt.js
|
//#include password_prompt.js
|
||||||
@ -189,7 +189,7 @@ var PDFViewerApplication = {
|
|||||||
|
|
||||||
if (this.supportsFullscreen) {
|
if (this.supportsFullscreen) {
|
||||||
var toolbar = SecondaryToolbar;
|
var toolbar = SecondaryToolbar;
|
||||||
PresentationMode.initialize({
|
PDFPresentationMode.initialize({
|
||||||
container: container,
|
container: container,
|
||||||
pdfThumbnailViewer: this.pdfThumbnailViewer,
|
pdfThumbnailViewer: this.pdfThumbnailViewer,
|
||||||
contextMenuItems: [
|
contextMenuItems: [
|
||||||
@ -1344,14 +1344,14 @@ var PDFViewerApplication = {
|
|||||||
if (!this.supportsFullscreen) {
|
if (!this.supportsFullscreen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PresentationMode.request();
|
PDFPresentationMode.request();
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollPresentationMode: function pdfViewScrollPresentationMode(delta) {
|
scrollPresentationMode: function pdfViewScrollPresentationMode(delta) {
|
||||||
if (!this.supportsFullscreen) {
|
if (!this.supportsFullscreen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PresentationMode.mouseScroll(delta);
|
PDFPresentationMode.mouseScroll(delta);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//#if GENERIC
|
//#if GENERIC
|
||||||
|
Loading…
x
Reference in New Issue
Block a user