]> _ Git - fluidbook-html5.git/commitdiff
wip #1023 @6
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 3 Feb 2017 18:17:58 +0000 (19:17 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 3 Feb 2017 18:17:58 +0000 (19:17 +0100)
js/libs/fluidbook/fluidbook.js
js/main.js

index 7c9a509803e032ec5bbc55888fa32b854edf559f..e169f7d566750ee9aba5a2ba0c605824cf0aca3f 100644 (file)
@@ -1206,17 +1206,17 @@ Fluidbook.prototype = {
         if (this.datas.pdfName.substr(0, 4) == 'http') {
             pdf = this.datas.pdfName;
         } else {
-            pdf = 'data/' + this.datas.pdfName;
+            pdf = this.relativeToAbsolute('data/' + this.datas.pdfName);
         }
         var e = pdf.split('/');
         pdfName = e.pop();
         /*if (this.gal && !OFFLINEAPP) {
-            this.displayLoader();
-            this.gal.downloadAndCall('extras', function () {
-                $this._openFile(pdf, $("#print"), 'pdf', pdfName);
-            });
-        } else {*/
-            this._openFile(pdf, $("#print"), 'pdf', pdfName);
+         this.displayLoader();
+         this.gal.downloadAndCall('extras', function () {
+         $this._openFile(pdf, $("#print"), 'pdf', pdfName);
+         });
+         } else {*/
+        this._openFile(pdf, $("#print"), 'pdf', pdfName);
         //}
     },
     _openFile: function (url, e, type, localname) {
@@ -1301,11 +1301,17 @@ Fluidbook.prototype = {
 
         if (this.datas.phonegap == 'android') {
             if (types_android[type] != undefined) {
+                fb('open pdf file');
                 this.displayLoader();
                 window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function (fileSystem) {
+                    fb('got local file system');
+                    fb('try to resolve url');
                     window.resolveLocalFileSystemURL(url, function (entry) {
+                        fb('resolved from file');
                         window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function (dirEntry) {
+                            fb('resolved to dir');
                             entry.copyTo(dirEntry, 'document.pdf', function (copyEntry) {
+                                fb('copied file');
                                 window.plugins.webintent.startActivity({
                                     action: window.plugins.webintent.ACTION_VIEW,
                                     type: types_android[type],
@@ -1324,6 +1330,13 @@ Fluidbook.prototype = {
         }
         return false;
     },
+
+    relativeToAbsolute: function (relative) {
+        var a = document.createElement('a');
+        a.href = relative;
+        return a.cloneNode(false).href;
+    },
+
     highlightSearchTerms: function (pageNr) {
         return;
     },
index aee6b8f83b40809cfd3aa5fe697a52d2be64f407..84a067e139458f3e01764400be576533ee0bb07a 100644 (file)
@@ -76,7 +76,6 @@ try {
             cordovaPath = window.localStorage.getItem('cordova');
         }
 
-
         document.addEventListener("resume", onAppResume, false);
 
         loadJSLibrary(