@@ -135,52 +135,52 @@ function (comm, Layout, $, doc, Actions, FeedsLayout, ArticlesLayout, ContentLay
135
135
report : function ( ) {
136
136
var report = new ReportView ( ) ;
137
137
document . body . appendChild ( report . render ( ) . el ) ;
138
- }
139
- } ) ) ;
140
-
141
- // Prevent context-menu when alt is pressed
142
- document . addEventListener ( 'keyup' , function ( e ) {
143
- if ( e . keyCode == 18 ) {
144
- e . preventDefault ( ) ;
145
- }
146
- } ) ;
147
-
138
+ } ,
139
+ handleKeyDown : function ( e ) {
140
+ var ac = document . activeElement ;
141
+ if ( ac && ( ac . tagName == 'INPUT' || ac . tagName == 'TEXTAREA' ) ) {
142
+ return ;
143
+ }
148
144
149
- document . addEventListener ( 'keydown' , function ( e ) {
150
- var ac = document . activeElement
151
- if ( ac && ( ac . tagName == 'INPUT' || ac . tagName == 'TEXTAREA' ) ) {
152
- return ;
153
- }
145
+ var str = '' ;
146
+ if ( e . ctrlKey ) str += 'ctrl+' ;
147
+ if ( e . shiftKey ) str += 'shift+' ;
154
148
155
- var str = '' ;
156
- if ( e . ctrlKey ) str += 'ctrl+' ;
157
- if ( e . shiftKey ) str += 'shift+' ;
149
+ if ( e . keyCode > 46 && e . keyCode < 91 ) {
150
+ str += String . fromCharCode ( e . keyCode ) . toLowerCase ( ) ;
151
+ } else if ( e . keyCode in shortcuts . keys ) {
152
+ str += shortcuts . keys [ e . keyCode ] ;
153
+ } else {
154
+ return ;
155
+ }
158
156
159
- if ( e . keyCode > 46 && e . keyCode < 91 ) {
160
- str += String . fromCharCode ( e . keyCode ) . toLowerCase ( ) ;
161
- } else if ( e . keyCode in shortcuts . keys ) {
162
- str += shortcuts . keys [ e . keyCode ] ;
163
- } else {
164
- return ;
165
- }
157
+ var focus = document . activeElement . getAttribute ( 'name' ) ;
166
158
167
- var focus = document . activeElement . getAttribute ( 'name' ) ;
159
+ if ( focus && focus in shortcuts ) {
160
+ if ( str in shortcuts [ focus ] ) {
161
+ app . actions . execute ( shortcuts [ focus ] [ str ] , e ) ;
162
+ e . preventDefault ( ) ;
163
+ return ;
164
+ }
165
+ }
168
166
169
- if ( focus && focus in shortcuts ) {
170
- if ( str in shortcuts [ focus ] ) {
171
- app . actions . execute ( shortcuts [ focus ] [ str ] , e ) ;
167
+ if ( str in shortcuts . global ) {
168
+ app . actions . execute ( shortcuts . global [ str ] , e ) ;
172
169
e . preventDefault ( ) ;
173
- return ;
174
170
}
175
171
}
172
+ } ) ) ;
176
173
177
- if ( str in shortcuts . global ) {
178
- app . actions . execute ( shortcuts . global [ str ] , e ) ;
174
+ // Prevent context-menu when alt is pressed
175
+ document . addEventListener ( 'keyup' , function ( e ) {
176
+ if ( e . keyCode == 18 ) {
179
177
e . preventDefault ( ) ;
180
178
}
181
-
182
179
} ) ;
183
180
184
181
182
+ document . addEventListener ( 'keydown' , app . handleKeyDown ) ;
183
+
184
+
185
185
return app ;
186
186
} ) ;
0 commit comments