Browse Source

Zoom: fixes and improvements

fixes #2397
pull/2453/head
Vulich Fernando 6 years ago
parent
commit
8456831acc
  1. 20
      app.js
  2. 8
      app/ux/WebView.js
  3. 9
      electron/menu.js

20
app.js

@ -147,3 +147,23 @@ ipc.on('toggleStatusBar', function() {
window.addEventListener('focus', function() {
if(Ext.cq1("app-main")) Ext.cq1("app-main").getActiveTab().down('component').el.dom.focus();
});
// Handles zoom from menu
ipc.on('resetzoom-webview', function() {
var tabPanel = Ext.cq1('app-main');
if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
tabPanel.getActiveTab().resetZoom();
});
ipc.on('zoomin-webview', function() {
var tabPanel = Ext.cq1('app-main');
if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
tabPanel.getActiveTab().zoomIn();
});
ipc.on('zoomout-webview', function() {
var tabPanel = Ext.cq1('app-main');
if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
tabPanel.getActiveTab().zoomOut();
});

8
app/ux/WebView.js

@ -807,25 +807,29 @@ Ext.define('Rambox.ux.WebView',{
}
,zoomIn: function() {
if ( this.timeout ) clearTimeout( this.timeout );
this.timeout = setTimeout(() => {
var me = this;
var webview = me.getWebView();
me.zoomLevel = me.zoomLevel + 0.25;
if ( me.record.get('enabled') ) {
webview.setZoomLevel(me.zoomLevel);
me.record.set('zoomLevel', me.zoomLevel);
}
}, 100);
}
,zoomOut: function() {
if ( this.timeout ) clearTimeout( this.timeout );
this.timeout = setTimeout(() => {
var me = this;
var webview = me.getWebView();
me.zoomLevel = me.zoomLevel - 0.25;
if ( me.record.get('enabled') ) {
webview.setZoomLevel(me.zoomLevel);
me.record.set('zoomLevel', me.zoomLevel);
}
}, 100);
}
,resetZoom: function() {

9
electron/menu.js

@ -172,13 +172,16 @@ module.exports = function(config) {
type: 'separator'
},
{
role: 'zoomin'
label: 'Zoom In',
click(item, win) { win.webContents.send('zoomin-webview')}
},
{
role: 'zoomout'
label: 'Zoom Out',
click(item, win) { win.webContents.send('zoomout-webview')}
},
{
role: 'resetzoom'
label: 'Reset Zoom',
click(item, win) { win.webContents.send('resetzoom-webview')}
}
]
},

Loading…
Cancel
Save