[Pkg-javascript-commits] [pdf.js] 49/157: Simplify the SimpleLinkService and use it to pass in a linkService instance in DefaultAnnotationsLayerFactory

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 06:46:33 UTC 2015


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

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

commit 4364b37e55d0b87d8c8af152c5322e329fab0621
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Jun 11 22:20:04 2015 +0200

    Simplify the SimpleLinkService and use it to pass in a linkService instance in DefaultAnnotationsLayerFactory
    
    Considering that most methods of `SimpleLinkService` are complete stubs, or practically "useless" considering what they return, we can actually simplify it even more.
    
    *Note:* This depends on the previous patch, that did a small amount of refactoring of `PDFViewer_scrollPageIntoView`, since `PDFViewer.linkService.page` is no longer accessed.
    
    ----------
    
    Currently the `pageviewer` components example doesn't work correctly (an error is printed in the console), since no `linkService` is present when the `AnnotationsLayerBuilder` is created.
    
    *Note:* Given that this uses the `SimpleLinkService`, clicking on e.g. internal links won't actually do anything. However, given that internal links (and similar features) are pretty much useless when only *one* page is loaded the `pageviewer` example, I don't think that really matters.
    Also, using the complete `PDFLinkService` would require a `PDFViewer` instance. That would significantly complicate the example, thus making it both less clear and less self contained.
---
 web/annotations_layer_builder.js |  5 +++--
 web/pdf_viewer.js                | 13 +++++--------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/web/annotations_layer_builder.js b/web/annotations_layer_builder.js
index b5ef814..8b4e66c 100644
--- a/web/annotations_layer_builder.js
+++ b/web/annotations_layer_builder.js
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*globals PDFJS, CustomStyle, mozL10n */
+/*globals PDFJS, CustomStyle, mozL10n, SimpleLinkService */
 
 'use strict';
 
@@ -171,7 +171,8 @@ DefaultAnnotationsLayerFactory.prototype = {
   createAnnotationsLayerBuilder: function (pageDiv, pdfPage) {
     return new AnnotationsLayerBuilder({
       pageDiv: pageDiv,
-      pdfPage: pdfPage
+      pdfPage: pdfPage,
+      linkService: new SimpleLinkService(),
     });
   }
 };
diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js
index b82edd1..48d94a2 100644
--- a/web/pdf_viewer.js
+++ b/web/pdf_viewer.js
@@ -81,7 +81,7 @@ var PDFViewer = (function pdfViewer() {
   function PDFViewer(options) {
     this.container = options.container;
     this.viewer = options.viewer || options.container.firstElementChild;
-    this.linkService = options.linkService || new SimpleLinkService(this);
+    this.linkService = options.linkService || new SimpleLinkService();
     this.removePageBorders = options.removePageBorders || false;
 
     this.defaultRenderingQueue = !options.renderingQueue;
@@ -744,22 +744,19 @@ var PDFViewer = (function pdfViewer() {
 })();
 
 var SimpleLinkService = (function SimpleLinkServiceClosure() {
-  function SimpleLinkService(pdfViewer) {
-    this.pdfViewer = pdfViewer;
-  }
+  function SimpleLinkService() {}
+
   SimpleLinkService.prototype = {
     /**
      * @returns {number}
      */
     get page() {
-      return this.pdfViewer.currentPageNumber;
+      return 0;
     },
     /**
      * @param {number} value
      */
-    set page(value) {
-      this.pdfViewer.currentPageNumber = value;
-    },
+    set page(value) {},
     /**
      * @param dest - The PDF destination object.
      */

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