diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 548fb692ee0..b4281a47dab 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -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'); diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index 8df10009d1c..6c9868d0568 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -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}); }, diff --git a/app/assets/javascripts/discourse/templates/modal/keyboard_shortcuts_help.hbs b/app/assets/javascripts/discourse/templates/modal/keyboard_shortcuts_help.hbs index afe909607b7..1c2d3adee3a 100644 --- a/app/assets/javascripts/discourse/templates/modal/keyboard_shortcuts_help.hbs +++ b/app/assets/javascripts/discourse/templates/modal/keyboard_shortcuts_help.hbs @@ -38,6 +38,7 @@