From 7327087188a1d2ebdcb2873b09bcfb19381ac93b Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 20 Dec 2018 20:25:34 +0100 Subject: [PATCH] wip #2303 @3 --- js/libs/fluidbook/fluidbook.js | 8 +++----- js/libs/fluidbook/fluidbook.links.js | 14 ++++++++++---- js/libs/fluidbook/fluidbook.nav.js | 17 +++++++++++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index ef219dd1..24e99922 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -626,11 +626,9 @@ Fluidbook.prototype = { var pdf; var pdfName; - console.log('open PDF : ' + this.datas.pages + " || " + this.contentlock.getMaxPage()); - if (this.datas.pages != this.contentlock.getMaxPage()) { pdf = 'https://workshop.fluidbook.com/s/e/' + this.datas.cid + '/1-' + this.contentlock.getMaxPage(); - } else if (this.datas.pdfName.substr(0, 4) == 'http') { + } else if (this.datas.pdfName.substr(0, 4) === 'http') { pdf = this.datas.pdfName; } else { pdf = this.relativeToAbsolute('data/' + this.datas.pdfName); @@ -654,7 +652,7 @@ Fluidbook.prototype = { type = e.pop(); } - if (url.indexOf('http') == 0) { + if (url.indexOf('http') === 0) { return this._downloadFilePhonegap(url, localname, window.TEMPORARY, this._openFilePhonegap, [url, e, type]); } else { if (this._openFilePhonegap(url, e, type)) { @@ -717,7 +715,7 @@ Fluidbook.prototype = { if (this.datas.phonegap === 'ios') { console.log('open download on ios ' + type + ' -> ' + types_ios[type]); this.displayLoader(); - if (types_ios[type] != undefined) { + if (types_ios[type] !== undefined) { console.log('intro to open with External file util'); try { diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index 6f0ccec0..0d5fee71 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -80,8 +80,8 @@ FluidbookLinks.prototype = { target = '_self'; } var href = $(this).attr('href'); - var external = href.substr(0, 4) == 'http'; - if (href == '#') { + var external = href.substr(0, 4) === 'http'; + if (href === '#') { return true; } @@ -93,11 +93,17 @@ FluidbookLinks.prototype = { return false; } - if ($(this).data('type') == 16 && external) { + if ($(this).data('type') === 16 && external) { target = '_system'; } - if (target == '_self') { + if ($this.fluidbook.datas.phonegap === 'android' && $(this).data('type') === 16 && !external) { + var url = $(this).attr('href') + $this.fluidbook._openFile($this.fluidbook.relativeToAbsolute(url), $("body"), 'pdf'); + return; + } + + if (target === '_self') { return true; } fluidbook.wopen($(this).attr('href'), target); diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index ac711071..ebbcdccc 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -414,7 +414,7 @@ FluidbookNav.prototype = { } else if (icon == 'pdf' && this.fluidbook.datas.pdf) { link = this.addLink(navType, 'nav-download', '#', 'download', 'download', 'download'); } else if (icon == 'print' && this.fluidbook.datas.print) { - link = this.addLink(navType, 'nav-print', '#/print', 'print', 'print', 'print'); + link = this.addLink(navType, 'nav-print', '#', 'print', 'print', 'print'); } else if (icon == 'basket' && this.fluidbook.cart != undefined && this.fluidbook.cart.enabled) { link = this.addLink(navType, 'nav-basket', '#/cart', 'cart', 'basket', 'basket'); $(this.fluidbook).on('fluidbook.cart.updateIcon', {link: $(link).attr('id')}, function (e, data) { @@ -698,7 +698,7 @@ FluidbookNav.prototype = { event.preventDefault(); // Should we show complex PDF download options? Or just give them the full PDF? - if ($this.fluidbook.datas.pdfComplex) { + if ($this.fluidbook.datas.pdfComplex && this.datas.phonegap === false) { $this.fluidbook.menu.openView('download'); } else { $this.fluidbook.downloadPDF($(this)); @@ -708,10 +708,15 @@ FluidbookNav.prototype = { }); // Print icon - // $(document).on('click', '.icon-print', function () { - // $this.fluidbook.print($(this)); - // return false; - // }); + $(document).on('click', '.icon-print', function () { + if ($this.fluidbook.datas.phonegap !== false) { + $this.fluidbook.print($(this)); + return false; + } else { + $this.fluidbook.menu.openView('print'); + } + return false; + }); // Bookmarks icon $(document).on('click', '.icon-bookmarks', function () { -- 2.39.5