webui: fix the login window

The login window now functions correctly under ExtJS 4.0.
This commit is contained in:
Damien Churchill 2011-06-13 11:55:45 +01:00
parent 8ae14de208
commit bf4b826809
1 changed files with 31 additions and 24 deletions

View File

@ -46,35 +46,41 @@ Ext.define('Deluge.LoginWindow', {
resizable: false, resizable: false,
title: _('Login'), title: _('Login'),
width: 300, width: 300,
height: 120, height: 105,
initComponent: function() { initComponent: function() {
this.callParent(arguments); this.callParent(arguments);
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
// this.addButton({ this.addDocked({
// text: _('Login'), xtype: 'toolbar',
// handler: this.onLogin, dock: 'bottom',
// scope: this defaultType: 'button',
// }); items: [
'->',
{text: _('Login'), handler: this.onLogin, scope: this}
]
});
this.form = this.add({ this.form = this.add({
xtype: 'form', xtype: 'form',
baseCls: 'x-plain', baseCls: 'x-plain',
labelWidth: 55,
width: 300, width: 300,
defaults: {width: 200}, items: [{
defaultType: 'textfield' xtype: 'textfield',
fieldLabel: _('Password'),
name: 'password',
inputType: 'password',
labelWidth: 60,
width: 275,
listeners: {
specialkey: {
scope: this,
fn: this.onSpecialKey
}
}
}]
}); });
this.passwordField = this.form.add({
xtype: 'textfield',
fieldLabel: _('Password'),
id: '_password',
name: 'password',
inputType: 'password'
});
this.passwordField.on('specialkey', this.onSpecialKey, this);
}, },
logout: function() { logout: function() {
@ -94,7 +100,7 @@ Ext.define('Deluge.LoginWindow', {
} }
if (skipCheck) { if (skipCheck) {
return this.callParent(arguments); return this.callParent();
} }
deluge.client.auth.check_session({ deluge.client.auth.check_session({
@ -117,13 +123,14 @@ Ext.define('Deluge.LoginWindow', {
}, },
onLogin: function() { onLogin: function() {
var passwordField = this.passwordField; var f = this.form.getForm(),
deluge.client.auth.login(passwordField.getValue(), { p = f.getValues().password;;
deluge.client.auth.login(p, {
success: function(result) { success: function(result) {
if (result) { if (result) {
deluge.events.fire('login'); deluge.events.fire('login');
this.hide(); this.hide();
passwordField.setRawValue(''); f.setValues({password: ''});
} else { } else {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Login Failed'), title: _('Login Failed'),
@ -131,7 +138,7 @@ Ext.define('Deluge.LoginWindow', {
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
fn: function() { fn: function() {
passwordField.focus(true, 10); f.findField('password').focus(true, 10);
}, },
icon: Ext.MessageBox.WARNING, icon: Ext.MessageBox.WARNING,
iconCls: 'x-deluge-icon-warning' iconCls: 'x-deluge-icon-warning'
@ -150,6 +157,6 @@ Ext.define('Deluge.LoginWindow', {
}, },
onShow: function() { onShow: function() {
this.passwordField.focus(true, true); this.form.getForm().findField('password').focus(true, 10);
} }
}); });