Commit 763cbce0 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_js_style: hide the page until full rendering is done

parent bd7a8fb7
......@@ -5,6 +5,16 @@
loopEventListener, history, console) {
"use strict";
function hidePage() {
document.documentElement.hidden = true;
document.documentElement.style.display = 'none';
}
function showPage() {
document.documentElement.hidden = false;
document.documentElement.style.display = 'unset';
}
// XXX Copy/paste from renderjs
function ajax(url) {
var xhr;
......@@ -386,7 +396,7 @@
rJS(window)
.allowPublicAcquisition("reportServiceError", function () {
this.element.hidden = false;
showPage();
throw rJS.AcquisitionError();
})
.declareJob("listenURLChange", listenURLChange)
......@@ -426,10 +436,16 @@
gadget.listenURLChange();
body.appendChild(style_gadget.element);
gadget.element.hidden = false;
// Show the page after the first rendering
// This prevent displaying the original HTML page
// in case cpu/network is too slow
showPage();
scrollToHash(window.location.hash);
}, function (error) {
gadget.element.hidden = false;
// Ensure the page is visible in case of error
showPage();
throw error;
});
}, function (error) {
......@@ -448,5 +464,13 @@
});
});
// Hide the page as soon as possible
// This prevent displaying the original HTML page
// in case cpu/network is too slow
// (when fetching rendering gadget or if pages containes img elements)
// Hiding the page MUST NOT be done in the HTML, to ensure compatibility
// with browsers without javascript
hidePage();
}(window, document, RSVP, rJS, XMLHttpRequest, DOMParser, URL,
rJS.loopEventListener, history, console));
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment