startmin.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. $(function() {
  2. $('#side-menu').metisMenu();
  3. $("#contract").click(function(e) {
  4. e.preventDefault();
  5. var w = $("#wrapper");
  6. if (w.hasClass("contracted")) {
  7. w.removeClass("contracted");
  8. setCookie('sidebar-contracted', '0');
  9. } else {
  10. w.addClass("contracted");
  11. setCookie('sidebar-contracted', '1');
  12. }
  13. setLinkContent();
  14. $(window).trigger('resize');
  15. });
  16. setLinkContent();
  17. function setLinkContent() {
  18. if ($("#wrapper").hasClass("contracted"))
  19. $("#contract").html('<i class="fa fa-arrow-circle-o-right fa-fw"></i> <span>Cerrar menu</span>');
  20. else
  21. $("#contract").html('<i class="fa fa-arrow-circle-o-left fa-fw"></i> <span>Cerrar menu</span>');
  22. }
  23. function setCookie(name, value, path) {
  24. if (path == null) {
  25. var arr = _webApp_site.replace('http://', '').replace('https://', '').split('/');
  26. arr.splice(0);
  27. path = '/' + arr.join('/') + (arr.length > 0 ? '/' : '');
  28. }
  29. var d = new Date();
  30. d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000));
  31. document.cookie = name + "=" + value + "; expires=" + d.toUTCString() + "; path=/";
  32. }
  33. if ($.blockUI) {
  34. $.blockUI.defaults.message = '<img src="assets/images/ajax-loader.svg" alt="">';
  35. $.blockUI.defaults.css = {
  36. padding : 0,
  37. margin : '0 auto',
  38. width : '30%',
  39. top : '40%',
  40. left : '35%',
  41. textAlign: 'center',
  42. color : '#000'
  43. };
  44. $.blockUI.defaults.overlayCSS = {
  45. backgroundColor: '#000',
  46. opacity : 0.8
  47. }
  48. }
  49. });
  50. //Loads the correct sidebar on window load,
  51. //collapses the sidebar on window resize.
  52. // Sets the min-height of #page-wrapper to window size
  53. $(function() {
  54. $(window).bind("load resize", function() {
  55. let width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
  56. if (width < 768)
  57. $('div.navbar-collapse').addClass('collapse');
  58. else
  59. $('div.navbar-collapse').removeClass('collapse');
  60. });
  61. const url = window.location;
  62. const element = $('ul.nav a').filter(function() {
  63. return this.href == url /*|| url.href.indexOf(this.href) == 0*/;
  64. }).addClass('active').parent().parent().addClass('in').parent();
  65. if (element.is('li')) {
  66. element.addClass('active');
  67. }
  68. });