From 9bf11933469bf253ccad43f5c656c2c740965964 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 3 Feb 2017 19:17:58 +0100 Subject: [PATCH] wip #1023 @6 --- js/libs/fluidbook/fluidbook.js | 27 ++++++++++++++++++++------- js/main.js | 1 - 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 7c9a5098..e169f7d5 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -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; }, diff --git a/js/main.js b/js/main.js index aee6b8f8..84a067e1 100644 --- a/js/main.js +++ b/js/main.js @@ -76,7 +76,6 @@ try { cordovaPath = window.localStorage.getItem('cordova'); } - document.addEventListener("resume", onAppResume, false); loadJSLibrary( -- 2.39.5