summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-12-03 14:07:07 -0800
committerCorey Hulen <corey@hulen.com>2015-12-03 14:07:07 -0800
commit09746ce3a24b873d482e6c7779ecd004221450b0 (patch)
tree1a514de501eafc862c89d675ca3cc288f358c8b3 /web/react/utils
parente1d9f4b621f12e9f319355eac02bf3672754202c (diff)
parentea46790fd20f01be925e4ba62317b8bb691b79bb (diff)
downloadchat-09746ce3a24b873d482e6c7779ecd004221450b0.tar.gz
chat-09746ce3a24b873d482e6c7779ecd004221450b0.tar.bz2
chat-09746ce3a24b873d482e6c7779ecd004221450b0.zip
Merge pull request #1608 from hmhealey/safarifonts
Changed font changing code to use jquery to fix Safari weirdness
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/utils.jsx22
1 files changed, 13 insertions, 9 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 788d8a45c..0a52f5b37 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -695,15 +695,19 @@ export function applyTheme(theme) {
}
export function applyFont(fontName) {
- const body = document.querySelector('body');
- const keys = Object.getOwnPropertyNames(body.classList);
- keys.forEach((k) => {
- const className = body.classList[k];
- if (className && className.lastIndexOf('font') === 0) {
- body.classList.remove(className);
+ const body = $('body');
+
+ for (const key of Reflect.ownKeys(Constants.FONTS)) {
+ const className = Constants.FONTS[key];
+
+ if (fontName === key) {
+ if (!body.hasClass(className)) {
+ body.addClass(className);
+ }
+ } else {
+ body.removeClass(className);
}
- });
- body.classList.add(Constants.FONTS[fontName]);
+ }
}
export function changeCss(className, classValue, classRepeat) {
@@ -1238,4 +1242,4 @@ export function getPostTerm(post) {
export function isFeatureEnabled(feature) {
return PreferenceStore.getPreference(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, Constants.FeatureTogglePrefix + feature.label, {value: 'false'}).value === 'true';
-} \ No newline at end of file
+}