Skip to content

Commit

Permalink
Hide loading message in case of fast iframe loading
Browse files Browse the repository at this point in the history
Previously, in case the iframe was already fully loaded, the callbacks
were not called, and thus the loading message didn't disappear.
  • Loading branch information
pabzm committed Feb 21, 2025
1 parent afb91ac commit 1cbcc21
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions program/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,17 @@ function rcube_webmail() {

if (this.task === 'mail' && (this.env.action === 'preview' || this.env.action === 'show')) {
document.querySelectorAll('iframe.framed-message-part').forEach((iframe) => {
// Resize twice initially: first time when the iframe's
// document was parsed, to already provide roughly the
// correct height; second time when all resources have been
// loaded, to finally ensure the correct height with all
// images etc.
iframe.addEventListener('DOMContentLoaded', () => this.resize_preview_iframe(iframe));
iframe.addEventListener('load', () => {
this.resize_preview_iframe(iframe);
// Hide "Loading data" message.
$(iframe).siblings('.loading').hide();
// Show notice
if (iframe.contentDocument.body.dataset.extlinks === 'true') {
$(this.gui_objects.remoteobjectsmsg).show();
this.enable_command('load-remote', true);
}
});
if (iframe.contentDocument.readyState === 'complete') {
this.iframe_actions_after_load(iframe);
} else {
// Resize twice initially: first time when the iframe's
// document was parsed, to already provide roughly the
// correct height; second time when all resources have been
// loaded, to finally ensure the correct height with all
// images etc.
iframe.addEventListener('DOMContentLoaded', () => this.resize_preview_iframe(iframe));
iframe.addEventListener('load', () => this.iframe_actions_after_load(iframe));
}
// Also run on window resizes, because the changed text flow could need more space.
window.addEventListener('resize', () => this.resize_preview_iframe(iframe));
});
Expand Down Expand Up @@ -10683,6 +10678,17 @@ function rcube_webmail() {
setTimeout('window.print()', 10);
};

this.iframe_actions_after_load = function (iframe) {
this.resize_preview_iframe(iframe);
// Hide "Loading data" message.
$(iframe).siblings('.loading').hide();
// Show notice
if (iframe.contentDocument.body.dataset.extlinks === 'true') {
$(this.gui_objects.remoteobjectsmsg).show();
this.enable_command('load-remote', true);
}
};

this.resize_preview_iframe = function (iframe) {
// Cancel runs that we're scheduled ealier but didn't run yet.
if (iframe.resizePreviewIframeTimer) {
Expand Down

0 comments on commit 1cbcc21

Please sign in to comment.