Commit bccee238 authored by Florian Staudacher's avatar Florian Staudacher
Browse files

Merge pull request #3399 from Raven24/fix-3327

don't open comment pane on show page, if a modifier key is pressed
parents b6bc2eac 64a20793
...@@ -62,9 +62,9 @@ app.pages.PostViewer = app.views.Base.extend({ ...@@ -62,9 +62,9 @@ app.pages.PostViewer = app.views.Base.extend({
if($(evt.target).is("textarea")) { return } if($(evt.target).is("textarea")) { return }
switch(evt.keyCode) { switch(evt.keyCode) {
case 37: case KEYCODES.LEFT:
app.router.navigate(model.get("next_post"), true); break; app.router.navigate(model.get("next_post"), true); break;
case 39: case KEYCODES.RIGHT:
app.router.navigate(model.get("previous_post"), true); break; app.router.navigate(model.get("previous_post"), true); break;
default: default:
break; break;
...@@ -78,19 +78,25 @@ app.pages.PostViewer = app.views.Base.extend({ ...@@ -78,19 +78,25 @@ app.pages.PostViewer = app.views.Base.extend({
commentAnywhere : function(evt) { commentAnywhere : function(evt) {
/* ignore enter, space bar, arrow keys */ /* ignore enter, space bar, arrow keys */
if(_.include([13, 32, 37, 38, 39, 40], evt.keyCode)) { return } if(_.include([KEYCODES.RETURN, KEYCODES.SPACE, KEYCODES.LEFT,
KEYCODES.UP, KEYCODES.RIGHT, KEYCODES.DOWN], evt.keyCode) ||
this.modifierPressed(evt) ) { return }
this.interactionsView.invokePane(); this.interactionsView.invokePane();
$('#new-post-comment textarea').focus(); $('#new-post-comment textarea').focus();
}, },
invokePane : function(evt) { invokePane : function(evt) {
if(evt.keyCode != 32) { return } if(evt.keyCode != KEYCODES.SPACE) { return }
this.interactionsView.invokePane(); this.interactionsView.invokePane();
}, },
closePane : function(evt) { closePane : function(evt) {
if(evt.keyCode != 27) { return } if(evt.keyCode != KEYCODES.ESC) { return }
this.interactionsView.hidePane(); this.interactionsView.hidePane();
},
modifierPressed: function(evt) {
return (evt.altKey || evt.ctrlKey || evt.shiftKey);
} }
}); });
...@@ -12,6 +12,7 @@ CAPSLOCK : 20, ...@@ -12,6 +12,7 @@ CAPSLOCK : 20,
ESCAPE : 27, ESCAPE : 27,
ESC : 27, ESC : 27,
SPACEBAR : 32, SPACEBAR : 32,
SPACE: 32,
PAGEUP : 33, PAGEUP : 33,
PAGEDOWN : 34, PAGEDOWN : 34,
END : 35, END : 35,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment