jQuery.style.switcher.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Theme color settings
  2. $(document).ready(function(){
  3. function store(name, val) {
  4. if (typeof (Storage) !== "undefined") {
  5. localStorage.setItem(name, val);
  6. } else {
  7. window.alert('Please use a modern browser to properly view this template!');
  8. }
  9. }
  10. $("*[data-theme]").click(function(e){
  11. e.preventDefault();
  12. var currentStyle = $(this).attr('data-theme');
  13. store('theme', currentStyle);
  14. $('#theme').attr({href: 'css/colors/'+currentStyle+'.css'})
  15. });
  16. var currentTheme = get('theme');
  17. if(currentTheme)
  18. {
  19. $('#theme').attr({href: 'css/colors/'+currentTheme+'.css'});
  20. }
  21. // color selector
  22. $('#themecolors').on('click', 'a', function(){
  23. $('#themecolors li a').removeClass('working');
  24. $(this).addClass('working')
  25. });
  26. });
  27. function get(name) {
  28. }
  29. $(document).ready(function(){
  30. $("*[data-theme]").click(function(e){
  31. e.preventDefault();
  32. var currentStyle = $(this).attr('data-theme');
  33. store('theme', currentStyle);
  34. $('#theme').attr({href: 'css/colors/'+currentStyle+'.css'})
  35. });
  36. var currentTheme = get('theme');
  37. if(currentTheme)
  38. {
  39. $('#theme').attr({href: 'css/colors/'+currentTheme+'.css'});
  40. }
  41. // color selector
  42. $('#themecolors').on('click', 'a', function(){
  43. $('#themecolors li a').removeClass('working');
  44. $(this).addClass('working')
  45. });
  46. });