matrix.js 4.4 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. });
  46. // === Resize window related === //
  47. $(window).resize(function()
  48. {
  49. if($(window).width() > 479)
  50. {
  51. ul.css({'display':'block'});
  52. $('#content-header .btn-group').css({width:'auto'});
  53. }
  54. if($(window).width() < 479)
  55. {
  56. ul.css({'display':'none'});
  57. fix_position();
  58. }
  59. if($(window).width() > 768)
  60. {
  61. $('#user-nav > ul').css({width:'auto',margin:'0'});
  62. $('#content-header .btn-group').css({width:'auto'});
  63. }
  64. });
  65. if($(window).width() < 468)
  66. {
  67. ul.css({'display':'none'});
  68. fix_position();
  69. }
  70. if($(window).width() > 479)
  71. {
  72. $('#content-header .btn-group').css({width:'auto'});
  73. ul.css({'display':'block'});
  74. }
  75. // === Tooltips === //
  76. $('.tip').tooltip();
  77. $('.tip-left').tooltip({ placement: 'left' });
  78. $('.tip-right').tooltip({ placement: 'right' });
  79. $('.tip-top').tooltip({ placement: 'top' });
  80. $('.tip-bottom').tooltip({ placement: 'bottom' });
  81. // === Search input typeahead === //
  82. $('#search input[type=text]').typeahead({
  83. source: ['Dashboard','Form elements','Common Elements','Validation','Wizard','Buttons','Icons','Interface elements','Support','Calendar','Gallery','Reports','Charts','Graphs','Widgets'],
  84. items: 4
  85. });
  86. // === Fixes the position of buttons group in content header and top user navigation === //
  87. function fix_position()
  88. {
  89. var uwidth = $('#user-nav > ul').width();
  90. $('#user-nav > ul').css({width:uwidth,'margin-left':'-' + uwidth / 2 + 'px'});
  91. var cwidth = $('#content-header .btn-group').width();
  92. $('#content-header .btn-group').css({width:cwidth,'margin-left':'-' + uwidth / 2 + 'px'});
  93. }
  94. // === Style switcher === //
  95. $('#style-switcher i').click(function()
  96. {
  97. if($(this).hasClass('open'))
  98. {
  99. $(this).parent().animate({marginRight:'-=190'});
  100. $(this).removeClass('open');
  101. } else
  102. {
  103. $(this).parent().animate({marginRight:'+=190'});
  104. $(this).addClass('open');
  105. }
  106. $(this).toggleClass('icon-arrow-left');
  107. $(this).toggleClass('icon-arrow-right');
  108. });
  109. $('#style-switcher a').click(function()
  110. {
  111. var style = $(this).attr('href').replace('#','');
  112. $('.skin-color').attr('href','css/maruti.'+style+'.css');
  113. $(this).siblings('a').css({'border-color':'transparent'});
  114. $(this).css({'border-color':'#aaaaaa'});
  115. });
  116. $('.lightbox_trigger').click(function(e) {
  117. e.preventDefault();
  118. var image_href = $(this).attr("href");
  119. if ($('#lightbox').length > 0) {
  120. $('#imgbox').html('<img src="' + image_href + '" /><p><i class="icon-remove icon-white"></i></p>');
  121. $('#lightbox').slideDown(500);
  122. }
  123. else {
  124. var lightbox =
  125. '<div id="lightbox" style="display:none;">' +
  126. '<div id="imgbox"><img src="' + image_href +'" />' +
  127. '<p><i class="icon-remove icon-white"></i></p>' +
  128. '</div>' +
  129. '</div>';
  130. $('body').append(lightbox);
  131. $('#lightbox').slideDown(500);
  132. }
  133. });
  134. $('#lightbox').live('click', function() {
  135. $('#lightbox').hide(200);
  136. });
  137. //<![CDATA[
  138. bkLib.onDomLoaded(function() {
  139. new nicEditor().panelInstance('editor')
  140. });
  141. //]]>
  142. });