]>
Commit | Line | Data |
---|---|---|
1 | function set_style(name){ | |
2 | $('link[rel~="stylesheet"]').each(function (e){ | |
3 | e.disabled = true; | |
4 | }); | |
5 | $('link[title="' + name + '"]')[0].disabled = false; | |
6 | localStorage.setItem("theme", name); | |
7 | } | |
8 | ||
9 | $(function() { | |
10 | var theme_ul = '<ul class="list-inline" id="themes">' + | |
11 | '<li><a role="button" data-theme="cyborg">Black</a>' + | |
12 | '<li><a role="button" data-theme="slate">Grey</a>' + | |
13 | '<li><a role="button" data-theme="readable">White</a></ul>'; | |
14 | var sidebar = $('#sidebar')[0]; | |
15 | sidebar.insertBefore(m(theme_ul), sidebar.firstChild); | |
16 | $('#themes a').on('click', function(e){ | |
17 | set_style(this.dataset.theme); | |
18 | }); | |
19 | }); | |
20 | ||
21 | var theme = localStorage.getItem("theme"); | |
22 | if(theme) { | |
23 | if(theme == "cerulean" || theme == "cosmo") | |
24 | theme = "readable"; | |
25 | set_style(theme); | |
26 | } |