index.js
1.59 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
/**
* index
* 默认依赖
*/
'use strict';
var $ = require('jquery');
require('yoho.bootstrap');
/*左侧导航*/
$('.leftpanel .nav .parent>a').click(function() {
var coll = $(this).parents('.collapsed').length,
child = $(this).parent().find('.children');
if (!coll) {
$('.leftpanel .nav .parent-focus').each(function() {
$(this).find('.children').slideUp('fast');
$(this).removeClass('parent-focus');
});
if(!child.is(':visible')) {
child.slideDown('fast');
if(!child.parent().hasClass('active'))
child.parent().addClass('parent-focus');
} else {
child.slideUp('fast');
child.parent().removeClass('parent-focus');
}
}
return false;
});
var me={
setUrl:function(value){
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = "url" + "="+ escape (value) + ";expires=" + exp.toGMTString();
},
getUrl:function(){
var arr,reg=new RegExp("(^| )url=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
};
window.me=me;
$(".leftpanel .nav .children a").each(function(){
var attr=$(this).attr("href");
if(attr==window.location.pathname){
$(this).parents(".children").show();
$(this).parent("li").addClass("active");
$(this).parents(".parent").addClass("parent-focus");
window.me.setUrl(window.location.pathname);
}
});