commit e33bc0d972fb61e573a1b24354ca2f4af4bd4f5c
parent d0b8cf57e8b5076db4c4590e6cc830bd001b7682
Author: Felicia Hummel <felicia@partkeepr.com>
Date: Tue, 17 Jan 2017 18:27:40 +0100
Use ExtJS6-style keymaps, fixes #789
Diffstat:
2 files changed, 84 insertions(+), 78 deletions(-)
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Auth/LoginDialog.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Auth/LoginDialog.js
@@ -2,84 +2,90 @@
* Defines the login dialog
*/
Ext.define('PartKeepr.LoginDialog', {
- extend: 'Ext.Window',
+ extend: 'Ext.Window',
- title: i18n("PartKeepr: Login"),
-
- maxWidth: 400,
+ title: i18n("PartKeepr: Login"),
- modal: true,
- resizable: false,
-
- layout: 'anchor',
- bodyStyle: 'padding: 5px;',
-
- /**
- * Initializes the login dialog component
+ maxWidth: 400,
+
+ modal: true,
+ resizable: false,
+
+ layout: 'anchor',
+ bodyStyle: 'padding: 5px;',
+
+ keyMap: {
+ scope: 'this',
+ ESC: 'onEsc',
+ ENTER: 'login'
+ },
+
+ /**
+ * Initializes the login dialog component
*
* @todo Get rid of this stuff and implement it ExtJS5 (modern style)
- */
- initComponent: function () {
-
- this.loginField = Ext.ComponentMgr.create({
- xtype: 'textfield',
- value: "",
- fieldLabel: i18n("Username"),
- anchor: '100%'
- });
+ */
+ initComponent: function ()
+ {
- this.passwordField = Ext.ComponentMgr.create({
- xtype: 'textfield',
- inputType: "password",
- value: "",
- fieldLabel: i18n("Password"),
- anchor: '100%'
+ this.loginField = Ext.ComponentMgr.create({
+ xtype: 'textfield',
+ value: "",
+ fieldLabel: i18n("Username"),
+ anchor: '100%'
});
-
- Ext.apply(this, {
- items: [
- this.loginField,
- this.passwordField
- ],
- dockedItems: [{
- xtype: 'toolbar',
- enableOverflow: false,
- dock: 'bottom',
- ui: 'footer',
- pack: 'start',
- defaults: {minWidth: 100},
- items: [
- {
- text: i18n("Connect"),
- iconCls: "web-icon connect",
- handler: Ext.bind(this.login, this)
- },{
- text: i18n("Close"),
- iconCls: "web-icon cancel",
- handler: Ext.bind(this.close, this)
- }]
- }]
- });
-
- this.callParent(arguments);
- this.on("render", this.assignEnterKey, this);
- // Focus the login field on show
- // @workaround Set the focus 100ms after the dialog has been shown.
- this.on("show", function () { this.loginField.focus(); }, this, { delay: 100 });
- },
- /**
- * Assigns the enter key to the login window.
- */
- assignEnterKey: function () {
- var keyMap = this.getKeyMap();
- keyMap.on(Ext.event.Event.ENTER, this.login, this);
- },
- /**
- * Fires the "login" event
- */
- login: function () {
- this.fireEvent("login", this.loginField.getValue(), this.passwordField.getValue());
- }
+ this.passwordField = Ext.ComponentMgr.create({
+ xtype: 'textfield',
+ inputType: "password",
+ value: "",
+ fieldLabel: i18n("Password"),
+ anchor: '100%'
+ });
+
+ Ext.apply(this, {
+ items: [
+ this.loginField,
+ this.passwordField
+ ],
+ dockedItems: [
+ {
+ xtype: 'toolbar',
+ enableOverflow: false,
+ dock: 'bottom',
+ ui: 'footer',
+ pack: 'start',
+ defaults: {minWidth: 100},
+ items: [
+ {
+ text: i18n("Connect"),
+ iconCls: "web-icon connect",
+ handler: Ext.bind(this.login, this)
+ }, {
+ text: i18n("Close"),
+ iconCls: "web-icon cancel",
+ handler: Ext.bind(this.close, this)
+ }
+ ]
+ }
+ ]
+ });
+
+ this.callParent(arguments);
+
+ // Focus the login field on show
+ // @workaround Set the focus 100ms after the dialog has been shown.
+ this.on("show", function ()
+ {
+ this.loginField.focus();
+ }, this, {delay: 100});
+ },
+ /**
+ * Fires the "login" event
+ */
+ login: function ()
+ {
+ this.fireEvent("login", this.loginField.getValue(), this.passwordField.getValue());
+ }
});
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Dialogs/ExceptionWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Dialogs/ExceptionWindow.js
@@ -12,6 +12,12 @@ Ext.define('PartKeepr.ExceptionWindow', {
constrain: true,
cls: Ext.baseCSSPrefix + 'message-box',
+ keyMap: {
+ scope: 'this',
+ ESC: 'onEsc',
+ ENTER: 'onEsc'
+ },
+
initComponent: function ()
{
this.iconComponent = Ext.create('Ext.Component', {
@@ -215,12 +221,6 @@ Ext.define('PartKeepr.ExceptionWindow', {
this.show();
this.topContainer.layout.setActiveItem(0);
-
- var keyMap = this.getKeyMap();
- keyMap.on(Ext.event.Event.ENTER, function ()
- {
- this.hide();
- }, this);
},
/**
* Recursively converts a trace to an ExtJS tree