X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=js%2F90-themes.js;h=756b15612991212da6c750ff7d7ad00655861ba5;hb=35fc050c68c786aea19320eafc99e923c523a8f3;hp=1e6fdceb66d996c31291974f5d44412a4abce126;hpb=8798626b0e96a4d1eb423f7f70ece78a2fcb4ae7;p=gruntmaster-page.git diff --git a/js/90-themes.js b/js/90-themes.js index 1e6fdce..756b156 100644 --- a/js/90-themes.js +++ b/js/90-themes.js @@ -1,21 +1,28 @@ -(function(){ - 'use strict'; - function set_style(name){ - $('#stylesheet').attr("href", "/static/css/" + name + ".css"); - localStorage.setItem("theme", name); - } - - $( 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"); }); +function set_style(name){ + $('link[title]').each(e => e.disabled = true); + $('link[title="' + name + '"]')[0].disabled = false; + localStorage.setItem("theme", name); + $(function() { + if(name == 'slate' || name == 'cyborg') + $('.logo').each(e => e.classList.remove('logo-light')); + else + $('.logo').each(e => e.classList.add('logo-light')); }); +} + +$(function() { + var theme_ul = ''; + var sidebar = $('#sidebar')[0]; + sidebar.insertBefore(m(theme_ul), sidebar.firstChild); + $('#themes a').on('click', e => set_style(e.target.dataset.theme)); +}); - var theme = localStorage.getItem("theme"); - if(theme) { - if(theme == "cerulean" || theme == "cosmo") - theme = "readable"; - set_style(theme); - } -})(); +let theme = localStorage.getItem("theme"); +if(theme) { + if(theme == "cerulean" || theme == "cosmo") + theme = "readable"; + set_style(theme); +}