[Pkg-javascript-commits] [pdf.js] 323/414: Prepare viewer.js for async loading and module separation.

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:35 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 313b418a20f3cb72975c1977288706689f69ce06
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Fri Apr 1 10:29:44 2016 -0500

    Prepare viewer.js for async loading and module separation.
---
 web/app.js                  | 62 ++++++---------------------------------------
 web/platform_integration.js | 30 ++++++++++++++++++++++
 web/ui_utils.js             |  2 ++
 web/viewer.html             |  2 ++
 web/viewer.js               | 51 +++++++++++++++++++++++++++++++++++++
 5 files changed, 93 insertions(+), 54 deletions(-)

diff --git a/web/app.js b/web/app.js
index 487d4cb..0f65a88 100644
--- a/web/app.js
+++ b/web/app.js
@@ -20,12 +20,11 @@
            PDFOutlineViewer, PDFAttachmentViewer, OverlayManager,
            PDFFindController, PDFFindBar, PDFViewer, PDFRenderingQueue,
            PresentationModeState, parseQueryString, RenderingStates,
-           UNKNOWN_SCALE, DEFAULT_SCALE_VALUE,
+           UNKNOWN_SCALE, DEFAULT_SCALE_VALUE, DEFAULT_URL, mozL10n,
            IGNORE_CURRENT_POSITION_ON_ZOOM: true */
 
 'use strict';
 
-var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
 var DEFAULT_SCALE_DELTA = 1.1;
 var MIN_SCALE = 0.25;
 var MAX_SCALE = 10.0;
@@ -49,27 +48,9 @@ function configure(PDFJS) {
 //#endif
 }
 
-var mozL10n = document.mozL10n || document.webL10n;
-
 //#include ui_utils.js
 //#include preferences.js
-
-//#if !(FIREFOX || MOZCENTRAL)
-//#include mozPrintCallback_polyfill.js
-//#endif
-
-//#if GENERIC || CHROME
-//#include download_manager.js
-//#endif
-
-//#if FIREFOX || MOZCENTRAL
-//#include firefoxcom.js
-//#endif
-
-//#if CHROME
-//#include chromecom.js
-//#endif
-
+//#include platform_integration.js
 //#include view_history.js
 //#include pdf_find_bar.js
 //#include pdf_find_controller.js
@@ -127,6 +108,8 @@ var PDFViewerApplication = {
 
   // called once when the document is loaded
   initialize: function pdfViewInitialize() {
+    configure(PDFJS);
+
     var pdfRenderingQueue = new PDFRenderingQueue();
     pdfRenderingQueue.onIdle = this.cleanup.bind(this);
     this.pdfRenderingQueue = pdfRenderingQueue;
@@ -346,6 +329,10 @@ var PDFViewerApplication = {
     });
   },
 
