index.js
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* index
* 默认依赖
*/
'use strict';
var $ = require('jquery');
var isMenuShow = false;
var localStorage = window.localStorage;
/*左侧导航*/
$('.leftpanel .nav .parent>a').click(function() {
var parent = $(this).parent(),
child = parent.find('.children');
parent.siblings('.active').find('.children').removeClass("active").slideUp('fast');
parent.siblings('.active').removeClass("active");
if(parent.hasClass('active')){
$(".parent ").removeClass("active");
$('.children').removeClass("active").slideUp('fast');
isMenuShow = false;
}else{
$(this).parent(".parent ").addClass("active");
child.slideDown('fast').addClass("active");
isMenuShow = true;
}
return false;
});
/*菜单*/
$(".leftpanel .nav .children a").each(function() {
var attr = $(this).attr('href');
if (!isMenuShow && attr == window.location.pathname + window.location.search) {
$(this).parents(".children").show();
$(this).parent("li").addClass("active");
$(this).parents(".parent").addClass("active");
localStorage.setItem("router", attr);
localStorage.getItem("router");
isMenuShow = true;
}
});
if (!isMenuShow && localStorage.getItem("router")) {
$(".leftpanel .nav .children a").each(function() {
var attr = $(this).attr('href');
if (localStorage.getItem("router") == attr) {
$(this).parents(".children").show();
$(this).parent("li").addClass("active");
$(this).parents(".parent").addClass("active");
isMenuShow = true;
}
});
}
// LocalStorage.setItem("router",);
$('.panel-heading').hover(function() {
$(this).find('.panel-btns').fadeIn('fast');
}, function() {
$(this).find('.panel-btns').fadeOut('fast');
});
$('.panel .panel-close').click(function() {
$(this).closest('.panel').fadeOut(200);
return false;
});