X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=js%2F90-themes.js;h=0b043b8e393adc21146c4a698286f441ea499f98;hb=911c62b8bdc652e0d33d33cd366905acdcb93290;hp=74506c83b98ba7e951d92a5749955c4f1a3d1ec5;hpb=bcf95b418334059308214ea1c1546536c2ebf545;p=gruntmaster-page.git diff --git a/js/90-themes.js b/js/90-themes.js index 74506c8..0b043b8 100644 --- a/js/90-themes.js +++ b/js/90-themes.js @@ -1,20 +1,36 @@ (function(){ 'use strict'; function set_style(name){ - $('#stylesheet').attr("href", "/css/" + name + ".css"); + $('link[rel~="stylesheet"]').prop('disabled', true); + $('link[title="' + name + '"]').prop('disabled', false); localStorage.setItem("theme", name); + $(document).ready(function() { + if(name == 'slate' || name == 'cyborg') + $('.logo').removeClass('logo-light'); + else + $('.logo').addClass('logo-light'); + }); + } + + 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').removeClass('hidden'); - $('#theme_slate' ).on('click', function () { set_style("slate"); }); - $('#theme_cerulean').on('click', function () { set_style("cerulean"); }); - $('#theme_cyborg' ).on('click', function () { set_style("cyborg"); }); - $('#theme_cosmo' ).on('click', function () { set_style("cosmo"); }); + selector = $('
    Themes:
    '); + add_themelink('cyborg', 'Black'); + add_themelink('slate', 'Grey'); + add_themelink('readable', 'White'); + $('#sidebar').prepend(selector); }); var theme = localStorage.getItem("theme"); if(theme) { + if(theme == "cerulean" || theme == "cosmo") + theme = "readable"; set_style(theme); } })();