diff --git a/deluge/ui/web/js/deluge-bars.js b/deluge/ui/web/js/deluge-bars.js index 439a9ba9d..febfb70fb 100644 --- a/deluge/ui/web/js/deluge-bars.js +++ b/deluge/ui/web/js/deluge-bars.js @@ -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) { diff --git a/deluge/ui/web/js/deluge-login.js b/deluge/ui/web/js/deluge-login.js index ed9e7f003..b88d7a5f1 100644 --- a/deluge/ui/web/js/deluge-login.js +++ b/deluge/ui/web/js/deluge-login.js @@ -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}} -}); \ No newline at end of file +(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(); +})(); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-ui.js b/deluge/ui/web/js/deluge-ui.js index 86ef629fc..1d704865c 100644 --- a/deluge/ui/web/js/deluge-ui.js +++ b/deluge/ui/web/js/deluge-ui.js @@ -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() {