Merge pull request #593 from Xaekai/themesanity

Default theme reference refactor
This commit is contained in:
Calvin Montgomery 2016-07-10 20:46:33 -07:00 committed by GitHub
commit 44cc6336b9
5 changed files with 15 additions and 9 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.18.3",
"version": "3.18.4",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -1,3 +1,5 @@
- var DEFAULT_THEME = "/css/themes/slate.css";
mixin head()
meta(charset="utf-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
@ -7,7 +9,10 @@ mixin head()
title= siteTitle
link(href="/css/sticky-footer-navbar.css", rel="stylesheet")
link(href="/css/cytube.css", rel="stylesheet")
link(id="usertheme", href="/css/themes/slate.css", rel="stylesheet")
link(id="usertheme", href=DEFAULT_THEME, rel="stylesheet")
script(type="text/javascript").
var DEFAULT_THEME = '#{DEFAULT_THEME}';
script(src="/js/theme.js")
//[if lt IE 9]
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>

View File

@ -97,7 +97,7 @@ function getOrDefault(k, def) {
}
var USEROPTS = {
theme : getOrDefault("theme", "/css/themes/slate.css"),
theme : getOrDefault("theme", DEFAULT_THEME), // Set in head template
layout : getOrDefault("layout", "fluid"),
synch : getOrDefault("synch", true),
hidevid : getOrDefault("hidevid", false),
@ -204,9 +204,9 @@ function eraseCookie(name) {
(function () {
var localVersion = parseFloat(getOpt("version"));
if (isNaN(localVersion)) {
USEROPTS.theme = "/css/themes/slate.css";
USEROPTS.theme = DEFAULT_THEME;
USEROPTS.layout = "fluid";
setOpt("theme", "/css/themes/slate.css");
setOpt("theme", DEFAULT_THEME);
setOpt("layout", "fluid");
setOpt("version", CL_VERSION);
}

View File

@ -3,7 +3,8 @@
return s.trim();
});
var theme = "/css/themes/slate.css";
// Set in the head template.
var theme = DEFAULT_THEME;
for (var i = 0; i < c.length; i++) {
if (c[i].indexOf("cytube-theme=") === 0) {
theme = c[i].split("=")[1];
@ -15,8 +16,8 @@
return;
}
if (theme !== "/css/themes/slate.css") {
console.log("THEME COOKIE:", theme);
if (theme !== DEFAULT_THEME) {
console.info("THEME COOKIE:", theme);
var cur = document.getElementById("usertheme");
cur.parentNode.removeChild(cur);
var css = document.createElement("link");

View File

@ -696,7 +696,7 @@ function applyOpts() {
var old = $("#usertheme").attr("id", "usertheme_old");
var theme = USEROPTS.theme;
if (theme === "default") {
theme = "/css/themes/slate.css";
theme = DEFAULT_THEME;
}
$("<link/>").attr("rel", "stylesheet")
.attr("type", "text/css")