load dark theme css on demand

pull/83/head
Thibault Duplessis 2013-06-03 13:33:29 +02:00
parent 1f65675fff
commit 5f8221c454
3 changed files with 10 additions and 10 deletions

View File

@ -7,7 +7,7 @@ import controllers.routes
trait AssetHelper {
val assetVersion = 29
val assetVersion = 30
def cssTag(name: String) = css("stylesheets/" + name)

View File

@ -13,7 +13,9 @@ moreJs: Html = Html(""))(body: Html)(implicit ctx: Context)
<html lang="@lang.language">
<head>
<title>@isProd.fold("lichess", "[dev]") @title • @trans.freeOnlineChess()</title>
@if(setting.bg == "dark") {
@cssTag("dark.css")
}
@cssTag("common.css")
@cssTag("board.css")
@moreCss

View File

@ -435,16 +435,14 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars
$('#top .themepicker').removeClass("shown");
});
// bgpicker
var bgs = ["light", "dark"];
var bg = $body.hasClass("dark") ? "dark" : "light";
function invertBg(bg) {
return bg == "dark" ? "light" : "dark";
}
$('#top a.bgpicker').click(function() {
bg = invertBg(bg);
$body.removeClass(bgs.join(' ')).addClass(bg);
var bg = $body.hasClass("dark") ? "light" : "dark";
$body.removeClass('light dark').addClass(bg);
if (bg == 'dark' && $('link[href*="dark\.css"]').length == 0) {
$('link[href*="common\.css"]').clone().each(function() {
$(this).attr('href', $(this).attr('href').replace(/common\.css/, 'dark.css')).appendTo('head');
});
}
$.post($(this).attr('href'), {
bg: bg
});