]> _ Git - fluidbook-html5.git/commitdiff
(no commit message)
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Apr 2014 15:42:18 +0000 (15:42 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Apr 2014 15:42:18 +0000 (15:42 +0000)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.resize.js

index 7f43000a3b46044ff779432cde530addb449bd89..aeba36b2376ae5684a70325a5ebc386add35c562 100644 (file)
@@ -753,6 +753,8 @@ Fluidbook.prototype = {
                        }
                } else if (view == 'video') {
                        this.openVideo(param1, cb);
+               } else if (view == 'audio') {
+                       this.openAudio(param1, cb);
                } else if (view == 'webvideo') {
                        this.openWebVideo(param1, param2, cb);
                } else if (view == 'multimedia') {
@@ -906,6 +908,26 @@ Fluidbook.prototype = {
                        callback();
                }
        },
+       openAudio: function(audio, callback) {
+               var a = $('a[href="#/audio/' + audio + '"]');
+               var markup = decodeURIComponent($(a).attr('data-audio'));
+               var view = '<div class="caption"><a href="#" class="back">' + this.l10n.__('back') + '</a></div>';
+               view += '<div class="content">';
+               view += markup;
+               view += '</div>';
+               $("#view").append('<div class="mview">' + view + '</div>');
+               this.stats.track(11);
+               var $this = this;
+               var times = [250, 500, 750, 1000, 1250];
+               $.each(times, function(k, v) {
+                       setTimeout(function() {
+                               $this.resize.resizePopupAudios();
+                       }, v);
+               });
+               if (callback != undefined) {
+                       callback();
+               }
+       },
        openWebVideo: function(service, video, callback) {
 
                var view = '<div class="caption"><a href="#" class="back">' + this.l10n.__('back') + '</a></div>';
index 77deb90da652476de8dabb55c1a2e996e4e8687b..e8a8358c53a349fce1c0d772044dafe43f1af618 100644 (file)
-function FluidbookResize(fluidbook) {\r
-       this.fluidbook = fluidbook;\r
-       this.marginw = 50;\r
-       this.marginh = 20;\r
-       this.corr = 0.8;\r
-       this.referenceWidthLandscape = 1024;\r
-       this.referenceWidthPortrait =400;\r
-       this.referenceHeight = 600;\r
-       this.orientation = '';\r
-       this.textScale = 2;\r
-       this.bookScale = 1;\r
-       this.ww = $(window).width();\r
-       this.hh = $(window).height();\r
-       this.init();\r
-       this.navresizeTimeout = 0;\r
-}\r
-\r
-FluidbookResize.prototype = {\r
-       init: function() {\r
-\r
-               var left = this.fluidbook.l10n.dir == 'ltr' ? '0%' : '100%';\r
-               var right = this.fluidbook.l10n.dir == 'ltr' ? '100%' : '0%';\r
-\r
-               $("#nav,#searchHints").transform({\r
-                       origin: [left, '0%']\r
-               });\r
-\r
-               $("#logo").transform({\r
-                       origin: [right, '0%']\r
-               });\r
-\r
-               $("#footer").transform({\r
-                       origin: [right, '100%']\r
-               });\r
-\r
-               $("#next").transform({\r
-                       origin: [right, '50%']\r
-               });\r
-\r
-               $("#previous").transform({\r
-                       origin: [left, '50%']\r
-               });\r
-       },\r
-       resize: function(init) {\r
-               if (init == undefined || init == null) {\r
-                       init = false;\r
-               }\r
-\r
-               $("#main").hide();\r
-\r
-               var $this = this;\r
-               this.updateWindow();\r
-               this.handleOrientation();\r
-\r
-               var interfaceScale;\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
-                       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
-               var cssNavScale = [navScale, navScale];\r
-\r
-               $("#main").css({\r
-                       width: this.ww,\r
-                       height: this.hh\r
-               });\r
-\r
-               this.resizeView();\r
-\r
-               var marginY, marginX, marginTop, marginBottom, marginLeft, marginRight;\r
-\r
-               if (this.fluidbook.pad.enabled) {\r
-                       marginY = 0;\r
-                       marginX = 0;\r
-                       extraX = 0;\r
-                       marginTop = 0;\r
-                       marginBottom = 0;\r
-                       marginLeft = 0;\r
-                       marginRight = 0;\r
-               } else {\r
-                       marginX = 50;\r
-                       marginY = 20;\r
-\r
-                       var extraX = parseInt(this.fluidbook.datas.mobileExtraXSpace);\r
-                       if (isNaN(extraX)) {\r
-                               extraX = 0;\r
-                       }\r
-\r
-                       marginTop = (this.fluidbook.datas.menuHeight + marginY) * interfaceScale;\r
-                       marginBottom = (10 + marginY) * interfaceScale;\r
-                       marginLeft = (marginX + extraX) * interfaceScale;\r
-                       marginRight = marginLeft;\r
-               }\r
-\r
-               var aw = this.ww - marginLeft - marginRight;\r
-               var ah = this.hh - marginTop - marginBottom;\r
-               var fhh = this.fluidbook.datas.height;\r
-               var fww = this.fluidbook.datas.width;\r
-               if (this.orientation == 'landscape') {\r
-                       fww *= 2;\r
-               }\r
-\r
-               this.bookScale = Math.min(aw / fww, ah / fhh);\r
-               var fw = this.bookScale * fww;\r
-               var fh = this.bookScale * fhh;\r
-               $("#fluidbook").transform({\r
-                       scale: [this.bookScale, this.bookScale],\r
-                       origin: ['50%', '50%']\r
-               });\r
-               var top = marginTop + (ah - fhh) / 2;\r
-               var left = marginLeft + (aw - fww) / 2;\r
-               $("#fluidbook").css({\r
-                       top: top,\r
-                       left: left,\r
-                       width: fww,\r
-                       height: fhh\r
-               });\r
-\r
-\r
-               $("#next").transform({\r
-                       scale: cssInterfaceScale,\r
-                       translateX: 40 * (1 - interfaceScale) + 'px'\r
-               });\r
-\r
-               $("#previous").transform({\r
-                       scale: cssInterfaceScale,\r
-                       translateX: -40 * (1 - interfaceScale) + 'px'\r
-               })\r
-\r
-               $("#nav,#logo,footer,#searchHints").transform({\r
-                       scale: navScale\r
-               });\r
-\r
-               var headerHeight = this.fluidbook.datas.menuHeight * navScale;\r
-               $('header').css({\r
-                       height: headerHeight,\r
-                       backgroundSize: '100% ' + headerHeight + 'px'\r
-               });\r
-\r
-               this.refw = fw;\r
-               this.refh = fh;\r
-\r
-               if (this.fluidbook.help) {\r
-                       this.fluidbook.help.resize(this.ww, this.hh, interfaceScale, navScale);\r
-               }\r
-               this.fluidbook.coquillette.resize(this.ww, this.hh);\r
-               this.fluidbook.background.resize(this.ww, this.hh);\r
-\r
-               var timeout = 0;\r
-               if (this.fluidbook.support.android) {\r
-                       timeout = 1000;\r
-               }\r
-\r
-               if (timeout > 0) {\r
-                       $("#next,#previous").hide();\r
-                       clearTimeout(this.navresizeTimeout);\r
-                       this.navresizeTimeout = setTimeout(function() {\r
-                               $this.resizeNav(interfaceScale)\r
-                       }, timeout);\r
-               } else {\r
-                       this.resizeNav(interfaceScale);\r
-               }\r
-\r
-\r
-\r
-               this.resizePopupVideos();\r
-               this.resizeSplash();\r
-\r
-               if (this.fluidbook.form) {\r
-                       this.fluidbook.form.resize();\r
-               }\r
-\r
-               $("#main").show();\r
-       },\r
-       resizeNav: function(interfaceScale) {\r
-               var topNext = (this.hh - 100 * interfaceScale) / 2;\r
-               $("#next,#previous").css({\r
-                       top: topNext\r
-               });\r
-               $("#next,#previous").show();\r
-       },\r
-       resizePopupVideos: function() {\r
-               var maxh = this.hh - 80;\r
-               $(".mview .videoContainer video").each(function() {\r
-                       var w = $(window).width() - 40;\r
-\r
-                       var ratio = parseInt($(this).attr('data-width')) / parseInt($(this).attr('data-height'));\r
-                       var h = w / ratio;\r
-                       $(this).css({\r
-                               height: h,\r
-                               maxHeight: maxh\r
-                       });\r
-               });\r
-       },\r
-       resizeSplash: function() {\r
-               if ($("#splash").length == 0) {\r
-                       return;\r
-               }\r
-               $("#splash").css({\r
-                       width: this.ww,\r
-                       height: this.hh\r
-               });\r
-\r
-               if ($("#splash").css('opacity') == 0) {\r
-                       $("#splash").css('opacity', 1);\r
-               }\r
-\r
-               var lw = $("#splash .logo").width();\r
-               var lh = $("#splash .logo").height();\r
-\r
-               $("#splash .logo").css({\r
-                       top: (this.hh / 2) - 30 - lh - 10,\r
-                       left: (this.ww - lw) / 2\r
-               });\r
-       },\r
-       updateWindow: function() {\r
-               this.ww = $(window).width();\r
-               this.hh = $(window).height();\r
-       },\r
-       resizeView: function() {\r
-               var $this = this;\r
-               this.updateWindow();\r
-\r
-               $(".mview").css({\r
-                       width: this.ww,\r
-                       minHeight: this.hh,\r
-                       maxHeight: this.hh,\r
-                       height: this.hh\r
-               });\r
-\r
-               $(".mview").find('.caption,.content').css({\r
-                       width: this.ww\r
-               });\r
-\r
-\r
-               $(".mview .caption h2").each(function() {\r
-                       var wavailable = $this.ww;\r
-                       $(this).parent().find('a.back').each(function() {\r
-                               wavailable -= ($(this).outerWidth() + 10) * 2;\r
-                       });\r
-                       $(this).css('max-width', wavailable);\r
-               });\r
-\r
-               if ($("#archivesview").length == 1) {\r
-                       var w = this.fluidbook.datas.filesInfos.archives.width;\r
-                       var ratio = $("#archivesview img").width() / w;\r
-                       $("#archivesview .links").transform({scale: [ratio]});\r
-               }\r
-\r
-               $(".bookmarkView").each(function() {\r
-                       var w = $(this).parent().width();\r
-                       var perCol = Math.floor(w / 120);\r
-\r
-                       var uw = perCol * 120;\r
-                       var m = (w - uw) / 2;\r
-                       $(this).css({\r
-                               width: uw,\r
-                               margin: '0 auto'\r
-                       })\r
-               });\r
-       },\r
-       handleOrientation: function() {\r
-               var changeOrientation = this.orientation != '';\r
-               var o = this.fluidbook.support.getOrientation();\r
-               var newo;\r
-               if (o == 0 || o == 180) {\r
-                       newo = 'portrait';\r
-                       $('body').removeClass('landscape');\r
-               } else {\r
-                       newo = 'landscape';\r
-                       $('body').removeClass('portrait');\r
-               }\r
-               var force = this.fluidbook.datas.mobileNavigationType != 'book';\r
-               if (!force && this.orientation == newo) {\r
-                       return;\r
-               }\r
-               this.orientation = newo;\r
-\r
-               $('body').addClass(this.orientation);\r
-\r
-               this.fluidbook.displayOnePage = (this.orientation == 'portrait');\r
-\r
-               if (changeOrientation) {\r
-                       this.fluidbook.resetZoom();\r
-                       this.fluidbook.pageTransition();\r
-               }\r
-       }\r
-};\r
-\r
+function FluidbookResize(fluidbook) {
+       this.fluidbook = fluidbook;
+       this.marginw = 50;
+       this.marginh = 20;
+       this.corr = 0.8;
+       this.referenceWidthLandscape = 1024;
+       this.referenceWidthPortrait = 400;
+       this.referenceHeight = 600;
+       this.orientation = '';
+       this.textScale = 2;
+       this.bookScale = 1;
+       this.ww = $(window).width();
+       this.hh = $(window).height();
+       this.init();
+       this.navresizeTimeout = 0;
+}
+
+FluidbookResize.prototype = {
+       init: function() {
+
+               var left = this.fluidbook.l10n.dir == 'ltr' ? '0%' : '100%';
+               var right = this.fluidbook.l10n.dir == 'ltr' ? '100%' : '0%';
+
+               $("#nav,#searchHints").transform({
+                       origin: [left, '0%']
+               });
+
+               $("#logo").transform({
+                       origin: [right, '0%']
+               });
+
+               $("#footer").transform({
+                       origin: [right, '100%']
+               });
+
+               $("#next").transform({
+                       origin: [right, '50%']
+               });
+
+               $("#previous").transform({
+                       origin: [left, '50%']
+               });
+       },
+       resize: function(init) {
+               if (init == undefined || init == null) {
+                       init = false;
+               }
+
+               $("#main").hide();
+
+               var $this = this;
+               this.updateWindow();
+               this.handleOrientation();
+
+               var interfaceScale;
+               if (this.orientation == 'landscape') {
+                       interfaceScale = Math.min(1, this.ww / this.referenceWidthLandscape, this.hh / this.referenceHeight);
+               } else if (this.orientation == 'portrait') {
+                       var nminwidth = ($("#nav a").length * 51) + 205 + 50;
+                       var refWidth = Math.max(this.referenceWidthPortrait, nminwidth);
+
+                       interfaceScale = Math.min(1, this.ww / refWidth, this.hh / this.referenceHeight);
+               }
+               var navScale = interfaceScale * parseInt(this.fluidbook.datas.mobileNavScale) / 100;
+               var cssInterfaceScale = [interfaceScale, interfaceScale];
+               var cssNavScale = [navScale, navScale];
+
+               $("#main").css({
+                       width: this.ww,
+                       height: this.hh
+               });
+
+               this.resizeView();
+
+               var marginY, marginX, marginTop, marginBottom, marginLeft, marginRight;
+
+               if (this.fluidbook.pad.enabled) {
+                       marginY = 0;
+                       marginX = 0;
+                       extraX = 0;
+                       marginTop = 0;
+                       marginBottom = 0;
+                       marginLeft = 0;
+                       marginRight = 0;
+               } else {
+                       marginX = 50;
+                       marginY = 20;
+
+                       var extraX = parseInt(this.fluidbook.datas.mobileExtraXSpace);
+                       if (isNaN(extraX)) {
+                               extraX = 0;
+                       }
+
+                       marginTop = (this.fluidbook.datas.menuHeight + marginY) * interfaceScale;
+                       marginBottom = (10 + marginY) * interfaceScale;
+                       marginLeft = (marginX + extraX) * interfaceScale;
+                       marginRight = marginLeft;
+               }
+
+               var aw = this.ww - marginLeft - marginRight;
+               var ah = this.hh - marginTop - marginBottom;
+               var fhh = this.fluidbook.datas.height;
+               var fww = this.fluidbook.datas.width;
+               if (this.orientation == 'landscape') {
+                       fww *= 2;
+               }
+
+               this.bookScale = Math.min(aw / fww, ah / fhh);
+               var fw = this.bookScale * fww;
+               var fh = this.bookScale * fhh;
+               $("#fluidbook").transform({
+                       scale: [this.bookScale, this.bookScale],
+                       origin: ['50%', '50%']
+               });
+               var top = marginTop + (ah - fhh) / 2;
+               var left = marginLeft + (aw - fww) / 2;
+               $("#fluidbook").css({
+                       top: top,
+                       left: left,
+                       width: fww,
+                       height: fhh
+               });
+
+
+               $("#next").transform({
+                       scale: cssInterfaceScale,
+                       translateX: 40 * (1 - interfaceScale) + 'px'
+               });
+
+               $("#previous").transform({
+                       scale: cssInterfaceScale,
+                       translateX: -40 * (1 - interfaceScale) + 'px'
+               })
+
+               $("#nav,#logo,footer,#searchHints").transform({
+                       scale: navScale
+               });
+
+               var headerHeight = this.fluidbook.datas.menuHeight * navScale;
+               $('header').css({
+                       height: headerHeight,
+                       backgroundSize: '100% ' + headerHeight + 'px'
+               });
+
+               this.refw = fw;
+               this.refh = fh;
+
+               if (this.fluidbook.help) {
+                       this.fluidbook.help.resize(this.ww, this.hh, interfaceScale, navScale);
+               }
+               this.fluidbook.coquillette.resize(this.ww, this.hh);
+               this.fluidbook.background.resize(this.ww, this.hh);
+
+               var timeout = 0;
+               if (this.fluidbook.support.android) {
+                       timeout = 1000;
+               }
+
+               if (timeout > 0) {
+                       $("#next,#previous").hide();
+                       clearTimeout(this.navresizeTimeout);
+                       this.navresizeTimeout = setTimeout(function() {
+                               $this.resizeNav(interfaceScale)
+                       }, timeout);
+               } else {
+                       this.resizeNav(interfaceScale);
+               }
+
+
+
+               this.resizePopupVideos();
+               this.resizeSplash();
+
+               if (this.fluidbook.form) {
+                       this.fluidbook.form.resize();
+               }
+
+               $("#main").show();
+       },
+       resizeNav: function(interfaceScale) {
+               var topNext = (this.hh - 100 * interfaceScale) / 2;
+               $("#next,#previous").css({
+                       top: topNext
+               });
+               $("#next,#previous").show();
+       },
+       resizePopupVideos: function() {
+               var maxh = this.hh - 80;
+               $(".mview .videoContainer video").each(function() {
+                       var w = $(window).width() - 40;
+
+                       var ratio = parseInt($(this).attr('data-width')) / parseInt($(this).attr('data-height'));
+                       var h = w / ratio;
+                       $(this).css({
+                               height: h,
+                               maxHeight: maxh
+                       });
+               });
+       },
+       resizePopupAudios: function() {
+               $(".mview audio").each(function() {
+                       var w = $(window).width() - 200;
+                       var h = 30;
+                       $(this).css({
+                               height: h,
+                               width: w,
+                               display: 'block',
+                               margin: '40px auto'
+                       });
+               });
+       },
+       resizeSplash: function() {
+               if ($("#splash").length == 0) {
+                       return;
+               }
+               $("#splash").css({
+                       width: this.ww,
+                       height: this.hh
+               });
+
+               if ($("#splash").css('opacity') == 0) {
+                       $("#splash").css('opacity', 1);
+               }
+
+               var lw = $("#splash .logo").width();
+               var lh = $("#splash .logo").height();
+
+               $("#splash .logo").css({
+                       top: (this.hh / 2) - 30 - lh - 10,
+                       left: (this.ww - lw) / 2
+               });
+       },
+       updateWindow: function() {
+               this.ww = $(window).width();
+               this.hh = $(window).height();
+       },
+       resizeView: function() {
+               var $this = this;
+               this.updateWindow();
+
+               $(".mview").css({
+                       width: this.ww,
+                       minHeight: this.hh,
+                       maxHeight: this.hh,
+                       height: this.hh
+               });
+
+               $(".mview").find('.caption,.content').css({
+                       width: this.ww
+               });
+
+
+               $(".mview .caption h2").each(function() {
+                       var wavailable = $this.ww;
+                       $(this).parent().find('a.back').each(function() {
+                               wavailable -= ($(this).outerWidth() + 10) * 2;
+                       });
+                       $(this).css('max-width', wavailable);
+               });
+
+               if ($("#archivesview").length == 1) {
+                       var w = this.fluidbook.datas.filesInfos.archives.width;
+                       var ratio = $("#archivesview img").width() / w;
+                       $("#archivesview .links").transform({scale: [ratio]});
+               }
+
+               $(".bookmarkView").each(function() {
+                       var w = $(this).parent().width();
+                       var perCol = Math.floor(w / 120);
+
+                       var uw = perCol * 120;
+                       var m = (w - uw) / 2;
+                       $(this).css({
+                               width: uw,
+                               margin: '0 auto'
+                       })
+               });
+       },
+       handleOrientation: function() {
+               var changeOrientation = this.orientation != '';
+               var o = this.fluidbook.support.getOrientation();
+               var newo;
+               if (o == 0 || o == 180) {
+                       newo = 'portrait';
+                       $('body').removeClass('landscape');
+               } else {
+                       newo = 'landscape';
+                       $('body').removeClass('portrait');
+               }
+               var force = this.fluidbook.datas.mobileNavigationType != 'book';
+               if (!force && this.orientation == newo) {
+                       return;
+               }
+               this.orientation = newo;
+
+               $('body').addClass(this.orientation);
+
+               this.fluidbook.displayOnePage = (this.orientation == 'portrait');
+
+               if (changeOrientation) {
+                       this.fluidbook.resetZoom();
+                       this.fluidbook.pageTransition();
+               }
+       }
+};
+