From c3569dd45f7f3d38b5736132bd576354402945d5 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 8 Dec 2014 17:00:26 +0000 Subject: [PATCH] add a progress event in the pdfng viewer --- .../web/public/coffee/ide/pdfng/directives/pdfJs.coffee | 9 +++++++++ .../coffee/ide/pdfng/directives/pdfRenderer.coffee | 2 +- .../public/coffee/ide/pdfng/directives/pdfViewer.coffee | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee index 43ab26f6f5..19f34b6a80 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee @@ -147,6 +147,12 @@ define [ for event in attrs.resizeOn.split(",") scope.$on event, (e) -> #console.log 'got a resize event', event, e + # + + scope.$on 'progress', (event, progress) -> + scope.$apply () -> + console.log 'progress', progress.loaded, progress.total, progress + scope.progress = Math.floor(progress.loaded/progress.total*100) template: """
@@ -190,6 +196,9 @@ define [ +
+
+
""" } ] diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfRenderer.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfRenderer.coffee index 68bfc560a7..7a92c164d2 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfRenderer.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfRenderer.coffee @@ -12,7 +12,7 @@ define [ PDFJS.disableAutoFetch = true PDFJS.disableFontFace = true @scale = @options.scale || 1 - @document = $q.when(PDFJS.getDocument @url) + @document = $q.when(PDFJS.getDocument @url, null, null, @options.progressCallback) @navigateFn = @options.navigateFn @spinner = new pdfSpinner @resetState() diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee index 93fe7a0952..29a15a0416 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee @@ -30,6 +30,8 @@ define [ # this function captures clicks on the annotation links $scope.navigateTo = ref $scope.$apply() + progressCallback: (progress) -> + $scope.$emit 'progress', progress }) # we will have all the main information needed to start display