+  run: function pdfViewRun() {
+    this.initialize().then(webViewerInitialized);
+  },
+
   zoomIn: function pdfViewZoomIn(ticks) {
     var newScale = this.pdfViewer.currentScale;
     do {
@@ -1245,23 +1232,6 @@ var PDFViewerApplication = {
 window.PDFView = PDFViewerApplication; // obsolete name, using it as an alias
 //#endif
 
-//#if CHROME
-//(function rewriteUrlClosure() {
-//  // Run this code outside DOMContentLoaded to make sure that the URL
-//  // is rewritten as soon as possible.
-//  var queryString = document.location.search.slice(1);
-//  var params = parseQueryString(queryString);
-//  DEFAULT_URL = params.file || '';
-//
-//  // Example: chrome-extension://.../http://example.com/file.pdf
-//  var humanReadableUrl = '/' + DEFAULT_URL + location.hash;
-//  history.replaceState(history.state, '', humanReadableUrl);
-//  if (top === window) {
-//    chrome.runtime.sendMessage('showPageAction');
-//  }
-//})();
-//#endif
-
 //#if GENERIC
 var HOSTED_VIEWER_ORIGINS = ['null',
   'http://mozilla.github.io', 'https://mozilla.github.io'];
@@ -1293,20 +1263,6 @@ function validateFileURL(file) {
 }
 //#endif
 
-function webViewerLoad(evt) {
-//#if !PRODUCTION
-  require.config({paths: {'pdfjs': '../src'}});
-  require(['pdfjs/main_loader'],
-    function (loader) {
-      configure(PDFJS);
-      PDFViewerApplication.initialize().then(webViewerInitialized);
-    });
-//#else
-//  configure(PDFJS);
-//  PDFViewerApplication.initialize().then(webViewerInitialized);
-//#endif
-}
-
 function webViewerInitialized() {
 //#if GENERIC
   var queryString = document.location.search.substring(1);
@@ -1550,8 +1506,6 @@ function webViewerInitialized() {
 //#endif
 }
 
-document.addEventListener('DOMContentLoaded', webViewerLoad, true);
-
 document.addEventListener('pagerendered', function (e) {
   var pageNumber = e.detail.pageNumber;
   var pageIndex = pageNumber - 1;
diff --git a/web/platform_integration.js b/web/platform_integration.js
new file mode 100644
index 0000000..bd7f80d
--- /dev/null
+++ b/web/platform_integration.js
@@ -0,0 +1,30 @@
+/* Copyright 2016 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.
+ */
+
+//#if !(FIREFOX || MOZCENTRAL)
+//#include mozPrintCallback_polyfill.js
+//#endif
+
+//#if GENERIC || CHROME
+//#include download_manager.js
+//#endif
+
+//#if FIREFOX || MOZCENTRAL
+//#include firefoxcom.js
+//#endif
+
+//#if CHROME
+//#include chromecom.js
+//#endif
diff --git a/web/ui_utils.js b/web/ui_utils.js
index 5bb0592..976a45f 100644
--- a/web/ui_utils.js
+++ b/web/ui_utils.js
@@ -23,6 +23,8 @@ var MAX_AUTO_SCALE = 1.25;
 var SCROLLBAR_PADDING = 40;
 var VERTICAL_PADDING = 5;
 
+var mozL10n = document.mozL10n || document.webL10n;
+
 /**
  * Returns scale factor for the canvas. It makes sense for the HiDPI displays.
  * @return {Object} The object with horizontal (sx) and vertical (sy)
diff --git a/web/viewer.html b/web/viewer.html
index 98ee829..0018bba 100644
--- a/web/viewer.html
+++ b/web/viewer.html
@@ -65,6 +65,7 @@ See https://github.com/adobe-type-tools/cmap-resources
     <script src="default_preferences.js"></script>
     <script src="preferences.js"></script>
     <script src="download_manager.js"></script>
+    <script src="platform_integration.js"></script>
     <script src="view_history.js"></script>
     <script src="pdf_link_service.js"></script>
     <script src="pdf_rendering_queue.js"></script>
@@ -87,6 +88,7 @@ See https://github.com/adobe-type-tools/cmap-resources
     <script src="overlay_manager.js"></script>
     <script src="password_prompt.js"></script>
     <script src="pdf_document_properties.js"></script>
+    <script src="app.js"></script>
 <!--#endif-->
 
 <!--#if !MINIFIED -->
diff --git a/web/viewer.js b/web/viewer.js
new file mode 100644
index 0000000..9709d35
--- /dev/null
+++ b/web/viewer.js
@@ -0,0 +1,51 @@
+/* Copyright 2016 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 require, parseQueryString, chrome, PDFViewerApplication */
+
+'use strict';
+
+var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
+
+//#include app.js
+
+//#if CHROME
+//(function rewriteUrlClosure() {
+//  // Run this code outside DOMContentLoaded to make sure that the URL
+//  // is rewritten as soon as possible.
+//  var queryString = document.location.search.slice(1);
+//  var params = parseQueryString(queryString);
+//  DEFAULT_URL = params.file || '';
+//
+//  // Example: chrome-extension://.../http://example.com/file.pdf
+//  var humanReadableUrl = '/' + DEFAULT_URL + location.hash;
+//  history.replaceState(history.state, '', humanReadableUrl);
+//  if (top === window) {
+//    chrome.runtime.sendMessage('showPageAction');
+//  }
+//})();
+//#endif
+
+function webViewerLoad() {
+//#if !PRODUCTION
+  require.config({paths: {'pdfjs': '../src'}});
+  require(['pdfjs/main_loader'], function (loader) {
+    PDFViewerApplication.run();
+  });
+//#else
+//PDFViewerApplication.run();
+//#endif
+}
+
+document.addEventListener('DOMContentLoaded', webViewerLoad, true);

-- 
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