matrix.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. $(document).ready(function(){
  2. // === Sidebar navigation === //
  3. $('.submenu > a').click(function(e)
  4. {
  5. e.preventDefault();
  6. var submenu = $(this).siblings('ul');
  7. var li = $(this).parents('li');
  8. var submenus = $('#sidebar li.submenu ul');
  9. var submenus_parents = $('#sidebar li.submenu');
  10. if(li.hasClass('open'))
  11. {
  12. if(($(window).width() > 768) || ($(window).width() < 479)) {
  13. submenu.slideUp();
  14. } else {
  15. submenu.fadeOut(250);
  16. }
  17. li.removeClass('open');
  18. } else
  19. {
  20. if(($(window).width() > 768) || ($(window).width() < 479)) {
  21. submenus.slideUp();
  22. submenu.slideDown();
  23. } else {
  24. submenus.fadeOut(250);
  25. submenu.fadeIn(250);
  26. }
  27. submenus_parents.removeClass('open');
  28. li.addClass('open');
  29. }
  30. });
  31. var ul = $('#sidebar > ul');
  32. $('#sidebar > a').click(function(e)
  33. {
  34. e.preventDefault();
  35. var sidebar = $('#sidebar');
  36. if(sidebar.hasClass('open'))
  37. {
  38. sidebar.removeClass('open');
  39. ul.slideUp(250);
  40. } else
  41. {
  42. sidebar.addClass('open');
  43. ul.slideDown(250);
  44. }
  45. // var li = $(this).parents('li');
  46. // li.addClass('active');
  47. });
  48. // === Resize window related === //
  49. $(window).resize(function()
  50. {
  51. if($(window).width() > 479)
  52. {
  53. ul.css({'display':'block'});
  54. $('#content-header .btn-group').css({width:'auto'});
  55. }
  56. if($(window).width() < 479)
  57. {
  58. ul.css({'display':'none'});
  59. fix_position();
  60. }
  61. if($(window).width() > 768)
  62. {
  63. $('#user-nav > ul').css({width:'auto',margin:'0'});
  64. $('#content-header .btn-group').css({width:'auto'});
  65. }
  66. });
  67. if($(window).width() < 468)
  68. {
  69. ul.css({'display':'none'});
  70. fix_position();
  71. }
  72. if($(window).width() > 479)
  73. {
  74. $('#content-header .btn-group').css({width:'auto'});
  75. ul.css({'display':'block'});
  76. }
  77. // === Tooltips === //
  78. $('.tip').tooltip();
  79. $('.tip-left').tooltip({ placement: 'left' });
  80. $('.tip-right').tooltip({ placement: 'right' });
  81. $('.tip-top').tooltip({ placement: 'top' });
  82. $('.tip-bottom').tooltip({ placement: 'bottom' });
  83. // === Search input typeahead === //
  84. $('#search input[type=text]').typeahead({
  85. source: ['Dashboard','Form elements','Common Elements','Validation','Wizard','Buttons','Icons','Interface elements','Support','Calendar','Gallery','Reports','Charts','Graphs','Widgets'],
  86. items: 4
  87. });
  88. // === Fixes the position of buttons group in content header and top user navigation === //
  89. function fix_position()
  90. {
  91. var uwidth = $('#user-nav > ul').width();
  92. $('#user-nav > ul').css({width:uwidth,'margin-left':'-' + uwidth / 2 + 'px'});
  93. var cwidth = $('#content-header .btn-group').width();
  94. $('#content-header .btn-group').css({width:cwidth,'margin-left':'-' + uwidth / 2 + 'px'});
  95. }
  96. // === Style switcher === //
  97. $('#style-switcher i').click(function()
  98. {
  99. if($(this).hasClass('open'))
  100. {
  101. $(this).parent().animate({marginRight:'-=190'});
  102. $(this).removeClass('open');
  103. } else
  104. {
  105. $(this).parent().animate({marginRight:'+=190'});
  106. $(this).addClass('open');
  107. }
  108. $(this).toggleClass('icon-arrow-left');
  109. $(this).toggleClass('icon-arrow-right');
  110. });
  111. $('#style-switcher a').click(function()
  112. {
  113. var style = $(this).attr('href').replace('#','');
  114. $('.skin-color').attr('href','css/maruti.'+style+'.css');
  115. $(this).siblings('a').css({'border-color':'transparent'});
  116. $(this).css({'border-color':'#aaaaaa'});
  117. });
  118. $('.lightbox_trigger').click(function(e) {
  119. e.preventDefault();
  120. var image_href = $(this).attr("href");
  121. if ($('#lightbox').length > 0) {
  122. $('#imgbox').html('<img src="' + image_href + '" /><p><i class="icon-remove icon-white"></i></p>');
  123. $('#lightbox').slideDown(500);
  124. }
  125. else {
  126. var lightbox =
  127. '<div id="lightbox" style="display:none;">' +
  128. '<div id="imgbox"><img src="' + image_href +'" />' +
  129. '<p><i class="icon-remove icon-white"></i></p>' +
  130. '</div>' +
  131. '</div>';
  132. $('body').append(lightbox);
  133. $('#lightbox').slideDown(500);
  134. }
  135. });
  136. $('#lightbox').live('click', function() {
  137. $('#lightbox').hide(200);
  138. });
  139. });