Skip to content

Commit d4dc1ce

Browse files
committed
Hide loading message in case of fast iframe loading
Previously, in case the iframe was already fully loaded, the callbacks were not called, and thus the loading message didn't disappear.
1 parent 1350b2e commit d4dc1ce

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

program/js/app.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,17 @@ function rcube_webmail() {
250250

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

10681+
this.iframe_actions_after_load = function (iframe) {
10682+
this.resize_preview_iframe(iframe);
10683+
// Hide "Loading data" message.
10684+
$(iframe).siblings('.loading').hide();
10685+
// Show notice
10686+
if (iframe.contentDocument.body.dataset.extlinks === 'true') {
10687+
$(this.gui_objects.remoteobjectsmsg).show();
10688+
this.enable_command('load-remote', true);
10689+
}
10690+
};
10691+
1068610692
this.resize_preview_iframe = function (iframe) {
1068710693
// Cancel runs that we're scheduled ealier but didn't run yet.
1068810694
if (iframe.resizePreviewIframeTimer) {

0 commit comments

Comments
 (0)