demo.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. $(function () {
  2. skinChanger();
  3. activateNotificationAndTasksScroll();
  4. setSkinListHeightAndScroll(true);
  5. setSettingListHeightAndScroll(true);
  6. $(window).resize(function () {
  7. setSkinListHeightAndScroll(false);
  8. setSettingListHeightAndScroll(false);
  9. });
  10. });
  11. //Skin changer
  12. function skinChanger() {
  13. $('.right-sidebar .demo-choose-skin li').on('click', function () {
  14. var $body = $('body');
  15. var $this = $(this);
  16. var existTheme = $('.right-sidebar .demo-choose-skin li.active').data('theme');
  17. $('.right-sidebar .demo-choose-skin li').removeClass('active');
  18. $body.removeClass('theme-' + existTheme);
  19. $this.addClass('active');
  20. $body.addClass('theme-' + $this.data('theme'));
  21. });
  22. }
  23. //Skin tab content set height and show scroll
  24. function setSkinListHeightAndScroll(isFirstTime) {
  25. var height = $(window).height() - ($('.navbar').innerHeight() + $('.right-sidebar .nav-tabs').outerHeight());
  26. var $el = $('.demo-choose-skin');
  27. if (!isFirstTime){
  28. $el.slimScroll({ destroy: true }).height('auto');
  29. $el.parent().find('.slimScrollBar, .slimScrollRail').remove();
  30. }
  31. $el.slimscroll({
  32. height: height + 'px',
  33. color: 'rgba(0,0,0,0.5)',
  34. size: '6px',
  35. alwaysVisible: false,
  36. borderRadius: '0',
  37. railBorderRadius: '0'
  38. });
  39. }
  40. //Setting tab content set height and show scroll
  41. function setSettingListHeightAndScroll(isFirstTime) {
  42. var height = $(window).height() - ($('.navbar').innerHeight() + $('.right-sidebar .nav-tabs').outerHeight());
  43. var $el = $('.right-sidebar .demo-settings');
  44. if (!isFirstTime){
  45. $el.slimScroll({ destroy: true }).height('auto');
  46. $el.parent().find('.slimScrollBar, .slimScrollRail').remove();
  47. }
  48. $el.slimscroll({
  49. height: height + 'px',
  50. color: 'rgba(0,0,0,0.5)',
  51. size: '6px',
  52. alwaysVisible: false,
  53. borderRadius: '0',
  54. railBorderRadius: '0'
  55. });
  56. }
  57. //Activate notification and task dropdown on top right menu
  58. function activateNotificationAndTasksScroll() {
  59. $('.navbar-right .dropdown-menu .body .menu').slimscroll({
  60. height: '254px',
  61. color: 'rgba(0,0,0,0.5)',
  62. size: '4px',
  63. alwaysVisible: false,
  64. borderRadius: '0',
  65. railBorderRadius: '0'
  66. });
  67. }
  68. //Google Analiytics ======================================================================================
  69. addLoadEvent(loadTracking);
  70. var trackingId = 'UA-30038099-6';
  71. function addLoadEvent(func) {
  72. var oldonload = window.onload;
  73. if (typeof window.onload != 'function') {
  74. window.onload = func;
  75. } else {
  76. window.onload = function () {
  77. oldonload();
  78. func();
  79. }
  80. }
  81. }
  82. function loadTracking() {
  83. (function (i, s, o, g, r, a, m) {
  84. i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
  85. (i[r].q = i[r].q || []).push(arguments)
  86. }, i[r].l = 1 * new Date(); a = s.createElement(o),
  87. m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
  88. })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
  89. ga('create', trackingId, 'auto');
  90. ga('send', 'pageview');
  91. }
  92. //========================================================================================================