Skip to content

Commit d1cea4a

Browse files
committed
Merge pull request mozilla#2863 from kkujala/presentation
Replace fullscreen with presentationMode
2 parents 78ad4d4 + 5e08f80 commit d1cea4a

File tree

4 files changed

+53
-46
lines changed

4 files changed

+53
-46
lines changed

web/viewer.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,9 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
865865
content: url(images/toolbarButton-zoomIn.png);
866866
}
867867

868-
.toolbarButton.fullscreen::before {
868+
.toolbarButton.presentationMode::before {
869869
display: inline-block;
870-
content: url(images/toolbarButton-fullscreen.png);
870+
content: url(images/toolbarButton-presentationMode.png);
871871
}
872872

873873
.toolbarButton.print::before {

web/viewer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<div id="toolbarViewerRight">
146146
<input id="fileInput" class="fileInput" type="file" oncontextmenu="return false;" style="visibility: hidden; position: fixed; right: 0; top: 0" />
147147

148-
<button id="fullscreen" class="toolbarButton fullscreen hiddenSmallView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
148+
<button id="presentationMode" class="toolbarButton presentationMode hiddenSmallView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
149149
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
150150
</button>
151151

web/viewer.js

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ var PDFView = {
701701
sidebarOpen: false,
702702
pageViewScroll: null,
703703
thumbnailViewScroll: null,
704-
isFullscreen: false,
704+
isPresentationMode: false,
705705
previousScale: null,
706706
pageRotation: 0,
707707
mouseScrollTimeStamp: 0,
@@ -880,11 +880,12 @@ var PDFView = {
880880
var support = doc.requestFullscreen || doc.mozRequestFullScreen ||
881881
doc.webkitRequestFullScreen;
882882

883-
// Disable fullscreen button if we're in an iframe
884-
if (window.parent !== window)
883+
// Disable presentation mode button if we're in an iframe
884+
if (window.parent !== window) {
885885
support = false;
886+
}
886887

887-
Object.defineProperty(this, 'supportsFullScreen', { value: support,
888+
Object.defineProperty(this, 'supportsFullscreen', { value: support,
888889
enumerable: true,
889890
configurable: true,
890891
writable: false });
@@ -1191,7 +1192,7 @@ var PDFView = {
11911192
pageNumber = self.pages.length;
11921193
}
11931194
self.page = pageNumber;
1194-
if (!self.isFullscreen) { // Avoid breaking fullscreen mode.
1195+
if (!self.isPresentationMode) { // Avoid breaking presentation mode.
11951196
var currentPage = self.pages[pageNumber - 1];
11961197
currentPage.scrollIntoView(dest);
11971198
}
@@ -1715,10 +1716,10 @@ var PDFView = {
17151716
},
17161717

17171718
getVisiblePages: function pdfViewGetVisiblePages() {
1718-
if (!this.isFullscreen) {
1719+
if (!this.isPresentationMode) {
17191720
return this.getVisibleElements(this.container, this.pages, true);
17201721
} else {
1721-
// The algorithm in getVisibleElements is broken in fullscreen mode.
1722+
// The algorithm in getVisibleElements is broken in presentation mode.
17221723
var visible = [], page = this.page;
17231724
var currentPage = this.pages[page - 1];
17241725
visible.push({ id: currentPage.id, view: currentPage });
@@ -1830,11 +1831,12 @@ var PDFView = {
18301831
div.removeChild(div.lastChild);
18311832
},
18321833

1833-
fullscreen: function pdfViewFullscreen() {
1834-
var isFullscreen = document.fullscreenElement || document.mozFullScreen ||
1835-
document.webkitIsFullScreen;
1834+
presentationMode: function pdfViewPresentationMode() {
1835+
var isPresentationMode = document.fullscreenElement ||
1836+
document.mozFullScreen ||
1837+
document.webkitIsFullScreen;
18361838

1837-
if (isFullscreen) {
1839+
if (isPresentationMode) {
18381840
return false;
18391841
}
18401842

@@ -1849,12 +1851,12 @@ var PDFView = {
18491851
return false;
18501852
}
18511853

1852-
this.isFullscreen = true;
1854+
this.isPresentationMode = true;
18531855
var currentPage = this.pages[this.page - 1];
18541856
this.previousScale = this.currentScaleValue;
18551857
this.parseScale('page-fit', true);
18561858

1857-
// Wait for fullscreen to take effect
1859+
// Wait for presentation mode to take effect
18581860
setTimeout(function() {
18591861
currentPage.scrollIntoView();
18601862
}, 0);
@@ -1863,15 +1865,15 @@ var PDFView = {
18631865
return true;
18641866
},
18651867

1866-
exitFullscreen: function pdfViewExitFullscreen() {
1867-
this.isFullscreen = false;
1868+
exitPresentationMode: function pdfViewExitPresentationMode() {
1869+
this.isPresentationMode = false;
18681870
this.parseScale(this.previousScale);
18691871
this.page = this.page;
18701872
this.clearMouseScrollState();
18711873
this.hidePresentationControls();
18721874

18731875
// Ensure that the thumbnail of the current page is visible
1874-
// when exiting fullscreen mode.
1876+
// when exiting presentation mode.
18751877
scrollIntoView(document.getElementById('thumbnailContainer' + this.page));
18761878
},
18771879

@@ -1923,7 +1925,7 @@ var PDFView = {
19231925
return;
19241926
}
19251927

1926-
// Wait for fullscreen to take effect
1928+
// Wait for presentation mode to take effect
19271929
setTimeout(function() {
19281930
currentPage.scrollIntoView();
19291931
}, 0);
@@ -1964,7 +1966,7 @@ var PDFView = {
19641966
DOWN: 1
19651967
};
19661968

1967-
// In fullscreen mode scroll one page at a time.
1969+
// In presentation mode scroll one page at a time.
19681970
var pageFlipDirection = (this.mouseScrollDelta > 0) ?
19691971
PageFlipDirection.UP :
19701972
PageFlipDirection.DOWN;
@@ -3155,7 +3157,7 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
31553157
}
31563158

31573159
if (!PDFView.supportsFullscreen) {
3158-
document.getElementById('fullscreen').classList.add('hidden');
3160+
document.getElementById('presentationMode').classList.add('hidden');
31593161
}
31603162

31613163
if (PDFView.supportsIntegratedFind) {
@@ -3220,9 +3222,9 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
32203222
PDFView.zoomOut();
32213223
});
32223224

3223-
document.getElementById('fullscreen').addEventListener('click',
3225+
document.getElementById('presentationMode').addEventListener('click',
32243226
function() {
3225-
PDFView.fullscreen();
3227+
PDFView.presentationMode();
32263228
});
32273229

32283230
document.getElementById('openFile').addEventListener('click',
@@ -3323,7 +3325,7 @@ function updateViewarea() {
33233325
currentId = visiblePages[0].id;
33243326
}
33253327

3326-
if (!PDFView.isFullscreen) {
3328+
if (!PDFView.isPresentationMode) {
33273329
updateViewarea.inProgress = true; // used in "set page"
33283330
PDFView.page = currentId;
33293331
updateViewarea.inProgress = false;
@@ -3478,35 +3480,36 @@ window.addEventListener('DOMMouseScroll', function(evt) {
34783480
var direction = (ticks > 0) ? 'zoomOut' : 'zoomIn';
34793481
for (var i = 0, length = Math.abs(ticks); i < length; i++)
34803482
PDFView[direction]();
3481-
} else if (PDFView.isFullscreen) {
3483+
} else if (PDFView.isPresentationMode) {
34823484
var FIREFOX_DELTA_FACTOR = -40;
34833485
PDFView.mouseScroll(evt.detail * FIREFOX_DELTA_FACTOR);
34843486
}
34853487
}, false);
34863488

34873489
window.addEventListener('mousemove', function mousemove(evt) {
3488-
if (PDFView.isFullscreen) {
3490+
if (PDFView.isPresentationMode) {
34893491
PDFView.showPresentationControls();
34903492
}
34913493
}, false);
34923494

34933495
window.addEventListener('mousedown', function mousedown(evt) {
3494-
if (PDFView.isFullscreen && evt.button === 0) {
3495-
// Enable clicking of links in fullscreen mode.
3496+
if (PDFView.isPresentationMode && evt.button === 0) {
3497+
// Enable clicking of links in presentation mode.
34963498
// Note: Only links that point to the currently loaded PDF document works.
34973499
var targetHref = evt.target.href;
34983500
var internalLink = targetHref && (targetHref.replace(/#.*$/, '') ===
34993501
window.location.href.replace(/#.*$/, ''));
35003502
if (!internalLink) {
3501-
// Unless an internal link was clicked, advance a page in fullscreen mode.
3503+
// Unless an internal link was clicked, advance a page in presentation
3504+
// mode.
35023505
evt.preventDefault();
35033506
PDFView.page++;
35043507
}
35053508
}
35063509
}, false);
35073510

35083511
window.addEventListener('click', function click(evt) {
3509-
if (PDFView.isFullscreen && evt.button === 0) {
3512+
if (PDFView.isPresentationMode && evt.button === 0) {
35103513
// Necessary since preventDefault() in 'mousedown' won't stop
35113514
// the event propagation in all circumstances.
35123515
evt.preventDefault();
@@ -3578,7 +3581,7 @@ window.addEventListener('keydown', function keydown(evt) {
35783581
}
35793582
var controlsElement = document.getElementById('toolbar');
35803583
while (curElement) {
3581-
if (curElement === controlsElement && !PDFView.isFullscreen)
3584+
if (curElement === controlsElement && !PDFView.isPresentationMode)
35823585
return; // ignoring if the 'toolbar' element is focused
35833586
curElement = curElement.parentNode;
35843587
}
@@ -3588,10 +3591,11 @@ window.addEventListener('keydown', function keydown(evt) {
35883591
case 38: // up arrow
35893592
case 33: // pg up
35903593
case 8: // backspace
3591-
if (!PDFView.isFullscreen && PDFView.currentScaleValue !== 'page-fit') {
3594+
if (!PDFView.isPresentationMode &&
3595+
PDFView.currentScaleValue !== 'page-fit') {
35923596
break;
35933597
}
3594-
/* in fullscreen mode */
3598+
/* in presentation mode */
35953599
/* falls through */
35963600
case 37: // left arrow
35973601
// horizontal scrolling using arrow keys
@@ -3613,7 +3617,8 @@ window.addEventListener('keydown', function keydown(evt) {
36133617
case 40: // down arrow
36143618
case 34: // pg down
36153619
case 32: // spacebar
3616-
if (!PDFView.isFullscreen && PDFView.currentScaleValue !== 'page-fit') {
3620+
if (!PDFView.isPresentationMode &&
3621+
PDFView.currentScaleValue !== 'page-fit') {
36173622
break;
36183623
}
36193624
/* falls through */
@@ -3630,13 +3635,13 @@ window.addEventListener('keydown', function keydown(evt) {
36303635
break;
36313636

36323637
case 36: // home
3633-
if (PDFView.isFullscreen) {
3638+
if (PDFView.isPresentationMode) {
36343639
PDFView.page = 1;
36353640
handled = true;
36363641
}
36373642
break;
36383643
case 35: // end
3639-
if (PDFView.isFullscreen) {
3644+
if (PDFView.isPresentationMode) {
36403645
PDFView.page = PDFView.pdfDocument.numPages;
36413646
handled = true;
36423647
}
@@ -3670,19 +3675,21 @@ window.addEventListener('afterprint', function afterPrint(evt) {
36703675
PDFView.afterPrint();
36713676
});
36723677

3673-
(function fullscreenClosure() {
3674-
function fullscreenChange(e) {
3675-
var isFullscreen = document.fullscreenElement || document.mozFullScreen ||
3676-
document.webkitIsFullScreen;
3678+
(function presentationModeClosure() {
3679+
function presentationModeChange(e) {
3680+
var isPresentationMode = document.fullscreenElement ||
3681+
document.mozFullScreen ||
3682+
document.webkitIsFullScreen;
36773683

3678-
if (!isFullscreen) {
3679-
PDFView.exitFullscreen();
3684+
if (!isPresentationMode) {
3685+
PDFView.exitPresentationMode();
36803686
}
36813687
}
36823688

3683-
window.addEventListener('fullscreenchange', fullscreenChange, false);
3684-
window.addEventListener('mozfullscreenchange', fullscreenChange, false);
3685-
window.addEventListener('webkitfullscreenchange', fullscreenChange, false);
3689+
window.addEventListener('fullscreenchange', presentationModeChange, false);
3690+
window.addEventListener('mozfullscreenchange', presentationModeChange, false);
3691+
window.addEventListener('webkitfullscreenchange', presentationModeChange,
3692+
false);
36863693
})();
36873694

36883695
(function animationStartedClosure() {

0 commit comments

Comments
 (0)