FEATURE: Added Pin/Unpin Keyboard Shortcut

This commit is contained in:
cpradio 2014-11-12 09:36:24 -05:00
parent a036ac7bdc
commit 61cc8ead44
4 changed files with 16 additions and 0 deletions

View File

@ -369,6 +369,11 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
this.get('content').clearPin();
},
togglePinnedForUser: function() {
if (this.get('pinned_at'))
this.get('pinned') ? this.get('content').clearPin() : this.get('content').rePin();
},
replyAsNewTopic: function(post) {
var composerController = this.get('controllers.composer'),
quoteController = this.get('controllers.quote-button'),
@ -437,6 +442,10 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
}
},
togglePinnedState: function() {
this.send('togglePinnedForUser');
},
showExpandButton: function() {
var post = this.get('post');
return post.get('post_number') === 1 && post.get('topic.expandable_first_post');

View File

@ -52,6 +52,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
'shift+j': 'nextSection',
'j': 'selectDown',
'shift+k': 'prevSection',
'shift+p': 'pinUnpinTopic',
'k': 'selectUp',
'u': 'goBack',
'/': 'showSearch',
@ -134,6 +135,10 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
Discourse.__container__.lookup('controller:composer').open({action: Discourse.Composer.CREATE_TOPIC, draftKey: Discourse.Composer.DRAFT});
},
pinUnpinTopic: function() {
Discourse.__container__lookup('controller:topic').togglePinnedState();
},
toggleProgress: function() {
Discourse.__container__.lookup('controller:topic-progress').send('toggleExpansion', {highlight: true});
},

View File

@ -38,6 +38,7 @@
<h4>{{i18n keyboard_shortcuts_help.actions.title}}</h4>
<ul>
<li>{{{i18n keyboard_shortcuts_help.actions.star}}}</li>
<li>{{{i18n keyboard_shortcuts_help.actions.pin_unpin_topic}}}</li>
<li>{{{i18n keyboard_shortcuts_help.actions.share_topic}}}</li>
<li>{{{i18n keyboard_shortcuts_help.actions.share_post}}}</li>
<li>{{{i18n keyboard_shortcuts_help.actions.reply_as_new_topic}}}</li>

View File

@ -2189,6 +2189,7 @@ en:
actions:
title: 'Actions'
star: '<b>f</b> Star topic'
pin_unpin_topic: '<b>shift p</b> Pin/Unpin topic'
share_topic: '<b>shift s</b> Share topic'
share_post: '<b>s</b> Share post'
reply_as_new_topic: '<b>t</b> Reply as linked topic'