diff options
Diffstat (limited to 'web/react/utils')
-rw-r--r-- | web/react/utils/constants.jsx | 1 | ||||
-rw-r--r-- | web/react/utils/emoticons.jsx | 8 | ||||
-rw-r--r-- | web/react/utils/utils.jsx | 22 |
3 files changed, 18 insertions, 13 deletions
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx index 8164095b9..b641e966b 100644 --- a/web/react/utils/constants.jsx +++ b/web/react/utils/constants.jsx @@ -55,6 +55,7 @@ export default { SUGGESTION_PRETEXT_CHANGED: null, SUGGESTION_RECEIVED_SUGGESTIONS: null, + SUGGESTION_CLEAR_SUGGESTIONS: null, SUGGESTION_COMPLETE_WORD: null, SUGGESTION_SELECT_NEXT: null, SUGGESTION_SELECT_PREVIOUS: null diff --git a/web/react/utils/emoticons.jsx b/web/react/utils/emoticons.jsx index 8943e9544..ab04936c0 100644 --- a/web/react/utils/emoticons.jsx +++ b/web/react/utils/emoticons.jsx @@ -116,19 +116,19 @@ function initializeEmoticonMap() { const out = new Map(); for (let i = 0; i < emoticonNames.length; i++) { - out[emoticonNames[i]] = true; + out.set(emoticonNames[i], true); } return out; } -const emoticonMap = initializeEmoticonMap(); +export const emoticonMap = initializeEmoticonMap(); export function handleEmoticons(text, tokens) { let output = text; function replaceEmoticonWithToken(fullMatch, prefix, matchText, name) { - if (emoticonMap[name]) { + if (emoticonMap.has(name)) { const index = tokens.size; const alias = `MM_EMOTICON${index}`; @@ -159,4 +159,4 @@ export function getImagePathForEmoticon(name) { return `/static/images/emoji/${name}.png`; } return `/static/images/emoji`; -}
\ No newline at end of file +} 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 +} |