name = v.countryName + ' (' + v.langName + ')';\r
}\r
\r
-\r
- view += '<li data-level="0"><a href="' + url + '" class="level0"><img src="images/flags/' + v.flag + '.png" alt="' + name + '" />' + name + '</a></li>';\r
+ var c = '';\r
+ if ($this.datas.phonegap) {\r
+ view += '<li data-level="0"><a href="#" data-id="' + url + '" data-locale="' + v.lang + '" class="level0 appswitchlocale"><img src="images/flags/' + v.flag + '.png" alt="' + name + '" />' + name + '</a></li>';\r
+ } else {\r
+ view += '<li data-level="0"><a href="' + url + '" class="level0"><img src="images/flags/' + v.flag + '.png" alt="' + name + '" />' + name + '</a></li>';\r
+ }\r
});\r
view += '</ul>';\r
view += '</div>';\r
var pubid = publications[0];
try {
- url = window.location.toString();
- url.replace(/\/this.fluidbook.datas.id\//, "/" + pubid + "/");
-
- if (this.fluidbook.datas.id == pubid) {
- url = '';
- }
+ url = pubid;
} catch (err) {
url = '';
}
// Array of bundle names in the order that they appear in the manifest.
this.bundleOrder = [];
// Table of callbacks, per bundle.
+ this.loadingBundles = {};
+ this.loadedBundles = {};
+
this.loaded = {};
this.progress = {};
this.error = {};
this.check(bundleName, function(result) {
if (result.success) {
// Already downloaded. Success!
+ that.loadedBundles[bundleName] = true;
+ that.loadingBundles[bundleName] = false;
fireCallback_(that.loaded, bundleName, {
success: true,
cached: true,
bundleName: bundleName
});
- callback();
+ callback();
} else {
if (!that.online()) {
// Otherwise, since we're offline, error out.
callback();
} else {
// Setup a loop via callback chaining.
+ that.loadedBundles[bundleName] = false;
+ that.loadingBundles[bundleName] = true;
(function loop(index) {
// If we've finished loading all of the assets in the bundle.
if (index == bundle.length) {
+ that.loadedBundles[bundleName] = true;
+ that.loadingBundles[bundleName] = false;
fireCallback_(that.loaded, bundleName, {
bundleName: bundleName,
success: true
GAL.prototype.downloadAndCall = function(bundleName, callback, timeoutIfNotLoaded) {
var $this = this;
- this.check(bundleName, function(info) {
- if (info.success) {
+
+ if ($this.loadedBundles[bundleName]) {
+ callback();
+ } else if ($this.loadingBundles[bundleName]) {
+ $this.onLoaded(bundleName, function() {
callback();
- } else {
- $this.download(bundleName, callback, timeoutIfNotLoaded);
- }
- });
+ });
+ } else {
+ this.check(bundleName, function(info) {
+ if (info.success) {
+ callback();
+ } else {
+ $this.download(bundleName, callback, timeoutIfNotLoaded);
+ }
+ });
+ }
};
/**
// Set this.bundles object and this.bundleOrder array
for (var i = 0, bundle; bundle = manifest.bundles[i]; ++i) {
this.bundles[bundle.name] = bundle.contents;
+ this.loadedBundles[bundle.name] = false;
+ this.loadingBundles[bundle.name] = false;
this.bundleOrder.push(bundle.name);
}
}
var longpresstime = undefined;
var startAfterLoading = false;
var gal = null;
+var home = window.location.toString();
$(function() {
FastClick.attach(document.body);
return false;
});
+ $(document).on('click', 'a.appswitchlocale', function() {
+ try {
+ fluidbook.displayLoader();
+ if ($(".mview").length > 0) {
+ $("#main").hide();
+ $("#view").addClass('fadeout');
+ } else {
+ $("#main").addClass('fadeout');
+ }
+ var $this = this;
+ var locale = $(this).data('locale');
+ var id = $(this).data('id');
+ window.localStorage.setItem('locale', locale);
+
+ var topmanifest = window.sessionStorage.getItem('topmanifest');
+ window.gallocale = new GameAssetLoader(JSON.parse(topmanifest), window.sessionStorage.getItem('galfsprefix'));
+ window.gallocale.init(function() {
+ window.gallocale.downloadAndCall('p_' + id, function() {
+ var url = window.home;
+ var replace = "/" + fluidbook.datas.id + "/";
+ var replaceby = "/" + id + "/";
+ url = url.replace(replace, replaceby);
+ var c = window.localStorage.getItem('collection');
+ window.location = url;
+ });
+ });
+ } catch (err) {
+ console.error(err.message);
+ }
+ return false;
+
+ });
+
$("#logo").click(clickLogo);
$(document).on('click', ".mview .back", function() {
display:none;\r
overflow:hidden;\r
visibility: hidden;\r
+ opacity:1;\r
+}\r
+\r
+#main.fadeout,#view.fadeout{\r
+ transition: opacity 500ms ease-out;\r
+ -moz-transition: opacity 500ms ease-out;\r
+ -webkit-transition: opacity 500ms ease-out;\r
+ -ms-transition: opacity 500ms ease-out;\r
+ -o-transition: opacity 500ms ease-out;\r
+\r
+ opacity:0;\r
}\r
\r
#hiddencontents{\r