Adapt background in sticky switcher to selected theme

pull/16/head
Christoph Zwerschke 4 years ago
parent 82ae6c7726
commit 2e00e7a6c1

@ -14,6 +14,7 @@
padding-bottom: 9px;
background: white;
box-shadow: 0 2px 1px -1px #ccc;
z-index: 999999;
}
</style>
<script type="text/javascript">

@ -3,7 +3,7 @@ var frameworks = "a11yana,bahunya,bare,base,bullframe,bulma,caiuss,caramel,cardi
add_switcher();
function switch_css(css) {
document.getElementsByTagName("link")[0].href = "https://dohliam.github.io/dropin-minimal-css/min/" + css + ".min.css";
css_link.href = "https://dohliam.github.io/dropin-minimal-css/min/" + css + ".min.css";
}
function capitalize(s) {
@ -13,6 +13,12 @@ function capitalize(s) {
return u;
}
function on_css_load() {
var bgColor = getComputedStyle(document.body).backgroundColor;
if (bgColor.match(/^rgba\(.*\)/) ) bgColor = 'white';
switcher.style.backgroundColor = bgColor;
}
function inline_switcher() {
switcher = document.getElementById("switcher");
frameworks_array = frameworks.split(",");
@ -30,21 +36,23 @@ function inline_switcher() {
}
function add_switcher() {
stylesheet = document.getElementsByTagName("link")[0];
if (stylesheet == undefined) {
css_link = document.getElementsByTagName("link")[0];
if (css_link == undefined) {
head = document.getElementsByTagName('head')[0];
link = document.createElement('link');
link.rel="stylesheet";
link.type="text/css";
link.href="https://dohliam.github.io/dropin-minimal-css/min/" + frameworks.split(",")[0] + ".min.css";
head.appendChild(link);
css_link = document.createElement('link');
css_link.rel="stylesheet";
css_link.type="text/css";
css_link.href="https://dohliam.github.io/dropin-minimal-css/min/" + frameworks.split(",")[0] + ".min.css";
head.appendChild(css_link);
}
var new_div = document.createElement('div');
new_div.id = 'switcher';
new_div.innerHTML = ' <div>&nbsp;</div>\n <script type="text/javascript">inline_switcher();</script>';
document.body.insertBefore(new_div, document.body.firstChild);
document.body.prepend(new_div);
document.body.style.paddingLeft = "24px";
inline_switcher();
css_link.onload = on_css_load;
}

Loading…
Cancel
Save