Add a function for making a DOM element from HTML
[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 9$(function() {
81c2ef98
MG
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>';
7093e9ba 14 var sidebar = $('#sidebar')[0];
81c2ef98 15 sidebar.insertBefore(m(theme_ul), sidebar.firstChild);
7093e9ba
MG
16 $('#themes a').on('click', function(e){
17 set_style(this.dataset.theme);
7dc32473 18 });
7093e9ba 19});
7dc32473 20
7093e9ba
MG
21var theme = localStorage.getItem("theme");
22if(theme) {
23 if(theme == "cerulean" || theme == "cosmo")
24 theme = "readable";
25 set_style(theme);
26}
This page took 0.019171 seconds and 4 git commands to generate.