<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Security-Policy"
- content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.google-analytics.com *.youtube.com *.ytimg.com; img-src * data:">
+ content="default-src 'self' data: gap: 'unsafe-inline' *; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.google-analytics.com *.youtube.com *.ytimg.com; img-src * data:">
<!--<meta name="apple-mobile-web-app-capable" content="yes">-->
<meta name="viewport" content="initial-scale=1,minimum-scale=1,user-scalable=no">
<meta name="google" content="notranslate">
return;
}
-// window.onerror = function(errorMsg, url, lineNumber) {
-// console.log(errorMsg + ' in ' + url + ' at line ' + lineNumber, 'error');
-// };
-
function is(type, obj) {
var clas = Object.prototype.toString.call(obj).slice(8, -1);
return obj !== undefined && obj !== null && clas === type;
});
$(document).on('click', '.bookmarkssub a.print', function () {
+ $(this).data('ios-preview', '1');
$this.fluidbook._openFile($this.getPDF(), $(this), 'pdf', $this.getBookmarksCompacted() + '.pdf');
return false;
});
var doublePage = $("#nextDoublePage");
var currentDoublePage = $("#currentDoublePage");
this.displayLoader();
- this.loader.preloadPagesBeforeTransition([turning.currentLeft, turning.currentRight], function () {
+ this.loader.preloadPagesBeforeTransition(turning.end, function () {
$("#pages").addClass('_3dtransition');
$this.loader.setContentsInDoublePage(currentDoublePage, turning.flat, true, function () {
$this.loader.setContentsInDoublePage(doublePage, turning.flip, true, function () {
$('#menuList > ul > li, #shareLinks').fadeIn(300);
},
- print: function () {
+ print: function (button) {
var $this = this;
var pdf;
var pdfName;
$this._openFile(pdf, $("#print"), 'pdf', pdfName);
});
} else {*/
- this._openFile(pdf, $("#print"), 'pdf', pdfName);
+ this._openFile(pdf, button, 'pdf', pdfName);
//}
},
_openFile: function (url, e, type, localname) {
}
if (url.indexOf('http') == 0) {
- return this._downloadFilePhonegap(url, localname, LocalFileSystem.TEMPORARY, this._openFilePhonegap, [url, e, type]);
+ return this._downloadFilePhonegap(url, localname, window.TEMPORARY, this._openFilePhonegap, [url, e, type]);
} else {
if (this._openFilePhonegap(url, e, type)) {
return;
this.wopen(url, '_blank');
},
_downloadFilePhonegap: function (url, localname, fs, callback, callbackArgs) {
+ console.log('download file phonegap');
var $this = this;
if (fs == undefined) {
fs = LocalFileSystem.PERSISTENT;
window.webkitRequestFileSystem;
requestFileSystem(fs, 0, function (fileSystem) {
+ console.log('fs requested');
fileSystem.root.getFile("dummy.html", {create: true, exclusive: false}, function (fileEntry) {
+ console.log('dummy file created')
var filePath = fileEntry.toURL().replace("dummy.html", "") + localname;
var fileTransfer = new FileTransfer();
var uri = encodeURI(url);
uri,
filePath,
function (entry) {
+ console.log('file donwloaded');
if (callback != undefined) {
if (callbackArgs == undefined) {
callbackArgs = [];
}
},
function (error) {
-
+ console.log('file error');
}
);
});
var types_ios = {pdf: 'com.adobe.pdf'};
var types_android = {pdf: 'application/pdf'};
if (this.datas.phonegap == 'ios') {
+ console.log('open download on ios ' + type + ' -> ' + types_ios[type]);
this.displayLoader();
if (types_ios[type] != undefined) {
- var offset = $(e).offset();
- offset.left += ($(e).width() / 2);
- offset.top += ($(e).height());
+ console.log('intro to open with External file util');
+
+ try {
+ var offset = $(e).offset();
+
+ offset.left += ($(e).width() / 2);
+ offset.top += ($(e).height() / 2);
+
+ offset.left *= window.devicePixelRatio;
+ offset.top *= window.devicePixelRatio;
+
+ if ($(e).data('ios-preview') == '1') {
+ offset.top = offset.left = 0;
+ }
+ } catch (err) {
+ console.log('error while getting offset');
+ }
+
try {
+ console.log('attempt to open with External file util');
ExternalFileUtil.openWith(url, types_ios[type], function () {
+ console.log('ok to open with External file util : ' + url);
+
$this.hideLoader();
}, function () {
+ console.log('failed to open with External file util');
$this.wopen(url, "_blank", 'location=no');
$this.hideLoader();
}, offset);
} catch (err) {
+ console.error('unable to open with externalfileutil');
$this.wopen(url, "_blank", 'location=no');
$this.hideLoader();
}
div = $('<div />');
}
+
left = ((page % 2 == 0) && this.fluidbook.l10n.ltr) || ((page % 2 == 1) && this.fluidbook.l10n.rtl);
var h = this.fluidbook.datas.thumbHeight;
loadImage: function (src, width, height, type, callback) {
var img = new Image();
var $this = this;
- var callbackCalled=false;
+ var callbackCalled = false;
if (callback && typeof callback == 'function') {
$(img).one('load', function () {
setTimeout(function () {
- if(!callbackCalled) {
+ if (!callbackCalled) {
callbackCalled = true;
callback();
}
}
if (callback && typeof callback == 'function' && (img.complete || img.readyState == 'complete' || img.readyState == 4)) {
setTimeout(function () {
- if(!callbackCalled) {
+ if (!callbackCalled) {
callbackCalled = true;
callback();
}
// Allow #anchor links to trigger correctly and close the menu
// Ref: https://github.com/FrDH/jQuery.mmenu/issues/687#issuecomment-279377172
onClick: {
- preventDefault: function () {
- $this.menuAPI.close();
- }
+ close: function () {
+ if (fluidbook.datas.phonegap == 'ios') {
+ return !$(this).is('#menu_download,#menu_print');
+ }
+ return true;
+ },
+ preventDefault:function(){
+ return false;
+ },
},
"extensions": [
// Sharing icons - this may contain many different icons
} else if (icon == 'friend') {
if (this.fluidbook.share.isEnabled()) {
-
if (navType == 'horizontalNav') {
-
if (this.fluidbook.datas.share) {
link = this.addLink(navType, 'nav-share', '#/share', 'share', 'share', 'share');
}
-
} else if (navType == 'menu') {
-
// Save HTML so it can be added to menu once MMenu is initialised
this.shareLinksHTML = '<div id="shareLinks"><div class="share-icons">' + this.fluidbook.share.getShareLinks(true) + '</div></div>';
-
}
}
} else if (icon == 'bookmark' && this.fluidbook.datas.bookmark) {
link = this.addLink(navType, 'nav-bookmarks', '#/bookmark', 'bookmarks', 'bookmarks', 'bookmarks');
-
} 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');
-
} else if (icon == 'lang' && this.fluidbook.l10n.multilangEnabled) {
// Note: the "!" at the beginning of the title/help parameters means that we don't want these strings translated
link = this.addLink(navType, 'nav-locales', '#/locales', 'locales', '!' + this.fluidbook.l10n.getCurrentLanguageName(), '!Select Language');
-
} else if (icon == 'archives') {
if (this.fluidbook.datas.archivesLink != '') {
link = this.addLink(navType, 'nav-archives', this.fluidbook.datas.archivesLink, 'archives', '!' + this.fluidbook.datas.archivesLabel, '!' + this.fluidbook.datas.archivesLabel);
// Download icon
$(document).on('click', '.icon-download', function () {
- $this.fluidbook.print();
+ $this.fluidbook.print($(this));
return false;
});
// Print icon
$(document).on('click', '.icon-print', function () {
- $this.fluidbook.print();
+ $this.fluidbook.print($(this));
return false;
});
break;
}
+
this.transitions2d = Modernizr.csstransforms && Modernizr.csstransitions;
this.transitions3d = Modernizr.csstransforms3d && Modernizr.preserve3d && this.transitions2d;
if (Modernizr.mq('(min-device-width : 320px) and (max-device-width : 480px)')) {
this.resolution = 150;
} else {
- this.resolution = Modernizr.mq('(-webkit-min-device-pixel-ratio: 2)') ? 300 : 150;
+ this.resolution = Modernizr.mq('(-webkit-min-device-pixel-ratio: 2)') ? this.fluidbook.datas.retinaResolution : 150;
}
} else {
this.resolution = window.resolution;
document.addEventListener("resume", onAppResume, false);
- loadJSLibrary(
- cordovaPath
- , cordovaLoaded);
+ loadJSLibrary(cordovaPath, cordovaLoaded);
if (window.cordova) {
console.log('cordova already loaded');
cordovaLoaded();
if (PLATFORM == 'ios') {
try {
window.ExternalFileUtil = cordova.require('com.techblue.cordova.plugin.externalfileutilios.ExternalFileUtilIos');
- }catch (err){
+ } catch (err) {
console.error('Error while loading ExternalFileUtil plugin');
}
} else if (PLATFORM == 'android') {
}
}
- function loadJSLibrary(url, callback) {
+ function loadJSLibrary(url, callback, error) {
if (jsLibraries.indexOf(url) > -1) {
if (callback != undefined) {
callback();
callback();
}
};
+ script.onerror = function () {
+ console.error('Error loading ' + url);
+ if (error != undefined) {
+ error();
+ }
+ }
}
script.src = url;
}
function init() {
+ console.log('init !');
if (INITED == true) {
return;
}
}
function initEvents() {
+ console.log('init events');
resize(true);
if (DATAS.preventRightClick) {
});
$(document).trigger('fluidbookready');
+ $(this).trigger('fluidbook.ready');
setTimeout(function () {
resize();
if (!startAfterLoading) {
fluidbook.changeAddress();
}
+
+ console.log('fluidbook.ready');
}
} catch (err) {
console.log(err);