X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=js%2F90-themes.js;h=c87291949e978a5af15fba9207b7ed72e104a09a;hb=8345760abf4953980a85e0d5f9cade421f73d4ff;hp=74506c83b98ba7e951d92a5749955c4f1a3d1ec5;hpb=bcf95b418334059308214ea1c1546536c2ebf545;p=plack-app-gruntmaster.git diff --git a/js/90-themes.js b/js/90-themes.js index 74506c8..c872919 100644 --- a/js/90-themes.js +++ b/js/90-themes.js @@ -1,20 +1,22 @@ -(function(){ - 'use strict'; - function set_style(name){ - $('#stylesheet').attr("href", "/css/" + name + ".css"); - localStorage.setItem("theme", name); - } +function set_style(name){ + $('link[rel~="stylesheet"]').each(e => e.disabled = true); + $('link[title="' + name + '"]')[0].disabled = false; + localStorage.setItem("theme", name); +} - $( 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"); }); - }); +$(function() { + var theme_ul = ''; + var sidebar = $('#sidebar')[0]; + sidebar.insertBefore(m(theme_ul), sidebar.firstChild); + $('#themes a').on('click', e => set_style(this.dataset.theme)); +}); - var theme = localStorage.getItem("theme"); - if(theme) { - set_style(theme); - } -})(); +let theme = localStorage.getItem("theme"); +if(theme) { + if(theme == "cerulean" || theme == "cosmo") + theme = "readable"; + set_style(theme); +}