]> _ Git - fluidbook-html5.git/commitdiff
(no commit message)
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Sep 2013 08:10:28 +0000 (08:10 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Sep 2013 08:10:28 +0000 (08:10 +0000)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.loader.js
js/libs/fluidbook/fluidbook.resize.js
js/libs/fluidbook/fluidbook.tooltip.js
js/libs/gal/gal.js
js/main.js

index c8e3aa0cfd96770baa846146d8189e2cd5d804ff..dfc5ff0a37c0c5c05bd8aa8815ac53094b2e02df 100644 (file)
@@ -727,10 +727,8 @@ Fluidbook.prototype = {
        _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
@@ -1141,8 +1139,6 @@ Fluidbook.prototype = {
                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
@@ -1198,8 +1194,16 @@ Fluidbook.prototype = {
                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
index 6b9124b0575352d95467dfa23bf081b42c5b630d..869a87d92114d5c778982153ef1a9b3ce6523a3c 100644 (file)
@@ -198,9 +198,19 @@ FluidbookLoader.prototype = {
                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();
@@ -264,10 +274,6 @@ FluidbookLoader.prototype = {
                $(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
index b534f7c3ec0255835fd4e988ed8daa506f2a898c..77deb90da652476de8dabb55c1a2e996e4e8687b 100644 (file)
@@ -4,7 +4,7 @@ function FluidbookResize(fluidbook) {
        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
@@ -56,7 +56,10 @@ FluidbookResize.prototype = {
                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
index 42dbce84477df6769745240a94186b6092c5ae32..c0fe1b5563d9deebbb23faf8e8827d85f443a630 100644 (file)
@@ -6,24 +6,27 @@ function FluidbookTooltip(fluidbook) {
 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 == '') {
index 9569006b277fba1f8b7912a0a8bc81cb252849fe..e073ea2e9ace3aab0bf4138473bf4bbe82079a4c 100644 (file)
         * 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) {
@@ -91,6 +99,7 @@
                                                                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) {
index 529cd397f598d76cc9e4050aa9443865873e5051..cc56f7976d4364ca64c018276b4461eb6deb2880 100644 (file)
@@ -82,6 +82,8 @@ function onDeviceReady() {
        }
 
        if (navigator.onLine && manifest) {
+               var readyToLoad = false;
+               var finishedLoading = false;
                gal = new GameAssetLoader(JSON.parse(manifest), fsprefix);
 
                gal.init(function() {
@@ -92,16 +94,26 @@ function onDeviceReady() {
                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 {