Editor: avoid flicker of "Edit style" heading on load

This commit is contained in:
tophf 2015-07-19 19:49:17 +03:00
parent 4f61494e0d
commit ea18ae2c89

View File

@ -1013,6 +1013,7 @@ function init() {
return; return;
} }
// This is an edit // This is an edit
tE("heading", "editStyleHeading", null, false);
requestStyle(); requestStyle();
function requestStyle() { function requestStyle() {
chrome.extension.sendMessage({method: "getStyles", id: params.id}, function callback(styles) { chrome.extension.sendMessage({method: "getStyles", id: params.id}, function callback(styles) {
@ -1031,7 +1032,6 @@ function initWithStyle(style) {
document.getElementById("name").value = style.name; document.getElementById("name").value = style.name;
document.getElementById("enabled").checked = style.enabled == "true"; document.getElementById("enabled").checked = style.enabled == "true";
document.getElementById("url").href = style.url; document.getElementById("url").href = style.url;
tE("heading", "editStyleHeading", null, false);
// if this was done in response to an update, we need to clear existing sections // if this was done in response to an update, we need to clear existing sections
document.querySelectorAll("#sections > div").forEach(function(div) { document.querySelectorAll("#sections > div").forEach(function(div) {
div.parentNode.removeChild(div); div.parentNode.removeChild(div);
@ -1225,6 +1225,7 @@ function saveComplete(style) {
// Go from new style URL to edit style URL // Go from new style URL to edit style URL
if (location.href.indexOf("id=") == -1) { if (location.href.indexOf("id=") == -1) {
history.replaceState({}, document.title, "edit.html?id=" + style.id); history.replaceState({}, document.title, "edit.html?id=" + style.id);
tE("heading", "editStyleHeading", null, false);
} }
updateTitle(); updateTitle();
} }