enable tab switch with key shortcuts
authorCornelius Weiß <c.weiss@metaways.de>
Tue, 5 Jul 2016 08:08:11 +0000 (10:08 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 8 Jul 2016 09:30:17 +0000 (11:30 +0200)
* CTRL-1 for first tab, CTRL-2 for second, ...

Change-Id: I4d0a19e853bab9fd6068a0edd4c9b020dc8c8aba
Reviewed-on: http://gerrit.tine20.com/customers/3305
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/js/ux/TabPanelKeyPlugin.js

index 96adacc..9a7d92c 100644 (file)
@@ -24,7 +24,8 @@ Ext.ux.TabPanelKeyPlugin.prototype = {
         
     init : function(panel) {
         this.panel = panel;
-        this.panel.onRender = this.panel.onRender.createSequence(this.onRender, this);
+        this.panel.on('afterrender', this.onRender, this);
+        this.panel.on('add', this.onItemAdd, this);
     },
     
     /**
@@ -41,17 +42,27 @@ Ext.ux.TabPanelKeyPlugin.prototype = {
         
         for (var index = 0; index < tabCount; index++) {
             var item = this.panel.items.items[index];
-            if(item.disabled !== true) {
-                new Ext.KeyMap(this.panel.el, [{
-                    key: index + 49,
-                    ctrl: true,
-                    scope: this,
-                    fn: this.switchTab
-                }]);
-            }
+            this.registerKeyMap(item, index);
         }
     },
-    
+
+    onItemAdd: function(panel, item, index) {
+        this.registerKeyMap(item, index);
+    },
+
+    registerKeyMap: function(item, index, el) {
+        el = el || Ext.getBody();
+
+        if(item.disabled !== true) {
+            new Ext.KeyMap(el, [{
+                key: index + 49,
+                ctrl: true,
+                scope: this,
+                fn: this.switchTab
+            }]);
+        }
+    },
+
     /**
      * switch to tab
      * @param Integer code