More iframe dialog handling optimizations (references #2421)

This commit is contained in:
Bernd Bestel 2024-01-13 09:32:59 +01:00
parent efae5fea5b
commit fc072b13f2
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

View File

@ -542,8 +542,10 @@ if ($(".custom-file-label").length > 0)
$("<style>").html('.custom-file-label::after { content: "' + __t("Select file") + '"; }').appendTo("head");
}
ResizeResponsiveEmbeds = function(fillEntireViewport = false)
ResizeResponsiveEmbeds = function(fillEntireViewport = false, iframesOnly = false)
{
if (!iframesOnly)
{
if (!fillEntireViewport)
{
var maxHeight = $("body").height() - $("#mainNav").outerHeight() - 62;
@ -552,12 +554,25 @@ ResizeResponsiveEmbeds = function(fillEntireViewport = false)
{
var maxHeight = $("body").height();
}
$("embed.embed-responsive").attr("height", maxHeight.toString() + "px");
}
$("iframe.embed-responsive").each(function()
{
$(this).attr("height", $(this)[0].contentWindow.document.body.scrollHeight.toString() + "px");
var iframeHeight = $(this)[0].contentWindow.document.body.scrollHeight;
if (iframeHeight == 0)
{
// Iframe has most likely not finished loading yet => try again later
setTimeout(function()
{
ResizeResponsiveEmbeds(fillEntireViewport, true);
}, 150);
}
else
{
$(this).attr("height", iframeHeight.toString() + "px");
}
});
}
$(window).on('resize', function()