Merge pull request #775 from SISheogorath/feature/nightMode
Persist nightmode so we can re-enable it on reload
This commit is contained in:
commit
ea1d35eddb
1 changed files with 18 additions and 3 deletions
|
@ -16,6 +16,7 @@ import toMarkdown from 'to-markdown'
|
||||||
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import randomColor from 'randomcolor'
|
import randomColor from 'randomcolor'
|
||||||
|
import store from 'store'
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
|
||||||
|
@ -431,11 +432,12 @@ $(document).ready(function () {
|
||||||
clearMap()
|
clearMap()
|
||||||
}
|
}
|
||||||
checkEditorStyle()
|
checkEditorStyle()
|
||||||
|
|
||||||
|
/* cache dom references */
|
||||||
|
var $body = $('body')
|
||||||
|
|
||||||
/* we need this only on touch devices */
|
/* we need this only on touch devices */
|
||||||
if (isTouchDevice) {
|
if (isTouchDevice) {
|
||||||
/* cache dom references */
|
|
||||||
var $body = $('body')
|
|
||||||
|
|
||||||
/* bind events */
|
/* bind events */
|
||||||
$(document)
|
$(document)
|
||||||
.on('focus', 'textarea, input', function () {
|
.on('focus', 'textarea, input', function () {
|
||||||
|
@ -445,6 +447,12 @@ $(document).ready(function () {
|
||||||
$body.removeClass('fixfixed')
|
$body.removeClass('fixfixed')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-enable nightmode
|
||||||
|
if (store.get('nightMode') || Cookies.get('nightMode')) {
|
||||||
|
$body.addClass('night')
|
||||||
|
}
|
||||||
|
|
||||||
// showup
|
// showup
|
||||||
$().showUp('.navbar', {
|
$().showUp('.navbar', {
|
||||||
upClass: 'navbar-hide',
|
upClass: 'navbar-hide',
|
||||||
|
@ -1680,6 +1688,13 @@ function toggleNightMode () {
|
||||||
$body.addClass('night')
|
$body.addClass('night')
|
||||||
appState.nightMode = true
|
appState.nightMode = true
|
||||||
}
|
}
|
||||||
|
if (store.enabled) {
|
||||||
|
store.set('nightMode', !isActive)
|
||||||
|
} else {
|
||||||
|
Cookies.set('nightMode', !isActive, {
|
||||||
|
expires: 365
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function emitPermission (_permission) {
|
function emitPermission (_permission) {
|
||||||
if (_permission !== permission) {
|
if (_permission !== permission) {
|
||||||
|
|
Loading…
Reference in a new issue