Browse Source

Added Keyboard Shortcuts

- Ctrl + Tab to navigate tabs forward.
- Ctrl + Shift + Tab to navigate tabs backward.
- Fixed @ shortcut, because was switching always to tab number 2.
- Added zoom to services with Ctrl + NumPlus, Ctrl + NumMinus and Ctrl +
NumZero.
- Fixes #31 .
- Fixes #58 .
pull/92/merge
Ramiro Saenz 9 years ago
parent
commit
fb3a08953a
  1. 77
      app/Application.js
  2. 1
      app/ux/WebView.js
  3. 1
      app/view/main/Main.js

77
app/Application.js

@ -20,11 +20,78 @@ Ext.define('Rambox.Application', {
// Add shortcuts to switch services using CTRL + Number
var map = new Ext.util.KeyMap({
target: document
,key: "0123456789"
,ctrl: true
,fn: function(key) {
Ext.cq1('app-main').setActiveTab(key - 48);
}
,binding: [
{
key: "\t"
,ctrl: true
,alt: false
,shift: false
,handler: function(key) {
var tabPanel = Ext.cq1('app-main');
var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab());
if ( !tabPanel.items.items[activeIndex + 1] ) {
activeIndex = -1;
} else if ( tabPanel.items.items[activeIndex + 1].tabConfig.xtype === 'tbfill' ) {
activeIndex++;
}
tabPanel.setActiveTab( activeIndex + 1 );
}
}
,{
key: "\t"
,ctrl: true
,alt: false
,shift: true
,handler: function(key) {
var tabPanel = Ext.cq1('app-main');
var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab());
if ( !tabPanel.items.items[activeIndex - 1] ) {
activeIndex = tabPanel.items.length;
} else if ( tabPanel.items.items[activeIndex - 1].tabConfig.xtype === 'tbfill' ) {
activeIndex--;
}
tabPanel.setActiveTab( activeIndex - 1 );
}
}
,{
key: [Ext.event.Event.NUM_PLUS, Ext.event.Event.NUM_MINUS]
,ctrl: true
,alt: false
,shift: false
,handler: function(key) {
var tabPanel = Ext.cq1('app-main');
if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
var currentLevel = tabPanel.getActiveTab().zoomLevel;
if ( key === Ext.event.Event.NUM_PLUS ) { // Plus key
currentLevel = currentLevel + 0.25;
} else { // Minus Key
currentLevel = currentLevel - 0.25;
}
tabPanel.getActiveTab().down('component').el.dom.getWebContents().setZoomLevel(currentLevel);
tabPanel.getActiveTab().zoomLevel = currentLevel;
}
}
,{
key: Ext.event.Event.NUM_ZERO
,ctrl: true
,alt: false
,shift: false
,handler: function(key) {
var tabPanel = Ext.cq1('app-main');
if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
tabPanel.getActiveTab().down('component').el.dom.getWebContents().setZoomLevel(0);
tabPanel.getActiveTab().zoomLevel = 0;
}
}
,{
key: "0123456789"
,ctrl: true
,alt: false
,handler: function(key) {
Ext.cq1('app-main').setActiveTab(key - 48);
}
}
]
});
// Remove spinner after 3 secs

1
app/ux/WebView.js

@ -7,6 +7,7 @@ Ext.define('Rambox.ux.WebView',{
// private
,notifications: 0
,zoomLevel: 0
// CONFIG
,hideMode: 'offsets'

1
app/view/main/Main.js

@ -45,6 +45,7 @@ Ext.define('Rambox.view.main.Main', {
,reorderable: false
,autoScroll: true
,layout: 'hbox'
,tabConfig: {} // Created empty for Keyboard Shortcuts
,items: [
{
xtype: 'panel'

Loading…
Cancel
Save