Skip to content
Snippets Groups Projects
Commit 3d893fa4 authored by Guillaume Delhumeau's avatar Guillaume Delhumeau
Browse files

XWIKI-13778: Improve the loading time when a user opens a Flamingo Theme in edit mode.

parent d3b82f14
No related branches found
No related tags found
No related merge requests found
......@@ -362,9 +362,14 @@
// Put a gray curtain in front of the iframe
var addCurtain = function() {
var iframePosition = iframe.position();
$("<div id=\"preview-curtain\"><h2>$services.localization.render('platform.flamingo.themes.loading')</h2></div>").insertAfter(iframe);
var previewCurtain = $("#preview-curtain");
if (previewCurtain.length > 0) {
// The curtain already exist, do nothing.
return;
}
var iframePosition = iframe.position();
previewCurtain = $("<div id=\"preview-curtain\"><h2>$services.localization.render('platform.flamingo.themes.loading')</h2></div>");
previewCurtain.insertAfter(iframe);
previewCurtain.width(iframe.outerWidth(true));
previewCurtain.height(iframe.outerHeight(true));
previewCurtain.css("left", iframePosition.left);
......@@ -501,7 +506,6 @@
// 3: Refresh the live preview
waitUntilLessIsLoadedInIFrame(function(){
removeCurtain();
// We need to refresh just after LESS is loaded because the fist rendering does not handle the variables of the
// flamingo theme. Unfortunately, it means that the preview is rendered twice at the loading of the page.
// We refresh it in a thread to avoid blocking the browser.
......@@ -509,8 +513,8 @@
});
};
// Initialize the iframe
waitUntilIFrameIsLoaded(initIframe);
// Add the curtain which will be removed when the iframe will be loaded and the LESS code compiled
addCurtain()
// The user can navigate to an other page inside the iframe, so when the page changes (onload),
// we re-init the iframe to use LESS
iframe.load(initIframe);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment