提交 | 用户 | 时间
|
e7c126
|
1 |
$(function(){ |
H |
2 |
|
|
3 |
// logout |
|
4 |
$("#logoutBtn").click(function(){ |
|
5 |
layer.confirm( I18n.logout_confirm , { |
|
6 |
icon: 3, |
|
7 |
title: I18n.system_tips , |
|
8 |
btn: [ I18n.system_ok, I18n.system_cancel ] |
|
9 |
}, function(index){ |
|
10 |
layer.close(index); |
|
11 |
|
|
12 |
$.post(base_url + "/logout", function(data, status) { |
|
13 |
if (data.code == "200") { |
|
14 |
layer.msg( I18n.logout_success ); |
|
15 |
setTimeout(function(){ |
|
16 |
window.location.href = base_url + "/"; |
|
17 |
}, 500); |
|
18 |
} else { |
|
19 |
layer.open({ |
|
20 |
title: I18n.system_tips , |
|
21 |
btn: [ I18n.system_ok ], |
|
22 |
content: (data.msg || I18n.logout_fail), |
|
23 |
icon: '2' |
|
24 |
}); |
|
25 |
} |
|
26 |
}); |
|
27 |
}); |
|
28 |
|
|
29 |
}); |
|
30 |
|
|
31 |
// slideToTop |
|
32 |
var slideToTop = $("<div />"); |
|
33 |
slideToTop.html('<i class="fa fa-chevron-up"></i>'); |
|
34 |
slideToTop.css({ |
|
35 |
position: 'fixed', |
|
36 |
bottom: '20px', |
|
37 |
right: '25px', |
|
38 |
width: '40px', |
|
39 |
height: '40px', |
|
40 |
color: '#eee', |
|
41 |
'font-size': '', |
|
42 |
'line-height': '40px', |
|
43 |
'text-align': 'center', |
|
44 |
'background-color': '#222d32', |
|
45 |
cursor: 'pointer', |
|
46 |
'border-radius': '5px', |
|
47 |
'z-index': '99999', |
|
48 |
opacity: '.7', |
|
49 |
'display': 'none' |
|
50 |
}); |
|
51 |
slideToTop.on('mouseenter', function () { |
|
52 |
$(this).css('opacity', '1'); |
|
53 |
}); |
|
54 |
slideToTop.on('mouseout', function () { |
|
55 |
$(this).css('opacity', '.7'); |
|
56 |
}); |
|
57 |
$('.wrapper').append(slideToTop); |
|
58 |
$(window).scroll(function () { |
|
59 |
if ($(window).scrollTop() >= 150) { |
|
60 |
if (!$(slideToTop).is(':visible')) { |
|
61 |
$(slideToTop).fadeIn(500); |
|
62 |
} |
|
63 |
} else { |
|
64 |
$(slideToTop).fadeOut(500); |
|
65 |
} |
|
66 |
}); |
|
67 |
$(slideToTop).click(function () { |
|
68 |
$("html,body").animate({ // firefox ie not support body, chrome support body. but found that new version chrome not support body too. |
|
69 |
scrollTop: 0 |
|
70 |
}, 100); |
|
71 |
}); |
|
72 |
|
|
73 |
// left menu status v: js + server + cookie |
|
74 |
$('.sidebar-toggle').click(function(){ |
|
75 |
var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings'); // on=open,off=close |
|
76 |
if ('off' == xxljob_adminlte_settings) { |
|
77 |
xxljob_adminlte_settings = 'on'; |
|
78 |
} else { |
|
79 |
xxljob_adminlte_settings = 'off'; |
|
80 |
} |
|
81 |
$.cookie('xxljob_adminlte_settings', xxljob_adminlte_settings, { expires: 7 }); //$.cookie('the_cookie', '', { expires: -1 }); |
|
82 |
}); |
|
83 |
|
|
84 |
// left menu status v1: js + cookie |
|
85 |
/* |
|
86 |
var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings'); |
|
87 |
if (xxljob_adminlte_settings == 'off') { |
|
88 |
$('body').addClass('sidebar-collapse'); |
|
89 |
} |
|
90 |
*/ |
|
91 |
|
|
92 |
|
|
93 |
// update pwd |
|
94 |
$('#updatePwd').on('click', function(){ |
|
95 |
$('#updatePwdModal').modal({backdrop: false, keyboard: false}).modal('show'); |
|
96 |
}); |
|
97 |
var updatePwdModalValidate = $("#updatePwdModal .form").validate({ |
|
98 |
errorElement : 'span', |
|
99 |
errorClass : 'help-block', |
|
100 |
focusInvalid : true, |
|
101 |
rules : { |
|
102 |
password : { |
|
103 |
required : true , |
|
104 |
rangelength:[4,50] |
|
105 |
} |
|
106 |
}, |
|
107 |
messages : { |
|
108 |
password : { |
|
109 |
required : '请输入密码' , |
|
110 |
rangelength : "密码长度限制为4~50" |
|
111 |
} |
|
112 |
}, |
|
113 |
highlight : function(element) { |
|
114 |
$(element).closest('.form-group').addClass('has-error'); |
|
115 |
}, |
|
116 |
success : function(label) { |
|
117 |
label.closest('.form-group').removeClass('has-error'); |
|
118 |
label.remove(); |
|
119 |
}, |
|
120 |
errorPlacement : function(error, element) { |
|
121 |
element.parent('div').append(error); |
|
122 |
}, |
|
123 |
submitHandler : function(form) { |
|
124 |
$.post(base_url + "/user/updatePwd", $("#updatePwdModal .form").serialize(), function(data, status) { |
|
125 |
if (data.code == 200) { |
|
126 |
$('#updatePwdModal').modal('hide'); |
|
127 |
|
|
128 |
layer.msg( I18n.change_pwd_suc_to_logout ); |
|
129 |
setTimeout(function(){ |
|
130 |
$.post(base_url + "/logout", function(data, status) { |
|
131 |
if (data.code == 200) { |
|
132 |
window.location.href = base_url + "/"; |
|
133 |
} else { |
|
134 |
layer.open({ |
|
135 |
icon: '2', |
|
136 |
content: (data.msg|| I18n.logout_fail) |
|
137 |
}); |
|
138 |
} |
|
139 |
}); |
|
140 |
}, 500); |
|
141 |
} else { |
|
142 |
layer.open({ |
|
143 |
icon: '2', |
|
144 |
content: (data.msg|| I18n.change_pwd + I18n.system_fail ) |
|
145 |
}); |
|
146 |
} |
|
147 |
}); |
|
148 |
} |
|
149 |
}); |
|
150 |
$("#updatePwdModal").on('hide.bs.modal', function () { |
|
151 |
$("#updatePwdModal .form")[0].reset(); |
|
152 |
updatePwdModalValidate.resetForm(); |
|
153 |
$("#updatePwdModal .form .form-group").removeClass("has-error"); |
|
154 |
}); |
|
155 |
|
|
156 |
}); |