support concept of default theme
parent
c6f75fbf37
commit
6fa2d35630
|
@ -7,6 +7,7 @@
|
||||||
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
|
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
|
||||||
"enableLabs": true,
|
"enableLabs": true,
|
||||||
"default_federate": true,
|
"default_federate": true,
|
||||||
|
"default_theme": "light",
|
||||||
"roomDirectory": {
|
"roomDirectory": {
|
||||||
"servers": [
|
"servers": [
|
||||||
"matrix.org"
|
"matrix.org"
|
||||||
|
|
|
@ -25,9 +25,8 @@
|
||||||
var match = file.match(/^bundles\/.*?\/theme-(.*)\.css$/);
|
var match = file.match(/^bundles\/.*?\/theme-(.*)\.css$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
var title = match[1].charAt(0).toUpperCase() + match[1].slice(1);
|
var title = match[1].charAt(0).toUpperCase() + match[1].slice(1);
|
||||||
var light = match[1] == 'light';
|
|
||||||
%>
|
%>
|
||||||
<link rel="<%= light ? '' : 'alternate ' %>stylesheet" title="<%= title %>"
|
<link rel="alternate stylesheet" title="<%= title %>"
|
||||||
href="<%= file %>">
|
href="<%= file %>">
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<link rel="stylesheet" href="<%= file %>">
|
<link rel="stylesheet" href="<%= file %>">
|
||||||
|
|
|
@ -281,6 +281,23 @@ async function loadApp() {
|
||||||
configError = e;
|
configError = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// as quickly as we possibly can, set a default theme...
|
||||||
|
const styleElements = Object.create(null);
|
||||||
|
let a;
|
||||||
|
for (let i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
|
||||||
|
const href = a.getAttribute("href");
|
||||||
|
// shouldn't we be using the 'title' tag rather than the href?
|
||||||
|
const match = href.match(/^bundles\/.*\/theme-(.*)\.css$/);
|
||||||
|
if (match) {
|
||||||
|
if (match[1] === (configJson.default_theme || 'light')) {
|
||||||
|
// remove the alternative flag off the stylesheet
|
||||||
|
a.setAttribute("rel", "stylesheet");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// XXX: do we also need to call MatrixChat.setTheme here to do any random fixups (e.g. svg tint)
|
||||||
|
|
||||||
|
|
||||||
if (window.localStorage && window.localStorage.getItem('mx_accepts_unsupported_browser')) {
|
if (window.localStorage && window.localStorage.getItem('mx_accepts_unsupported_browser')) {
|
||||||
console.log('User has previously accepted risks in using an unsupported browser');
|
console.log('User has previously accepted risks in using an unsupported browser');
|
||||||
validBrowser = true;
|
validBrowser = true;
|
||||||
|
|
Loading…
Reference in New Issue