diff options
author | Christoph (Sheogorath) Kern | 2018-03-24 14:35:48 +0100 |
---|---|---|
committer | GitHub | 2018-03-24 14:35:48 +0100 |
commit | ea1d35eddb12815f0d28b4531d6671ed8a1a4e23 (patch) | |
tree | 12e5d1e1c5654f411a3c6e96e844144cf7e951fa /public | |
parent | fa4a8418afc57a45f71471ca7fd1adcd4d8d4cd4 (diff) | |
parent | 32c578db083bf92a145728049343319990169726 (diff) |
Merge pull request #775 from SISheogorath/feature/nightMode
Persist nightmode so we can re-enable it on reload
Diffstat (limited to '')
-rw-r--r-- | public/js/index.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/public/js/index.js b/public/js/index.js index 096f7fde..68fb2614 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -16,6 +16,7 @@ import toMarkdown from 'to-markdown' import { saveAs } from 'file-saver' import randomColor from 'randomcolor' +import store from 'store' import _ from 'lodash' @@ -431,11 +432,12 @@ $(document).ready(function () { clearMap() } checkEditorStyle() + + /* cache dom references */ + var $body = $('body') + /* we need this only on touch devices */ if (isTouchDevice) { - /* cache dom references */ - var $body = $('body') - /* bind events */ $(document) .on('focus', 'textarea, input', function () { @@ -445,6 +447,12 @@ $(document).ready(function () { $body.removeClass('fixfixed') }) } + + // Re-enable nightmode + if (store.get('nightMode') || Cookies.get('nightMode')) { + $body.addClass('night') + } + // showup $().showUp('.navbar', { upClass: 'navbar-hide', @@ -1680,6 +1688,13 @@ function toggleNightMode () { $body.addClass('night') appState.nightMode = true } + if (store.enabled) { + store.set('nightMode', !isActive) + } else { + Cookies.set('nightMode', !isActive, { + expires: 365 + }) + } } function emitPermission (_permission) { if (_permission !== permission) { |