Merge branch 'placeholder-slow-connection' into 5.1-candidate

This commit is contained in:
ansuz 2022-08-30 14:14:53 +05:30
commit c0a82b2bc3
3 changed files with 48 additions and 9 deletions

View File

@ -15,16 +15,44 @@ elem.innerHTML = [
'</div>' '</div>'
].join(''); ].join('');
var key = 'CRYPTPAD_STORE|colortheme'; // handle outer
if (localStorage[key] && localStorage[key] === 'dark') {
elem.classList.add('dark-theme');
}
if (!localStorage[key] && localStorage[key+'_default'] && localStorage[key+'_default'] === 'dark') {
elem.classList.add('dark-theme');
}
var req;
try {
req = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
if ((req.theme || req.themeOS) === 'dark') { // handle inner
elem.classList.add('dark-theme');
}
} catch (e) {}
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
document.body.appendChild(elem); document.body.appendChild(elem);
window.CP_preloadingTime = +new Date();
// soft transition between inner and outer placeholders
if (req && req.time && (+new Date() - req.time > 2000)) {
try {
var logo = document.querySelector('.placeholder-logo-container');
var message = document.querySelector('.placeholder-message-container');
logo.style.opacity = 100;
message.style.opacity = 100;
logo.style.animation = 'none';
message.style.animation = 'none';
} catch (err) {}
}
// fallback if CSS animations not available // fallback if CSS animations not available
setTimeout(() => { setTimeout(() => {
try { try {
document.querySelector('.placeholder-logo-container').style.opacity = 100; document.querySelector('.placeholder-logo-container').style.opacity = 100;
document.querySelector('.placeholder-message-container').style.opacity = 100; document.querySelector('.placeholder-message-container').style.opacity = 100;
} catch (err) { } catch (e) {}
console.error(err);
}
}, 3000); }, 3000);
}); });
}()); }());

View File

@ -9,6 +9,14 @@
font-style: normal; font-style: normal;
} }
.cp-app-noscroll body {
background: transparent;
}
.cp-app-noscroll #placeholder {
z-index: 9999999; /* loading screen -1 */
background-color: transparent;
}
#placeholder { #placeholder {
visibility: visible; visibility: visible;
position: fixed; position: fixed;
@ -28,12 +36,11 @@
align-items: center; align-items: center;
font: 20px 'Open Sans', 'Helvetica Neue', sans-serif !important; font: 20px 'Open Sans', 'Helvetica Neue', sans-serif !important;
} }
@media (prefers-color-scheme: dark) { #placeholder.dark-theme {
#placeholder { background-color: #212121; /* @cp_loading-bg (dark) */
background-color: #212121; /* @cp_loading-bg (dark) */ color: #EEEEEE; /* @cp_loading-fg (dark) */
color: #EEEEEE; /* @cp_loading-fg (dark) */
}
} }
#placeholder .placeholder-logo-container { #placeholder .placeholder-logo-container {
height: 300px; height: 300px;
width: 300px; width: 300px;
@ -61,6 +68,9 @@
opacity: 0; opacity: 0;
animation: fadein 5s ease 2s forwards; animation: fadein 5s ease 2s forwards;
} }
#placeholder .placeholder-message-container p {
margin-top: 0;
}
#placeholder .placeholder-logo { #placeholder .placeholder-logo {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;

View File

@ -51,7 +51,8 @@ define([
pfx: window.location.origin, pfx: window.location.origin,
theme: localStorage[themeKey], theme: localStorage[themeKey],
themeOS: localStorage[themeKey+'_default'], themeOS: localStorage[themeKey+'_default'],
lang: lang lang: lang,
time: window.CP_preloadingTime
}; };
window.rc = requireConfig; window.rc = requireConfig;
window.apiconf = ApiConfig; window.apiconf = ApiConfig;