72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
|
/* 切换用户登录框 */
|
|||
|
function switch_user(){
|
|||
|
art.dialog.open('\\cn\\control\\switch_user.jsp', {
|
|||
|
title: '切换用户',
|
|||
|
lock:true,
|
|||
|
fixed: true,
|
|||
|
resize: false,
|
|||
|
// 在open()方法中,init会等待iframe加载完毕后执行
|
|||
|
init: function () {
|
|||
|
var iframe = this.iframe.contentWindow;
|
|||
|
var top = art.dialog.top;// 引用顶层页面window对象
|
|||
|
var username = iframe.document.getElementById('login-form-username');
|
|||
|
//username.value = 'guest';
|
|||
|
setTimeout(function () {
|
|||
|
username.select();
|
|||
|
}, 80);
|
|||
|
//top.document.title = '切换用户';
|
|||
|
},
|
|||
|
button:[
|
|||
|
{
|
|||
|
name:'切换',
|
|||
|
focus:true,
|
|||
|
callback: function () {
|
|||
|
var iframe = this.iframe.contentWindow;
|
|||
|
if (!iframe.document.body) {
|
|||
|
art.dialog.tips('iframe还没加载完毕呢');
|
|||
|
return false;
|
|||
|
};
|
|||
|
var form = iframe.document.getElementById('login-form'),
|
|||
|
username = iframe.document.getElementById('login-form-username'),
|
|||
|
password = iframe.document.getElementById('login-form-password');
|
|||
|
if (check(username) && check(password)) form.submit();
|
|||
|
return false;
|
|||
|
}
|
|||
|
},
|
|||
|
{
|
|||
|
name:'取消',
|
|||
|
callback:function(){
|
|||
|
art.dialog.tips('您取消了操作!',1.5,false);
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
]
|
|||
|
});
|
|||
|
// 表单验证
|
|||
|
var check = function (input) {
|
|||
|
if (input.value === '') {
|
|||
|
inputError(input);
|
|||
|
input.focus();
|
|||
|
return false;
|
|||
|
} else {
|
|||
|
return true;
|
|||
|
};
|
|||
|
};
|
|||
|
// 输入错误提示
|
|||
|
var inputError = function (input) {
|
|||
|
clearTimeout(inputError.timer);
|
|||
|
var num = 0;
|
|||
|
var fn = function () {
|
|||
|
inputError.timer = setTimeout(function () {
|
|||
|
input.className = input.className === '' ? 'login-form-error' : '';
|
|||
|
if (num === 5) {
|
|||
|
input.className === '';
|
|||
|
} else {
|
|||
|
fn(num ++);
|
|||
|
};
|
|||
|
}, 150);
|
|||
|
};
|
|||
|
fn();
|
|||
|
};
|
|||
|
|
|||
|
}
|