Replace fullscreen with presentationMode
This commit is contained in:
parent
78ad4d4eaf
commit
5e08f8039d
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 491 B |
@ -865,9 +865,9 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
|||||||
content: url(images/toolbarButton-zoomIn.png);
|
content: url(images/toolbarButton-zoomIn.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
.toolbarButton.fullscreen::before {
|
.toolbarButton.presentationMode::before {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
content: url(images/toolbarButton-fullscreen.png);
|
content: url(images/toolbarButton-presentationMode.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
.toolbarButton.print::before {
|
.toolbarButton.print::before {
|
||||||
|
@ -145,7 +145,7 @@ limitations under the License.
|
|||||||
<div id="toolbarViewerRight">
|
<div id="toolbarViewerRight">
|
||||||
<input id="fileInput" class="fileInput" type="file" oncontextmenu="return false;" style="visibility: hidden; position: fixed; right: 0; top: 0" />
|
<input id="fileInput" class="fileInput" type="file" oncontextmenu="return false;" style="visibility: hidden; position: fixed; right: 0; top: 0" />
|
||||||
|
|
||||||
<button id="fullscreen" class="toolbarButton fullscreen hiddenSmallView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
|
<button id="presentationMode" class="toolbarButton presentationMode hiddenSmallView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
|
||||||
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ var PDFView = {
|
|||||||
sidebarOpen: false,
|
sidebarOpen: false,
|
||||||
pageViewScroll: null,
|
pageViewScroll: null,
|
||||||
thumbnailViewScroll: null,
|
thumbnailViewScroll: null,
|
||||||
isFullscreen: false,
|
isPresentationMode: false,
|
||||||
previousScale: null,
|
previousScale: null,
|
||||||
pageRotation: 0,
|
pageRotation: 0,
|
||||||
mouseScrollTimeStamp: 0,
|
mouseScrollTimeStamp: 0,
|
||||||
@ -880,11 +880,12 @@ var PDFView = {
|
|||||||
var support = doc.requestFullscreen || doc.mozRequestFullScreen ||
|
var support = doc.requestFullscreen || doc.mozRequestFullScreen ||
|
||||||
doc.webkitRequestFullScreen;
|
doc.webkitRequestFullScreen;
|
||||||
|
|
||||||
// Disable fullscreen button if we're in an iframe
|
// Disable presentation mode button if we're in an iframe
|
||||||
if (window.parent !== window)
|
if (window.parent !== window) {
|
||||||
support = false;
|
support = false;
|
||||||
|
}
|
||||||
|
|
||||||
Object.defineProperty(this, 'supportsFullScreen', { value: support,
|
Object.defineProperty(this, 'supportsFullscreen', { value: support,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true,
|
configurable: true,
|
||||||
writable: false });
|
writable: false });
|
||||||
@ -1191,7 +1192,7 @@ var PDFView = {
|
|||||||
pageNumber = self.pages.length;
|
pageNumber = self.pages.length;
|
||||||
}
|
}
|
||||||
self.page = pageNumber;
|
self.page = pageNumber;
|
||||||
if (!self.isFullscreen) { // Avoid breaking fullscreen mode.
|
if (!self.isPresentationMode) { // Avoid breaking presentation mode.
|
||||||
var currentPage = self.pages[pageNumber - 1];
|
var currentPage = self.pages[pageNumber - 1];
|
||||||
currentPage.scrollIntoView(dest);
|
currentPage.scrollIntoView(dest);
|
||||||
}
|
}
|
||||||
@ -1715,10 +1716,10 @@ var PDFView = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getVisiblePages: function pdfViewGetVisiblePages() {
|
getVisiblePages: function pdfViewGetVisiblePages() {
|
||||||
if (!this.isFullscreen) {
|
if (!this.isPresentationMode) {
|
||||||
return this.getVisibleElements(this.container, this.pages, true);
|
return this.getVisibleElements(this.container, this.pages, true);
|
||||||
} else {
|
} else {
|
||||||
// The algorithm in getVisibleElements is broken in fullscreen mode.
|
// The algorithm in getVisibleElements is broken in presentation mode.
|
||||||
var visible = [], page = this.page;
|
var visible = [], page = this.page;
|
||||||
var currentPage = this.pages[page - 1];
|
var currentPage = this.pages[page - 1];
|
||||||
visible.push({ id: currentPage.id, view: currentPage });
|
visible.push({ id: currentPage.id, view: currentPage });
|
||||||
@ -1830,11 +1831,12 @@ var PDFView = {
|
|||||||
div.removeChild(div.lastChild);
|
div.removeChild(div.lastChild);
|
||||||
},
|
},
|
||||||
|
|
||||||
fullscreen: function pdfViewFullscreen() {
|
presentationMode: function pdfViewPresentationMode() {
|
||||||
var isFullscreen = document.fullscreenElement || document.mozFullScreen ||
|
var isPresentationMode = document.fullscreenElement ||
|
||||||
document.webkitIsFullScreen;
|
document.mozFullScreen ||
|
||||||
|
document.webkitIsFullScreen;
|
||||||
|
|
||||||
if (isFullscreen) {
|
if (isPresentationMode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1849,12 +1851,12 @@ var PDFView = {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isFullscreen = true;
|
this.isPresentationMode = true;
|
||||||
var currentPage = this.pages[this.page - 1];
|
var currentPage = this.pages[this.page - 1];
|
||||||
this.previousScale = this.currentScaleValue;
|
this.previousScale = this.currentScaleValue;
|
||||||
this.parseScale('page-fit', true);
|
this.parseScale('page-fit', true);
|
||||||
|
|
||||||
// Wait for fullscreen to take effect
|
// Wait for presentation mode to take effect
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
currentPage.scrollIntoView();
|
currentPage.scrollIntoView();
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -1863,15 +1865,15 @@ var PDFView = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
exitFullscreen: function pdfViewExitFullscreen() {
|
exitPresentationMode: function pdfViewExitPresentationMode() {
|
||||||
this.isFullscreen = false;
|
this.isPresentationMode = false;
|
||||||
this.parseScale(this.previousScale);
|
this.parseScale(this.previousScale);
|
||||||
this.page = this.page;
|
this.page = this.page;
|
||||||
this.clearMouseScrollState();
|
this.clearMouseScrollState();
|
||||||
this.hidePresentationControls();
|
this.hidePresentationControls();
|
||||||
|
|
||||||
// Ensure that the thumbnail of the current page is visible
|
// Ensure that the thumbnail of the current page is visible
|
||||||
// when exiting fullscreen mode.
|
// when exiting presentation mode.
|
||||||
scrollIntoView(document.getElementById('thumbnailContainer' + this.page));
|
scrollIntoView(document.getElementById('thumbnailContainer' + this.page));
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1923,7 +1925,7 @@ var PDFView = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for fullscreen to take effect
|
// Wait for presentation mode to take effect
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
currentPage.scrollIntoView();
|
currentPage.scrollIntoView();
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -1964,7 +1966,7 @@ var PDFView = {
|
|||||||
DOWN: 1
|
DOWN: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
// In fullscreen mode scroll one page at a time.
|
// In presentation mode scroll one page at a time.
|
||||||
var pageFlipDirection = (this.mouseScrollDelta > 0) ?
|
var pageFlipDirection = (this.mouseScrollDelta > 0) ?
|
||||||
PageFlipDirection.UP :
|
PageFlipDirection.UP :
|
||||||
PageFlipDirection.DOWN;
|
PageFlipDirection.DOWN;
|
||||||
@ -3155,7 +3157,7 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!PDFView.supportsFullscreen) {
|
if (!PDFView.supportsFullscreen) {
|
||||||
document.getElementById('fullscreen').classList.add('hidden');
|
document.getElementById('presentationMode').classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDFView.supportsIntegratedFind) {
|
if (PDFView.supportsIntegratedFind) {
|
||||||
@ -3220,9 +3222,9 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||||||
PDFView.zoomOut();
|
PDFView.zoomOut();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('fullscreen').addEventListener('click',
|
document.getElementById('presentationMode').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.fullscreen();
|
PDFView.presentationMode();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('openFile').addEventListener('click',
|
document.getElementById('openFile').addEventListener('click',
|
||||||
@ -3323,7 +3325,7 @@ function updateViewarea() {
|
|||||||
currentId = visiblePages[0].id;
|
currentId = visiblePages[0].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PDFView.isFullscreen) {
|
if (!PDFView.isPresentationMode) {
|
||||||
updateViewarea.inProgress = true; // used in "set page"
|
updateViewarea.inProgress = true; // used in "set page"
|
||||||
PDFView.page = currentId;
|
PDFView.page = currentId;
|
||||||
updateViewarea.inProgress = false;
|
updateViewarea.inProgress = false;
|
||||||
@ -3478,27 +3480,28 @@ window.addEventListener('DOMMouseScroll', function(evt) {
|
|||||||
var direction = (ticks > 0) ? 'zoomOut' : 'zoomIn';
|
var direction = (ticks > 0) ? 'zoomOut' : 'zoomIn';
|
||||||
for (var i = 0, length = Math.abs(ticks); i < length; i++)
|
for (var i = 0, length = Math.abs(ticks); i < length; i++)
|
||||||
PDFView[direction]();
|
PDFView[direction]();
|
||||||
} else if (PDFView.isFullscreen) {
|
} else if (PDFView.isPresentationMode) {
|
||||||
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) {
|
window.addEventListener('mousemove', function mousemove(evt) {
|
||||||
if (PDFView.isFullscreen) {
|
if (PDFView.isPresentationMode) {
|
||||||
PDFView.showPresentationControls();
|
PDFView.showPresentationControls();
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
window.addEventListener('mousedown', function mousedown(evt) {
|
window.addEventListener('mousedown', function mousedown(evt) {
|
||||||
if (PDFView.isFullscreen && evt.button === 0) {
|
if (PDFView.isPresentationMode && evt.button === 0) {
|
||||||
// Enable clicking of links in fullscreen mode.
|
// Enable clicking of links in presentation mode.
|
||||||
// Note: Only links that point to the currently loaded PDF document works.
|
// Note: Only links that point to the currently loaded PDF document works.
|
||||||
var targetHref = evt.target.href;
|
var targetHref = evt.target.href;
|
||||||
var internalLink = targetHref && (targetHref.replace(/#.*$/, '') ===
|
var internalLink = targetHref && (targetHref.replace(/#.*$/, '') ===
|
||||||
window.location.href.replace(/#.*$/, ''));
|
window.location.href.replace(/#.*$/, ''));
|
||||||
if (!internalLink) {
|
if (!internalLink) {
|
||||||
// Unless an internal link was clicked, advance a page in fullscreen mode.
|
// Unless an internal link was clicked, advance a page in presentation
|
||||||
|
// mode.
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
PDFView.page++;
|
PDFView.page++;
|
||||||
}
|
}
|
||||||
@ -3506,7 +3509,7 @@ window.addEventListener('mousedown', function mousedown(evt) {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
window.addEventListener('click', function click(evt) {
|
window.addEventListener('click', function click(evt) {
|
||||||
if (PDFView.isFullscreen && evt.button === 0) {
|
if (PDFView.isPresentationMode && evt.button === 0) {
|
||||||
// Necessary since preventDefault() in 'mousedown' won't stop
|
// Necessary since preventDefault() in 'mousedown' won't stop
|
||||||
// the event propagation in all circumstances.
|
// the event propagation in all circumstances.
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
@ -3578,7 +3581,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.isFullscreen)
|
if (curElement === controlsElement && !PDFView.isPresentationMode)
|
||||||
return; // ignoring if the 'toolbar' element is focused
|
return; // ignoring if the 'toolbar' element is focused
|
||||||
curElement = curElement.parentNode;
|
curElement = curElement.parentNode;
|
||||||
}
|
}
|
||||||
@ -3588,10 +3591,11 @@ 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.isFullscreen && PDFView.currentScaleValue !== 'page-fit') {
|
if (!PDFView.isPresentationMode &&
|
||||||
|
PDFView.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* in fullscreen 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
|
||||||
@ -3613,7 +3617,8 @@ 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.isFullscreen && PDFView.currentScaleValue !== 'page-fit') {
|
if (!PDFView.isPresentationMode &&
|
||||||
|
PDFView.currentScaleValue !== 'page-fit') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* falls through */
|
/* falls through */
|
||||||
@ -3630,13 +3635,13 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 36: // home
|
case 36: // home
|
||||||
if (PDFView.isFullscreen) {
|
if (PDFView.isPresentationMode) {
|
||||||
PDFView.page = 1;
|
PDFView.page = 1;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 35: // end
|
case 35: // end
|
||||||
if (PDFView.isFullscreen) {
|
if (PDFView.isPresentationMode) {
|
||||||
PDFView.page = PDFView.pdfDocument.numPages;
|
PDFView.page = PDFView.pdfDocument.numPages;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
@ -3670,19 +3675,21 @@ window.addEventListener('afterprint', function afterPrint(evt) {
|
|||||||
PDFView.afterPrint();
|
PDFView.afterPrint();
|
||||||
});
|
});
|
||||||
|
|
||||||
(function fullscreenClosure() {
|
(function presentationModeClosure() {
|
||||||
function fullscreenChange(e) {
|
function presentationModeChange(e) {
|
||||||
var isFullscreen = document.fullscreenElement || document.mozFullScreen ||
|
var isPresentationMode = document.fullscreenElement ||
|
||||||
document.webkitIsFullScreen;
|
document.mozFullScreen ||
|
||||||
|
document.webkitIsFullScreen;
|
||||||
|
|
||||||
if (!isFullscreen) {
|
if (!isPresentationMode) {
|
||||||
PDFView.exitFullscreen();
|
PDFView.exitPresentationMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('fullscreenchange', fullscreenChange, false);
|
window.addEventListener('fullscreenchange', presentationModeChange, false);
|
||||||
window.addEventListener('mozfullscreenchange', fullscreenChange, false);
|
window.addEventListener('mozfullscreenchange', presentationModeChange, false);
|
||||||
window.addEventListener('webkitfullscreenchange', fullscreenChange, false);
|
window.addEventListener('webkitfullscreenchange', presentationModeChange,
|
||||||
|
false);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(function animationStartedClosure() {
|
(function animationStartedClosure() {
|
||||||
|
Loading…
Reference in New Issue
Block a user