From d117a582df4dbbc8d18be3086571cf659a1f9259 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Sun, 19 Jan 2014 22:28:03 +0100 Subject: [PATCH] stylig bug fixed --- resources/public/js/themes.js | 60 ++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/resources/public/js/themes.js b/resources/public/js/themes.js index fc66f41..60be4e4 100644 --- a/resources/public/js/themes.js +++ b/resources/public/js/themes.js @@ -62,43 +62,45 @@ var themes = { }; function applyTheme() { + var ui = { theme: "default" }; if (location.search.length > 0) { - var ui = { theme: "default" }; location.search.slice(1).split("&").reduce(function(acc, e){ var p = e.split("="); acc[p[0]] = p[1]; return acc }, 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 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 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; - }, ""); + var fontURL = "http://fonts.googleapis.com/" + + "css?family=PT+Serif:700|Noticia+Text:700%s" + + "&subset=latin,cyrillic", + injection = ""; - 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); + 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); } \ No newline at end of file