LoginDialog.js (2380B)
1 /** 2 * Defines the login dialog 3 */ 4 Ext.define('PartKeepr.LoginDialog', { 5 extend: 'Ext.Window', 6 7 title: i18n("PartKeepr: Login"), 8 9 controller: 'LoginController', 10 11 maxWidth: 400, 12 13 modal: true, 14 resizable: false, 15 16 layout: 'anchor', 17 bodyStyle: 'padding: 5px;', 18 19 keyMap: { 20 ESC: 'onEsc', 21 ENTER: 'login' 22 }, 23 24 /** 25 * Initializes the login dialog component 26 * 27 * @todo Get rid of this stuff and implement it ExtJS5 (modern style) 28 */ 29 initComponent: function () 30 { 31 32 this.loginField = Ext.ComponentMgr.create({ 33 xtype: 'textfield', 34 value: "", 35 itemId: 'username', 36 fieldLabel: i18n("Username"), 37 anchor: '100%' 38 }); 39 40 this.passwordField = Ext.ComponentMgr.create({ 41 xtype: 'textfield', 42 inputType: "password", 43 itemId: 'password', 44 value: "", 45 fieldLabel: i18n("Password"), 46 anchor: '100%' 47 }); 48 49 Ext.apply(this, { 50 items: [ 51 this.loginField, 52 this.passwordField 53 ], 54 dockedItems: [ 55 { 56 xtype: 'toolbar', 57 enableOverflow: false, 58 dock: 'bottom', 59 ui: 'footer', 60 pack: 'start', 61 defaults: {minWidth: 100}, 62 items: [ 63 { 64 text: i18n("Connect"), 65 iconCls: "web-icon connect", 66 handler: 'login' 67 }, { 68 text: i18n("Close"), 69 iconCls: "web-icon cancel", 70 handler: Ext.bind(this.close, this) 71 } 72 ] 73 } 74 ] 75 }); 76 77 this.callParent(arguments); 78 79 // Focus the login field on show 80 // @workaround Set the focus 100ms after the dialog has been shown. 81 this.on("show", function () 82 { 83 this.loginField.focus(); 84 }, this, {delay: 100}); 85 }, 86 getUsername: function () { 87 return this.down("#username").getValue(); 88 }, 89 getPassword: function () { 90 return this.down("#password").getValue(); 91 } 92 });