layout.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. $(document).ready(function() {
  2. body_sizer();
  3. $("div[id='#fixed-sidebar']").on('click', function() {
  4. if ($(this).hasClass("switch-on")) {
  5. var windowHeight = $(window).height();
  6. var headerHeight = $('#page-header').height();
  7. var contentHeight = windowHeight - headerHeight;
  8. $('#page-sidebar').css('height', contentHeight);
  9. $('.scroll-sidebar').css('height', contentHeight);
  10. $('.scroll-sidebar').slimscroll({
  11. height: '100%',
  12. color: 'rgba(155, 164, 169, 0.68)',
  13. size: '6px'
  14. });
  15. var headerBg = $('#page-header').attr('class');
  16. $('#header-logo').addClass(headerBg);
  17. } else {
  18. var windowHeight = $(document).height();
  19. var headerHeight = $('#page-header').height();
  20. var contentHeight = windowHeight - headerHeight;
  21. $('#page-sidebar').css('height', contentHeight);
  22. $('.scroll-sidebar').css('height', contentHeight);
  23. $(".scroll-sidebar").slimScroll({
  24. destroy: true
  25. });
  26. $('#header-logo').removeClass('bg-gradient-9');
  27. }
  28. });
  29. });
  30. $(window).on('resize', function() {
  31. body_sizer();
  32. });
  33. function body_sizer() {
  34. if ($('body').hasClass('fixed-sidebar')) {
  35. var windowHeight = $(window).height();
  36. var headerHeight = $('#page-header').height();
  37. var contentHeight = windowHeight - headerHeight;
  38. $('#page-sidebar').css('height', contentHeight);
  39. $('.scroll-sidebar').css('height', contentHeight);
  40. $('#page-content').css('min-height', contentHeight);
  41. } else {
  42. var windowHeight = $(document).height();
  43. var headerHeight = $('#page-header').height();
  44. var contentHeight = windowHeight - headerHeight;
  45. $('#page-sidebar').css('height', contentHeight);
  46. $('.scroll-sidebar').css('height', contentHeight);
  47. $('#page-content').css('min-height', contentHeight);
  48. }
  49. };
  50. function pageTransitions() {
  51. var transitions = ['.pt-page-moveFromLeft', 'pt-page-moveFromRight', 'pt-page-moveFromTop', 'pt-page-moveFromBottom', 'pt-page-fade', 'pt-page-moveFromLeftFade', 'pt-page-moveFromRightFade', 'pt-page-moveFromTopFade', 'pt-page-moveFromBottomFade', 'pt-page-scaleUp', 'pt-page-scaleUpCenter', 'pt-page-flipInLeft', 'pt-page-flipInRight', 'pt-page-flipInBottom', 'pt-page-flipInTop', 'pt-page-rotatePullRight', 'pt-page-rotatePullLeft', 'pt-page-rotatePullTop', 'pt-page-rotatePullBottom', 'pt-page-rotateUnfoldLeft', 'pt-page-rotateUnfoldRight', 'pt-page-rotateUnfoldTop', 'pt-page-rotateUnfoldBottom'];
  52. for (var i in transitions) {
  53. var transition_name = transitions[i];
  54. if ($('.add-transition').hasClass(transition_name)) {
  55. $('.add-transition').addClass(transition_name + '-init page-transition');
  56. setTimeout(function() {
  57. $('.add-transition').removeClass(transition_name + ' ' + transition_name + '-init page-transition');
  58. }, 1200);
  59. return;
  60. }
  61. }
  62. };
  63. $(document).ready(function() {
  64. pageTransitions();
  65. // ADD SLIDEDOWN ANIMATION TO DROPDOWN //
  66. $('.dropdown').on('show.bs.dropdown', function(e){
  67. $(this).find('.dropdown-menu').first().stop(true, true).slideDown();
  68. });
  69. // ADD SLIDEUP ANIMATION TO DROPDOWN //
  70. $('.dropdown').on('hide.bs.dropdown', function(e){
  71. $(this).find('.dropdown-menu').first().stop(true, true).slideUp();
  72. });
  73. /* Sidebar menu */
  74. $(function() {
  75. $('#sidebar-menu').superclick({
  76. animation: {
  77. height: 'show'
  78. },
  79. animationOut: {
  80. height: 'hide'
  81. }
  82. });
  83. //automatically open the current path
  84. var path = window.location.pathname.split('/');
  85. path = path[path.length-1];
  86. if (path !== undefined) {
  87. $("#sidebar-menu").find("a[href$='" + path + "']").addClass('sfActive');
  88. $("#sidebar-menu").find("a[href$='" + path + "']").parents().eq(3).superclick('show');
  89. }
  90. });
  91. /* Colapse sidebar */
  92. $(function() {
  93. $('#close-sidebar').click(function() {
  94. $('body').toggleClass('closed-sidebar');
  95. $('.glyph-icon', this).toggleClass('icon-angle-right').toggleClass('icon-angle-left');
  96. });
  97. });
  98. /* Sidebar scroll */
  99. });