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 { body {
margin: 0; margin: 0;
font: 9pt arial,sans-serif; font: 12px arial,sans-serif;
} }
/************ header ************/ /************ header ************/
#header { #header {
height: calc(100vh - 30px); height: calc(100vh - 30px);
overflow: auto; overflow: auto;
width: 15rem; width: 250px;
position: fixed; position: fixed;
top: 0; top: 0;
padding: 0.95rem; padding: 15px;
border-right: 1px dashed #AAA; border-right: 1px dashed #AAA;
-webkit-box-shadow: 0 0 3rem -1.2rem black; -webkit-box-shadow: 0 0 3rem -1.2rem black;
} }
@ -58,10 +58,11 @@
margin-top: 0; margin-top: 0;
} }
#sections { #sections {
padding-left: 18rem; padding-left: 280px;
} }
#sections h2 { #sections h2 {
margin-top: 0.5rem; margin-top: 1rem;
margin-left: 1.7rem;
} }
.aligned { .aligned {
display: table-row; 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() { function init() {
var params = getParams(); var params = getParams();
if (!params.id) { // match should be 2 - one for the whole thing, one for the parentheses if (!params.id) { // match should be 2 - one for the whole thing, one for the parentheses
// This is an add // This is an add
tE("heading", "addStyleTitle");
var section = {code: ""} var section = {code: ""}
for (var i in CssToProperty) { for (var i in CssToProperty) {
if (params[i]) { if (params[i]) {
section[CssToProperty[i]] = [params[i]]; section[CssToProperty[i]] = [params[i]];
} }
} }
addSection(null, section); onload = () => {
// default to enabled onload = null;
document.getElementById("enabled").checked = true addSection(null, section);
tE("heading", "addStyleTitle"); // default to enabled
initHooks(); document.getElementById("enabled").checked = true
initHooks();
};
return; return;
} }
// This is an edit // This is an edit
@ -1090,14 +1093,25 @@ function init() {
getStylesSafe({id: params.id}).then(styles => { getStylesSafe({id: params.id}).then(styles => {
const style = styles[0]; const style = styles[0];
styleId = style.id; 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("name").value = style.name;
document.getElementById("enabled").checked = style.enabled; document.getElementById("enabled").checked = style.enabled;
document.getElementById("url").href = style.url; document.getElementById("url").href = style.url;
}
function initWithStyle({style, codeIsUpdated}) {
setStyleMeta(style);
if (codeIsUpdated === false) { if (codeIsUpdated === false) {
setCleanGlobal(); setCleanGlobal();