[Pkg-javascript-commits] [pdf.js] 88/116: Remove DownloadManager dependency

David Prévot taffit at moszumanska.debian.org
Fri Mar 6 16:20:04 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 4c6ca1c78f1f0e5ebf5cc06f14cd173f19d0edeb
Author: Tim van der Meij <timvandermeij at gmail.com>
Date:   Tue Jan 27 22:11:04 2015 +0100

    Remove DownloadManager dependency
    
    We can pass it in using the options object. Note that that this also avoids creating a DownloadManager object for each separate link (instead, having only one is enough).
---
 web/pdf_attachment_view.js | 8 ++++----
 web/viewer.js              | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/web/pdf_attachment_view.js b/web/pdf_attachment_view.js
index b69c4bf..6e8883f 100644
--- a/web/pdf_attachment_view.js
+++ b/web/pdf_attachment_view.js
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/* globals DownloadManager, getFileName */
+/* globals getFileName */
 
 'use strict';
 
@@ -22,6 +22,7 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
   function PDFAttachmentView(options) {
     this.container = options.container;
     this.attachments = options.attachments;
+    this.downloadManager = options.downloadManager;
   }
 
   PDFAttachmentView.prototype = {
@@ -34,12 +35,11 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
 
     _bindLink: function PDFAttachmentView_bindLink(button, item) {
       button.onclick = function downloadFile(e) {
-        var downloadManager = new DownloadManager();
         var content = item.content;
         var filename = item.filename;
-        downloadManager.downloadData(content, getFileName(filename), '');
+        this.downloadManager.downloadData(content, getFileName(filename), '');
         return false;
-      };
+      }.bind(this);
     },
 
     render: function PDFAttachmentView_render() {
diff --git a/web/viewer.js b/web/viewer.js
index 92ad38b..4c84921 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -988,7 +988,8 @@ var PDFViewerApplication = {
         var container = document.getElementById('attachmentsView');
         self.attachments = new PDFAttachmentView({
           container: container,
-          attachments: attachments
+          attachments: attachments,
+          downloadManager: new DownloadManager()
         });
         self.attachments.render();
         document.getElementById('viewAttachments').disabled = !attachments;

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