diff --git a/pos/static/js/config.js b/pos/static/js/config.js index e61ca6f..dbc1b2b 100644 --- a/pos/static/js/config.js +++ b/pos/static/js/config.js @@ -55,7 +55,7 @@ const Config = (() => { // ------------------------------------------------------------------------- // Theme switcher // ------------------------------------------------------------------------- - function setTheme(theme) { + /*function setTheme(theme) { document.documentElement.setAttribute('data-theme', theme); try { localStorage.setItem('pos_theme', theme); } catch(e) {} @@ -70,7 +70,22 @@ const Config = (() => { var opts = document.querySelectorAll('.theme-option'); if (opts[idx]) opts[idx].classList.add('is-selected'); } - window.setTheme = setTheme; + window.setTheme = setTheme;*/ + + function setTheme(theme) { + if (window.posSetTheme) window.posSetTheme(theme); + + document.querySelectorAll('.theme-btn').forEach(function(btn) { + btn.classList.toggle('is-active', btn.dataset.themeTarget === theme); + }); + + document.querySelectorAll('.theme-option').forEach(function(opt) { + opt.classList.remove('is-selected'); + }); + var idx = theme === 'industrial' ? 0 : 1; + var opts = document.querySelectorAll('.theme-option'); + if (opts[idx]) opts[idx].classList.add('is-selected'); + } function selectThemeOption(theme) { setTheme(theme); diff --git a/pos/static/js/dashboard.js b/pos/static/js/dashboard.js index 4309215..485c1f9 100644 --- a/pos/static/js/dashboard.js +++ b/pos/static/js/dashboard.js @@ -46,7 +46,7 @@ const Dashboard = (() => { // ------------------------------------------------------------------------- // Theme switcher // ------------------------------------------------------------------------- - function setTheme(theme) { + /*function setTheme(theme) { document.documentElement.setAttribute('data-theme', theme); try { localStorage.setItem('pos_theme', theme); } catch(e) {} const btnInd = document.getElementById('btn-industrial'); @@ -54,7 +54,15 @@ const Dashboard = (() => { if (btnInd) btnInd.classList.toggle('active', theme === 'industrial'); if (btnMod) btnMod.classList.toggle('active', theme === 'modern'); } - window.setTheme = setTheme; + window.setTheme = setTheme;*/ + + function setTheme(theme) { + if (window.posSetTheme) window.posSetTheme(theme); + const btnInd = document.getElementById('btn-industrial'); + const btnMod = document.getElementById('btn-modern'); + if (btnInd) btnInd.classList.toggle('active', theme === 'industrial'); + if (btnMod) btnMod.classList.toggle('active', theme === 'modern'); + } // ------------------------------------------------------------------------- // Sidebar toggle (mobile) diff --git a/pos/static/js/reports.js b/pos/static/js/reports.js index 4b9cf3e..66b7909 100644 --- a/pos/static/js/reports.js +++ b/pos/static/js/reports.js @@ -59,7 +59,7 @@ const Reports = (() => { // ------------------------------------------------------------------------- // Theme switcher // ------------------------------------------------------------------------- - function setTheme(theme) { + /* function setTheme(theme) { document.documentElement.setAttribute('data-theme', theme); try { localStorage.setItem('pos_theme', theme); } catch(e) {} var btnInd = document.getElementById('btn-industrial'); @@ -67,7 +67,15 @@ const Reports = (() => { if (btnInd) btnInd.classList.toggle('is-active', theme === 'industrial'); if (btnMod) btnMod.classList.toggle('is-active', theme === 'modern'); } - window.setTheme = setTheme; + window.setTheme = setTheme;*/ + + function setTheme(theme) { + if (window.posSetTheme) window.posSetTheme(theme); + var btnInd = document.getElementById('btn-industrial'); + var btnMod = document.getElementById('btn-modern'); + if (btnInd) btnInd.classList.toggle('is-active', theme === 'industrial'); + if (btnMod) btnMod.classList.toggle('is-active', theme === 'modern'); + } // ------------------------------------------------------------------------- // Tab switcher with lazy loading