themeswitcher.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* Admin layout options */
  2. $(document).on('ready', function() {
  3. $('#theme-switcher-wrapper .switch-toggle').on('click', this, function() {
  4. var dataToggle = $(this).prev().attr('data-toggletarget');
  5. $('body').toggleClass(dataToggle);
  6. if ( dataToggle = 'closed-sidebar' ) {
  7. $('#close-sidebar .glyph-icon').toggleClass('icon-angle-right').toggleClass('icon-angle-left');
  8. }
  9. });
  10. $('.switch-toggle[id="#boxed-layout"]').click(function(){
  11. if ( $('#boxed-layout').attr("checked") ) {
  12. $('.boxed-bg-wrapper').slideDown();
  13. } else {
  14. $('.boxed-bg-wrapper').slideUp();
  15. }
  16. });
  17. });
  18. /* Open theme switcher */
  19. $(function() {
  20. $(".theme-switcher").click(function() {
  21. $("#theme-options").toggleClass('active');
  22. });
  23. });
  24. /* Admin header style */
  25. $(function() {
  26. $('.set-adminheader-style').click(function() {
  27. $('.set-adminheader-style').removeClass('active');
  28. $(this).addClass('active');
  29. var newBg = $(this).attr('data-header-bg');
  30. $("#page-header").removeClass(function(index, css) {
  31. return (css.match(/(^|\s)bg-\S+/g) || []).join(' ');
  32. });
  33. $("#page-header").removeClass(function(index, css) {
  34. return (css.match(/(^|\s)font-\S+/g) || []).join(' ');
  35. });
  36. $('#page-header').addClass(newBg);
  37. });
  38. });
  39. /* Admin sidebar style */
  40. $(function() {
  41. $('.set-sidebar-style').click(function() {
  42. $('.set-sidebar-style').removeClass('active');
  43. $(this).addClass('active');
  44. var newBg = $(this).attr('data-header-bg');
  45. $("#page-sidebar").removeClass(function(index, css) {
  46. return (css.match(/(^|\s)bg-\S+/g) || []).join(' ');
  47. });
  48. $("#page-sidebar").removeClass(function(index, css) {
  49. return (css.match(/(^|\s)font-\S+/g) || []).join(' ');
  50. });
  51. $('#page-sidebar').addClass(newBg);
  52. });
  53. });
  54. /* Boxed layout background style */
  55. $(function() {
  56. $('.set-background-style').click(function() {
  57. $('.set-background-style').removeClass('active');
  58. $(this).addClass('active');
  59. var newBg = $(this).attr('data-header-bg');
  60. $("body").removeClass(function(index, css) {
  61. return (css.match(/(^|\s)pattern-\S+/g) || []).join(' ');
  62. });
  63. $("body").removeClass(function(index, css) {
  64. return (css.match(/(^|\s)full-\S+/g) || []).join(' ');
  65. });
  66. $("body").removeClass(function(index, css) {
  67. return (css.match(/(^|\s)bg-\S+/g) || []).join(' ');
  68. });
  69. $("body").removeClass(function(index, css) {
  70. return (css.match(/(^|\s)fixed-\S+/g) || []).join(' ');
  71. });
  72. $('body').addClass(newBg);
  73. });
  74. });
  75. /* Frontend header style */
  76. $(function() {
  77. $('.set-header-style').click(function() {
  78. $('.set-header-style').removeClass('active');
  79. $(this).addClass('active');
  80. var newBg = $(this).attr('data-header-bg');
  81. $(".main-header").removeClass(function(index, css) {
  82. return (css.match(/(^|\s)bg-\S+/g) || []).join(' ');
  83. });
  84. $(".main-header").removeClass(function(index, css) {
  85. return (css.match(/(^|\s)font-\S+/g) || []).join(' ');
  86. });
  87. $('.main-header').addClass(newBg);
  88. });
  89. });
  90. /* Frontend footer style */
  91. $(function() {
  92. $('.set-footer-style').click(function() {
  93. $('.set-footer-style').removeClass('active');
  94. $(this).addClass('active');
  95. var newBg = $(this).attr('data-header-bg');
  96. $(".main-footer").removeClass(function(index, css) {
  97. return (css.match(/(^|\s)bg-\S+/g) || []).join(' ');
  98. });
  99. $(".main-footer").removeClass(function(index, css) {
  100. return (css.match(/(^|\s)font-\S+/g) || []).join(' ');
  101. });
  102. $('.main-footer').addClass(newBg);
  103. });
  104. });
  105. /* Frontend top menu style */
  106. $(function() {
  107. $('.set-topmenu-style').click(function() {
  108. $('.set-topmenu-style').removeClass('active');
  109. $(this).addClass('active');
  110. var newBg = $(this).attr('data-header-bg');
  111. $(".top-bar").removeClass(function(index, css) {
  112. return (css.match(/(^|\s)bg-\S+/g) || []).join(' ');
  113. });
  114. $(".top-bar").removeClass(function(index, css) {
  115. return (css.match(/(^|\s)font-\S+/g) || []).join(' ');
  116. });
  117. $('.top-bar').addClass(newBg);
  118. });
  119. });
  120. /* Theme styler scroll */
  121. $(function() {
  122. $('.scroll-switcher').slimscroll({
  123. height: '100%',
  124. color: 'rgba(0,0,0,0.3)',
  125. size: '10px',
  126. alwaysVisible: true
  127. });
  128. //
  129. //$(".scroll-switcher").slimScroll({
  130. // destroy: true
  131. //});
  132. });
  133. function swither_resizer() {
  134. var windowHeight = $(window).height();
  135. $('#theme-switcher-wrapper').height(windowHeight / 1.4);
  136. }
  137. $(document).on('ready', function() {
  138. swither_resizer();
  139. });
  140. $(window).on('resize', function() {
  141. swither_resizer();
  142. });