Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-1975 Theme Framework & GH-1972 Palm Theme #517

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Real fix
  • Loading branch information
zarembsky committed Mar 19, 2020
commit 60cfc917487f71fd5513b42f6e945a3f331ac3c3
@@ -218,37 +218,38 @@ export function setTheme(doc, name, account, reload = false) {
// First remove all other style elements which may be there
const styleList = doc.head.getElementsByTagName('link');
// Other kinds of loops are not supported equally across browsers
let themeStyle = null;
for (let i = 0; i < styleList.length; i++) {
const style = styleList[i];
if (style.title.startsWith(styleTitlePrefix)) {
doc.head.removeChild(style);
themeStyle = style;
}
}

console.log('setting theme...');
if (name !== 'default') {
console.log('name != default');
if (!account) { return; }
console.log('account is initialized', account);
const { themeData } = account;
if (!themeData) { return; }
console.log('themeData is initialized', themeData);
const { css } = themeData[name];

// Create element for the theme being set, if it is not there
const themeStyle = doc.createElement('link');
themeStyle.rel = 'stylesheet';
themeStyle.media = 'screen';
themeStyle.type = 'text/css';
themeStyle.title = `${styleTitlePrefix} ${name}`;

// Set content of style element to the theme text.
themeStyle.href = css;
doc.head.appendChild(themeStyle);

if( reload ) {
console.log("DOCUMENT RELOADED");
doc.location.reload();
if (!themeStyle) {
themeStyle = doc.createElement('link');
themeStyle.rel = 'stylesheet';
themeStyle.media = 'screen';
themeStyle.type = 'text/css';
themeStyle.title = `${styleTitlePrefix}`;
themeStyle.href = css;
doc.head.appendChild(themeStyle);
} else {
themeStyle.href = css;
}
} else {
for (let i = 0; i < styleList.length; i++) {
const style = styleList[i];
if (style.title.startsWith(styleTitlePrefix)) {
doc.head.removeChild(style);
}
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.