2012-06-05 01:30:13 +02:00
|
|
|
if (typeof jQuery!=='undefined') {
|
|
|
|
(function($) {
|
|
|
|
var iframe = $('#Iframepage-iframe');
|
|
|
|
var loading = $('#Iframepage-loading');
|
|
|
|
|
|
|
|
// Add not-ready marker for third party use.
|
|
|
|
iframe.addClass('iframepage-not-ready');
|
|
|
|
// Show loading message
|
|
|
|
iframe.hide();
|
|
|
|
loading.show();
|
|
|
|
|
2019-08-09 01:16:41 +02:00
|
|
|
$( iframe ).on('load', function() {
|
|
|
|
// Iframe content has been loaded
|
|
|
|
loading.hide();
|
|
|
|
iframe.show();
|
2012-06-05 01:30:13 +02:00
|
|
|
|
2019-08-09 01:16:41 +02:00
|
|
|
if (iframe.hasClass('iframepage-height-auto')===true) {
|
|
|
|
// Try to set the height to the height of the iframe content (only possible if it is the same domain)
|
|
|
|
try {
|
|
|
|
// Use plain JS to get iframe size. There is some timing issue with jQuery
|
|
|
|
// which causes the iframe size to be 0 even after iframe.show().
|
|
|
|
const domframe = document.querySelector('#Iframepage-iframe');
|
|
|
|
var iframeInsideSize = domframe.contentWindow.document.body.offsetHeight;
|
|
|
|
iframe.css('height', (parseInt(iframeInsideSize)+100)+'px');
|
2012-06-05 01:30:13 +02:00
|
|
|
}
|
2019-08-09 01:16:41 +02:00
|
|
|
catch(e) {
|
|
|
|
// Failed to set the height, we fall back to default css height.
|
|
|
|
}
|
|
|
|
}
|
2012-06-05 01:30:13 +02:00
|
|
|
|
2019-08-09 01:16:41 +02:00
|
|
|
// Finally, remove the marker
|
|
|
|
iframe.removeClass('iframepage-not-ready');
|
2012-06-05 01:30:13 +02:00
|
|
|
});
|
|
|
|
})(jQuery);
|
|
|
|
}
|