]>
Commit | Line | Data |
---|---|---|
c7a5e4e0 MG |
1 | (function(){ |
2 | 'use strict'; | |
3 | function set_style(name){ | |
d53c616a MG |
4 | $('link[rel~="stylesheet"]').prop('disabled', true); |
5 | $('link[title="' + name + '"]').prop('disabled', false); | |
c7a5e4e0 | 6 | localStorage.setItem("theme", name); |
59731c89 MG |
7 | $(document).ready(function() { |
8 | if(name == 'slate' || name == 'cyborg') | |
9 | $('.logo').removeClass('logo-light'); | |
10 | else | |
11 | $('.logo').addClass('logo-light'); | |
12 | }); | |
c7a5e4e0 | 13 | } |
7dc32473 | 14 | |
bdaa8919 MG |
15 | var selector; |
16 | ||
17 | function add_themelink(theme, text) { | |
18 | var link = $('<a role="button">' + text + '</a>'); | |
19 | link.appendTo(selector.find('ul')).wrap('<li>').on('click', function () { set_style(theme) }); | |
20 | } | |
21 | ||
c7a5e4e0 | 22 | $( document ).ready(function() { |
bdaa8919 MG |
23 | selector = $('<div>Themes: <ul class="list-inline"></ul></div>'); |
24 | add_themelink('cyborg', 'Black'); | |
25 | add_themelink('slate', 'Grey'); | |
26 | add_themelink('readable', 'White'); | |
27 | $('#sidebar').prepend(selector); | |
7dc32473 MG |
28 | }); |
29 | ||
c7a5e4e0 MG |
30 | var theme = localStorage.getItem("theme"); |
31 | if(theme) { | |
a96f684c MG |
32 | if(theme == "cerulean" || theme == "cosmo") |
33 | theme = "readable"; | |
c7a5e4e0 MG |
34 | set_style(theme); |
35 | } | |
36 | })(); |