Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/website/layouts/_default/initializr.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,26 @@
}

if (frame && loader) {
frame.addEventListener("load", function () {
var loaderHidden = false;
var hideLoader = function () {
if (loaderHidden) {
return;
}
loaderHidden = true;
loader.classList.add("done");
};

frame.addEventListener("load", function () {
window.setTimeout(hideLoader, 8000);
});

window.addEventListener("message", function (evt) {
if (evt.source !== frame.contentWindow || !evt.data || evt.data.type !== "cn1-initializr-ui-ready") {
return;
}
window.requestAnimationFrame(function () {
hideLoader();
});
});
}
})();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ public void run() {
refresh.run();
initWebsiteThemeSync(form);
form.show();
notifyWebsiteUiReady();
}

private void notifyWebsiteUiReady() {
WebsiteThemeNative nativeBridge = NativeLookup.create(WebsiteThemeNative.class);
if (nativeBridge != null && nativeBridge.isSupported()) {
nativeBridge.notifyUiReady();
}
}

private Container createLocalizationPanel(boolean[] includeLocalizationBundles,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

public interface WebsiteThemeNative extends NativeInterface {
boolean isDarkMode();
void notifyUiReady();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ var o = {};
callback.complete(!!dark);
};


o.notifyUiReady_ = function(callback) {
var sendReady = function() {
try {
if (window.parent && window.parent !== window && window.parent.postMessage) {
window.parent.postMessage({ type: "cn1-initializr-ui-ready" }, "*");
}
} catch (ignored) {
// Ignore cross-origin or sandbox restrictions.
}
callback.complete();
};

if (window.requestAnimationFrame) {
window.requestAnimationFrame(function() {
window.requestAnimationFrame(sendReady);
});
} else {
window.setTimeout(sendReady, 48);
}
};

o.isSupported_ = function(callback) {
callback.complete(true);
};
Expand Down
Loading