]> _ Git - fluidbook-html5.git/commitdiff
(no commit message)
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 8 Oct 2013 15:50:53 +0000 (15:50 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 8 Oct 2013 15:50:53 +0000 (15:50 +0000)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.l10n.js
js/libs/gal/gal.js
js/main.js
style/fluidbook.css

index 42ef1a0aa881237efedccddc72d00af6914258da..b49c4cd2d58193250a494123015fc745fb6d92de 100644 (file)
@@ -979,8 +979,12 @@ Fluidbook.prototype = {
                                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
index ed83475af46442908888e3a0e12c6bc8e7074d6e..8516e224692527a6258699de116736e7ca9c05e0 100644 (file)
@@ -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 = '';
                                }
index 58df043074d164b7d48f83b2390d8f763295526d..4eed7ed64b8ba894c1cfe6e1b230cb5fc75847d9 100644 (file)
@@ -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 = {};
                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);
                }
        }
index e55417562ccabe90ef3b027aa963ceea5b7ef12e..85b3bc9d65f42c2c30da177bac0283486dd07eeb 100644 (file)
@@ -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() {
index b694a8bb7957158295a4c74668d4efe8565f8735..5e8e69f226ac7e519c605c095ede2472225da1ea 100644 (file)
@@ -86,6 +86,17 @@ body{
        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