From d978c4c27f41b648967c4427986779c752a67c62 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Thu, 3 Jul 2014 00:13:55 +0200 Subject: [PATCH] Support opening of file in Chrome. --- static/js/directives/pdfviewer.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/static/js/directives/pdfviewer.js b/static/js/directives/pdfviewer.js index 415c240e..d3fcab72 100644 --- a/static/js/directives/pdfviewer.js +++ b/static/js/directives/pdfviewer.js @@ -68,9 +68,15 @@ define(['require', 'jquery', 'underscore', 'text!partials/pdfviewer.html', 'pdf' subscope.$on("downloadComplete", function(event) { event.stopPropagation(); }); - subscope.$on("writeComplete", function(event, url) { + subscope.$on("writeComplete", function(event, url, fileInfo) { event.stopPropagation(); - $scope.doOpenFile(url); + if (url.indexOf("blob:") === 0) { + $scope.doOpenFile(url); + } else { + fileInfo.file.file(function(fp) { + $scope.openFile(fp); + }); + } }); handler = mediaStream.tokens.on(subscope.info.id, function(event, currenttoken, to, data, type, to2, from, xfer) { //console.log("PdfViewer token request", currenttoken, data, type); @@ -163,8 +169,8 @@ define(['require', 'jquery', 'underscore', 'text!partials/pdfviewer.html', 'pdf' $scope.openFile = function(file) { console.log("Loading PDF from", file); - var fp = file.file; - if (typeof URL !== "undefined" && URL.createObjectURL1) { + var fp = file.file || file; + if (typeof URL !== "undefined" && URL.createObjectURL) { var url = URL.createObjectURL(fp); $scope.doOpenFile(url); } else {