]> _ Git - fluidbook-html5.git/commitdiff
wait #5624 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 2 Dec 2022 17:37:31 +0000 (18:37 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 2 Dec 2022 17:37:31 +0000 (18:37 +0100)
js/libs/fluidbook/fluidbook.menu.js

index be4942a53473c5cfc16c9a96658423b328241c33..9e3416e3610521aa403ba93ed484a8a61e855e39 100644 (file)
@@ -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;