diff options
author | enahum <nahumhbl@gmail.com> | 2016-11-29 12:16:21 -0300 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-11-29 10:16:21 -0500 |
commit | 58215e573fec44fe9cadf09909b44007ef5c18e6 (patch) | |
tree | fad877d3513c3a5c26d1ee6638a30379919ce9d5 /webapp/utils | |
parent | 702c4cb12146d4b3d18807d56e013da3aed15836 (diff) | |
download | chat-58215e573fec44fe9cadf09909b44007ef5c18e6.tar.gz chat-58215e573fec44fe9cadf09909b44007ef5c18e6.tar.bz2 chat-58215e573fec44fe9cadf09909b44007ef5c18e6.zip |
Fix Theme in safari (#4668)
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/utils.jsx | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index 5c2823f41..b6d3b076f 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -687,18 +687,25 @@ export function applyFont(fontName) { } export function changeCss(className, classValue) { - let styleEl = document.querySelector('style[data-class="' + className + classValue + '"]'); + let styleEl = document.querySelector('style[data-class="' + className + '"]'); if (!styleEl) { styleEl = document.createElement('style'); styleEl.setAttribute('data-class', className); - } - // Append style element to head - document.head.appendChild(styleEl); + // Append style element to head + document.head.appendChild(styleEl); + } // Grab style sheet - var styleSheet = styleEl.sheet; - styleSheet.insertRule(className + '{' + classValue + '}', styleSheet.cssRules.length); + const styleSheet = styleEl.sheet; + let mediaQuery = ''; + if (className.indexOf('@media') >= 0) { + mediaQuery = '}'; + } + if (styleSheet.cssRules.length > 0) { + styleSheet.deleteRule(0); + } + styleSheet.insertRule(className + '{' + classValue + '}' + mediaQuery, 0); } export function updateCodeTheme(userTheme) { |