Ext.ns('app');
Ext.BLANK_IMAGE_URL = '../extjs/resources/images/default/s.gif';
Ext.QuickTips.init();
app.login = {
init:function(){
var textUsuario = new Ext.form.TextField({
fieldLabel:'Usuario',
id:'txtlogin',
name:'loginUsername',
allowBlank:false,
autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: 8 },
listeners : {
specialkey : function(field, e) {
if (e.getKey() == e.ENTER){
Ext.getCmp('txtpass').focus(true);
}
}
}
});
var textPassword = new Ext.form.TextField({
fieldLabel : 'Contraseña',
id : 'txtpass',
name : 'loginPassword',
inputType : 'password',
allowBlank : false,
autoCreate : {tag : "input", type : "text", autocomplete : "off", maxlength : 8 },
listeners : {
specialkey : function(field, e) {
if (e.getKey() == e.ENTER){
Ext.getCmp('login').focus(true);
}
}
}
});
var form = new Ext.FormPanel({
id : 'formlogin',
baseCls : 'x-plain',
frame : true,
autoScroll : false,
bodyStyle : 'padding:10px;',
url : 'php/login.php',
title : 'Por favor, identifíquese',
items : [{
xtype:'fieldset',
title:'Usuario / Contraseña',
autoWidth:true,
labelWidth: 90,
autoHeight:true,
defaultType: 'textfield',
items:[textUsuario,textPassword]
}],
buttons:[{
text:'Login',
id : 'login',
formBind: true,
handler:function(){
form.getForm().submit({
method:'POST',
waitTitle:'Conectando',
waitMsg:'Enviando datos...',
success:function(){
win.hide();
Ext.Msg.wait('Cargando escritorio... por favor espere!');
window.setTimeout(function(){
Ext.Msg.hide();
var redirect = 'desktop.php';
window.location = redirect;
},1000);
},
failure:function(form, action){
if(action.failureType == 'server'){
respuesta = Ext.util.JSON.decode(action.response.responseText);
Ext.MessageBox.show({
title : 'ERROR',
msg : respuesta.errors.razon,
icon : Ext.MessageBox.ERROR,
buttons : Ext.MessageBox.OK
});
}else{
Ext.Msg.alert('¡Atención!', 'Fallo de conexión con el servidor de autenticación: ' + action.response.responseText);
}
var login = Ext.getCmp('formlogin');
form.reset();
Ext.getCmp('txtlogin').focus(true,500);
}
});
}
}]
});
var win = new Ext.Window({
id:'winlogin',
layout:'fit',
width:340,
height:180,
closable: false,
resizable: false,
plain: true,
border: false,
modal:true,
items: [form],
listeners : {
afterrender : function(){
Ext.getCmp('txtlogin').focus(true,500);
}
}
});
win.show();
}
}
Ext.onReady(app.login.init,app.login); It looks like you're new here. If you want to get involved, click one of these buttons!
The content of this site is copyrighted by Quizzpot.com, it is prohibited to publish our tutorials on other blogs, magazines or any other media without prior permission.
Copyright © 2012 Quizzpot.
Our visitors are mostly developers and Web designers, advertise with us, you only need to contact us .