-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpc.js
100 lines (86 loc) · 1.88 KB
/
pc.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
define([], function(){
var Tips = (function(){
var $tipBox = $(".tips-box");
return {
show: function(){
$tipBox.removeClass("hide");
},
hide: function(){
$tipBox.addClass("hide");
},
init: function(){
}
}
})();
var resetTags = function(){
var tags = $(".tagcloud a");
tags.css({"font-size": "12px"});
for(var i=0,len=tags.length; i<len; i++){
var num = tags.eq(i).html().length % 5 +1;
tags[i].className = "";
tags.eq(i).addClass("color"+num);
}
}
var slide = function(idx){
var $wrap = $(".switch-wrap");
$wrap.css({
"transform": "translate(-"+idx*100+"%, 0 )"
});
$(".icon-wrap").addClass("hide");
$(".icon-wrap").eq(idx).removeClass("hide");
}
var bind = function(){
var switchBtn = $("#myonoffswitch");
var tagcloud = $(".second-part");
var navDiv = $(".first-part");
switchBtn.click(function(){
if(switchBtn.hasClass("clicked")){
switchBtn.removeClass("clicked");
tagcloud.removeClass("turn-left");
navDiv.removeClass("turn-left");
}else{
switchBtn.addClass("clicked");
tagcloud.addClass("turn-left");
navDiv.addClass("turn-left");
resetTags();
}
});
var timeout;
var isEnterBtn = false;
var isEnterTips = false;
$(".icon").bind("mouseenter", function(){
isEnterBtn = true;
Tips.show();
}).bind("mouseleave", function(){
isEnterBtn = false;
setTimeout(function(){
if(!isEnterTips){
Tips.hide();
}
}, 100);
});
$(".tips-box").bind("mouseenter", function(){
isEnterTips = true;
Tips.show();
}).bind("mouseleave", function(){
isEnterTips = false;
setTimeout(function(){
if(!isEnterBtn){
Tips.hide();
}
}, 100);
});
$(".tips-inner li").bind("click", function(){
var idx = $(this).index();
slide(idx);
Tips.hide();
});
}
return {
init: function(){
resetTags();
bind();
Tips.init();
}
}
});