X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=js%2F90-themes.js;h=6afd44448943594cea0a80416b42ea0495e8d420;hb=bdaa8919598cbbd8753fd6795b34b594b1b30805;hp=1e6fdceb66d996c31291974f5d44412a4abce126;hpb=8798626b0e96a4d1eb423f7f70ece78a2fcb4ae7;p=plack-app-gruntmaster.git diff --git a/js/90-themes.js b/js/90-themes.js index 1e6fdce..6afd444 100644 --- a/js/90-themes.js +++ b/js/90-themes.js @@ -1,15 +1,24 @@ (function(){ 'use strict'; function set_style(name){ - $('#stylesheet').attr("href", "/static/css/" + name + ".css"); + $('link[rel~="stylesheet"]').prop('disabled', true); + $('link[title="' + name + '"]').prop('disabled', false); localStorage.setItem("theme", name); } + var selector; + + function add_themelink(theme, text) { + var link = $('' + text + ''); + link.appendTo(selector.find('ul')).wrap('
  • ').on('click', function () { set_style(theme) }); + } + $( document ).ready(function() { - $('#theme-selector').detach().prependTo($('#sidebar')); - $('#theme_slate' ).on('click', function () { set_style("slate"); }); - $('#theme_cyborg' ).on('click', function () { set_style("cyborg"); }); - $('#theme_readable').on('click', function () { set_style("readable"); }); + selector = $('
    Themes:
    '); + add_themelink('cyborg', 'Black'); + add_themelink('slate', 'Grey'); + add_themelink('readable', 'White'); + $('#sidebar').prepend(selector); }); var theme = localStorage.getItem("theme");