仰望星辰工作室

better-staridc-MNBT

better-staridc-MNBT/ imsetes/js/index.min.js 4.9 KB · 133 行 原始文件
Z zfhsh first commit 1 天前
1;jQuery( function() {
2 // 停止
3 $("body").on('click','[data-stopPropagation]',function (e) {
4 e.stopPropagation();
5 });
6
7 // 滚动条
8 if($('.lyear-scroll')[0]) {
9 $('.lyear-scroll').each(function(){
10 new PerfectScrollbar(this, {
11 swipeEasing: false,
12 suppressScrollX: true
13 });
14 });
15 }
16
17 // 侧边栏
18 $(document).on('click', '.lyear-aside-toggler', function() {
19 $('.lyear-layout-sidebar').toggleClass('lyear-aside-open');
20 $("body").toggleClass('lyear-layout-sidebar-close');
21
22 if ($('.lyear-mask-modal').length == 0) {
23 $('<div class="lyear-mask-modal"></div>').prependTo('body');
24 } else {
25 $( '.lyear-mask-modal' ).remove();
26 }
27 });
28
29 // 遮罩层
30 $(document).on('click', '.lyear-mask-modal', function() {
31 $( this ).remove();
32 $('.lyear-layout-sidebar').toggleClass('lyear-aside-open');
33 $('body').toggleClass('lyear-layout-sidebar-close');
34 });
35
36 // 侧边栏导航
37 $(document).on('click', '.nav-item-has-subnav > a', function() {
38 $subnavToggle = jQuery( this );
39 $navHasSubnav = $subnavToggle.parent();
40 $topHasSubNav = $subnavToggle.parents('.nav-item-has-subnav').last();
41 $subnav = $navHasSubnav.find('.nav-subnav').first();
42 $viSubHeight = $navHasSubnav.siblings().find('.nav-subnav:visible').outerHeight();
43 $scrollBox = $('.lyear-layout-sidebar-info');
44 $navHasSubnav.siblings().find('.nav-subnav:visible').slideUp(500).parent().removeClass('open');
45 $subnav.slideToggle( 300, function() {
46 $navHasSubnav.toggleClass( 'open' );
47
48 // 新增滚动条处理
49 var scrollHeight = 0;
50 pervTotal = $topHasSubNav.prevAll().length,
51 boxHeight = $scrollBox.outerHeight(),
52 innerHeight = $('.sidebar-main').outerHeight(),
53 thisScroll = $scrollBox.scrollTop(),
54 thisSubHeight = $(this).outerHeight(),
55 footHeight = 121;
56
57 if (footHeight + innerHeight - boxHeight >= (pervTotal * 48)) {
58 scrollHeight = pervTotal * 48;
59 }
60 if ($subnavToggle.parents('.nav-item-has-subnav').length == 1) {
61 $scrollBox.animate({scrollTop: scrollHeight}, 300);
62 } else {
63 // 子菜单操作
64 if (typeof($viSubHeight) != 'undefined' && $viSubHeight != null) {
65 scrollHeight = thisScroll + thisSubHeight - $viSubHeight;
66 $scrollBox.animate({scrollTop: scrollHeight}, 300);
67 } else {
68 if ((thisScroll + boxHeight - $scrollBox[0].scrollHeight) == 0) {
69 scrollHeight = thisScroll - thisSubHeight;
70 $scrollBox.animate({scrollTop: scrollHeight}, 300);
71 }
72 }
73 }
74 });
75 });
76
77 // 读取cookie中的主题设置
78 var the_logo_bg = $.cookie('the_logo_bg'),
79 the_header_bg = $.cookie('the_header_bg'),
80 the_sidebar_bg = $.cookie('the_sidebar_bg');
81
82 if (the_logo_bg) $('body').attr('data-logobg', the_logo_bg);
83 if (the_header_bg) $('body').attr('data-headerbg', the_header_bg);
84 if (the_sidebar_bg) $('body').attr('data-sidebarbg', the_sidebar_bg);
85
86 // 处理主题配色下拉选中
87 $(".dropdown-skin :radio").each(function(){
88 var $this = $(this),
89 radioName = $this.attr('name');
90 switch (radioName) {
91 case 'logo_bg':
92 $this.val() == the_logo_bg && $this.prop("checked", true);
93 break;
94 case 'header_bg':
95 $this.val() == the_header_bg && $this.prop("checked", true);
96 break;
97 case 'sidebar_bg':
98 $this.val() == the_sidebar_bg && $this.prop("checked", true);
99 }
100 });
101
102 // 设置主题配色
103 setTheme = function(input_name, data_name) {
104 $("input[name='"+input_name+"']").click(function(){
105 $('body').attr(data_name, $(this).val());
106 $.cookie('the_'+input_name, $(this).val());
107 });
108 }
109 setTheme('sidebar_bg', 'data-sidebarbg');
110 setTheme('logo_bg', 'data-logobg');
111 setTheme('header_bg', 'data-headerbg');
112
113 // 选项卡
114 $('#iframe-content').multitabs({
115 iframe : true,
116 refresh : 'no', // iframe中页面是否刷新,'no':'从不刷新','nav':'点击菜单刷新','all':'菜单和tab点击都刷新'
117 nav: {
118 backgroundColor: '#ffffff',
119 },
120 init : [{
121 type : 'main',
122 title : '首页',
123 url : 'sy.php'
124 }]
125 });
126
127 $(document).on('click', '.nav-item .multitabs', function() {
128 $('.nav-item').removeClass('active');
129 $('.nav-subnav li').removeClass('active');
130 $(this).parents('li').addClass('active');
131 $(this).parents('.nav-item-has-subnav').addClass('open').first().addClass('active');
132 });
133});