index.min.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ;
  2. jQuery( function() {
  3. $("body").on('click','[data-stopPropagation]',function (e) {
  4. e.stopPropagation();
  5. });
  6. // 滚动条
  7. const ps = new PerfectScrollbar('.lyear-layout-sidebar-scroll', {
  8. swipeEasing: false,
  9. suppressScrollX: true
  10. });
  11. // 侧边栏
  12. $(document).on('click', '.lyear-aside-toggler', function() {
  13. $('.lyear-layout-sidebar').toggleClass('lyear-aside-open');
  14. $("body").toggleClass('lyear-layout-sidebar-close');
  15. if ($('.lyear-mask-modal').length == 0) {
  16. $('<div class="lyear-mask-modal"></div>').prependTo('body');
  17. } else {
  18. $( '.lyear-mask-modal' ).remove();
  19. }
  20. });
  21. // 遮罩层
  22. $(document).on('click', '.lyear-mask-modal', function() {
  23. $( this ).remove();
  24. $('.lyear-layout-sidebar').toggleClass('lyear-aside-open');
  25. $('body').toggleClass('lyear-layout-sidebar-close');
  26. });
  27. // 侧边栏导航
  28. $(document).on('click', '.nav-item-has-subnav > a', function() {
  29. $subnavToggle = jQuery( this );
  30. $navHasSubnav = $subnavToggle.parent();
  31. $topHasSubNav = $subnavToggle.parents('.nav-item-has-subnav').last();
  32. $subnav = $navHasSubnav.find('.nav-subnav').first();
  33. $viSubHeight = $navHasSubnav.siblings().find('.nav-subnav:visible').outerHeight();
  34. $scrollBox = $('.lyear-layout-sidebar-scroll');
  35. $navHasSubnav.siblings().find('.nav-subnav:visible').slideUp(500).parent().removeClass('open');
  36. $subnav.slideToggle( 300, function() {
  37. $navHasSubnav.toggleClass( 'open' );
  38. // 新增滚动条处理
  39. var scrollHeight = 0;
  40. pervTotal = $topHasSubNav.prevAll().length,
  41. boxHeight = $scrollBox.outerHeight(),
  42. innerHeight = $('.sidebar-main').outerHeight(),
  43. thisScroll = $scrollBox.scrollTop(),
  44. thisSubHeight = $(this).outerHeight(),
  45. footHeight = 121;
  46. if (footHeight + innerHeight - boxHeight >= (pervTotal * 48)) {
  47. scrollHeight = pervTotal * 48;
  48. }
  49. if ($subnavToggle.parents('.nav-item-has-subnav').length == 1) {
  50. $scrollBox.animate({scrollTop: scrollHeight}, 300);
  51. } else {
  52. // 子菜单操作
  53. if (typeof($viSubHeight) != 'undefined' && $viSubHeight != null) {
  54. scrollHeight = thisScroll + thisSubHeight - $viSubHeight;
  55. $scrollBox.animate({scrollTop: scrollHeight}, 300);
  56. } else {
  57. if ((thisScroll + boxHeight - $scrollBox[0].scrollHeight) == 0) {
  58. scrollHeight = thisScroll - thisSubHeight;
  59. $scrollBox.animate({scrollTop: scrollHeight}, 300);
  60. }
  61. }
  62. }
  63. });
  64. });
  65. // 设置主题配色
  66. setTheme = function(input_name, data_name) {
  67. $("input[name='"+input_name+"']").click(function(){
  68. $('body').attr(data_name, $(this).val());
  69. });
  70. }
  71. setTheme('logo_bg', 'data-logobg');
  72. setTheme('header_bg', 'data-headerbg');
  73. setTheme('sidebar_bg', 'data-sidebarbg');
  74. // 选项卡
  75. $('#iframe-content').multitabs({
  76. iframe : true,
  77. nav: {
  78. backgroundColor: '#ffffff',
  79. },
  80. init : [{
  81. type : 'main',
  82. title : '首页',
  83. url : 'lyear_main.html'
  84. }]
  85. });
  86. $(document).on('click', '.nav-item .multitabs', function() {
  87. $('.nav-item').removeClass('active');
  88. $('.nav-subnav li').removeClass('active');
  89. $(this).parents('li').addClass('active');
  90. $(this).parents('.nav-item-has-subnav').addClass('open').first().addClass('active');
  91. });
  92. });