sb-admin-2.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. $(function() {
  2. $('#side-menu').metisMenu();
  3. });
  4. //Loads the correct sidebar on window load,
  5. //collapses the sidebar on window resize.
  6. // Sets the min-height of #page-wrapper to window size
  7. $(function() {
  8. $(window).bind("load resize", function() {
  9. var topOffset = 50;
  10. var width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
  11. if (width < 768) {
  12. $('div.navbar-collapse').addClass('collapse');
  13. topOffset = 100; // 2-row-menu
  14. } else {
  15. $('div.navbar-collapse').removeClass('collapse');
  16. }
  17. var height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
  18. height = height - topOffset;
  19. if (height < 1) height = 1;
  20. if (height > topOffset) {
  21. $("#page-wrapper").css("min-height", (height) + "px");
  22. }
  23. });
  24. var url = window.location;
  25. // var element = $('ul.nav a').filter(function() {
  26. // return this.href == url;
  27. // }).addClass('active').parent().parent().addClass('in').parent();
  28. var element = $('ul.nav a').filter(function() {
  29. return this.href == url;
  30. }).addClass('active').parent();
  31. while (true) {
  32. if (element.is('li')) {
  33. element = element.parent().addClass('in').parent();
  34. } else {
  35. break;
  36. }
  37. }
  38. });