From 16716d19502989836db9de6f3fdd73be1cbe077d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 8 Oct 2013 15:50:53 +0000 Subject: [PATCH] --- js/libs/fluidbook/fluidbook.js | 8 +++++-- js/libs/fluidbook/fluidbook.l10n.js | 7 +----- js/libs/gal/gal.js | 34 +++++++++++++++++++++++------ js/main.js | 34 +++++++++++++++++++++++++++++ style/fluidbook.css | 11 ++++++++++ 5 files changed, 79 insertions(+), 15 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 42ef1a0a..b49c4cd2 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -979,8 +979,12 @@ Fluidbook.prototype = { name = v.countryName + ' (' + v.langName + ')'; } - - view += '
  • ' + name + '' + name + '
  • '; + var c = ''; + if ($this.datas.phonegap) { + view += '
  • ' + name + '' + name + '
  • '; + } else { + view += '
  • ' + name + '' + name + '
  • '; + } }); view += ''; view += ''; diff --git a/js/libs/fluidbook/fluidbook.l10n.js b/js/libs/fluidbook/fluidbook.l10n.js index ed83475a..8516e224 100644 --- a/js/libs/fluidbook/fluidbook.l10n.js +++ b/js/libs/fluidbook/fluidbook.l10n.js @@ -75,12 +75,7 @@ FluidbookL10N.prototype = { 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 = ''; } diff --git a/js/libs/gal/gal.js b/js/libs/gal/gal.js index 58df0430..4eed7ed6 100644 --- a/js/libs/gal/gal.js +++ b/js/libs/gal/gal.js @@ -37,6 +37,9 @@ // 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 = {}; @@ -80,13 +83,15 @@ 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. @@ -96,9 +101,13 @@ 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 @@ -163,13 +172,22 @@ 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); + } + }); + } }; /** @@ -281,6 +299,8 @@ // 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); } } diff --git a/js/main.js b/js/main.js index e5541756..85b3bc9d 100644 --- a/js/main.js +++ b/js/main.js @@ -8,6 +8,7 @@ var jsLibraries = []; var longpresstime = undefined; var startAfterLoading = false; var gal = null; +var home = window.location.toString(); $(function() { FastClick.attach(document.body); @@ -200,6 +201,39 @@ function initEvents() { 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() { diff --git a/style/fluidbook.css b/style/fluidbook.css index b694a8bb..5e8e69f2 100644 --- a/style/fluidbook.css +++ b/style/fluidbook.css @@ -86,6 +86,17 @@ body{ display:none; overflow:hidden; visibility: hidden; + opacity:1; +} + +#main.fadeout,#view.fadeout{ + transition: opacity 500ms ease-out; + -moz-transition: opacity 500ms ease-out; + -webkit-transition: opacity 500ms ease-out; + -ms-transition: opacity 500ms ease-out; + -o-transition: opacity 500ms ease-out; + + opacity:0; } #hiddencontents{ -- 2.39.5