Break dependencies between PresentationMode and other code, and add PresentationMode related utility methods to PDFViewer
This patch: - Adds a couple of utility methods to `PDFViewer` to enable checking `presentationModeState` without cumbersome comparisons. - Disentangles `PresentationMode` from `PDFHistory` and `HandTool`, by adding event listeners for `presentationmodechanged` to both of them. - Adds a utility function to `PDFViewerApplication` for requesting PresentationMode. - Prevents initialization of `PresentationMode` if the browser does not support the fullscreen API.
This commit is contained in:
parent
846eb967cc
commit
2dc1af8028
@ -51,6 +51,17 @@ var HandTool = {
|
|||||||
}
|
}
|
||||||
}.bind(this), function rejected(reason) {});
|
}.bind(this), function rejected(reason) {});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
window.addEventListener('presentationmodechanged', function (evt) {
|
||||||
|
if (evt.detail.switchInProgress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (evt.detail.active) {
|
||||||
|
this.enterPresentationMode();
|
||||||
|
} else {
|
||||||
|
this.exitPresentationMode();
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
* 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, PresentationMode */
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -31,6 +30,7 @@ var PDFHistory = {
|
|||||||
this.reInitialized = false;
|
this.reInitialized = false;
|
||||||
this.allowHashChange = true;
|
this.allowHashChange = true;
|
||||||
this.historyUnlocked = true;
|
this.historyUnlocked = true;
|
||||||
|
this.isViewerInPresentationMode = false;
|
||||||
|
|
||||||
this.previousHash = window.location.hash.substring(1);
|
this.previousHash = window.location.hash.substring(1);
|
||||||
this.currentBookmark = '';
|
this.currentBookmark = '';
|
||||||
@ -122,6 +122,10 @@ var PDFHistory = {
|
|||||||
// the 'DOMContentLoaded' event is not fired on 'pageshow'.
|
// the 'DOMContentLoaded' event is not fired on 'pageshow'.
|
||||||
window.addEventListener('beforeunload', pdfHistoryBeforeUnload, false);
|
window.addEventListener('beforeunload', pdfHistoryBeforeUnload, false);
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
window.addEventListener('presentationmodechanged', function(e) {
|
||||||
|
self.isViewerInPresentationMode = !!e.detail.active;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {
|
_isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {
|
||||||
@ -286,7 +290,7 @@ var PDFHistory = {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var params = { hash: this.currentBookmark, page: this.currentPage };
|
var params = { hash: this.currentBookmark, page: this.currentPage };
|
||||||
if (PresentationMode.active) {
|
if (this.isViewerInPresentationMode) {
|
||||||
params.hash = null;
|
params.hash = null;
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
|
@ -374,11 +374,8 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
|
|
||||||
if (!noScroll) {
|
if (!noScroll) {
|
||||||
var page = this._currentPageNumber, dest;
|
var page = this._currentPageNumber, dest;
|
||||||
var inPresentationMode =
|
if (this.location && !IGNORE_CURRENT_POSITION_ON_ZOOM &&
|
||||||
this.presentationModeState === PresentationModeState.CHANGING ||
|
!(this.isInPresentationMode || this.isChangingPresentationMode)) {
|
||||||
this.presentationModeState === PresentationModeState.FULLSCREEN;
|
|
||||||
if (this.location && !inPresentationMode &&
|
|
||||||
!IGNORE_CURRENT_POSITION_ON_ZOOM) {
|
|
||||||
page = this.location.pageNumber;
|
page = this.location.pageNumber;
|
||||||
dest = [null, { name: 'XYZ' }, this.location.left,
|
dest = [null, { name: 'XYZ' }, this.location.left,
|
||||||
this.location.top, null];
|
this.location.top, null];
|
||||||
@ -402,11 +399,9 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
if (!currentPage) {
|
if (!currentPage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var inPresentationMode =
|
var hPadding = (this.isInPresentationMode || this.removePageBorders) ?
|
||||||
this.presentationModeState === PresentationModeState.FULLSCREEN;
|
|
||||||
var hPadding = (inPresentationMode || this.removePageBorders) ?
|
|
||||||
0 : SCROLLBAR_PADDING;
|
0 : SCROLLBAR_PADDING;
|
||||||
var vPadding = (inPresentationMode || this.removePageBorders) ?
|
var vPadding = (this.isInPresentationMode || this.removePageBorders) ?
|
||||||
0 : VERTICAL_PADDING;
|
0 : VERTICAL_PADDING;
|
||||||
var pageWidthScale = (this.container.clientWidth - hPadding) /
|
var pageWidthScale = (this.container.clientWidth - hPadding) /
|
||||||
currentPage.width * currentPage.scale;
|
currentPage.width * currentPage.scale;
|
||||||
@ -452,8 +447,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
dest) {
|
dest) {
|
||||||
var pageView = this.pages[pageNumber - 1];
|
var pageView = this.pages[pageNumber - 1];
|
||||||
|
|
||||||
if (this.presentationModeState ===
|
if (this.isInPresentationMode) {
|
||||||
PresentationModeState.FULLSCREEN) {
|
|
||||||
if (this.linkService.page !== pageView.id) {
|
if (this.linkService.page !== pageView.id) {
|
||||||
// Avoid breaking getVisiblePages in presentation mode.
|
// Avoid breaking getVisiblePages in presentation mode.
|
||||||
this.linkService.page = pageView.id;
|
this.linkService.page = pageView.id;
|
||||||
@ -607,7 +601,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
currentId = visiblePages[0].id;
|
currentId = visiblePages[0].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.presentationModeState !== PresentationModeState.FULLSCREEN) {
|
if (!this.isInPresentationMode) {
|
||||||
this.currentPageNumber = currentId;
|
this.currentPageNumber = currentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,13 +626,21 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
this.container.blur();
|
this.container.blur();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get isInPresentationMode() {
|
||||||
|
return this.presentationModeState === PresentationModeState.FULLSCREEN;
|
||||||
|
},
|
||||||
|
|
||||||
|
get isChangingPresentationMode() {
|
||||||
|
return this.PresentationModeState === PresentationModeState.CHANGING;
|
||||||
|
},
|
||||||
|
|
||||||
get isHorizontalScrollbarEnabled() {
|
get isHorizontalScrollbarEnabled() {
|
||||||
return (this.presentationModeState === PresentationModeState.FULLSCREEN ?
|
return (this.isInPresentationMode ?
|
||||||
false : (this.container.scrollWidth > this.container.clientWidth));
|
false : (this.container.scrollWidth > this.container.clientWidth));
|
||||||
},
|
},
|
||||||
|
|
||||||
_getVisiblePages: function () {
|
_getVisiblePages: function () {
|
||||||
if (this.presentationModeState !== PresentationModeState.FULLSCREEN) {
|
if (!this.isInPresentationMode) {
|
||||||
return getVisibleElements(this.container, this.pages, true);
|
return getVisibleElements(this.container, this.pages, true);
|
||||||
} else {
|
} else {
|
||||||
// The algorithm in getVisibleElements doesn't work in all browsers and
|
// The algorithm in getVisibleElements doesn't work in all browsers and
|
||||||
@ -709,13 +711,11 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
* @returns {TextLayerBuilder}
|
* @returns {TextLayerBuilder}
|
||||||
*/
|
*/
|
||||||
createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport) {
|
createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport) {
|
||||||
var isViewerInPresentationMode =
|
|
||||||
this.presentationModeState === PresentationModeState.FULLSCREEN;
|
|
||||||
return new TextLayerBuilder({
|
return new TextLayerBuilder({
|
||||||
textLayerDiv: textLayerDiv,
|
textLayerDiv: textLayerDiv,
|
||||||
pageIndex: pageIndex,
|
pageIndex: pageIndex,
|
||||||
viewport: viewport,
|
viewport: viewport,
|
||||||
findController: isViewerInPresentationMode ? null : this.findController
|
findController: this.isInPresentationMode ? null : this.findController
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -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 scrollIntoView, HandTool, PDFViewerApplication */
|
/* globals scrollIntoView, PDFViewerApplication */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -23,6 +23,7 @@ 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 PresentationMode = {
|
||||||
|
initialized: false,
|
||||||
active: false,
|
active: false,
|
||||||
args: null,
|
args: null,
|
||||||
contextMenuOpen: false,
|
contextMenuOpen: false,
|
||||||
@ -31,6 +32,7 @@ var PresentationMode = {
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
initialize: function presentationModeInitialize(options) {
|
initialize: function presentationModeInitialize(options) {
|
||||||
|
this.initialized = true;
|
||||||
this.container = options.container;
|
this.container = options.container;
|
||||||
this.secondaryToolbar = options.secondaryToolbar;
|
this.secondaryToolbar = options.secondaryToolbar;
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ var PresentationMode = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
request: function presentationModeRequest() {
|
request: function presentationModeRequest() {
|
||||||
if (!PDFViewerApplication.supportsFullscreen || this.isFullscreen ||
|
if (!this.initialized || this.isFullscreen ||
|
||||||
!this.viewer.hasChildNodes()) {
|
!this.viewer.hasChildNodes()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -147,7 +149,6 @@ var PresentationMode = {
|
|||||||
window.addEventListener('contextmenu', this.contextMenu, false);
|
window.addEventListener('contextmenu', this.contextMenu, false);
|
||||||
|
|
||||||
this.showControls();
|
this.showControls();
|
||||||
HandTool.enterPresentationMode();
|
|
||||||
this.contextMenuOpen = false;
|
this.contextMenuOpen = false;
|
||||||
this.container.setAttribute('contextmenu', 'viewerContextMenu');
|
this.container.setAttribute('contextmenu', 'viewerContextMenu');
|
||||||
|
|
||||||
@ -178,7 +179,6 @@ var PresentationMode = {
|
|||||||
|
|
||||||
this.hideControls();
|
this.hideControls();
|
||||||
PDFViewerApplication.clearMouseScrollState();
|
PDFViewerApplication.clearMouseScrollState();
|
||||||
HandTool.exitPresentationMode();
|
|
||||||
this.container.removeAttribute('contextmenu');
|
this.container.removeAttribute('contextmenu');
|
||||||
this.contextMenuOpen = false;
|
this.contextMenuOpen = false;
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ var SecondaryToolbar = {
|
|||||||
|
|
||||||
initialize: function secondaryToolbarInitialize(options) {
|
initialize: function secondaryToolbarInitialize(options) {
|
||||||
this.toolbar = options.toolbar;
|
this.toolbar = options.toolbar;
|
||||||
this.presentationMode = options.presentationMode;
|
|
||||||
this.documentProperties = options.documentProperties;
|
this.documentProperties = options.documentProperties;
|
||||||
this.buttonContainer = this.toolbar.firstElementChild;
|
this.buttonContainer = this.toolbar.firstElementChild;
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ var SecondaryToolbar = {
|
|||||||
|
|
||||||
// Event handling functions.
|
// Event handling functions.
|
||||||
presentationModeClick: function secondaryToolbarPresentationModeClick(evt) {
|
presentationModeClick: function secondaryToolbarPresentationModeClick(evt) {
|
||||||
this.presentationMode.request();
|
PDFViewerApplication.requestPresentationMode();
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -174,7 +174,6 @@ var PDFViewerApplication = {
|
|||||||
|
|
||||||
SecondaryToolbar.initialize({
|
SecondaryToolbar.initialize({
|
||||||
toolbar: document.getElementById('secondaryToolbar'),
|
toolbar: document.getElementById('secondaryToolbar'),
|
||||||
presentationMode: PresentationMode,
|
|
||||||
toggleButton: document.getElementById('secondaryToolbarToggle'),
|
toggleButton: document.getElementById('secondaryToolbarToggle'),
|
||||||
presentationModeButton:
|
presentationModeButton:
|
||||||
document.getElementById('secondaryPresentationMode'),
|
document.getElementById('secondaryPresentationMode'),
|
||||||
@ -190,14 +189,16 @@ var PDFViewerApplication = {
|
|||||||
documentPropertiesButton: document.getElementById('documentProperties')
|
documentPropertiesButton: document.getElementById('documentProperties')
|
||||||
});
|
});
|
||||||
|
|
||||||
PresentationMode.initialize({
|
if (this.supportsFullscreen) {
|
||||||
container: container,
|
PresentationMode.initialize({
|
||||||
secondaryToolbar: SecondaryToolbar,
|
container: container,
|
||||||
firstPage: document.getElementById('contextFirstPage'),
|
secondaryToolbar: SecondaryToolbar,
|
||||||
lastPage: document.getElementById('contextLastPage'),
|
firstPage: document.getElementById('contextFirstPage'),
|
||||||
pageRotateCw: document.getElementById('contextPageRotateCw'),
|
lastPage: document.getElementById('contextLastPage'),
|
||||||
pageRotateCcw: document.getElementById('contextPageRotateCcw')
|
pageRotateCw: document.getElementById('contextPageRotateCw'),
|
||||||
});
|
pageRotateCcw: document.getElementById('contextPageRotateCcw')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
PasswordPrompt.initialize({
|
PasswordPrompt.initialize({
|
||||||
overlayName: 'passwordOverlay',
|
overlayName: 'passwordOverlay',
|
||||||
@ -1334,6 +1335,13 @@ var PDFViewerApplication = {
|
|||||||
this.pdfViewer.scrollPageIntoView(pageNumber);
|
this.pdfViewer.scrollPageIntoView(pageNumber);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
requestPresentationMode: function pdfViewRequestPresentationMode() {
|
||||||
|
if (!this.supportsFullscreen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PresentationMode.request();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function flips the page in presentation mode if the user scrolls up
|
* This function flips the page in presentation mode if the user scrolls up
|
||||||
* or down with large enough motion and prevents page flipping too often.
|
* or down with large enough motion and prevents page flipping too often.
|
||||||
@ -1976,7 +1984,7 @@ function handleMouseWheel(evt) {
|
|||||||
evt.wheelDelta / MOUSE_WHEEL_DELTA_FACTOR;
|
evt.wheelDelta / MOUSE_WHEEL_DELTA_FACTOR;
|
||||||
var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn';
|
var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn';
|
||||||
|
|
||||||
if (PresentationMode.active) {
|
if (PDFViewerApplication.pdfViewer.isInPresentationMode) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
PDFViewerApplication.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR);
|
PDFViewerApplication.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR);
|
||||||
} else if (evt.ctrlKey || evt.metaKey) {
|
} else if (evt.ctrlKey || evt.metaKey) {
|
||||||
@ -1990,9 +1998,9 @@ window.addEventListener('DOMMouseScroll', handleMouseWheel);
|
|||||||
window.addEventListener('mousewheel', handleMouseWheel);
|
window.addEventListener('mousewheel', handleMouseWheel);
|
||||||
|
|
||||||
window.addEventListener('click', function click(evt) {
|
window.addEventListener('click', function click(evt) {
|
||||||
if (!PresentationMode.active) {
|
if (!PDFViewerApplication.pdfViewer.isInPresentationMode) {
|
||||||
if (SecondaryToolbar.opened &&
|
if (SecondaryToolbar.opened &&
|
||||||
PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
|
PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
|
||||||
SecondaryToolbar.close();
|
SecondaryToolbar.close();
|
||||||
}
|
}
|
||||||
} else if (evt.button === 0) {
|
} else if (evt.button === 0) {
|
||||||
@ -2013,15 +2021,13 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
(evt.shiftKey ? 4 : 0) |
|
(evt.shiftKey ? 4 : 0) |
|
||||||
(evt.metaKey ? 8 : 0);
|
(evt.metaKey ? 8 : 0);
|
||||||
|
|
||||||
|
var pdfViewer = PDFViewerApplication.pdfViewer;
|
||||||
|
var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
|
||||||
|
|
||||||
// First, handle the key bindings that are independent whether an input
|
// First, handle the key bindings that are independent whether an input
|
||||||
// control is selected or not.
|
// control is selected or not.
|
||||||
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
|
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
|
||||||
// either CTRL or META key with optional SHIFT.
|
// either CTRL or META key with optional SHIFT.
|
||||||
var pdfViewer = PDFViewerApplication.pdfViewer;
|
|
||||||
var inPresentationMode = pdfViewer &&
|
|
||||||
(pdfViewer.presentationModeState === PresentationModeState.CHANGING ||
|
|
||||||
pdfViewer.presentationModeState === PresentationModeState.FULLSCREEN);
|
|
||||||
|
|
||||||
switch (evt.keyCode) {
|
switch (evt.keyCode) {
|
||||||
case 70: // f
|
case 70: // f
|
||||||
if (!PDFViewerApplication.supportsIntegratedFind) {
|
if (!PDFViewerApplication.supportsIntegratedFind) {
|
||||||
@ -2040,7 +2046,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
case 107: // FF '+' and '='
|
case 107: // FF '+' and '='
|
||||||
case 187: // Chrome '+'
|
case 187: // Chrome '+'
|
||||||
case 171: // FF with German keyboard
|
case 171: // FF with German keyboard
|
||||||
if (!inPresentationMode) {
|
if (!isViewerInPresentationMode) {
|
||||||
PDFViewerApplication.zoomIn();
|
PDFViewerApplication.zoomIn();
|
||||||
}
|
}
|
||||||
handled = true;
|
handled = true;
|
||||||
@ -2048,14 +2054,14 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
case 173: // FF/Mac '-'
|
case 173: // FF/Mac '-'
|
||||||
case 109: // FF '-'
|
case 109: // FF '-'
|
||||||
case 189: // Chrome '-'
|
case 189: // Chrome '-'
|
||||||
if (!inPresentationMode) {
|
if (!isViewerInPresentationMode) {
|
||||||
PDFViewerApplication.zoomOut();
|
PDFViewerApplication.zoomOut();
|
||||||
}
|
}
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case 48: // '0'
|
case 48: // '0'
|
||||||
case 96: // '0' on Numpad of Swedish keyboard
|
case 96: // '0' on Numpad of Swedish keyboard
|
||||||
if (!inPresentationMode) {
|
if (!isViewerInPresentationMode) {
|
||||||
// keeping it unhandled (to restore page zoom to 100%)
|
// keeping it unhandled (to restore page zoom to 100%)
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
// ... and resetting the scale after browser adjusts its scale
|
// ... and resetting the scale after browser adjusts its scale
|
||||||
@ -2083,7 +2089,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
|
||||||
SecondaryToolbar.presentationModeClick();
|
PDFViewerApplication.requestPresentationMode();
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case 71: // g
|
case 71: // g
|
||||||
@ -2117,15 +2123,15 @@ 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 (!PresentationMode.active &&
|
if (!isViewerInPresentationMode &&
|
||||||
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* in presentation mode */
|
/* in presentation mode */
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 37: // left arrow
|
case 37: // left arrow
|
||||||
// horizontal scrolling using arrow keys
|
// horizontal scrolling using arrow keys
|
||||||
if (PDFViewerApplication.pdfViewer.isHorizontalScrollbarEnabled) {
|
if (pdfViewer.isHorizontalScrollbarEnabled) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* falls through */
|
/* falls through */
|
||||||
@ -2148,14 +2154,14 @@ 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 (!PresentationMode.active &&
|
if (!isViewerInPresentationMode &&
|
||||||
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 39: // right arrow
|
case 39: // right arrow
|
||||||
// horizontal scrolling using arrow keys
|
// horizontal scrolling using arrow keys
|
||||||
if (PDFViewerApplication.pdfViewer.isHorizontalScrollbarEnabled) {
|
if (pdfViewer.isHorizontalScrollbarEnabled) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* falls through */
|
/* falls through */
|
||||||
@ -2166,13 +2172,13 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 36: // home
|
case 36: // home
|
||||||
if (PresentationMode.active || PDFViewerApplication.page > 1) {
|
if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
|
||||||
PDFViewerApplication.page = 1;
|
PDFViewerApplication.page = 1;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 35: // end
|
case 35: // end
|
||||||
if (PresentationMode.active || (PDFViewerApplication.pdfDocument &&
|
if (isViewerInPresentationMode || (PDFViewerApplication.pdfDocument &&
|
||||||
PDFViewerApplication.page < PDFViewerApplication.pagesCount)) {
|
PDFViewerApplication.page < PDFViewerApplication.pagesCount)) {
|
||||||
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
||||||
handled = true;
|
handled = true;
|
||||||
@ -2180,7 +2186,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 72: // 'h'
|
case 72: // 'h'
|
||||||
if (!PresentationMode.active) {
|
if (!isViewerInPresentationMode) {
|
||||||
HandTool.toggle();
|
HandTool.toggle();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2193,7 +2199,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 (!PresentationMode.active &&
|
if (!isViewerInPresentationMode &&
|
||||||
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
PDFViewerApplication.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2207,25 +2213,25 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handled && !PresentationMode.active) {
|
if (!handled && !isViewerInPresentationMode) {
|
||||||
// 33=Page Up 34=Page Down 35=End 36=Home
|
// 33=Page Up 34=Page Down 35=End 36=Home
|
||||||
// 37=Left 38=Up 39=Right 40=Down
|
// 37=Left 38=Up 39=Right 40=Down
|
||||||
if (evt.keyCode >= 33 && evt.keyCode <= 40 &&
|
if (evt.keyCode >= 33 && evt.keyCode <= 40 &&
|
||||||
!PDFViewerApplication.pdfViewer.containsElement(curElement)) {
|
!pdfViewer.containsElement(curElement)) {
|
||||||
// The page container is not focused, but a page navigation key has been
|
// The page container is not focused, but a page navigation key has been
|
||||||
// pressed. Change the focus to the viewer container to make sure that
|
// pressed. Change the focus to the viewer container to make sure that
|
||||||
// navigation by keyboard works as expected.
|
// navigation by keyboard works as expected.
|
||||||
PDFViewerApplication.pdfViewer.focus();
|
pdfViewer.focus();
|
||||||
}
|
}
|
||||||
// 32=Spacebar
|
// 32=Spacebar
|
||||||
if (evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
|
if (evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
|
||||||
//#if (FIREFOX || MOZCENTRAL)
|
//#if (FIREFOX || MOZCENTRAL)
|
||||||
// // Workaround for issue in Firefox, that prevents scroll keys from
|
// // Workaround for issue in Firefox, that prevents scroll keys from
|
||||||
// // working when elements with 'tabindex' are focused. (#3498)
|
// // working when elements with 'tabindex' are focused. (#3498)
|
||||||
// PDFViewerApplication.pdfViewer.blur();
|
// pdfViewer.blur();
|
||||||
//#else
|
//#else
|
||||||
if (!PDFViewerApplication.pdfViewer.containsElement(curElement)) {
|
if (!pdfViewer.containsElement(curElement)) {
|
||||||
PDFViewerApplication.pdfViewer.focus();
|
pdfViewer.focus();
|
||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
@ -2234,13 +2240,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 (PresentationMode.active) {
|
if (isViewerInPresentationMode) {
|
||||||
PDFHistory.back();
|
PDFHistory.back();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 39: // right arrow
|
case 39: // right arrow
|
||||||
if (PresentationMode.active) {
|
if (isViewerInPresentationMode) {
|
||||||
PDFHistory.forward();
|
PDFHistory.forward();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user