Repository navigation
Expand file tree
/
Copy pathhome.js
More file actions
93 lines (91 loc) · 2.53 KB
/
Copy pathhome.js
File metadata and controls
93 lines (91 loc) · 2.53 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
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
$(function(){
homeObject.navbarClickInit();
homeObject.narImgClickInit();
homeObject.bindWindowResize();
homeObject.narLinkDonClickInit();
})
var homeObject={
navbarClickInit:function(){
$("#home_navbar a").click(function(){
homeObject.changeNavBar($(this));
});
},
changeNavBar:function(obj){
$("#home_navbar").find("li").removeClass("active");
obj.parent().addClass("active");
},
narImgClickInit:function(){
$("#link_img a").click(function(){
if($(this).attr("isBox")=='yes'){
if($(this).attr("active")=="no"){
homeObject.clearPopBox();
$("#narImg .popover-title").html("扫码,加我微信~");
$("#narImg img").attr("src","../src/img/wechat.jpg");
homeObject.popBoxConvert($(this));
$(this).attr("active","yes");
$("#narImg").removeClass("out");
$("#narImg").addClass("in");
}else{
homeObject.clearPopBox();
$("#narImg").removeClass("in");
$("#narImg").addClass("out");
$("#narImg img").attr("src","");
$(this).attr("active","no");
}
}else{
homeObject.clearPopBox();
}
});
},
narLinkDonClickInit:function(){
$("#nar_link a").click(function(){
if($(this).attr("isBox")=='yes'){
if($(this).attr("active")=="no"){
homeObject.clearPopBox();
$("#narImg .popover-title").html("扫码,犒赏我~");
$("#narImg img").attr("src","../src/img/wechatpay.jpg");
homeObject.popBoxConvert($(this));
$(this).attr("active","yes");
$("#narImg").removeClass("out");
$("#narImg").addClass("in");
}else{
homeObject.clearPopBox();
$("#narImg").removeClass("in");
$("#narImg").addClass("out");
$("#narImg img").attr("src","");
$(this).attr("active","no");
}
}else{
homeObject.clearPopBox();
}
});
},
clearPopBox:function(){
$("#narImg").removeClass("in");
$("#narImg").addClass("out");
$("#narImg img").attr("src","");
$("#home_navbar a[isBox='yes']").attr("active","no");
},
popBoxConvert:function(obj){
var x = obj.offset().top;
var y = obj.offset().left;
var x_con = obj.outerHeight();
var y_con = $("#narImg").outerWidth();
var _x = x+x_con;
var _y = y-((y_con-obj.outerWidth())/2);
$("#narImg").css("top",_x+"px");
$("#narImg").css("left",_y+"px");
},
bindWindowResize:function(){
$(window).resize(function () {
var obj = $("#link_img a[active='yes']");
if(obj&&obj.length>0){
homeObject.popBoxConvert(obj);
}
var _obj = $("#nar_link a[active='yes']");
if(_obj&&_obj.length>0){
homeObject.popBoxConvert(_obj);
}
});
}
}