|
|
@ -68,6 +68,86 @@ var PDFPresentationMode = { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Request the browser to enter fullscreen mode. |
|
|
|
|
|
|
|
* @returns {boolean} Indicating if the request was successful. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
request: function pdfPresentationModeRequest() { |
|
|
|
|
|
|
|
if (!this.initialized || this.switchInProgress || this.active || |
|
|
|
|
|
|
|
!this.viewer.hasChildNodes()) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this._setSwitchInProgress(); |
|
|
|
|
|
|
|
this._notifyStateChange(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.container.requestFullscreen) { |
|
|
|
|
|
|
|
this.container.requestFullscreen(); |
|
|
|
|
|
|
|
} else if (this.container.mozRequestFullScreen) { |
|
|
|
|
|
|
|
this.container.mozRequestFullScreen(); |
|
|
|
|
|
|
|
} else if (this.container.webkitRequestFullscreen) { |
|
|
|
|
|
|
|
this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); |
|
|
|
|
|
|
|
} else if (this.container.msRequestFullscreen) { |
|
|
|
|
|
|
|
this.container.msRequestFullscreen(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.args = { |
|
|
|
|
|
|
|
page: PDFViewerApplication.page, |
|
|
|
|
|
|
|
previousScale: PDFViewerApplication.currentScaleValue |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Switches page when the user scrolls (using a scroll wheel or a touchpad) |
|
|
|
|
|
|
|
* with large enough motion, to prevent accidental page switches. |
|
|
|
|
|
|
|
* @param {number} delta - The delta value from the mouse event. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
mouseScroll: function pdfPresentationModeMouseScroll(delta) { |
|
|
|
|
|
|
|
if (!this.initialized && !this.active) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var MOUSE_SCROLL_COOLDOWN_TIME = 50; |
|
|
|
|
|
|
|
var PAGE_SWITCH_THRESHOLD = 120; |
|
|
|
|
|
|
|
var PageSwitchDirection = { |
|
|
|
|
|
|
|
UP: -1, |
|
|
|
|
|
|
|
DOWN: 1 |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currentTime = (new Date()).getTime(); |
|
|
|
|
|
|
|
var storedTime = this.mouseScrollTimeStamp; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If we've already switched page, avoid accidentally switching page again.
|
|
|
|
|
|
|
|
if (currentTime > storedTime && |
|
|
|
|
|
|
|
currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// If the user changes scroll direction, reset the accumulated scroll delta.
|
|
|
|
|
|
|
|
if ((this.mouseScrollDelta > 0 && delta < 0) || |
|
|
|
|
|
|
|
(this.mouseScrollDelta < 0 && delta > 0)) { |
|
|
|
|
|
|
|
this._resetMouseScrollState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.mouseScrollDelta += delta; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) { |
|
|
|
|
|
|
|
var pageSwitchDirection = (this.mouseScrollDelta > 0) ? |
|
|
|
|
|
|
|
PageSwitchDirection.UP : PageSwitchDirection.DOWN; |
|
|
|
|
|
|
|
var page = PDFViewerApplication.page; |
|
|
|
|
|
|
|
this._resetMouseScrollState(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If we're already on the first/last page, we don't need to do anything.
|
|
|
|
|
|
|
|
if ((page === 1 && pageSwitchDirection === PageSwitchDirection.UP) || |
|
|
|
|
|
|
|
(page === PDFViewerApplication.pagesCount && |
|
|
|
|
|
|
|
pageSwitchDirection === PageSwitchDirection.DOWN)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PDFViewerApplication.page = (page + pageSwitchDirection); |
|
|
|
|
|
|
|
this.mouseScrollTimeStamp = currentTime; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
get isFullscreen() { |
|
|
|
get isFullscreen() { |
|
|
|
return !!(document.fullscreenElement || |
|
|
|
return !!(document.fullscreenElement || |
|
|
|
document.mozFullScreen || |
|
|
|
document.mozFullScreen || |
|
|
@ -87,6 +167,19 @@ var PDFPresentationMode = { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_notifyStateChange: function pdfPresentationModeNotifyStateChange() { |
|
|
|
|
|
|
|
var self = PDFPresentationMode; |
|
|
|
|
|
|
|
var event = document.createEvent('CustomEvent'); |
|
|
|
|
|
|
|
event.initCustomEvent('presentationmodechanged', true, true, { |
|
|
|
|
|
|
|
active: self.active, |
|
|
|
|
|
|
|
switchInProgress: !!self.switchInProgress |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
window.dispatchEvent(event); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Used to initialize a timeout when requesting Presentation Mode, |
|
|
|
* Used to initialize a timeout when requesting Presentation Mode, |
|
|
|
* i.e. when the browser is requested to enter fullscreen mode. |
|
|
|
* i.e. when the browser is requested to enter fullscreen mode. |
|
|
@ -115,51 +208,6 @@ var PDFPresentationMode = { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Request the browser to enter fullscreen mode. |
|
|
|
|
|
|
|
* @returns {boolean} Indicating if the request was successful. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
request: function pdfPresentationModeRequest() { |
|
|
|
|
|
|
|
if (!this.initialized || this.switchInProgress || this.active || |
|
|
|
|
|
|
|
!this.viewer.hasChildNodes()) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this._setSwitchInProgress(); |
|
|
|
|
|
|
|
this._notifyStateChange(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.container.requestFullscreen) { |
|
|
|
|
|
|
|
this.container.requestFullscreen(); |
|
|
|
|
|
|
|
} else if (this.container.mozRequestFullScreen) { |
|
|
|
|
|
|
|
this.container.mozRequestFullScreen(); |
|
|
|
|
|
|
|
} else if (this.container.webkitRequestFullscreen) { |
|
|
|
|
|
|
|
this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); |
|
|
|
|
|
|
|
} else if (this.container.msRequestFullscreen) { |
|
|
|
|
|
|
|
this.container.msRequestFullscreen(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.args = { |
|
|
|
|
|
|
|
page: PDFViewerApplication.page, |
|
|
|
|
|
|
|
previousScale: PDFViewerApplication.currentScaleValue |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_notifyStateChange: function pdfPresentationModeNotifyStateChange() { |
|
|
|
|
|
|
|
var self = PDFPresentationMode; |
|
|
|
|
|
|
|
var event = document.createEvent('CustomEvent'); |
|
|
|
|
|
|
|
event.initCustomEvent('presentationmodechanged', true, true, { |
|
|
|
|
|
|
|
active: self.active, |
|
|
|
|
|
|
|
switchInProgress: !!self.switchInProgress |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
window.dispatchEvent(event); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @private |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -222,35 +270,6 @@ var PDFPresentationMode = { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_showControls: function pdfPresentationModeShowControls() { |
|
|
|
|
|
|
|
var self = PDFPresentationMode; |
|
|
|
|
|
|
|
if (self.controlsTimeout) { |
|
|
|
|
|
|
|
clearTimeout(self.controlsTimeout); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self.container.classList.add(SELECTOR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.controlsTimeout = setTimeout(function showControlsTimeout() { |
|
|
|
|
|
|
|
self.container.classList.remove(SELECTOR); |
|
|
|
|
|
|
|
delete self.controlsTimeout; |
|
|
|
|
|
|
|
}, DELAY_BEFORE_HIDING_CONTROLS); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_hideControls: function pdfPresentationModeHideControls() { |
|
|
|
|
|
|
|
var self = PDFPresentationMode; |
|
|
|
|
|
|
|
if (!self.controlsTimeout) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
clearTimeout(self.controlsTimeout); |
|
|
|
|
|
|
|
self.container.classList.remove(SELECTOR); |
|
|
|
|
|
|
|
delete self.controlsTimeout; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @private |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -282,51 +301,32 @@ var PDFPresentationMode = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Switches page when the user scrolls (using a scroll wheel or a touchpad) |
|
|
|
* @private |
|
|
|
* with large enough motion, to prevent accidental page switches. |
|
|
|
|
|
|
|
* @param {number} delta - The delta value from the mouse event. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
mouseScroll: function pdfPresentationModeMouseScroll(delta) { |
|
|
|
_showControls: function pdfPresentationModeShowControls() { |
|
|
|
if (!this.initialized && !this.active) { |
|
|
|
var self = PDFPresentationMode; |
|
|
|
return; |
|
|
|
if (self.controlsTimeout) { |
|
|
|
|
|
|
|
clearTimeout(self.controlsTimeout); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self.container.classList.add(SELECTOR); |
|
|
|
} |
|
|
|
} |
|
|
|
var MOUSE_SCROLL_COOLDOWN_TIME = 50; |
|
|
|
self.controlsTimeout = setTimeout(function showControlsTimeout() { |
|
|
|
var PAGE_SWITCH_THRESHOLD = 120; |
|
|
|
self.container.classList.remove(SELECTOR); |
|
|
|
var PageSwitchDirection = { |
|
|
|
delete self.controlsTimeout; |
|
|
|
UP: -1, |
|
|
|
}, DELAY_BEFORE_HIDING_CONTROLS); |
|
|
|
DOWN: 1 |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currentTime = (new Date()).getTime(); |
|
|
|
|
|
|
|
var storedTime = this.mouseScrollTimeStamp; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If we've already switched page, avoid accidentally switching page again.
|
|
|
|
/** |
|
|
|
if (currentTime > storedTime && |
|
|
|
* @private |
|
|
|
currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) { |
|
|
|
*/ |
|
|
|
|
|
|
|
_hideControls: function pdfPresentationModeHideControls() { |
|
|
|
|
|
|
|
var self = PDFPresentationMode; |
|
|
|
|
|
|
|
if (!self.controlsTimeout) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// If the user changes scroll direction, reset the accumulated scroll delta.
|
|
|
|
clearTimeout(self.controlsTimeout); |
|
|
|
if ((this.mouseScrollDelta > 0 && delta < 0) || |
|
|
|
self.container.classList.remove(SELECTOR); |
|
|
|
(this.mouseScrollDelta < 0 && delta > 0)) { |
|
|
|
delete self.controlsTimeout; |
|
|
|
this._resetMouseScrollState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.mouseScrollDelta += delta; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) { |
|
|
|
|
|
|
|
var pageSwitchDirection = (this.mouseScrollDelta > 0) ? |
|
|
|
|
|
|
|
PageSwitchDirection.UP : PageSwitchDirection.DOWN; |
|
|
|
|
|
|
|
var page = PDFViewerApplication.page; |
|
|
|
|
|
|
|
this._resetMouseScrollState(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If we're already on the first/last page, we don't need to do anything.
|
|
|
|
|
|
|
|
if ((page === 1 && pageSwitchDirection === PageSwitchDirection.UP) || |
|
|
|
|
|
|
|
(page === PDFViewerApplication.pagesCount && |
|
|
|
|
|
|
|
pageSwitchDirection === PageSwitchDirection.DOWN)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PDFViewerApplication.page = (page + pageSwitchDirection); |
|
|
|
|
|
|
|
this.mouseScrollTimeStamp = currentTime; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|