fonts are loadedsynchronously now
This commit is contained in:
@@ -14,7 +14,6 @@ function md2html(input){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
applyTheme();
|
|
||||||
$note = $("note");
|
$note = $("note");
|
||||||
$action = $("action");
|
$action = $("action");
|
||||||
$preview = $("preview");
|
$preview = $("preview");
|
||||||
|
|||||||
@@ -61,17 +61,17 @@ var themes = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function applyTheme() {
|
|
||||||
var ui = { theme: "default" };
|
var ui = { theme: "default" };
|
||||||
if (location.search.length > 0) {
|
if (location.search.length > 0) {
|
||||||
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 = {
|
var vars = {
|
||||||
'@background': themes[ui.theme].background.normal,
|
'@background': themes[ui.theme].background.normal,
|
||||||
'@background_halftone': themes[ui.theme].background.halftone,
|
'@background_halftone': themes[ui.theme].background.halftone,
|
||||||
'@foreground': themes[ui.theme].foreground.normal,
|
'@foreground': themes[ui.theme].foreground.normal,
|
||||||
@@ -79,28 +79,27 @@ function applyTheme() {
|
|||||||
'@link_fresh': themes[ui.theme].link.fresh,
|
'@link_fresh': themes[ui.theme].link.fresh,
|
||||||
'@link_visited': themes[ui.theme].link.visited,
|
'@link_visited': themes[ui.theme].link.visited,
|
||||||
'@link_hover': themes[ui.theme].link.hover
|
'@link_hover': themes[ui.theme].link.hover
|
||||||
};
|
};
|
||||||
|
|
||||||
var fontURL = "http://fonts.googleapis.com/" +
|
var fontURL = "http://fonts.googleapis.com/" +
|
||||||
"css?family=PT+Serif:700|Noticia+Text:700%s" +
|
"css?family=PT+Serif:700|Noticia+Text:700%s" +
|
||||||
"&subset=latin,cyrillic",
|
"&subset=latin,cyrillic",
|
||||||
injection = "";
|
injection = "";
|
||||||
|
|
||||||
if(ui["header-font"] || ui["text-font"]) {
|
if(ui["header-font"] || ui["text-font"]) {
|
||||||
injection = ["header-font", "text-font"].reduce(function(acc, font){
|
injection = ["header-font", "text-font"].reduce(function(acc, font){
|
||||||
if(ui[font]) {
|
if(ui[font]) {
|
||||||
vars['@' + font.replace(/-/, "_")] = ui[font].replace(/\+/g," ");
|
vars['@' + font.replace(/-/, "_")] = ui[font].replace(/\+/g," ");
|
||||||
return acc + "|" + ui[font];
|
return acc + "|" + ui[font];
|
||||||
} else return acc;
|
} 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
@@ -32,10 +32,10 @@
|
|||||||
[:link {:rel "stylesheet/less" :type "text/css" :href "/style.less"}]
|
[:link {:rel "stylesheet/less" :type "text/css" :href "/style.less"}]
|
||||||
(html
|
(html
|
||||||
(include-js "/js/less.js")
|
(include-js "/js/less.js")
|
||||||
|
(include-js "/js/themes.js")
|
||||||
(include-js "/js/md5.js")
|
(include-js "/js/md5.js")
|
||||||
(include-js "/js/marked.js")
|
(include-js "/js/marked.js")
|
||||||
(include-js "/js/main.js")
|
(include-js "/js/main.js"))
|
||||||
(include-js "/js/themes.js"))
|
|
||||||
; google analytics code should appear in prod mode only
|
; google analytics code should appear in prod mode only
|
||||||
(if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))]
|
(if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))]
|
||||||
[:body {:onload "onLoad()"} content]))
|
[:body {:onload "onLoad()"} content]))
|
||||||
|
|||||||
Reference in New Issue
Block a user