Merge pull request #5947 from yurydelendik/b2g-viewer
Simplify B2G viewer
This commit is contained in:
commit
0a744fb326
@ -14,7 +14,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
@ -148,22 +147,7 @@ canvas {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page {
|
.pdfViewer .page .loadingIcon {
|
||||||
direction: ltr;
|
|
||||||
width: 81.6rem;
|
|
||||||
height: 105.6rem;
|
|
||||||
margin: 1rem auto;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page > a {
|
|
||||||
display: block;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loadingIcon {
|
|
||||||
width: 2.9rem;
|
width: 2.9rem;
|
||||||
height: 2.9rem;
|
height: 2.9rem;
|
||||||
background: url("images/spinner.png") no-repeat left top / 38rem ;
|
background: url("images/spinner.png") no-repeat left top / 38rem ;
|
||||||
|
@ -20,22 +20,25 @@ limitations under the License.
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
<title>PDF.js viewer</title>
|
<title>PDF.js viewer</title>
|
||||||
|
|
||||||
|
<script src="../pdfjs-components/build/pdf.js"></script>
|
||||||
|
<script src="../pdfjs-components/web/pdf_viewer.js"></script>
|
||||||
|
<script src="/shared/js/l10n.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="viewer.css"/>
|
<!-- Localization -->
|
||||||
<link rel="resource" type="application/l10n" href="locale/locale.properties"/>
|
<meta name="defaultLanguage" content="en-US">
|
||||||
<script src="l10n.js"></script>
|
<meta name="availableLanguages" content="ach,af,ak,an,ar,as,ast,az,be,bg,bn-BD,bn-IN,br,bs,ca,cs,csb,cy,da,de,el,en-GB,en-ZA,eo,es-AR,es-CL,es-ES,es-MX,et,eu,fa,ff,fi,fr,fy-NL,ga-IE,gd,gl,gu-IN,he,hi-IN,hr,hu,hy-AM,id,is,it,ja,ka,kk,km,kn,ko,ku,lg,lij,lt,lv,mai,mk,ml,mn,mr,ms,my,nb-NO,nl,nn-NO,nso,oc,or,pa-IN,pl,pt-BR,pt-PT,rm,ro,ru,rw,sah,si,sk,sl,son,sq,sr,sv-SE,sw,ta,ta-LK,te,th,tl,tn,tr,uk,ur,vi,wo,xh,zh-CN,zh-TW,zu">
|
||||||
<script src="../build/pdf.js"></script>
|
<link rel="localization" href="locale/{locale}/viewer.properties">
|
||||||
<script src="/shared/js/async_storage.js"></script>
|
|
||||||
|
|
||||||
<script src="viewer.js"></script>
|
<script src="viewer.js"></script>
|
||||||
|
|
||||||
<!-- Web Components -->
|
<!-- Web Components -->
|
||||||
<link rel="stylesheet" type="text/css" href="/shared/elements/gaia-theme/style.css" />
|
<link rel="stylesheet" type="text/css" href="/shared/elements/gaia-theme/gaia-theme.css">
|
||||||
<!-- <link rel="stylesheet" type="text/css" href="/shared/elements/gaia-icons/style.css" /> -->
|
<script src="/shared/elements/config.js" defer></script>
|
||||||
<script type="text/javascript" src="/shared/elements/config.js"></script>
|
<script src="/shared/elements/gaia-header/dist/gaia-header.js" defer></script>
|
||||||
<script type="text/javascript" src="/shared/elements/gaia-header/dist/script.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="../pdfjs-components/web/pdf_viewer.css">
|
||||||
|
<link rel="stylesheet" type="text/css" href="viewer.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<section role="region" id="activityHeader" class="skin-organic theme-settings">
|
<section role="region" id="activityHeader" class="skin-organic theme-settings">
|
||||||
@ -55,7 +58,7 @@ limitations under the License.
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div id="viewerContainer">
|
<div id="viewerContainer">
|
||||||
<div id="viewer"></div>
|
<div id="viewer" class="pdfViewer"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="loadingBar">
|
<div id="loadingBar">
|
||||||
@ -81,194 +84,5 @@ limitations under the License.
|
|||||||
<div class="clearBoth"></div>
|
<div class="clearBoth"></div>
|
||||||
<textarea id="errorMoreInfo" hidden='true' readonly="readonly"></textarea>
|
<textarea id="errorMoreInfo" hidden='true' readonly="readonly"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- BEGIN STUBS -->
|
|
||||||
<!--
|
|
||||||
Nothing below here is visible, the elements are just here
|
|
||||||
to prevent the viewer from breaking until we refactor it.
|
|
||||||
-->
|
|
||||||
<div id="stubs" style="display: none;">
|
|
||||||
<div id="outerContainer"></div>
|
|
||||||
<div id="sidebarContainer">
|
|
||||||
<div id="toolbarSidebar">
|
|
||||||
<button id="viewThumbnail"></button>
|
|
||||||
<button id="viewOutline"></button>
|
|
||||||
<button id="viewAttachments"></button>
|
|
||||||
</div>
|
|
||||||
<div id="sidebarContent">
|
|
||||||
<div id="thumbnailView"></div>
|
|
||||||
<div id="outlineView"></div>
|
|
||||||
<div id="attachmentsView"></div>
|
|
||||||
</div>
|
|
||||||
</div> <!-- sidebarContainer -->
|
|
||||||
|
|
||||||
<button id="secondaryToolbarToggle" class="toolbarButton" title="Tools" tabindex="17" data-l10n-id="tools">
|
|
||||||
<span data-l10n-id="tools_label">Tools</span>
|
|
||||||
</button>
|
|
||||||
<div id="secondaryToolbar" class="secondaryToolbar hidden doorHangerRight">
|
|
||||||
<div id="secondaryToolbarButtonContainer">
|
|
||||||
<button id="secondaryPresentationMode" class="secondaryToolbarButton presentationMode visibleLargeView" title="Switch to Presentation Mode" tabindex="18" data-l10n-id="presentation_mode">
|
|
||||||
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button id="secondaryOpenFile" class="secondaryToolbarButton openFile visibleLargeView" title="Open File" tabindex="19" data-l10n-id="open_file">
|
|
||||||
<span data-l10n-id="open_file_label">Open</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button id="secondaryPrint" class="secondaryToolbarButton print visibleMediumView" title="Print" tabindex="20" data-l10n-id="print">
|
|
||||||
<span data-l10n-id="print_label">Print</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button id="secondaryDownload" class="secondaryToolbarButton download visibleMediumView" title="Download" tabindex="21" data-l10n-id="download">
|
|
||||||
<span data-l10n-id="download_label">Download</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark visibleSmallView" title="Current view (copy or open in new window)" tabindex="22" data-l10n-id="bookmark">
|
|
||||||
<span data-l10n-id="bookmark_label">Current View</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div class="horizontalToolbarSeparator visibleLargeView"></div>
|
|
||||||
|
|
||||||
<button id="firstPage" class="secondaryToolbarButton firstPage" title="Go to First Page" tabindex="22" data-l10n-id="first_page">
|
|
||||||
<span data-l10n-id="first_page_label">Go to First Page</span>
|
|
||||||
</button>
|
|
||||||
<button id="lastPage" class="secondaryToolbarButton lastPage" title="Go to Last Page" tabindex="23" data-l10n-id="last_page">
|
|
||||||
<span data-l10n-id="last_page_label">Go to Last Page</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div class="horizontalToolbarSeparator"></div>
|
|
||||||
|
|
||||||
<button id="pageRotateCw" class="secondaryToolbarButton rotateCw" title="Rotate Clockwise" tabindex="24" data-l10n-id="page_rotate_cw">
|
|
||||||
<span data-l10n-id="page_rotate_cw_label">Rotate Clockwise</span>
|
|
||||||
</button>
|
|
||||||
<button id="pageRotateCcw" class="secondaryToolbarButton rotateCcw" title="Rotate Counterclockwise" tabindex="25" data-l10n-id="page_rotate_ccw">
|
|
||||||
<span data-l10n-id="page_rotate_ccw_label">Rotate Counterclockwise</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div> <!-- secondaryToolbar -->
|
|
||||||
|
|
||||||
<div id="mainContainer">
|
|
||||||
<div id="findbar">
|
|
||||||
<input id="findInput">
|
|
||||||
<button id="findPrevious"></button>
|
|
||||||
<button id="findNext"></button>
|
|
||||||
<input type="checkbox" id="findHighlightAll">
|
|
||||||
<input type="checkbox" id="findMatchCase">
|
|
||||||
<span id="findMsg"></span>
|
|
||||||
</div>
|
|
||||||
<div id="toolbarContainer">
|
|
||||||
<div id="toolbarViewer">
|
|
||||||
<div id="toolbarViewerLeft">
|
|
||||||
<button id="sidebarToggle"></button>
|
|
||||||
<button id="viewFind"></button>
|
|
||||||
<span id="numPages"></span>
|
|
||||||
</div>
|
|
||||||
<div id="toolbarViewerRight">
|
|
||||||
<button id="presentationMode"></button>
|
|
||||||
<input id="fileInput" type="file" />
|
|
||||||
<button id="fullscreen"></button>
|
|
||||||
<button id="openFile"></button>
|
|
||||||
<button id="print"></button>
|
|
||||||
<button id="download"></button>
|
|
||||||
<!-- <div class="toolbarButtonSpacer"></div> -->
|
|
||||||
<a href="#" id="viewBookmark"></a>
|
|
||||||
</div>
|
|
||||||
<div id="toolbarViewerMiddle">
|
|
||||||
<span id="scaleSelectContainer">
|
|
||||||
<select id="scaleSelect">
|
|
||||||
<option id="pageAutoOption" value="auto" selected="selected">Automatic Zoom</option>
|
|
||||||
<option id="pageActualOption" value="page-actual">Actual Size</option>
|
|
||||||
<option id="pageFitOption" value="page-fit">Fit Page</option>
|
|
||||||
<option id="pageWidthOption" value="page-width">Full Width</option>
|
|
||||||
<option id="customScaleOption" value="custom"></option>
|
|
||||||
<option value="0.5">50%</option>
|
|
||||||
<option value="0.75">75%</option>
|
|
||||||
<option value="1">100%</option>
|
|
||||||
<option value="1.25">125%</option>
|
|
||||||
<option value="1.5">150%</option>
|
|
||||||
<option value="2">200%</option>
|
|
||||||
</select>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<menu type="context" id="viewerContextMenu">
|
|
||||||
<menuitem id="contextFirstPage" label="First Page"
|
|
||||||
data-l10n-id="first_page"></menuitem>
|
|
||||||
<menuitem id="contextLastPage" label="Last Page"
|
|
||||||
data-l10n-id="last_page"></menuitem>
|
|
||||||
<menuitem id="contextPageRotateCw" label="Rotate Clockwise"
|
|
||||||
data-l10n-id="page_rotate_cw"></menuitem>
|
|
||||||
<menuitem id="contextPageRotateCcw" label="Rotate Counter-Clockwise"
|
|
||||||
data-l10n-id="page_rotate_ccw"></menuitem>
|
|
||||||
</menu>
|
|
||||||
|
|
||||||
</div> <!-- mainContainer -->
|
|
||||||
|
|
||||||
<div id="overlayContainer" class="hidden">
|
|
||||||
<div id="passwordOverlay" class="container hidden">
|
|
||||||
<div class="dialog">
|
|
||||||
<div class="row">
|
|
||||||
<p id="passwordText" data-l10n-id="password_label">Enter the password to open this PDF file:</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<input type="password" id="password" class="toolbarField" />
|
|
||||||
</div>
|
|
||||||
<div class="buttonRow">
|
|
||||||
<button id="passwordCancel" class="overlayButton"><span data-l10n-id="password_cancel">Cancel</span></button>
|
|
||||||
<button id="passwordSubmit" class="overlayButton"><span data-l10n-id="password_ok">OK</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="documentPropertiesOverlay" class="container hidden">
|
|
||||||
<div class="dialog">
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_file_name">File name:</span> <p id="fileNameField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_file_size">File size:</span> <p id="fileSizeField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="separator"></div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_title">Title:</span> <p id="titleField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_author">Author:</span> <p id="authorField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_subject">Subject:</span> <p id="subjectField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_keywords">Keywords:</span> <p id="keywordsField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_creation_date">Creation Date:</span> <p id="creationDateField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_modification_date">Modification Date:</span> <p id="modificationDateField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_creator">Creator:</span> <p id="creatorField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="separator"></div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_producer">PDF Producer:</span> <p id="producerField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_version">PDF Version:</span> <p id="versionField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<span data-l10n-id="document_properties_page_count">Page Count:</span> <p id="pageCountField">-</p>
|
|
||||||
</div>
|
|
||||||
<div class="buttonRow">
|
|
||||||
<button id="documentPropertiesClose" class="overlayButton"><span data-l10n-id="document_properties_close">Close</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div> <!-- overlayContainer -->
|
|
||||||
|
|
||||||
<div id="printContainer"></div>
|
|
||||||
</div>
|
|
||||||
<!-- END STUBS -->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
349
extensions/b2g/viewer.js
Normal file
349
extensions/b2g/viewer.js
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
/* Copyright 2014 Mozilla Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* globals PDFJS, Promise */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
PDFJS.useOnlyCssZoom = true;
|
||||||
|
PDFJS.disableTextLayer = true;
|
||||||
|
PDFJS.maxImageSize = 1024 * 1024;
|
||||||
|
PDFJS.workerSrc = '../pdfjs-components/build/pdf.worker.js';
|
||||||
|
PDFJS.cMapUrl = '../pdfjs-components/cmaps/';
|
||||||
|
PDFJS.cMapPacked = true;
|
||||||
|
|
||||||
|
var DEFAULT_SCALE_DELTA = 1.1;
|
||||||
|
var MIN_SCALE = 0.25;
|
||||||
|
var MAX_SCALE = 10.0;
|
||||||
|
var DEFAULT_SCALE_VALUE = 'auto';
|
||||||
|
|
||||||
|
var PDFViewerApplication = {
|
||||||
|
pdfDocument: null,
|
||||||
|
pdfViewer: null,
|
||||||
|
pdfHistory: null,
|
||||||
|
pdfLinkService: null,
|
||||||
|
|
||||||
|
open: function (params) {
|
||||||
|
var url = params.url, originalUrl = params.originalUrl;
|
||||||
|
var self = this;
|
||||||
|
this.setTitleUsingUrl(originalUrl);
|
||||||
|
|
||||||
|
// Loading document.
|
||||||
|
var loadingTask = PDFJS.getDocument(url);
|
||||||
|
loadingTask.onProgress = function (progressData) {
|
||||||
|
self.progress(progressData.loaded / progressData.total);
|
||||||
|
};
|
||||||
|
loadingTask.then(function (pdfDocument) {
|
||||||
|
// Document loaded, specifying document for the viewer.
|
||||||
|
this.pdfDocument = pdfDocument;
|
||||||
|
this.pdfViewer.setDocument(pdfDocument);
|
||||||
|
this.pdfLinkService.setDocument(pdfDocument);
|
||||||
|
this.pdfHistory.initialize(pdfDocument.fingerprint);
|
||||||
|
|
||||||
|
this.loadingBar.hide();
|
||||||
|
this.setTitleUsingMetadata(pdfDocument);
|
||||||
|
}.bind(this), function (exception) {
|
||||||
|
var message = exception && exception.message;
|
||||||
|
var loadingErrorMessage = mozL10n.get('loading_error', null,
|
||||||
|
'An error occurred while loading the PDF.');
|
||||||
|
|
||||||
|
if (exception instanceof PDFJS.InvalidPDFException) {
|
||||||
|
// change error message also for other builds
|
||||||
|
loadingErrorMessage = mozL10n.get('invalid_file_error', null,
|
||||||
|
'Invalid or corrupted PDF file.');
|
||||||
|
} else if (exception instanceof PDFJS.MissingPDFException) {
|
||||||
|
// special message for missing PDFs
|
||||||
|
loadingErrorMessage = mozL10n.get('missing_file_error', null,
|
||||||
|
'Missing PDF file.');
|
||||||
|
} else if (exception instanceof PDFJS.UnexpectedResponseException) {
|
||||||
|
loadingErrorMessage = mozL10n.get('unexpected_response_error', null,
|
||||||
|
'Unexpected server response.');
|
||||||
|
}
|
||||||
|
|
||||||
|
var moreInfo = {
|
||||||
|
message: message
|
||||||
|
};
|
||||||
|
self.error(loadingErrorMessage, moreInfo);
|
||||||
|
self.loadingBar.hide();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
get loadingBar() {
|
||||||
|
var bar = new PDFJS.ProgressBar('#loadingBar', {});
|
||||||
|
|
||||||
|
return PDFJS.shadow(this, 'loadingBar', bar);
|
||||||
|
},
|
||||||
|
|
||||||
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
||||||
|
this.url = url;
|
||||||
|
var title = PDFJS.getFileName(url) || url;
|
||||||
|
try {
|
||||||
|
title = decodeURIComponent(title);
|
||||||
|
} catch (e) {
|
||||||
|
// decodeURIComponent may throw URIError,
|
||||||
|
// fall back to using the unprocessed url in that case
|
||||||
|
}
|
||||||
|
this.setTitle(title);
|
||||||
|
},
|
||||||
|
|
||||||
|
setTitleUsingMetadata: function (pdfDocument) {
|
||||||
|
var self = this;
|
||||||
|
pdfDocument.getMetadata().then(function(data) {
|
||||||
|
var info = data.info, metadata = data.metadata;
|
||||||
|
self.documentInfo = info;
|
||||||
|
self.metadata = metadata;
|
||||||
|
|
||||||
|
// Provides some basic debug information
|
||||||
|
console.log('PDF ' + pdfDocument.fingerprint + ' [' +
|
||||||
|
info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() +
|
||||||
|
' / ' + (info.Creator || '-').trim() + ']' +
|
||||||
|
' (PDF.js: ' + (PDFJS.version || '-') +
|
||||||
|
(!PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
|
||||||
|
|
||||||
|
var pdfTitle;
|
||||||
|
if (metadata && metadata.has('dc:title')) {
|
||||||
|
var title = metadata.get('dc:title');
|
||||||
|
// Ghostscript sometimes returns 'Untitled', so prevent setting the
|
||||||
|
// title to 'Untitled.
|
||||||
|
if (title !== 'Untitled') {
|
||||||
|
pdfTitle = title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pdfTitle && info && info['Title']) {
|
||||||
|
pdfTitle = info['Title'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pdfTitle) {
|
||||||
|
self.setTitle(pdfTitle + ' - ' + document.title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
setTitle: function pdfViewSetTitle(title) {
|
||||||
|
document.title = title;
|
||||||
|
document.getElementById('activityTitle').textContent = title;
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function pdfViewError(message, moreInfo) {
|
||||||
|
var moreInfoText = mozL10n.get('error_version_info',
|
||||||
|
{version: PDFJS.version || '?', build: PDFJS.build || '?'},
|
||||||
|
'PDF.js v{{version}} (build: {{build}})') + '\n';
|
||||||
|
|
||||||
|
if (moreInfo) {
|
||||||
|
moreInfoText +=
|
||||||
|
mozL10n.get('error_message', {message: moreInfo.message},
|
||||||
|
'Message: {{message}}');
|
||||||
|
if (moreInfo.stack) {
|
||||||
|
moreInfoText += '\n' +
|
||||||
|
mozL10n.get('error_stack', {stack: moreInfo.stack},
|
||||||
|
'Stack: {{stack}}');
|
||||||
|
} else {
|
||||||
|
if (moreInfo.filename) {
|
||||||
|
moreInfoText += '\n' +
|
||||||
|
mozL10n.get('error_file', {file: moreInfo.filename},
|
||||||
|
'File: {{file}}');
|
||||||
|
}
|
||||||
|
if (moreInfo.lineNumber) {
|
||||||
|
moreInfoText += '\n' +
|
||||||
|
mozL10n.get('error_line', {line: moreInfo.lineNumber},
|
||||||
|
'Line: {{line}}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var errorWrapper = document.getElementById('errorWrapper');
|
||||||
|
errorWrapper.removeAttribute('hidden');
|
||||||
|
|
||||||
|
var errorMessage = document.getElementById('errorMessage');
|
||||||
|
errorMessage.textContent = message;
|
||||||
|
|
||||||
|
var closeButton = document.getElementById('errorClose');
|
||||||
|
closeButton.onclick = function() {
|
||||||
|
errorWrapper.setAttribute('hidden', 'true');
|
||||||
|
};
|
||||||
|
|
||||||
|
var errorMoreInfo = document.getElementById('errorMoreInfo');
|
||||||
|
var moreInfoButton = document.getElementById('errorShowMore');
|
||||||
|
var lessInfoButton = document.getElementById('errorShowLess');
|
||||||
|
moreInfoButton.onclick = function() {
|
||||||
|
errorMoreInfo.removeAttribute('hidden');
|
||||||
|
moreInfoButton.setAttribute('hidden', 'true');
|
||||||
|
lessInfoButton.removeAttribute('hidden');
|
||||||
|
errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
|
||||||
|
};
|
||||||
|
lessInfoButton.onclick = function() {
|
||||||
|
errorMoreInfo.setAttribute('hidden', 'true');
|
||||||
|
moreInfoButton.removeAttribute('hidden');
|
||||||
|
lessInfoButton.setAttribute('hidden', 'true');
|
||||||
|
};
|
||||||
|
moreInfoButton.removeAttribute('hidden');
|
||||||
|
lessInfoButton.setAttribute('hidden', 'true');
|
||||||
|
errorMoreInfo.value = moreInfoText;
|
||||||
|
},
|
||||||
|
|
||||||
|
progress: function pdfViewProgress(level) {
|
||||||
|
var percent = Math.round(level * 100);
|
||||||
|
// Updating the bar if value increases.
|
||||||
|
if (percent > this.loadingBar.percent || isNaN(percent)) {
|
||||||
|
this.loadingBar.percent = percent;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
get pagesCount() {
|
||||||
|
return this.pdfDocument.numPages;
|
||||||
|
},
|
||||||
|
|
||||||
|
set page(val) {
|
||||||
|
this.pdfViewer.currentPageNumber = val;
|
||||||
|
},
|
||||||
|
|
||||||
|
get page() {
|
||||||
|
return this.pdfViewer.currentPageNumber;
|
||||||
|
},
|
||||||
|
|
||||||
|
zoomIn: function pdfViewZoomIn(ticks) {
|
||||||
|
var newScale = this.pdfViewer.currentScale;
|
||||||
|
do {
|
||||||
|
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
|
||||||
|
newScale = Math.ceil(newScale * 10) / 10;
|
||||||
|
newScale = Math.min(MAX_SCALE, newScale);
|
||||||
|
} while (--ticks && newScale < MAX_SCALE);
|
||||||
|
this.pdfViewer.currentScaleValue = newScale;
|
||||||
|
},
|
||||||
|
|
||||||
|
zoomOut: function pdfViewZoomOut(ticks) {
|
||||||
|
var newScale = this.pdfViewer.currentScale;
|
||||||
|
do {
|
||||||
|
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
|
||||||
|
newScale = Math.floor(newScale * 10) / 10;
|
||||||
|
newScale = Math.max(MIN_SCALE, newScale);
|
||||||
|
} while (--ticks && newScale > MIN_SCALE);
|
||||||
|
this.pdfViewer.currentScaleValue = newScale;
|
||||||
|
},
|
||||||
|
|
||||||
|
initUI: function pdfViewInitUI() {
|
||||||
|
var linkService = new PDFJS.PDFLinkService();
|
||||||
|
this.pdfLinkService = linkService;
|
||||||
|
|
||||||
|
var container = document.getElementById('viewerContainer');
|
||||||
|
var pdfViewer = new PDFJS.PDFViewer({
|
||||||
|
container: container,
|
||||||
|
linkService: linkService
|
||||||
|
});
|
||||||
|
this.pdfViewer = pdfViewer;
|
||||||
|
linkService.setViewer(pdfViewer);
|
||||||
|
|
||||||
|
this.pdfHistory = new PDFJS.PDFHistory({
|
||||||
|
linkService: linkService
|
||||||
|
});
|
||||||
|
linkService.setHistory(this.pdfHistory);
|
||||||
|
|
||||||
|
document.getElementById('previous').addEventListener('click', function() {
|
||||||
|
PDFViewerApplication.page--;
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('next').addEventListener('click', function() {
|
||||||
|
PDFViewerApplication.page++;
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('zoomIn').addEventListener('click', function() {
|
||||||
|
PDFViewerApplication.zoomIn();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('zoomOut').addEventListener('click', function() {
|
||||||
|
PDFViewerApplication.zoomOut();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('pageNumber').addEventListener('click', function() {
|
||||||
|
this.select();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('pageNumber').addEventListener('change',
|
||||||
|
function() {
|
||||||
|
// Handle the user inputting a floating point number.
|
||||||
|
PDFViewerApplication.page = (this.value | 0);
|
||||||
|
|
||||||
|
if (this.value !== (this.value | 0).toString()) {
|
||||||
|
this.value = PDFViewerApplication.page;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
container.addEventListener('pagesinit', function () {
|
||||||
|
// We can use pdfViewer now, e.g. let's change default scale.
|
||||||
|
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||||
|
});
|
||||||
|
|
||||||
|
container.addEventListener('pagechange', function (evt) {
|
||||||
|
var page = evt.pageNumber;
|
||||||
|
if (evt.previousPageNumber !== page) {
|
||||||
|
document.getElementById('pageNumber').value = page;
|
||||||
|
}
|
||||||
|
var numPages = PDFViewerApplication.pagesCount;
|
||||||
|
|
||||||
|
document.getElementById('previous').disabled = (page <= 1);
|
||||||
|
document.getElementById('next').disabled = (page >= numPages);
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
PDFViewerApplication.initUI();
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
(function animationStartedClosure() {
|
||||||
|
// The offsetParent is not set until the PDF.js iframe or object is visible.
|
||||||
|
// Waiting for first animation.
|
||||||
|
PDFViewerApplication.animationStartedPromise = new Promise(
|
||||||
|
function (resolve) {
|
||||||
|
window.requestAnimationFrame(resolve);
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
// Support of the new version of navigator.mozL10n -- in PDF.js older/custom
|
||||||
|
// version is used.
|
||||||
|
var mozL10n = {
|
||||||
|
get: function (id, args, fallback) {
|
||||||
|
var s = (navigator.mozL10n && navigator.mozL10n.get(id)) || fallback;
|
||||||
|
s = s.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, key) {
|
||||||
|
return args[key] || '';
|
||||||
|
});
|
||||||
|
return s;
|
||||||
|
},
|
||||||
|
|
||||||
|
translate: function (fragment) {
|
||||||
|
if (navigator.mozL10n) {
|
||||||
|
navigator.mozL10n.translateFragment(fragment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.navigator.mozSetMessageHandler('activity', function(activity) {
|
||||||
|
var blob = activity.source.data.blob;
|
||||||
|
var fileURL = activity.source.data.url ||
|
||||||
|
activity.source.data.filename ||
|
||||||
|
' '; // if no url or filename, use a non-empty string
|
||||||
|
|
||||||
|
var url = URL.createObjectURL(blob);
|
||||||
|
// We need to delay opening until all HTML is loaded.
|
||||||
|
PDFViewerApplication.animationStartedPromise.then(function () {
|
||||||
|
PDFViewerApplication.open({url: url, originalUrl: fileURL});
|
||||||
|
|
||||||
|
var header = document.getElementById('header');
|
||||||
|
header.addEventListener('action', function() {
|
||||||
|
activity.postResult('close');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
34
make.js
34
make.js
@ -70,7 +70,6 @@ var DEFINES = {
|
|||||||
GENERIC: false,
|
GENERIC: false,
|
||||||
FIREFOX: false,
|
FIREFOX: false,
|
||||||
MOZCENTRAL: false,
|
MOZCENTRAL: false,
|
||||||
B2G: false,
|
|
||||||
CHROME: false,
|
CHROME: false,
|
||||||
MINIFIED: false,
|
MINIFIED: false,
|
||||||
SINGLE_FILE: false,
|
SINGLE_FILE: false,
|
||||||
@ -979,36 +978,45 @@ target.mozcentral = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
target.b2g = function() {
|
target.b2g = function() {
|
||||||
target.locale();
|
target.generic();
|
||||||
|
target.components();
|
||||||
|
|
||||||
echo();
|
echo();
|
||||||
echo('### Building B2G (Firefox OS App)');
|
echo('### Building B2G (Firefox OS App)');
|
||||||
var B2G_BUILD_CONTENT_DIR = B2G_BUILD_DIR + '/content/';
|
var B2G_BUILD_CONTENT_DIR = B2G_BUILD_DIR + '/content/';
|
||||||
var defines = builder.merge(DEFINES, { B2G: true });
|
target.bundle();
|
||||||
target.bundle({ defines: defines });
|
|
||||||
|
|
||||||
// Clear out everything in the b2g build directory
|
// Clear out everything in the b2g build directory
|
||||||
cd(ROOT_DIR);
|
cd(ROOT_DIR);
|
||||||
rm('-Rf', B2G_BUILD_DIR);
|
rm('-Rf', B2G_BUILD_DIR);
|
||||||
mkdir('-p', B2G_BUILD_CONTENT_DIR);
|
mkdir('-p', B2G_BUILD_CONTENT_DIR);
|
||||||
mkdir('-p', B2G_BUILD_CONTENT_DIR + BUILD_DIR);
|
|
||||||
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web');
|
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web');
|
||||||
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/web/cmaps');
|
// Simulating pdfjs-dist structure in the pdfjs-components folder.
|
||||||
|
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/pdfjs-components/web');
|
||||||
|
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/pdfjs-components/build');
|
||||||
|
mkdir('-p', B2G_BUILD_CONTENT_DIR + '/pdfjs-components/cmaps');
|
||||||
|
|
||||||
var setup = {
|
var setup = {
|
||||||
defines: defines,
|
defines: DEFINES,
|
||||||
copy: [
|
copy: [
|
||||||
['extensions/b2g/images', B2G_BUILD_CONTENT_DIR + '/web'],
|
['extensions/b2g/images', B2G_BUILD_CONTENT_DIR + '/web'],
|
||||||
['extensions/b2g/viewer.html', B2G_BUILD_CONTENT_DIR + '/web'],
|
['extensions/b2g/viewer.html', B2G_BUILD_CONTENT_DIR + '/web'],
|
||||||
['extensions/b2g/viewer.css', B2G_BUILD_CONTENT_DIR + '/web'],
|
['extensions/b2g/viewer.css', B2G_BUILD_CONTENT_DIR + '/web'],
|
||||||
|
['extensions/b2g/viewer.js', B2G_BUILD_CONTENT_DIR + '/web'],
|
||||||
['web/locale', B2G_BUILD_CONTENT_DIR + '/web'],
|
['web/locale', B2G_BUILD_CONTENT_DIR + '/web'],
|
||||||
['external/bcmaps/*', B2G_BUILD_CONTENT_DIR + '/web/cmaps'],
|
['build/generic/build/pdf.js',
|
||||||
['external/webL10n/l10n.js', B2G_BUILD_CONTENT_DIR + '/web']
|
B2G_BUILD_CONTENT_DIR + '/pdfjs-components/build'],
|
||||||
|
['build/generic/build/pdf.worker.js',
|
||||||
|
B2G_BUILD_CONTENT_DIR + '/pdfjs-components/build'],
|
||||||
|
['build/components/pdf_viewer.js',
|
||||||
|
B2G_BUILD_CONTENT_DIR + '/pdfjs-components/web'],
|
||||||
|
['build/components/pdf_viewer.css',
|
||||||
|
B2G_BUILD_CONTENT_DIR + '/pdfjs-components/web'],
|
||||||
|
['build/components/images',
|
||||||
|
B2G_BUILD_CONTENT_DIR + '/pdfjs-components/web'],
|
||||||
|
['external/bcmaps/*', B2G_BUILD_CONTENT_DIR + '/pdfjs-components/cmaps']
|
||||||
],
|
],
|
||||||
preprocess: [
|
preprocess: []
|
||||||
['web/viewer.js', B2G_BUILD_CONTENT_DIR + '/web'],
|
|
||||||
[BUILD_TARGETS, B2G_BUILD_CONTENT_DIR + BUILD_DIR]
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
builder.build(setup);
|
builder.build(setup);
|
||||||
|
|
||||||
|
@ -287,11 +287,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
var getXhr = function getXhr() {
|
var getXhr = function getXhr() {
|
||||||
//#if B2G
|
|
||||||
// return new XMLHttpRequest({ mozSystem: true });
|
|
||||||
//#else
|
|
||||||
return new XMLHttpRequest();
|
return new XMLHttpRequest();
|
||||||
//#endif
|
|
||||||
};
|
};
|
||||||
this.networkManager = new NetworkManager(this.url, {
|
this.networkManager = new NetworkManager(this.url, {
|
||||||
getXhr: getXhr,
|
getXhr: getXhr,
|
||||||
|
@ -35,7 +35,7 @@ var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var alwaysUseUint32ArrayView = false;
|
var alwaysUseUint32ArrayView = false;
|
||||||
//#if !(FIREFOX || MOZCENTRAL || B2G || CHROME)
|
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
||||||
// old webkits have issues with non-aligned arrays
|
// old webkits have issues with non-aligned arrays
|
||||||
try {
|
try {
|
||||||
new Uint32Array(new Uint8Array(5).buffer, 0, 1);
|
new Uint32Array(new Uint8Array(5).buffer, 0, 1);
|
||||||
|
@ -50,11 +50,7 @@ var NetworkManager = (function NetworkManagerClosure() {
|
|||||||
this.withCredentials = args.withCredentials || false;
|
this.withCredentials = args.withCredentials || false;
|
||||||
this.getXhr = args.getXhr ||
|
this.getXhr = args.getXhr ||
|
||||||
function NetworkManager_getXhr() {
|
function NetworkManager_getXhr() {
|
||||||
//#if B2G
|
|
||||||
// return new XMLHttpRequest({ mozSystem: true });
|
|
||||||
//#else
|
|
||||||
return new XMLHttpRequest();
|
return new XMLHttpRequest();
|
||||||
//#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.currXhrId = 0;
|
this.currXhrId = 0;
|
||||||
|
@ -503,8 +503,8 @@ Object.defineProperty(PDFJS, 'isLittleEndian', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL || B2G || CHROME)
|
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
||||||
//// Lazy test if the userAgant support CanvasTypedArrays
|
//// Lazy test if the userAgent support CanvasTypedArrays
|
||||||
function hasCanvasTypedArrays() {
|
function hasCanvasTypedArrays() {
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement('canvas');
|
||||||
canvas.width = canvas.height = 1;
|
canvas.width = canvas.height = 1;
|
||||||
|
@ -31,11 +31,6 @@ var DEFAULT_PREFERENCES = {
|
|||||||
disableStream: false,
|
disableStream: false,
|
||||||
disableAutoFetch: false,
|
disableAutoFetch: false,
|
||||||
disableFontFace: false,
|
disableFontFace: false,
|
||||||
//#if B2G
|
|
||||||
//disableTextLayer: true,
|
|
||||||
//useOnlyCssZoom: true
|
|
||||||
//#else
|
|
||||||
disableTextLayer: false,
|
disableTextLayer: false,
|
||||||
useOnlyCssZoom: false
|
useOnlyCssZoom: false
|
||||||
//#endif
|
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
/*jshint globalstrict: false */
|
/*jshint globalstrict: false */
|
||||||
/* globals PDFJS, PDFViewer, PDFPageView, TextLayerBuilder, PDFLinkService,
|
/* globals PDFJS, PDFViewer, PDFPageView, TextLayerBuilder, PDFLinkService,
|
||||||
DefaultTextLayerFactory, AnnotationsLayerBuilder, PDFHistory,
|
DefaultTextLayerFactory, AnnotationsLayerBuilder, PDFHistory,
|
||||||
DefaultAnnotationsLayerFactory, getFileName */
|
DefaultAnnotationsLayerFactory, getFileName, ProgressBar */
|
||||||
|
|
||||||
// Initializing PDFJS global object (if still undefined)
|
// Initializing PDFJS global object (if still undefined)
|
||||||
if (typeof PDFJS === 'undefined') {
|
if (typeof PDFJS === 'undefined') {
|
||||||
@ -42,4 +42,5 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
PDFJS.PDFHistory = PDFHistory;
|
PDFJS.PDFHistory = PDFHistory;
|
||||||
|
|
||||||
PDFJS.getFileName = getFileName;
|
PDFJS.getFileName = getFileName;
|
||||||
|
PDFJS.ProgressBar = ProgressBar;
|
||||||
}).call((typeof window === 'undefined') ? this : window);
|
}).call((typeof window === 'undefined') ? this : window);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
SCROLLBAR_PADDING, VERTICAL_PADDING, MAX_AUTO_SCALE, CSS_UNITS,
|
SCROLLBAR_PADDING, VERTICAL_PADDING, MAX_AUTO_SCALE, CSS_UNITS,
|
||||||
DEFAULT_SCALE, scrollIntoView, getVisibleElements, RenderingStates,
|
DEFAULT_SCALE, scrollIntoView, getVisibleElements, RenderingStates,
|
||||||
PDFJS, Promise, TextLayerBuilder, PDFRenderingQueue,
|
PDFJS, Promise, TextLayerBuilder, PDFRenderingQueue,
|
||||||
AnnotationsLayerBuilder */
|
AnnotationsLayerBuilder, DEFAULT_SCALE_VALUE */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -149,7 +149,8 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
get currentScale() {
|
get currentScale() {
|
||||||
return this._currentScale;
|
return this._currentScale !== UNKNOWN_SCALE ? this._currentScale :
|
||||||
|
DEFAULT_SCALE;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,7 +162,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
}
|
}
|
||||||
if (!this.pdfDocument) {
|
if (!this.pdfDocument) {
|
||||||
this._currentScale = val;
|
this._currentScale = val;
|
||||||
this._currentScaleValue = val.toString();
|
this._currentScaleValue = val !== UNKNOWN_SCALE ? val.toString() : null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._setScale(val, false);
|
this._setScale(val, false);
|
||||||
@ -265,7 +266,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
// Fetch a single page so we can get a viewport that will be the default
|
// Fetch a single page so we can get a viewport that will be the default
|
||||||
// viewport for all pages
|
// viewport for all pages
|
||||||
return firstPagePromise.then(function(pdfPage) {
|
return firstPagePromise.then(function(pdfPage) {
|
||||||
var scale = this._currentScale || 1.0;
|
var scale = this.currentScale;
|
||||||
var viewport = pdfPage.getViewport(scale * CSS_UNITS);
|
var viewport = pdfPage.getViewport(scale * CSS_UNITS);
|
||||||
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||||
var textLayerFactory = null;
|
var textLayerFactory = null;
|
||||||
@ -523,10 +524,10 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scale && scale !== this.currentScale) {
|
if (scale && scale !== this._currentScale) {
|
||||||
this.currentScaleValue = scale;
|
this.currentScaleValue = scale;
|
||||||
} else if (this.currentScale === UNKNOWN_SCALE) {
|
} else if (this._currentScale === UNKNOWN_SCALE) {
|
||||||
this.currentScaleValue = DEFAULT_SCALE;
|
this.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scale === 'page-fit' && !dest[4]) {
|
if (scale === 'page-fit' && !dest[4]) {
|
||||||
|
@ -160,24 +160,6 @@ var Preferences = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//#if B2G
|
|
||||||
//Preferences._writeToStorage = function (prefObj) {
|
|
||||||
// return new Promise(function (resolve) {
|
|
||||||
// asyncStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj),
|
|
||||||
// resolve);
|
|
||||||
// });
|
|
||||||
//};
|
|
||||||
//
|
|
||||||
//Preferences._readFromStorage = function (prefObj) {
|
|
||||||
// return new Promise(function (resolve) {
|
|
||||||
// asyncStorage.getItem('pdfjs.preferences', function (prefStr) {
|
|
||||||
// var readPrefs = JSON.parse(prefStr);
|
|
||||||
// resolve(readPrefs);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
//};
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
//#if CHROME
|
//#if CHROME
|
||||||
//Preferences._writeToStorage = function (prefObj) {
|
//Preferences._writeToStorage = function (prefObj) {
|
||||||
// return new Promise(function (resolve) {
|
// return new Promise(function (resolve) {
|
||||||
@ -221,7 +203,7 @@ var Preferences = {
|
|||||||
//};
|
//};
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL || B2G || CHROME)
|
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
||||||
Preferences._writeToStorage = function (prefObj) {
|
Preferences._writeToStorage = function (prefObj) {
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
|
localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var CSS_UNITS = 96.0 / 72.0;
|
var CSS_UNITS = 96.0 / 72.0;
|
||||||
var DEFAULT_SCALE = 'auto';
|
var DEFAULT_SCALE_VALUE = 'auto';
|
||||||
|
var DEFAULT_SCALE = 1.0;
|
||||||
var UNKNOWN_SCALE = 0;
|
var UNKNOWN_SCALE = 0;
|
||||||
var MAX_AUTO_SCALE = 1.25;
|
var MAX_AUTO_SCALE = 1.25;
|
||||||
var SCROLLBAR_PADDING = 40;
|
var SCROLLBAR_PADDING = 40;
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
* The way that the view parameters are stored depends on how PDF.js is built,
|
* The way that the view parameters are stored depends on how PDF.js is built,
|
||||||
* for 'node make <flag>' the following cases exist:
|
* for 'node make <flag>' the following cases exist:
|
||||||
* - FIREFOX or MOZCENTRAL - uses sessionStorage.
|
* - FIREFOX or MOZCENTRAL - uses sessionStorage.
|
||||||
* - B2G - uses asyncStorage.
|
|
||||||
* - GENERIC or CHROME - uses localStorage, if it is available.
|
* - GENERIC or CHROME - uses localStorage, if it is available.
|
||||||
*/
|
*/
|
||||||
var ViewHistory = (function ViewHistoryClosure() {
|
var ViewHistory = (function ViewHistoryClosure() {
|
||||||
@ -64,16 +63,12 @@ var ViewHistory = (function ViewHistoryClosure() {
|
|||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
var databaseStr = JSON.stringify(this.database);
|
var databaseStr = JSON.stringify(this.database);
|
||||||
|
|
||||||
//#if B2G
|
|
||||||
// asyncStorage.setItem('database', databaseStr, resolve);
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
//#if FIREFOX || MOZCENTRAL
|
//#if FIREFOX || MOZCENTRAL
|
||||||
// sessionStorage.setItem('pdfjsHistory', databaseStr);
|
// sessionStorage.setItem('pdfjsHistory', databaseStr);
|
||||||
// resolve();
|
// resolve();
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL || B2G)
|
//#if !(FIREFOX || MOZCENTRAL)
|
||||||
localStorage.setItem('database', databaseStr);
|
localStorage.setItem('database', databaseStr);
|
||||||
resolve();
|
resolve();
|
||||||
//#endif
|
//#endif
|
||||||
@ -82,15 +77,11 @@ var ViewHistory = (function ViewHistoryClosure() {
|
|||||||
|
|
||||||
_readFromStorage: function ViewHistory_readFromStorage() {
|
_readFromStorage: function ViewHistory_readFromStorage() {
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
//#if B2G
|
|
||||||
// asyncStorage.getItem('database', resolve);
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
//#if FIREFOX || MOZCENTRAL
|
//#if FIREFOX || MOZCENTRAL
|
||||||
// resolve(sessionStorage.getItem('pdfjsHistory'));
|
// resolve(sessionStorage.getItem('pdfjsHistory'));
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL || B2G)
|
//#if !(FIREFOX || MOZCENTRAL)
|
||||||
resolve(localStorage.getItem('database'));
|
resolve(localStorage.getItem('database'));
|
||||||
//#endif
|
//#endif
|
||||||
});
|
});
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
Promise, PDFLinkService, PDFOutlineView, PDFAttachmentView,
|
Promise, PDFLinkService, PDFOutlineView, PDFAttachmentView,
|
||||||
OverlayManager, PDFFindController, PDFFindBar, getVisibleElements,
|
OverlayManager, PDFFindController, PDFFindBar, getVisibleElements,
|
||||||
watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState,
|
watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState,
|
||||||
parseQueryString, RenderingStates, DEFAULT_SCALE, UNKNOWN_SCALE,
|
parseQueryString, RenderingStates, UNKNOWN_SCALE,
|
||||||
IGNORE_CURRENT_POSITION_ON_ZOOM: true */
|
DEFAULT_SCALE_VALUE, IGNORE_CURRENT_POSITION_ON_ZOOM: true */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -36,13 +36,9 @@ var SCALE_SELECT_CONTAINER_PADDING = 8;
|
|||||||
var SCALE_SELECT_PADDING = 22;
|
var SCALE_SELECT_PADDING = 22;
|
||||||
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
||||||
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
||||||
//#if B2G
|
|
||||||
//PDFJS.useOnlyCssZoom = true;
|
|
||||||
//PDFJS.disableTextLayer = true;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
PDFJS.imageResourcesPath = './images/';
|
PDFJS.imageResourcesPath = './images/';
|
||||||
//#if (FIREFOX || MOZCENTRAL || B2G || GENERIC || CHROME)
|
//#if (FIREFOX || MOZCENTRAL || GENERIC || CHROME)
|
||||||
//PDFJS.workerSrc = '../build/pdf.worker.js';
|
//PDFJS.workerSrc = '../build/pdf.worker.js';
|
||||||
//#endif
|
//#endif
|
||||||
//#if !PRODUCTION
|
//#if !PRODUCTION
|
||||||
@ -58,18 +54,13 @@ var mozL10n = document.mozL10n || document.webL10n;
|
|||||||
//#include ui_utils.js
|
//#include ui_utils.js
|
||||||
//#include preferences.js
|
//#include preferences.js
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL || B2G)
|
//#if !(FIREFOX || MOZCENTRAL)
|
||||||
//#include mozPrintCallback_polyfill.js
|
//#include mozPrintCallback_polyfill.js
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if GENERIC || CHROME
|
//#if GENERIC || CHROME
|
||||||
//#include download_manager.js
|
//#include download_manager.js
|
||||||
//#endif
|
//#endif
|
||||||
//#if B2G
|
|
||||||
//var DownloadManager = (function DownloadManagerClosure() {
|
|
||||||
// return function DownloadManager() {};
|
|
||||||
//})();
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
//#if FIREFOX || MOZCENTRAL
|
//#if FIREFOX || MOZCENTRAL
|
||||||
//#include firefoxcom.js
|
//#include firefoxcom.js
|
||||||
@ -475,9 +466,6 @@ var PDFViewerApplication = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.title = title;
|
document.title = title;
|
||||||
//#if B2G
|
|
||||||
// document.getElementById('activityTitle').textContent = title;
|
|
||||||
//#endif
|
|
||||||
},
|
},
|
||||||
|
|
||||||
close: function pdfViewClose() {
|
close: function pdfViewClose() {
|
||||||
@ -560,10 +548,6 @@ var PDFViewerApplication = {
|
|||||||
loadingErrorMessage = mozL10n.get('unexpected_response_error', null,
|
loadingErrorMessage = mozL10n.get('unexpected_response_error', null,
|
||||||
'Unexpected server response.');
|
'Unexpected server response.');
|
||||||
}
|
}
|
||||||
//#if B2G
|
|
||||||
// window.alert(loadingErrorMessage);
|
|
||||||
// return window.close();
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
var moreInfo = {
|
var moreInfo = {
|
||||||
message: message
|
message: message
|
||||||
@ -757,7 +741,7 @@ var PDFViewerApplication = {
|
|||||||
var id = this.documentFingerprint = pdfDocument.fingerprint;
|
var id = this.documentFingerprint = pdfDocument.fingerprint;
|
||||||
var store = this.store = new ViewHistory(id);
|
var store = this.store = new ViewHistory(id);
|
||||||
|
|
||||||
//#if (GENERIC || B2G)
|
//#if GENERIC
|
||||||
var baseDocumentUrl = null;
|
var baseDocumentUrl = null;
|
||||||
//#endif
|
//#endif
|
||||||
//#if (FIREFOX || MOZCENTRAL)
|
//#if (FIREFOX || MOZCENTRAL)
|
||||||
@ -994,10 +978,10 @@ var PDFViewerApplication = {
|
|||||||
this.page = 1;
|
this.page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pdfViewer.currentScale === UNKNOWN_SCALE) {
|
if (!this.pdfViewer.currentScaleValue) {
|
||||||
// Scale was not initialized: invalid bookmark or scale was not specified.
|
// Scale was not initialized: invalid bookmark or scale was not specified.
|
||||||
// Setting the default one.
|
// Setting the default one.
|
||||||
this.setScale(DEFAULT_SCALE, true);
|
this.setScale(DEFAULT_SCALE_VALUE, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1253,7 +1237,7 @@ function webViewerLoad(evt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function webViewerInitialized() {
|
function webViewerInitialized() {
|
||||||
//#if (GENERIC || B2G)
|
//#if GENERIC
|
||||||
var queryString = document.location.search.substring(1);
|
var queryString = document.location.search.substring(1);
|
||||||
var params = parseQueryString(queryString);
|
var params = parseQueryString(queryString);
|
||||||
var file = 'file' in params ? params.file : DEFAULT_URL;
|
var file = 'file' in params ? params.file : DEFAULT_URL;
|
||||||
@ -1903,7 +1887,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
// 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
|
||||||
PDFViewerApplication.setScale(DEFAULT_SCALE, true);
|
PDFViewerApplication.setScale(DEFAULT_SCALE_VALUE, true);
|
||||||
});
|
});
|
||||||
handled = false;
|
handled = false;
|
||||||
}
|
}
|
||||||
@ -2106,24 +2090,3 @@ window.addEventListener('afterprint', function afterPrint(evt) {
|
|||||||
window.requestAnimationFrame(resolve);
|
window.requestAnimationFrame(resolve);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
//#if B2G
|
|
||||||
//window.navigator.mozSetMessageHandler('activity', function(activity) {
|
|
||||||
// var blob = activity.source.data.blob;
|
|
||||||
// PDFJS.maxImageSize = 1024 * 1024;
|
|
||||||
// var fileURL = activity.source.data.url ||
|
|
||||||
// activity.source.data.filename ||
|
|
||||||
// " "; // if no url or filename, use a non-empty string
|
|
||||||
//
|
|
||||||
// var url = URL.createObjectURL(blob);
|
|
||||||
// // We need to delay opening until all HTML is loaded.
|
|
||||||
// PDFViewerApplication.animationStartedPromise.then(function () {
|
|
||||||
// PDFViewerApplication.open({url : url, originalUrl: fileURL});
|
|
||||||
//
|
|
||||||
// var header = document.getElementById('header');
|
|
||||||
// header.addEventListener('action', function() {
|
|
||||||
// activity.postResult('close');
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
//});
|
|
||||||
//#endif
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user