stylig bug fixed

This commit is contained in:
Christian Mueller
2014-01-19 22:28:03 +01:00
parent af7b94ddfe
commit d117a582df
+34 -32
View File
@@ -62,43 +62,45 @@ var themes = {
}; };
function applyTheme() { function applyTheme() {
var ui = { theme: "default" };
if (location.search.length > 0) { if (location.search.length > 0) {
var ui = { theme: "default" };
location.search.slice(1).split("&").reduce(function(acc, e){ location.search.slice(1).split("&").reduce(function(acc, e){
var p = e.split("="); var p = e.split("=");
acc[p[0]] = p[1]; acc[p[0]] = p[1];
return acc return acc
}, ui); }, ui);
var vars = {
'@background': themes[ui.theme].background.normal,
'@background_halftone': themes[ui.theme].background.halftone,
'@foreground': themes[ui.theme].foreground.normal,
'@foreground_halftone': themes[ui.theme].foreground.halftone,
'@link_fresh': themes[ui.theme].link.fresh,
'@link_visited': themes[ui.theme].link.visited,
'@link_hover': themes[ui.theme].link.hover
};
if(ui["header-font"] || ui["text-font"]) {
var fontURL = "http://fonts.googleapis.com/" +
"css?family=PT+Serif:700|Noticia+Text:700%s" +
"&subset=latin,cyrillic";
var injection = ["header-font", "text-font"].reduce(function(acc, font){
if(ui[font]) {
vars['@' + font.replace(/-/, "_")] = ui[font].replace(/\+/g," ");
return acc + "|" + ui[font];
} else return acc;
}, "");
fontURL = fontURL.replace(/%s/, injection);
var fileref = document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", fontURL)
document.getElementsByTagName("head")[0].appendChild(fileref)
}
less.modifyVars(vars);
} }
var vars = {
'@background': themes[ui.theme].background.normal,
'@background_halftone': themes[ui.theme].background.halftone,
'@foreground': themes[ui.theme].foreground.normal,
'@foreground_halftone': themes[ui.theme].foreground.halftone,
'@link_fresh': themes[ui.theme].link.fresh,
'@link_visited': themes[ui.theme].link.visited,
'@link_hover': themes[ui.theme].link.hover
};
var fontURL = "http://fonts.googleapis.com/" +
"css?family=PT+Serif:700|Noticia+Text:700%s" +
"&subset=latin,cyrillic",
injection = "";
if(ui["header-font"] || ui["text-font"]) {
injection = ["header-font", "text-font"].reduce(function(acc, font){
if(ui[font]) {
vars['@' + font.replace(/-/, "_")] = ui[font].replace(/\+/g," ");
return acc + "|" + ui[font];
} else return acc;
}, "");
}
fontURL = fontURL.replace(/%s/, injection);
var fileref = document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", fontURL)
document.getElementsByTagName("head")[0].appendChild(fileref)
less.modifyVars(vars);
} }