[Pkg-javascript-commits] [pdf.js] 01/01: PDF.js version 1.0.1207
David Prévot
taffit at moszumanska.debian.org
Sat Jun 20 21:36:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v1.0.1207
in repository pdf.js.
commit ad7fbc5919e75ac12a5c3e1547d5571784301b4b
Author: Yury Delendik <ydelendik at mozilla.com>
Date: Sat Mar 14 13:38:20 2015 -0500
PDF.js version 1.0.1207
---
extensions/b2g/viewer.html | 192 +-------------------------------------------
extensions/b2g/viewer.js | 195 +++++++++++++++++++++++++++++++++++++++++++++
make.js | 11 ++-
3 files changed, 201 insertions(+), 197 deletions(-)
diff --git a/extensions/b2g/viewer.html b/extensions/b2g/viewer.html
index 83aad6c..573d046 100644
--- a/extensions/b2g/viewer.html
+++ b/extensions/b2g/viewer.html
@@ -22,9 +22,8 @@ limitations under the License.
<link rel="stylesheet" href="viewer.css"/>
- <link rel="resource" type="application/l10n" href="locale/locale.properties"/>
- <script src="l10n.js"></script>
<script src="../build/pdf.js"></script>
+ <script src="../build/pdf_viewer.js"></script>
<script src="/shared/js/async_storage.js"></script>
<script src="viewer.js"></script>
@@ -81,194 +80,5 @@ limitations under the License.
<div class="clearBoth"></div>
<textarea id="errorMoreInfo" hidden='true' readonly="readonly"></textarea>
</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>
</html>
diff --git a/extensions/b2g/viewer.js b/extensions/b2g/viewer.js
new file mode 100644
index 0000000..fdf049c
--- /dev/null
+++ b/extensions/b2g/viewer.js
@@ -0,0 +1,195 @@
+/* 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.
+ */
+
+'use strict';
+
+PDFJS.useOnlyCssZoom = true;
+PDFJS.disableTextLayer = true;
+PDFJS.workerSrc = '../build/pdf.worker.js';
+PDFJS.cMapUrl = '../web/cmaps/';
+PDFJS.cMapPacked = true;
+
+var DEFAULT_SCALE_DELTA = 1.1;
+var MIN_SCALE = 0.25;
+var MAX_SCALE = 10.0;
+
+var PDFViewerApplication = {
+ pdfDocument: null,
+ pdfViewer: null,
+ loading: true,
+ updateScaleControls: false,
+
+ open: function (params) {
+ var url = params.url, originalUrl = params.originalUrl;
+
+ this.initUI();
+ this.setTitleUsingUrl(originalUrl);
+
+ // Loading document.
+ PDFJS.getDocument(url).then(function (pdfDocument) {
+ // Document loaded, specifying document for the viewer.
+ this.pdfDocument = pdfDocument;
+ this.pdfViewer.setDocument(pdfDocument);
+ }.bind(this));
+ },
+
+ setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
+ this.url = url;
+ try {
+ this.setTitle(decodeURIComponent(PDFJS.getFileName(url)) || url);
+ } catch (e) {
+ // decodeURIComponent may throw URIError,
+ // fall back to using the unprocessed url in that case
+ this.setTitle(url);
+ }
+ },
+
+ setTitle: function pdfViewSetTitle(title) {
+ document.title = title;
+ document.getElementById('activityTitle').textContent = title;
+ },
+
+ 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.setScale(newScale, true);
+ },
+
+ 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.setScale(newScale, true);
+ },
+
+ setScale: function (value, resetAutoSettings) {
+ this.updateScaleControls = !!resetAutoSettings;
+ this.pdfViewer.currentScaleValue = value;
+ this.updateScaleControls = true;
+ },
+
+ initUI: function pdfViewInitUI() {
+ var container = document.getElementById('viewerContainer');
+ var pdfViewer = new PDFJS.PDFViewer({
+ container: container
+ });
+ this.pdfViewer = pdfViewer;
+
+ container.addEventListener('pagesinit', function () {
+ // we can use pdfViewer now, e.g. let's change default scale.
+ pdfViewer.currentScaleValue = 'page-width';
+ });
+
+ 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;
+ }
+ });
+
+ window.addEventListener('pagechange', function pagechange(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);
+
+ // checking if the this.page was called from the updateViewarea function
+ if (evt.updateInProgress) {
+ return;
+ }
+ // Avoid scrolling the first page during loading
+ if (this.loading && page === 1) {
+ return;
+ }
+ PDFViewerApplication.pdfViewer.scrollPageIntoView(page);
+ }, 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);
+ });
+})();
+
+window.navigator.mozSetMessageHandler('activity', function(activity) {
+ var blob = activity.source.data.blob;
+ PDFJS.maxImageSize = 1024 * 1024;
+ var fileURL = activity.source.data.url;
+
+ 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');
+ });
+ });
+});
diff --git a/make.js b/make.js
index ff4c151..3ebe1e5 100644
--- a/make.js
+++ b/make.js
@@ -284,7 +284,7 @@ target.dist = function() {
rm('-rf', DIST_DIR);
mkdir('-p', DIST_DIR);
- exec('git clone --depth 1 ' + DIST_REPO_URL + ' ' + DIST_DIR);
+// exec('git clone --depth 1 ' + DIST_REPO_URL + ' ' + DIST_DIR);
echo();
echo('### Overwriting all files');
@@ -972,7 +972,7 @@ target.mozcentral = function() {
};
target.b2g = function() {
- target.locale();
+ target.dist();
echo();
echo('### Building B2G (Firefox OS App)');
@@ -994,12 +994,11 @@ target.b2g = function() {
['extensions/b2g/images', B2G_BUILD_CONTENT_DIR + '/web'],
['extensions/b2g/viewer.html', B2G_BUILD_CONTENT_DIR + '/web'],
['extensions/b2g/viewer.css', B2G_BUILD_CONTENT_DIR + '/web'],
- ['web/locale', B2G_BUILD_CONTENT_DIR + '/web'],
- ['external/bcmaps/*', B2G_BUILD_CONTENT_DIR + '/web/cmaps'],
- ['external/webL10n/l10n.js', B2G_BUILD_CONTENT_DIR + '/web']
+ ['extensions/b2g/viewer.js', B2G_BUILD_CONTENT_DIR + '/web'],
+ ['external/bcmaps/*', B2G_BUILD_CONTENT_DIR + '/web/cmaps']
],
preprocess: [
- ['web/viewer.js', B2G_BUILD_CONTENT_DIR + '/web'],
+ ['build/components/pdf_viewer.js', B2G_BUILD_CONTENT_DIR + '/build'],
[BUILD_TARGETS, B2G_BUILD_CONTENT_DIR + BUILD_DIR]
]
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list