feature: improve page loading + intl collator
This commit is contained in:
@ -187,13 +187,15 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
// Detect the lang & initialize, based on the browser or "language" item from localstorage
|
||||
jsI18n.detectLanguage();
|
||||
let timer;
|
||||
(new MutationObserver((mutations) => {
|
||||
mutations.forEach(mutation => {
|
||||
if(mutation.target.attributes["data-trans"] != null) {
|
||||
// Render the target of the mutation instantly
|
||||
jsI18n.processNode(mutation.target);
|
||||
// Then wait one arbitrary second to re-render the whole document in case a widget re-rendered
|
||||
setTimeout(() => jsI18n.processNode(document.querySelector('body')), 1000);
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => jsI18n.processNode(document.querySelector('body')), 500);
|
||||
}
|
||||
});
|
||||
}).observe(document.body, {
|
||||
|
@ -7,6 +7,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
document
|
||||
.querySelectorAll(".notLoggedIn")
|
||||
.forEach(el => (el.style.visibility = "visible"));
|
||||
document
|
||||
.querySelectorAll(".loggedIn")
|
||||
.forEach(el => (el.style.display = "none"));
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user