Replace Zepto with ki.js, rewrite all JS
[plack-app-gruntmaster.git] / js / 90-themes.js
CommitLineData
7093e9ba
MG
1function 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}
7dc32473 8
7093e9ba 9var theme_ul;
bdaa8919 10
7093e9ba
MG
11function add_themelink(theme, text) {
12 theme_ul.innerHTML += '<li><a role="button" data-theme="' + theme + '">' + text + '</a>'
13}
bdaa8919 14
7093e9ba
MG
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);
7dc32473 26 });
7093e9ba 27});
7dc32473 28
7093e9ba
MG
29var theme = localStorage.getItem("theme");
30if(theme) {
31 if(theme == "cerulean" || theme == "cosmo")
32 theme = "readable";
33 set_style(theme);
34}
This page took 0.019576 seconds and 4 git commands to generate.