mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-09 18:14:11 +00:00
tidy up the login window code, extend Ext.Window instead.
focus the password field upon the login window being displayed
This commit is contained in:
parent
b71ac41ff1
commit
2e4762a586
@ -50,7 +50,7 @@ Deluge.ToolBar = {
|
||||
onLogout: function() {
|
||||
this.Bar.items.get('logout').disable();
|
||||
Deluge.Events.fire('logout');
|
||||
Deluge.Login.Window.show();
|
||||
Deluge.Login.show();
|
||||
},
|
||||
|
||||
onConnectionManagerClick: function(item) {
|
||||
|
@ -21,79 +21,96 @@ Copyright:
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
Deluge.Login = {
|
||||
onLogin: function() {
|
||||
var passwordField = Deluge.Login.Form.items.get('password');
|
||||
Deluge.Client.web.login(passwordField.getValue(), {
|
||||
onSuccess: function(result) {
|
||||
if (result == true) {
|
||||
Deluge.Login.Window.hide();
|
||||
Deluge.Connections.loginShow();
|
||||
passwordField.setRawValue('');
|
||||
Deluge.Events.fire('login')
|
||||
} else {
|
||||
Ext.MessageBox.show({
|
||||
title: _('Login Failed'),
|
||||
msg: _('You entered an incorrect password'),
|
||||
buttons: Ext.MessageBox.OK,
|
||||
modal: false,
|
||||
icon: Ext.MessageBox.WARNING,
|
||||
iconCls: 'x-deluge-icon-warning'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onLogout: function() {
|
||||
Deluge.Login.Window.show();
|
||||
},
|
||||
|
||||
onKey: function(field, e) {
|
||||
if (e.getKey() == 13) Deluge.Login.onLogin();
|
||||
},
|
||||
|
||||
onRender: function() {
|
||||
Deluge.Events.on('logout', this.onLogout);
|
||||
}
|
||||
}
|
||||
|
||||
Deluge.Login.Form = new Ext.form.FormPanel({
|
||||
defaultType: 'textfield',
|
||||
id: 'loginForm',
|
||||
baseCls: 'x-plain',
|
||||
labelWidth: 55,
|
||||
items: [{
|
||||
fieldLabel: _('Password'),
|
||||
id: 'password',
|
||||
name: 'password',
|
||||
inputType: 'password',
|
||||
anchor: '100%',
|
||||
listeners: {
|
||||
'specialkey': {
|
||||
fn: Deluge.Login.onKey,
|
||||
scope: Deluge.Login
|
||||
}
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
Deluge.Login.Window = new Ext.Window({
|
||||
layout: 'fit',
|
||||
width: 300,
|
||||
height: 120,
|
||||
bodyStyle: 'padding: 10px 5px;',
|
||||
buttonAlign: 'center',
|
||||
closeAction: 'hide',
|
||||
closable: false,
|
||||
modal: true,
|
||||
plain: true,
|
||||
title: _('Login'),
|
||||
iconCls: 'x-deluge-login-window-icon',
|
||||
items: Deluge.Login.Form,
|
||||
buttons: [{
|
||||
text: _('Login'),
|
||||
handler: Deluge.Login.onLogin
|
||||
}],
|
||||
listeners: {'render': {fn: Deluge.Login.onRender, scope: Deluge.Login}}
|
||||
});
|
||||
(function(){
|
||||
var LoginWindow = function(config) {
|
||||
Ext.apply(this, {
|
||||
layout: 'fit',
|
||||
width: 300,
|
||||
height: 120,
|
||||
bodyStyle: 'padding: 10px 5px;',
|
||||
buttonAlign: 'center',
|
||||
closeAction: 'hide',
|
||||
closable: false,
|
||||
modal: true,
|
||||
plain: true,
|
||||
resizable: false,
|
||||
title: _('Login'),
|
||||
iconCls: 'x-deluge-login-window-icon'
|
||||
});
|
||||
Ext.apply(this, config);
|
||||
LoginWindow.superclass.constructor.call(this);
|
||||
};
|
||||
|
||||
Ext.extend(LoginWindow, Ext.Window, {
|
||||
initComponent: function() {
|
||||
LoginWindow.superclass.initComponent.call();
|
||||
Deluge.Events.on('logout', this.onLogout);
|
||||
this.on('show', this.onShow, this);
|
||||
|
||||
this.addButton({
|
||||
text: _('Login'),
|
||||
handler: this.onLogin,
|
||||
scope: this
|
||||
});
|
||||
|
||||
this.loginForm = this.add({
|
||||
xtype: 'form',
|
||||
defaultType: 'textfield',
|
||||
id: 'loginForm',
|
||||
baseCls: 'x-plain',
|
||||
labelWidth: 55,
|
||||
items: [{
|
||||
fieldLabel: _('Password'),
|
||||
id: 'password',
|
||||
name: 'password',
|
||||
inputType: 'password',
|
||||
anchor: '100%',
|
||||
listeners: {
|
||||
'specialkey': {
|
||||
fn: this.onKey,
|
||||
scope: this
|
||||
}
|
||||
}
|
||||
}]
|
||||
});
|
||||
},
|
||||
|
||||
onKey: function(field, e) {
|
||||
if (e.getKey() == 13) this.onLogin();
|
||||
},
|
||||
|
||||
onLogin: function() {
|
||||
var passwordField = this.loginForm.items.get('password');
|
||||
Deluge.Client.web.login(passwordField.getValue(), {
|
||||
onSuccess: function(result) {
|
||||
if (result == true) {
|
||||
this.hide();
|
||||
Deluge.Connections.loginShow();
|
||||
passwordField.setRawValue('');
|
||||
Deluge.Events.fire('login')
|
||||
} else {
|
||||
Ext.MessageBox.show({
|
||||
title: _('Login Failed'),
|
||||
msg: _('You entered an incorrect password'),
|
||||
buttons: Ext.MessageBox.OK,
|
||||
modal: false,
|
||||
icon: Ext.MessageBox.WARNING,
|
||||
iconCls: 'x-deluge-icon-warning'
|
||||
});
|
||||
}
|
||||
}.bindWithEvent(this)
|
||||
});
|
||||
},
|
||||
|
||||
onLogout: function() {
|
||||
this.show();
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
var passwordField = this.loginForm.items.get('password');
|
||||
passwordField.focus(false, 150);
|
||||
}
|
||||
});
|
||||
|
||||
Deluge.Login = new LoginWindow();
|
||||
})();
|
@ -48,7 +48,7 @@ Deluge.UI = {
|
||||
items: [this.MainPanel]
|
||||
});
|
||||
|
||||
Deluge.Login.Window.show();
|
||||
Deluge.Login.show();
|
||||
|
||||
Deluge.Events.on("connect", this.onConnect.bindWithEvent(this));
|
||||
Deluge.Events.on("disconnect", this.onDisconnect.bindWithEvent(this));
|
||||
@ -56,7 +56,7 @@ Deluge.UI = {
|
||||
},
|
||||
|
||||
notify: function(title, message) {
|
||||
this.roar.alert(title, message);
|
||||
//this.roar.alert(title, message);
|
||||
},
|
||||
|
||||
update: function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user