Avoid flickering of editor header on load, also for manage<=>edit nav

This commit is contained in:
tophf 2017-03-20 07:59:51 +03:00
parent 8c7f7b81f8
commit 7a7c679811
2 changed files with 28 additions and 13 deletions

View File

@ -41,16 +41,16 @@
body {
margin: 0;
font: 9pt arial,sans-serif;
font: 12px arial,sans-serif;
}
/************ header ************/
#header {
height: calc(100vh - 30px);
overflow: auto;
width: 15rem;
width: 250px;
position: fixed;
top: 0;
padding: 0.95rem;
padding: 15px;
border-right: 1px dashed #AAA;
-webkit-box-shadow: 0 0 3rem -1.2rem black;
}
@ -58,10 +58,11 @@
margin-top: 0;
}
#sections {
padding-left: 18rem;
padding-left: 280px;
}
#sections h2 {
margin-top: 0.5rem;
margin-top: 1rem;
margin-left: 1.7rem;
}
.aligned {
display: table-row;

30
edit.js
View File

@ -1066,23 +1066,26 @@ function beautify(event) {
}
}
window.addEventListener("load", init, false);
document.addEventListener("DOMContentLoaded", init);
function init() {
var params = getParams();
if (!params.id) { // match should be 2 - one for the whole thing, one for the parentheses
// This is an add
tE("heading", "addStyleTitle");
var section = {code: ""}
for (var i in CssToProperty) {
if (params[i]) {
section[CssToProperty[i]] = [params[i]];
}
}
addSection(null, section);
// default to enabled
document.getElementById("enabled").checked = true
tE("heading", "addStyleTitle");
initHooks();
onload = () => {
onload = null;
addSection(null, section);
// default to enabled
document.getElementById("enabled").checked = true
initHooks();
};
return;
}
// This is an edit
@ -1090,14 +1093,25 @@ function init() {
getStylesSafe({id: params.id}).then(styles => {
const style = styles[0];
styleId = style.id;
initWithStyle({style});
setStyleMeta(style);
onload = () => {
onload = null;
initWithStyle({style});
};
if (document.readyState != 'loading') {
onload();
}
});
}
function initWithStyle({style, codeIsUpdated}) {
function setStyleMeta(style) {
document.getElementById("name").value = style.name;
document.getElementById("enabled").checked = style.enabled;
document.getElementById("url").href = style.url;
}
function initWithStyle({style, codeIsUpdated}) {
setStyleMeta(style);
if (codeIsUpdated === false) {
setCleanGlobal();