_openView: function(view, param1, param2, callback) {\r
var $this = this;\r
if (this.gal != null && ['index', 'search', 'bookmark'].indexOf(view) >= 0) {\r
- this.gal.check('thumbnails', function(info) {\r
- if (info.success === true) {\r
- $this.__openView(view, param1, param2, callback);\r
- }\r
+ this.gal.downloadAndCall('thumbnails', function() {\r
+ $this.__openView(view, param1, param2, callback);\r
});\r
} else {\r
this.__openView(view, param1, param2, callback);\r
if (this.l10n.dir == 'rtl') {\r
left = -1 * ($(window).width() - left - $("#q").outerWidth());\r
}\r
-\r
-\r
$("#searchHints").css({top: top, left: left}).show();\r
},\r
killLastSearchHint: function() {\r
this.stats.track(12);\r
},\r
print: function() {\r
+ var $this = this;\r
var pdf = getBaseURL() + '/data/' + this.datas.pdfName;\r
- this._openFile(pdf, $("#print"), 'pdf', this.datas.pdfName);\r
+ if (this.gal) {\r
+ this.displayLoader();\r
+ this.gal.downloadAndCall('extras', function() {\r
+ $this._openFile(pdf, $("#print"), 'pdf', $this.datas.pdfName);\r
+ });\r
+ } else {\r
+ this._openFile(pdf, $("#print"), 'pdf', this.datas.pdfName);\r
+ }\r
},\r
_openFile: function(url, e, type, localname) {\r
\r
if (this.backgrounds[page] != undefined) {
callback();
} else {
- this.backgrounds[page] = this.loadImage(this.getBackgroundURL(page), null, null, null, callback);
+ var $this = this;
+ if (window.gal != undefined) {
+ window.gal.downloadAndCall('content_' + page, function() {
+ $this.__loadBackground(page, callback);
+ });
+ } else {
+ this.__loadBackground(page, callback);
+ }
}
},
+ __loadBackground: function(page, callback) {
+ this.backgrounds[page] = this.loadImage(this.getBackgroundURL(page), null, null, null, callback);
+ },
loadTexts: function(pageNr, callback) {
if (this.fluidbook.imagesVersion) {
callback();
$(this.imagesErrors).each(function() {
$(this).attr('src', $(this).attr('src'));
});
- $("#interface img,#nav img").each(function() {
- $(this).attr('src', '');
- $(this).attr('src', $(this).attr('src'));
- });
this.imagesErrors = [];
}
};
\ No newline at end of file
this.marginh = 20;\r
this.corr = 0.8;\r
this.referenceWidthLandscape = 1024;\r
- this.referenceWidthPortrait = 600;\r
+ this.referenceWidthPortrait =400;\r
this.referenceHeight = 600;\r
this.orientation = '';\r
this.textScale = 2;\r
if (this.orientation == 'landscape') {\r
interfaceScale = Math.min(1, this.ww / this.referenceWidthLandscape, this.hh / this.referenceHeight);\r
} else if (this.orientation == 'portrait') {\r
- interfaceScale = Math.min(1, this.ww / this.referenceWidthPortrait, this.hh / this.referenceHeight);\r
+ var nminwidth = ($("#nav a").length * 51) + 205+50;\r
+ var refWidth = Math.max(this.referenceWidthPortrait, nminwidth);\r
+\r
+ interfaceScale = Math.min(1, this.ww / refWidth, this.hh / this.referenceHeight);\r
}\r
var navScale = interfaceScale * parseInt(this.fluidbook.datas.mobileNavScale) / 100;\r
var cssInterfaceScale = [interfaceScale, interfaceScale];\r
FluidbookTooltip.prototype = {
init: function() {
var $this = this;
- $(document).on('mouseover', 'a[data-tooltip]', function() {
- var position = $(this).offset();
- position.top += $(this).outerHeight() + 20;
+ if (!Modernizr.ftouch) {
- var text = $(this).data('tooltip');
- if (text.substr(0, 1) == '~') {
- var text = $this.fluidbook.l10n.__(text.substring(1));
- $(this).data('tooltip', text);
- }
- var ok = $this.displayTooltip(text, position);
- if (ok) {
- $(this).one('mouseout', function() {
- $this.hideTooltip();
- });
- }
- return false;
- });
- $("body").append('<div id="tooltip"></div>');
+ $(document).on('mouseover', 'a[data-tooltip]', function() {
+ var position = $(this).offset();
+ position.top += $(this).outerHeight() + 20;
+
+ var text = $(this).data('tooltip');
+ if (text.substr(0, 1) == '~') {
+ var text = $this.fluidbook.l10n.__(text.substring(1));
+ $(this).data('tooltip', text);
+ }
+ var ok = $this.displayTooltip(text, position);
+ if (ok) {
+ $(this).one('mouseout', function() {
+ $this.hideTooltip();
+ });
+ }
+ return false;
+ });
+ $("body").append('<div id="tooltip"></div>');
+ }
},
displayTooltip: function(tooltip, position) {
if (tooltip == undefined || tooltip == '') {
* Downloads assets contained in the named bundle.
* @param {string} bundleName name of single bundle to download.
*/
- GAL.prototype.download = function(bundleName) {
+ GAL.prototype.download = function(bundleName, callback) {
var bundle = this.bundles[bundleName];
+ if (callback == undefined) {
+ callback = function() {
+ };
+ }
+
if (!bundle) {
// Attempting to download invalid bundle.
cached: true,
bundleName: bundleName
});
+ callback();
+
} else {
if (!that.online()) {
// Otherwise, since we're offline, error out.
fireCallback_(that.error, bundleName, {
error: 'Missing resources cant be downloaded while offline'
});
+ callback();
} else {
// Setup a loop via callback chaining.
(function loop(index) {
bundleName: bundleName,
success: true
});
+ callback();
return;
}
addCallback_(this.error, opt_bundleName, callback);
};
+ GAL.prototype.downloadAndCall = function(bundleName, callback) {
+ var $this = this;
+ this.check(bundleName, function(info) {
+ if (info.success) {
+ callback();
+ } else {
+ $this.download(bundleName, callback);
+ }
+ });
+ };
+
/**
* Checks if a bundle is already downloaded.
* @param {string} bundleName Name of bundle to check.
);
};
- GAL.prototype.initAdapter_=function(callback) {
+ GAL.prototype.initAdapter_ = function(callback) {
var $this = this;
if (this.adapter != null) {
}
if (navigator.onLine && manifest) {
+ var readyToLoad = false;
+ var finishedLoading = false;
gal = new GameAssetLoader(JSON.parse(manifest), fsprefix);
gal.init(function() {
gal.onLoaded(function(info) {
$(window).trigger('GALBundleLoaded', [info]);
});
-
- gal.check('content_4',function(){
- fluidbook.changeAddress();
+
+ gal.check('content_4', function(info) {
+ if (info.success) {
+ fluidbook.changeAddress();
+ }
});
-
- gal.check('extras',function(){
- window.localStorage.setItem('offline.' + DATAS.id, '1');
+
+ gal.check('extras', function(info) {
+ if (info.success) {
+ window.localStorage.setItem('offline.' + DATAS.id, '1');
+ }
})
$(window).on('GALBundleLoaded', function(e, info) {
+ if (info.bundleName == 'content_4') {
+ fluidbook.changeAddress();
+ }
+ if (info.bundleName == 'extras') {
+ window.localStorage.setItem('offline.' + DATAS.id, '1');
+ }
fluidbook.loader.retryErrorImages();
});
} else {