Keyboard shortcuts for new progress expansion

This commit is contained in:
Robin Ward 2014-06-13 14:02:55 -04:00
parent 42ca46e628
commit cf165320e2
5 changed files with 28 additions and 1 deletions

View File

@ -44,6 +44,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
FUNCTION_BINDINGS: {
'home': 'goToFirstPost',
'#': 'toggleProgress',
'end': 'goToLastPost',
'j': 'selectDown',
'k': 'selectUp',
@ -132,6 +133,10 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
}
},
toggleProgress: function() {
Discourse.__container__.lookup('controller:topic-progress').send('toggleExpansion');
},
showSearch: function() {
$('#search-button').click();
return false;

View File

@ -14,6 +14,7 @@
<h4>{{i18n keyboard_shortcuts_help.navigation.title}}</h4>
<ul>
<li>{{{i18n keyboard_shortcuts_help.navigation.back}}}</li>
<li>{{{i18n keyboard_shortcuts_help.navigation.jump}}}</li>
<li>{{{i18n keyboard_shortcuts_help.navigation.up_down}}}</li>
<li>{{{i18n keyboard_shortcuts_help.navigation.open}}}</li>
<li>{{{i18n keyboard_shortcuts_help.navigation.next_prev}}}</li>

View File

@ -76,10 +76,30 @@ export default Ember.View.extend({
this.set('docked', isDocked);
},
_focusWhenOpened: function() {
if (this.get('controller.expanded')) {
var self = this;
Em.run.schedule('afterRender', function() {
self.$('input').focus();
});
}
}.observes('controller.expanded'),
click: function(e) {
if ($(e.target).parents('#topic-progress').length) {
this.get('controller').send('toggleExpansion');
}
},
keyDown: function(e) {
var controller = this.get('controller');
if (controller.get('expanded')) {
if (e.keyCode === 13) {
controller.send('jumpPost');
} else if (e.keyCode === 27) {
controller.send('toggleExpansion');
}
}
}
});

View File

@ -11,7 +11,7 @@
}
.keyboard-shortcuts-modal .modal-body {
max-height: 500px;
max-height: 520px;
}
#keyboard-shortcuts-help {

View File

@ -1850,6 +1850,7 @@ en:
categories: '<b>g</b> then <b>c</b> Categories'
navigation:
title: 'Navigation'
jump: '<b>#</b> Go to post number'
back: '<b>u</b> Back'
up_down: '<b>k</b>/<b>j</b> Move selection up/down'
open: '<b>o</b> or <b>Enter</b> Open selected topic'