Merge branch 'master' of git://github.com/mozilla/pdf.js.git into loadingbychrome
Conflicts: web/viewer.js
This commit is contained in:
commit
f69e0dca53
@ -18,6 +18,8 @@ zoom_in_label=Zoom In
|
||||
zoom.title=Zoom
|
||||
print.title=Print
|
||||
print_label=Print
|
||||
fullscreen.title=Fullscreen
|
||||
fullscreen_label=Fullscreen
|
||||
open_file.title=Open File
|
||||
open_file_label=Open
|
||||
download.title=Download
|
||||
|
@ -38,6 +38,7 @@ var Pattern = (function PatternClosure() {
|
||||
// Both radial and axial shadings are handled by RadialAxial shading.
|
||||
return new Shadings.RadialAxial(dict, matrix, xref, res);
|
||||
default:
|
||||
TODO('Unsupported shading type: ' + type);
|
||||
return new Shadings.Dummy();
|
||||
}
|
||||
};
|
||||
@ -174,7 +175,12 @@ Shadings.Dummy = (function DummyClosure() {
|
||||
}
|
||||
|
||||
Dummy.fromIR = function Dummy_fromIR() {
|
||||
return 'hotpink';
|
||||
return {
|
||||
type: 'Pattern',
|
||||
getPattern: function Dummy_fromIR_getPattern() {
|
||||
return 'hotpink';
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Dummy.prototype = {
|
||||
|
BIN
web/images/toolbarButton-fullscreen.png
Normal file
BIN
web/images/toolbarButton-fullscreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 491 B |
@ -27,6 +27,50 @@ select {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#viewerContainer:-webkit-full-screen {
|
||||
top: 0px;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 24px;
|
||||
background-color: #404040;
|
||||
background-image: url(images/texture.png);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:-webkit-full-screen #viewer {
|
||||
margin: 0pt;
|
||||
padding: 0pt;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:-webkit-full-screen .page {
|
||||
margin: 0px auto;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#viewerContainer:-moz-full-screen {
|
||||
background-color: #404040;
|
||||
background-image: url(images/texture.png);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:-moz-full-screen .page:last-child {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
#viewerContainer:full-screen {
|
||||
top: 0px;
|
||||
background-color: #404040;
|
||||
background-image: url(images/texture.png);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* outer/inner center provides horizontal center */
|
||||
html[dir='ltr'] .outerCenter {
|
||||
float: right;
|
||||
@ -609,6 +653,11 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
||||
content: url(images/toolbarButton-zoomIn.png);
|
||||
}
|
||||
|
||||
.toolbarButton.fullscreen::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-fullscreen.png);
|
||||
}
|
||||
|
||||
.toolbarButton.print::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-print.png);
|
||||
|
@ -98,19 +98,25 @@
|
||||
</div>
|
||||
<div id="toolbarViewerRight">
|
||||
<input id="fileInput" class="fileInput" type="file" oncontextmenu="return false;" style="visibility: hidden; position: fixed; right: 0; top: 0" />
|
||||
<button id="openFile" class="toolbarButton openFile" title="Open File" tabindex="11" data-l10n-id="open_file" onclick="document.getElementById('fileInput').click()">
|
||||
|
||||
|
||||
<button id="fullscreen" class="toolbarButton fullscreen" title="Fullscreen" tabindex="11" data-l10n-id="fullscreen" onclick="PDFView.fullscreen();">
|
||||
<span data-l10n-id="fullscreen_label">Fullscreen</span>
|
||||
</button>
|
||||
|
||||
<button id="openFile" class="toolbarButton openFile" title="Open File" tabindex="12" data-l10n-id="open_file" onclick="document.getElementById('fileInput').click()">
|
||||
<span data-l10n-id="open_file_label">Open</span>
|
||||
</button>
|
||||
|
||||
<button id="print" class="toolbarButton print" title="Print" tabindex="11" data-l10n-id="print" onclick="window.print()">
|
||||
<button id="print" class="toolbarButton print" title="Print" tabindex="13" data-l10n-id="print" onclick="window.print()">
|
||||
<span data-l10n-id="print_label">Print</span>
|
||||
</button>
|
||||
|
||||
<button id="download" class="toolbarButton download" title="Download" onclick="PDFView.download();" tabindex="12" data-l10n-id="download">
|
||||
<button id="download" class="toolbarButton download" title="Download" onclick="PDFView.download();" tabindex="14" data-l10n-id="download">
|
||||
<span data-l10n-id="download_label">Download</span>
|
||||
</button>
|
||||
<!-- <div class="toolbarButtonSpacer"></div> -->
|
||||
<a href="#" id="viewBookmark" class="toolbarButton bookmark" title="Current view (copy or open in new window)" tabindex="13" data-l10n-id="bookmark"><span data-l10n-id="bookmark_label">Current View</span></a>
|
||||
<a href="#" id="viewBookmark" class="toolbarButton bookmark" title="Current view (copy or open in new window)" tabindex="15" data-l10n-id="bookmark"><span data-l10n-id="bookmark_label">Current View</span></a>
|
||||
</div>
|
||||
<div class="outerCenter">
|
||||
<div class="innerCenter" id="toolbarViewerMiddle">
|
||||
|
109
web/viewer.js
109
web/viewer.js
@ -241,6 +241,8 @@ var PDFView = {
|
||||
sidebarOpen: false,
|
||||
pageViewScroll: null,
|
||||
thumbnailViewScroll: null,
|
||||
isFullscreen: false,
|
||||
previousScale: null,
|
||||
|
||||
// called once when the document is loaded
|
||||
initialize: function pdfViewInitialize() {
|
||||
@ -307,6 +309,7 @@ var PDFView = {
|
||||
|
||||
var container = this.container;
|
||||
var currentPage = this.pages[this.page - 1];
|
||||
|
||||
var pageWidthScale = (container.clientWidth - kScrollbarPadding) /
|
||||
currentPage.width * currentPage.scale / kCssUnits;
|
||||
var pageHeightScale = (container.clientHeight - kScrollbarPadding) /
|
||||
@ -390,6 +393,17 @@ var PDFView = {
|
||||
return value;
|
||||
},
|
||||
|
||||
get supportsFullscreen() {
|
||||
var doc = document.documentElement;
|
||||
var support = doc.requestFullScreen || doc.mozRequestFullScreen ||
|
||||
doc.webkitRequestFullScreen;
|
||||
Object.defineProperty(this, 'supportsFullScreen', { value: support,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: false });
|
||||
return support;
|
||||
},
|
||||
|
||||
initPassiveLoading: function pdfViewInitPassiveLoading() {
|
||||
if (!PDFView.loadingBar) {
|
||||
PDFView.loadingBar = new ProgressBar('#loadingBar', {});
|
||||
@ -812,7 +826,7 @@ var PDFView = {
|
||||
}
|
||||
for (var i = 0; i < numVisible; ++i) {
|
||||
var view = visibleViews[i].view;
|
||||
if (!this.isViewFinshed(view))
|
||||
if (!this.isViewFinished(view))
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -821,19 +835,19 @@ var PDFView = {
|
||||
var lastVisible = visibleViews[visibleViews.length - 1];
|
||||
var nextPageIndex = lastVisible.id;
|
||||
// ID's start at 1 so no need to add 1.
|
||||
if (views[nextPageIndex] && !this.isViewFinshed(views[nextPageIndex]))
|
||||
if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex]))
|
||||
return views[nextPageIndex];
|
||||
} else {
|
||||
var previousPageIndex = visibleViews[0].id - 2;
|
||||
if (views[previousPageIndex] &&
|
||||
!this.isViewFinshed(views[previousPageIndex]))
|
||||
!this.isViewFinished(views[previousPageIndex]))
|
||||
return views[previousPageIndex];
|
||||
}
|
||||
// Everything that needs to be rendered has been.
|
||||
return false;
|
||||
},
|
||||
|
||||
isViewFinshed: function pdfViewNeedsRendering(view) {
|
||||
isViewFinished: function pdfViewNeedsRendering(view) {
|
||||
return view.renderingState === RenderingStates.FINISHED;
|
||||
},
|
||||
|
||||
@ -1055,6 +1069,18 @@ var PDFView = {
|
||||
}
|
||||
|
||||
var visible = [];
|
||||
|
||||
// Algorithm broken in fullscreen mode
|
||||
if (this.isFullscreen) {
|
||||
var currentPage = this.pages[this.page - 1];
|
||||
visible.push({
|
||||
id: currentPage.id,
|
||||
view: currentPage
|
||||
});
|
||||
|
||||
return visible;
|
||||
}
|
||||
|
||||
var bottom = top + scrollEl.clientHeight;
|
||||
for (; i <= views.length && currentHeight < bottom; ++i) {
|
||||
view = views[i - 1];
|
||||
@ -1098,6 +1124,44 @@ var PDFView = {
|
||||
var div = document.getElementById('printContainer');
|
||||
while (div.hasChildNodes())
|
||||
div.removeChild(div.lastChild);
|
||||
},
|
||||
|
||||
fullscreen: function pdfViewFullscreen() {
|
||||
var isFullscreen = document.fullscreen || document.mozFullScreen ||
|
||||
document.webkitIsFullScreen;
|
||||
|
||||
if (isFullscreen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var wrapper = document.getElementById('viewerContainer');
|
||||
if (document.documentElement.requestFullScreen) {
|
||||
wrapper.requestFullScreen();
|
||||
} else if (document.documentElement.mozRequestFullScreen) {
|
||||
wrapper.mozRequestFullScreen();
|
||||
} else if (document.documentElement.webkitRequestFullScreen) {
|
||||
wrapper.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.isFullscreen = true;
|
||||
var currentPage = this.pages[this.page - 1];
|
||||
this.previousScale = this.currentScaleValue;
|
||||
this.parseScale('page-fit', true);
|
||||
|
||||
// Wait for fullscreen to take effect
|
||||
setTimeout(function() {
|
||||
currentPage.scrollIntoView();
|
||||
}, 0);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
exitFullscreen: function pdfViewExitFullscreen() {
|
||||
this.isFullscreen = false;
|
||||
this.parseScale(this.previousScale);
|
||||
this.page = this.page;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1811,6 +1875,10 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
||||
document.getElementById('print').classList.add('hidden');
|
||||
}
|
||||
|
||||
if (!PDFView.supportsFullscreen) {
|
||||
document.getElementById('fullscreen').classList.add('hidden');
|
||||
}
|
||||
|
||||
// Listen for warnings to trigger the fallback UI. Errors should be caught
|
||||
// and call PDFView.error() so we don't need to listen for those.
|
||||
PDFJS.LogManager.addLogger({
|
||||
@ -1854,11 +1922,14 @@ function updateViewarea() {
|
||||
|
||||
PDFView.renderHighestPriority();
|
||||
|
||||
updateViewarea.inProgress = true; // used in "set page"
|
||||
var currentId = PDFView.page;
|
||||
var firstPage = visiblePages[0];
|
||||
PDFView.page = firstPage.id;
|
||||
updateViewarea.inProgress = false;
|
||||
|
||||
if (!PDFView.isFullscreen) {
|
||||
updateViewarea.inProgress = true; // used in "set page"
|
||||
PDFView.page = firstPage.id;
|
||||
updateViewarea.inProgress = false;
|
||||
}
|
||||
|
||||
var currentScale = PDFView.currentScale;
|
||||
var currentScaleValue = PDFView.currentScaleValue;
|
||||
@ -2044,7 +2115,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
return;
|
||||
var controlsElement = document.getElementById('controls');
|
||||
while (curElement) {
|
||||
if (curElement === controlsElement)
|
||||
if (curElement === controlsElement && !PDFView.isFullscreen)
|
||||
return; // ignoring if the 'controls' element is focused
|
||||
curElement = curElement.parentNode;
|
||||
}
|
||||
@ -2063,6 +2134,13 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
PDFView.page++;
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case 32: // spacebar
|
||||
if (PDFView.isFullscreen) {
|
||||
PDFView.page++;
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2078,3 +2156,18 @@ window.addEventListener('beforeprint', function beforePrint(evt) {
|
||||
window.addEventListener('afterprint', function afterPrint(evt) {
|
||||
PDFView.afterPrint();
|
||||
});
|
||||
|
||||
(function fullscreenClosure() {
|
||||
function fullscreenChange(e) {
|
||||
var isFullscreen = document.fullscreen || document.mozFullScreen ||
|
||||
document.webkitIsFullScreen;
|
||||
|
||||
if (!isFullscreen) {
|
||||
PDFView.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('fullscreenchange', fullscreenChange, false);
|
||||
window.addEventListener('mozfullscreenchange', fullscreenChange, false);
|
||||
window.addEventListener('webkitfullscreenchange', fullscreenChange, false);
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user