From: Vincent Vanwaelscappel Date: Fri, 2 Dec 2022 17:37:31 +0000 (+0100) Subject: wait #5624 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9479752fe390ce4a78e91caf59e1186068c80fc0;p=fluidbook-html5.git wait #5624 @0.5 --- diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index be4942a5..9e3416e3 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -793,10 +793,18 @@ FluidbookMenu.prototype = { break; case 'iframe': case 'freeiframe': - w = ww * 0.8; + iframe = $("#view .iframeHolder iframe"); if (parseInt(this.fluidbook.settings.iframePopupMaxWidth) > 0) { - w = Math.min(w, parseInt(this.fluidbook.settings.iframePopupMaxWidth)); + maxWidth = parseInt(this.fluidbook.settings.iframePopupMaxWidth); + } + maxWidth = this.getMetaIframeNumber(iframe, 'max-width', maxWidth); + $(iframe).closest('.iframeContainer').css('background-color', this.getMetaIframe(iframe, 'background-color', '#fff')); + w = ww * 0.8; + if (maxWidth > 0) { + console.log(maxWidth, w); + w = Math.min(w, maxWidth) } + h = hh * 0.8; if (ww < 800) { w = ww; @@ -805,9 +813,9 @@ FluidbookMenu.prototype = { } forceHeight = true; - w = Math.min(w, maxWidth); - - var iframe = $("#view .iframeHolder iframe"); + if (maxWidth > 0) { + w = Math.min(w, maxWidth); + } iframe.css('width', w); try { var doc = getIframeDocument(iframe); @@ -822,9 +830,14 @@ FluidbookMenu.prototype = { ih = -1; } + if (ih > 0) { h = Math.min(ih, h); } + let minHeight = this.getMetaIframeNumber(iframe, 'min-height', 0); + if (minHeight > 0) { + h = Math.max(h, minHeight); + } } break; case 'cart': @@ -1052,7 +1065,9 @@ FluidbookMenu.prototype = { captionHeight += $(this).outerHeight(); }); - w = Math.min(maxWidth, w); + if (maxWidth > 0) { + w = Math.min(maxWidth, w); + } css = {}; var ccss = {}; @@ -1116,6 +1131,30 @@ FluidbookMenu.prototype = { } }, + getMetaIframe: function (iframe, name, defaultValue) { + try { + var res = iframe.get(0).contentWindow.document.querySelector('meta[name="' + name + '"]').content; + if (res === undefined || res === null) { + return defaultValue; + } + return res; + } catch (e) { + return defaultValue; + } + }, + + getMetaIframeNumber: function (iframe, name, defaultValue) { + try { + var res = this.getMetaIframe(iframe, name, defaultValue); + if (isNaN(res)) { + return defaultValue; + } + return res; + } catch (e) { + return defaultValue; + } + }, + resizePopupAudios: function () { $(".mview audio").each(function () { var w = $(window).width() - 200;