| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- ;
- jQuery( function() {
-
- // 滚动条
- const ps = new PerfectScrollbar('.lyear-layout-sidebar-scroll', {
- swipeEasing: false,
- suppressScrollX: true
- });
-
- // 侧边栏
- jQuery( '[data-toggle="layout"]' ).on( 'click', function() {
- if ($('.lyear-mask-modal').length == 0) {
- $( '<div class="lyear-mask-modal"></div>' ).prependTo('body');
- }
- $( '.lyear-layout-sidebar' ).toggleClass( 'lyear-layout-sidebar-open' );
- $( '.lyear-layout-sidebar' ).toggleClass( 'lyear-layout-sidebar-visible' );
-
- $( '.lyear-mask-modal' ).on( 'click', function() {
- $( this ).remove();
- $( '.lyear-layout-sidebar' ).toggleClass( 'lyear-layout-sidebar-open' );
- $( '.lyear-layout-sidebar' ).toggleClass( 'lyear-layout-sidebar-visible' );
- });
- });
-
- // 侧边栏导航
- $( '.nav-item-has-subnav > a' ).on( 'click', function() {
- $subnavToggle = jQuery( this );
- $navHasSubnav = $subnavToggle.parent();
- $navHasSubnav.siblings().find('.nav-subnav:visible').slideUp(500).parent().removeClass('open');
- $subnav = $navHasSubnav.find( '.nav-subnav' );
- $subnav.slideToggle( 300, function() {
- $navHasSubnav.toggleClass( 'open' );
-
- // 新增滚动条处理
- var scrollHeight = 0;
- pervTotal = $navHasSubnav.prevAll().length,
- boxHeight = $('.lyear-layout-sidebar-scroll').outerHeight(),
- innerHeight = $('.sidebar-main').outerHeight();
-
- if (innerHeight - boxHeight >= (pervTotal * 48)) {
- scrollHeight = pervTotal * 48;
- }
- $('.lyear-layout-sidebar-scroll').animate({scrollTop: scrollHeight}, 300);
-
- });
- });
-
- // 提示
- if($('[data-toggle="tooltip"]')[0]) {
- $('[data-toggle="tooltip"]').tooltip({
- "container" : 'body',
- });
- }
-
- // 弹出框
- if($('[data-toggle="popover"]')[0]) {
- $('[data-toggle="popover"]').popover();
- }
-
- // 标签
- if($('.js-tags-input')[0]) {
- $('.js-tags-input').tagsInput({
- height: '36px',
- width: '100%',
- defaultText: '添加标签',
- removeWithBackspace: true,
- delimiter: [',']
- });
- }
-
- // 时间选择
- jQuery('.js-datetimepicker').each(function() {
- var $input = jQuery(this);
- $input.datetimepicker({
- format: $input.data('format') ? $input.data('format') : false,
- useCurrent: $input.data('use-current') ? $input.data('use-current') : false,
- locale: moment.locale('' + ($input.data('locale') ? $input.data('locale') : '') + ''),
- showTodayButton: $input.data('show-today-button') ? $input.data('show-today-button') : false,
- showClear: $input.data('show-clear') ? $input.data('show-clear') : false,
- showClose: $input.data('show-close') ? $input.data('show-close') : false,
- sideBySide: $input.data('side-by-side') ? $input.data('side-by-side') : false,
- inline: $input.data('inline') ? $input.data('inline') : false,
- });
- });
-
- // 日期选择
- jQuery('.js-datepicker').each(function() {
- var $input = jQuery(this);
- $input.datepicker({
- weekStart: 1,
- autoclose: true,
- todayHighlight: true,
- language: 'zh-CN',
- });
- });
-
- // 颜色选取
- jQuery('.js-colorpicker').each(function() {
- var $colorpicker = jQuery(this);
- var $colorpickerMode = $colorpicker.data('colorpicker-mode') ? $colorpicker.data('colorpicker-mode') : 'hex';
- var $colorpickerinline = $colorpicker.data('colorpicker-inline') ? true: false;
- $colorpicker.colorpicker({
- 'format': $colorpickerMode,
- 'inline': $colorpickerinline
- });
- });
-
- // 复选框全选
- $("#check-all").change(function () {
- $("input[type='checkbox']").prop('checked', $(this).prop("checked"));
- });
- });
|