diff --git a/gulp/res/js/theme.js b/gulp/res/js/theme.js index b58cc60d..9d181ea0 100644 --- a/gulp/res/js/theme.js +++ b/gulp/res/js/theme.js @@ -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': diff --git a/views/includes/head.pug b/views/includes/head.pug index 2396a537..0179335f 100644 --- a/views/includes/head.pug +++ b/views/includes/head.pug @@ -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}`) diff --git a/views/mixins/modal.pug b/views/mixins/modal.pug index 6f0c2f0b..5d7a3270 100644 --- a/views/mixins/modal.pug +++ b/views/mixins/modal.pug @@ -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