setting for users to disable board customcss

merge-requests/208/head
Thomas Lynch 4 years ago
parent 7823d6a891
commit b8da2ebbde
  1. 24
      gulp/res/js/theme.js
  2. 2
      views/includes/head.pug
  3. 4
      views/mixins/modal.pug

@ -1,4 +1,5 @@
let customCSSString = localStorage.getItem('customcss');
let disableBoardCss = localStorage.getItem('disableboardcss') == 'true';
window.addEventListener('settingsReady', function(event) {
@ -29,6 +30,16 @@ window.addEventListener('settingsReady', function(event) {
customCSSSetting.value = customCSSString;
customCSSSetting.addEventListener('input', editCustomCSS, false);
//for main theme
const disableBoardCssInput = document.getElementById('disableboardcss-setting');
disableBoardCssInput.addEventListener('change', () => {
disableBoardCss = !disableBoardCss;
setLocalStorage('disableboardcss', disableBoardCss);
console.log('toggling disable board custom css', disableBoardCss);
toggleBoardCss();
}, false);
disableBoardCssInput.checked = localStorage.getItem('disableboardcss') == 'true';
});
const customCSSLink = document.createElement('style');
@ -36,6 +47,19 @@ customCSSLink.rel = 'stylesheet';
customCSSLink.id = 'customcss';
document.head.appendChild(customCSSLink);
toggleBoardCss();
function toggleBoardCss() {
const boardCssLink = document.getElementById('board-customcss');
if (boardCssLink) {
if (disableBoardCss) {
boardCssLink.setAttribute('media', 'screen and (max-width: 1px)');
} else {
boardCssLink.removeAttribute('media');
}
}
}
function changeTheme(type) {
switch(type) {
case 'theme':

@ -13,7 +13,7 @@ link(rel='stylesheet' href=`/css/style.css?v=${commit}`)
- const codeTheme = isBoard ? board.settings.codeTheme : defaultCodeTheme;
link#theme(rel='stylesheet' data-theme=theme href=`/css/themes/${theme}.css`)
if isBoard && board.settings.customCss
style #{board.settings.customCss}
style#board-customcss #{board.settings.customCss}
link#codetheme(rel='stylesheet' data-theme=codeTheme href=`/css/codethemes/${codeTheme}.css`)
include ./favicon.pug
script(src=`/js/all.js?v=${commit}`)

@ -67,6 +67,10 @@ mixin modal(data)
label.postform-style.ph-5
input#hidepoststubs-setting(type='checkbox')
.rlabel Hide post stubs
.row
label.postform-style.ph-5
input#disableboardcss-setting(type='checkbox')
.rlabel Disable board custom CSS
.col
.row

Loading…
Cancel
Save