ui: name the theme-toggle handler instead of an inline IIFE
The theme toggle's onclick attribute held a 140-character inline IIFE that was hard to read amongst the other named-function handlers in the same header. Promoted it to cassandraToggleTheme() alongside cassandraSetTone / cassandraSetLang.
This commit is contained in:
parent
eedd32b885
commit
b13caa4c51
1 changed files with 8 additions and 1 deletions
|
|
@ -135,6 +135,13 @@
|
|||
});
|
||||
};
|
||||
|
||||
window.cassandraToggleTheme = function () {
|
||||
var d = document.documentElement;
|
||||
var t = d.dataset.theme === 'light' ? 'dark' : 'light';
|
||||
d.dataset.theme = t;
|
||||
try { localStorage.setItem('cassandra.theme', t); } catch (e) {}
|
||||
};
|
||||
|
||||
window.cassandraSetLang = async function (newLang) {
|
||||
var pill = document.getElementById('lang-toggle');
|
||||
if (!pill) return;
|
||||
|
|
@ -204,7 +211,7 @@
|
|||
onclick="cassandraSetTone('INTERMEDIATE')">Intermediate</button>
|
||||
</div>
|
||||
<button class="theme-toggle" type="button" aria-label="Toggle theme"
|
||||
onclick="(function(){var d=document.documentElement;var t=d.dataset.theme==='light'?'dark':'light';d.dataset.theme=t;try{localStorage.setItem('cassandra.theme',t);}catch(e){}})()">
|
||||
onclick="cassandraToggleTheme()">
|
||||
<span class="theme-toggle__label"></span>
|
||||
</button>
|
||||
{% set cu = request.state.current_user if request.state and request.state.current_user is defined else None %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue