From 2d3c2c11bbef02d4d02f363458cd1961716a5b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 21 Mar 2015 12:45:32 +0100 Subject: [PATCH] Load theme without angular to reduce flicker Initialising with dark theme prevents flicker --- index.html | 2 +- js/glowingbear.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 2984351..03aa1f2 100644 --- a/index.html +++ b/index.html @@ -14,6 +14,7 @@ + @@ -38,7 +39,6 @@ -

logo diff --git a/js/glowingbear.js b/js/glowingbear.js index 05b27a4..5e8817c 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -418,6 +418,27 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }); + + // Inject theme CSS + settings.addCallback('theme', function(theme) { + // Unload old theme + var oldThemeCSS = document.getElementById("themeCSS"); + if (oldThemeCSS) { + oldThemeCSS.parentNode.removeChild(oldThemeCSS); + } + + // Load new theme + (function() { + var elem = document.createElement("link"); + elem.rel = "stylesheet"; + elem.href = "css/themes/" + theme + ".css"; + elem.media = "screen"; + elem.id = "themeCSS"; + document.getElementsByTagName("head")[0].appendChild(elem); + })(); + }); + + // Update font family when changed settings.addCallback('fontfamily', function(fontfamily) { utils.changeClassStyle('favorite-font', 'fontFamily', fontfamily);