index.min.js 3.7 KB

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