@@ -5,6 +5,7 @@ import styles from './StatusBar.styl'
5
5
import ZoomManager from 'browser/main/lib/ZoomManager'
6
6
import i18n from 'browser/lib/i18n'
7
7
import context from 'browser/lib/context'
8
+ import EventEmitter from 'browser/main/lib/eventEmitter'
8
9
9
10
const electron = require ( 'electron' )
10
11
const { remote, ipcRenderer } = electron
@@ -13,6 +14,26 @@ const { dialog } = remote
13
14
const zoomOptions = [ 0.8 , 0.9 , 1 , 1.1 , 1.2 , 1.3 , 1.4 , 1.5 , 1.6 , 1.7 , 1.8 , 1.9 , 2.0 ]
14
15
15
16
class StatusBar extends React . Component {
17
+
18
+ constructor ( props ) {
19
+ super ( props )
20
+ this . handleZoomInMenuItem = this . handleZoomInMenuItem . bind ( this )
21
+ this . handleZoomOutMenuItem = this . handleZoomOutMenuItem . bind ( this )
22
+ this . handleZoomResetMenuItem = this . handleZoomResetMenuItem . bind ( this )
23
+ }
24
+
25
+ componentDidMount ( ) {
26
+ EventEmitter . on ( 'status:zoomin' , this . handleZoomInMenuItem )
27
+ EventEmitter . on ( 'status:zoomout' , this . handleZoomOutMenuItem )
28
+ EventEmitter . on ( 'status:zoomreset' , this . handleZoomResetMenuItem )
29
+ }
30
+
31
+ componentWillUnmount ( ) {
32
+ EventEmitter . off ( 'status:zoomin' , this . handleZoomInMenuItem )
33
+ EventEmitter . off ( 'status:zoomout' , this . handleZoomOutMenuItem )
34
+ EventEmitter . off ( 'status:zoomreset' , this . handleZoomResetMenuItem )
35
+ }
36
+
16
37
updateApp ( ) {
17
38
const index = dialog . showMessageBox ( remote . getCurrentWindow ( ) , {
18
39
type : 'warning' ,
@@ -48,6 +69,20 @@ class StatusBar extends React.Component {
48
69
} )
49
70
}
50
71
72
+ handleZoomInMenuItem ( ) {
73
+ const zoomFactor = ZoomManager . getZoom ( ) + 0.1
74
+ this . handleZoomMenuItemClick ( zoomFactor )
75
+ }
76
+
77
+ handleZoomOutMenuItem ( ) {
78
+ const zoomFactor = ZoomManager . getZoom ( ) - 0.1
79
+ this . handleZoomMenuItemClick ( zoomFactor )
80
+ }
81
+
82
+ handleZoomResetMenuItem ( ) {
83
+ this . handleZoomMenuItemClick ( 1.0 )
84
+ }
85
+
51
86
render ( ) {
52
87
const { config, status } = this . context
53
88
0 commit comments