help.js
4.79 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
$(function(){
positionTop();
mouseEvent("#mail");
mouseEvent("#top");
// 游览器兼容input的placeholder;
supportPlaceholder='placeholder'in document.createElement('input');
if(!supportPlaceholder){
var txt=$("textarea").attr("placeholder");
placeholder($("textarea"));
}
$(window).resize(function(){
positionTop();
});
$(window).scroll(function(){
if ($(window).scrollTop()>50){
$("#top").fadeIn(300);
}
else
{
$("#top").fadeOut(300);
}
});
$("#top").click(function(){
$('body,html').animate({scrollTop:0},300);
return false;
});
/**用户是否登录*/
$("#mail").click(function(){
$("#url").val(location.href);
$.ajax({
type: 'GET',
url: '/login/state?r=' + Math.random(),
success: function(data) {
if (data == 'N') {
changeCaptcha2();
$('#loginModal').modal({closeOnOverlayClick: false}).open();
} else {
$("#content").html("");
easyDialog.open({
container : 'feedback_popup'
});
}
},
error: function(data) {
if (data.responseText == 'N') {
changeCaptcha2();
$('#loginModal').modal({closeOnOverlayClick: false}).open();
} else {
$("#content").html("");
easyDialog.open({
container : 'feedback_popup'
});
}
}
});
});
$("#help_menu").find("li").each(function(){
$(this).find("a").click(function(){
$("#help_menu").find("li").each(function(){
$(this).find("a").removeClass();
});
$(this).addClass("selected");
});
});
$('#show_QR').mouseenter(function(){
$("#QR").css("display","block");
});
$('#show_QR').mouseleave(function(){
$("#QR").css("display","none");
});
//计算悬浮框还可以输入的字数
$("#status").keyup(function(){
$("#recommend").html("");
if($(this).val().length>200){
$(this).val($(this).val().substr(0, 200));
}
$("#counter").html(200-$(this).val().length);
});
$("#status").keydown(function(){
$("#recommend").html("");
if($(this).val().length>200){
$(this).val($(this).val().substr(0, 200));
}
$("#counter").html(200-$(this).val().length);
});
//placeholder兼容性
function placeholder(textarea){
var text = textarea.attr('placeholder'),
defaultValue = textarea.defaultValue;
if(!defaultValue){
textarea.val(text).addClass("phcolor");
}
textarea.focus(function(){
if(textarea.val() == text){
$(this).val("");
}
});
textarea.blur(function(){
if(textarea.val() == ""){
$(this).val(text).addClass("phcolor");
}
});
//输入的字符不为灰色
textarea.keydown(function(){
$(this).removeClass("phcolor");
});
}
// 右侧悬浮框的位置修改
function positionTop(){
var left=($(window).width()-1100)/2;
if(left-10>0){
$("#to_top").css("right",left-10);
}
else{
$("#to_top").css("right","5");
}
}
function mouseEvent(id){
$(id).mouseenter(function(){
$(this).find("img").css("display","none");
$(this).find("a").css("display","block");
});
$(id).mouseleave(function(){
$(this).find("img").css("display","block");
$(this).find("a").css("display","none");
});
}
})
var userFeedback = function() {
return {
getUserFeedback :function() {
var feedbackContent=$("#status").val();
if(feedbackContent ==''||feedbackContent =='您的宝贵意见将帮助我们不断改进!'){
// alert("反馈问题不能为空");
$("#recommend").html("反馈问题不能为空");
return;
}
$.ajax({
url : '/user/addUserFeedback',
type : 'post',
dataType : 'json',
data : {
content : feedbackContent
},
success : function(data) {
if(data==0){
// alert("提交有误,请联系客服");
$("#recommend").html("提交有误,请联系客服");
}else if(data==1){
easyDialog.open({
container : 'success_popup'
});
}else if(data==2){
// alert("反馈问题不能为空");
$("#recommend").html("反馈问题不能为空");
}
}
});
},
reload:function(){
$("#status").val('');
$("#recommend").html('');
$("#counter").html('200');
supportPlaceholder='placeholder'in document.createElement('input');
if(!supportPlaceholder){
var txt=$("textarea").attr("placeholder");
$("#status").val(txt).addClass("phcolor");
}
easyDialog.close();
}
}
}();