main.min.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ;
  2. jQuery( function() {
  3. // 滚动条
  4. const ps = new PerfectScrollbar('.lyear-layout-sidebar-scroll', {
  5. swipeEasing: false,
  6. suppressScrollX: true
  7. });
  8. // 侧边栏
  9. jQuery( '[data-toggle="layout"]' ).on( 'click', function() {
  10. if ($('.lyear-mask-modal').length == 0) {
  11. $( '<div class="lyear-mask-modal"></div>' ).prependTo('body');
  12. }
  13. $( '.lyear-layout-sidebar' ).toggleClass( 'lyear-layout-sidebar-open' );
  14. $( '.lyear-layout-sidebar' ).toggleClass( 'lyear-layout-sidebar-visible' );
  15. $( '.lyear-mask-modal' ).on( 'click', function() {
  16. $( this ).remove();
  17. $( '.lyear-layout-sidebar' ).toggleClass( 'lyear-layout-sidebar-open' );
  18. $( '.lyear-layout-sidebar' ).toggleClass( 'lyear-layout-sidebar-visible' );
  19. });
  20. });
  21. // 侧边栏导航
  22. $( '.nav-item-has-subnav > a' ).on( 'click', function() {
  23. $subnavToggle = jQuery( this );
  24. $navHasSubnav = $subnavToggle.parent();
  25. $navHasSubnav.siblings().find('.nav-subnav:visible').slideUp(500).parent().removeClass('open');
  26. $subnav = $navHasSubnav.find( '.nav-subnav' );
  27. $subnav.slideToggle( 300, function() {
  28. $navHasSubnav.toggleClass( 'open' );
  29. // 新增滚动条处理
  30. var scrollHeight = 0;
  31. pervTotal = $navHasSubnav.prevAll().length,
  32. boxHeight = $('.lyear-layout-sidebar-scroll').outerHeight(),
  33. innerHeight = $('.sidebar-main').outerHeight();
  34. if (innerHeight - boxHeight >= (pervTotal * 48)) {
  35. scrollHeight = pervTotal * 48;
  36. }
  37. $('.lyear-layout-sidebar-scroll').animate({scrollTop: scrollHeight}, 300);
  38. });
  39. });
  40. // 提示
  41. if($('[data-toggle="tooltip"]')[0]) {
  42. $('[data-toggle="tooltip"]').tooltip({
  43. "container" : 'body',
  44. });
  45. }
  46. // 弹出框
  47. if($('[data-toggle="popover"]')[0]) {
  48. $('[data-toggle="popover"]').popover();
  49. }
  50. // 标签
  51. if($('.js-tags-input')[0]) {
  52. $('.js-tags-input').tagsInput({
  53. height: '36px',
  54. width: '100%',
  55. defaultText: '添加标签',
  56. removeWithBackspace: true,
  57. delimiter: [',']
  58. });
  59. }
  60. // 时间选择
  61. jQuery('.js-datetimepicker').each(function() {
  62. var $input = jQuery(this);
  63. $input.datetimepicker({
  64. format: $input.data('format') ? $input.data('format') : false,
  65. useCurrent: $input.data('use-current') ? $input.data('use-current') : false,
  66. locale: moment.locale('' + ($input.data('locale') ? $input.data('locale') : '') + ''),
  67. showTodayButton: $input.data('show-today-button') ? $input.data('show-today-button') : false,
  68. showClear: $input.data('show-clear') ? $input.data('show-clear') : false,
  69. showClose: $input.data('show-close') ? $input.data('show-close') : false,
  70. sideBySide: $input.data('side-by-side') ? $input.data('side-by-side') : false,
  71. inline: $input.data('inline') ? $input.data('inline') : false,
  72. });
  73. });
  74. // 日期选择
  75. jQuery('.js-datepicker').each(function() {
  76. var $input = jQuery(this);
  77. $input.datepicker({
  78. weekStart: 1,
  79. autoclose: true,
  80. todayHighlight: true,
  81. language: 'zh-CN',
  82. });
  83. });
  84. // 颜色选取
  85. jQuery('.js-colorpicker').each(function() {
  86. var $colorpicker = jQuery(this);
  87. var $colorpickerMode = $colorpicker.data('colorpicker-mode') ? $colorpicker.data('colorpicker-mode') : 'hex';
  88. var $colorpickerinline = $colorpicker.data('colorpicker-inline') ? true: false;
  89. $colorpicker.colorpicker({
  90. 'format': $colorpickerMode,
  91. 'inline': $colorpickerinline
  92. });
  93. });
  94. // 复选框全选
  95. $("#check-all").change(function () {
  96. $("input[type='checkbox']").prop('checked', $(this).prop("checked"));
  97. });
  98. });