]> iEval git - gruntmaster-page.git/blob - js/90-themes.js
a61b4c0c0089983ff69f06341667ceb9f6d57e15
[gruntmaster-page.git] / js / 90-themes.js
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 var theme_ul;
10
11 function add_themelink(theme, text) {
12 theme_ul.innerHTML += '<li><a role="button" data-theme="' + theme + '">' + text + '</a>'
13 }
14
15 $(function() {
16 theme_ul = document.createElement('ul');
17 theme_ul.className = 'list-inline';
18 theme_ul.id = 'themes';
19 add_themelink('cyborg', 'Black');
20 add_themelink('slate', 'Grey');
21 add_themelink('readable', 'White');
22 var sidebar = $('#sidebar')[0];
23 sidebar.insertBefore(theme_ul, sidebar.firstChild);
24 $('#themes a').on('click', function(e){
25 set_style(this.dataset.theme);
26 });
27 });
28
29 var theme = localStorage.getItem("theme");
30 if(theme) {
31 if(theme == "cerulean" || theme == "cosmo")
32 theme = "readable";
33 set_style(theme);
34 }
This page took 0.05368 seconds and 3 git commands to generate.