Merge pull request #4274 from cpradio/fix-keyboard-shortcuts

FIX: Correct the topic notification keyboard shortcuts
This commit is contained in:
Jeff Atwood 2016-06-17 11:53:21 -07:00 committed by GitHub
commit c9de667a83
3 changed files with 33 additions and 4 deletions

View File

@ -11,5 +11,10 @@ export default MountWidget.extend({
@observes('topic.details.notification_level')
_triggerRerender() {
this.queueRerender();
},
didInsertElement() {
this._super();
this.dispatch('topic-notifications-button:keyboard-trigger', 'topic-notifications-button');
}
});

View File

@ -32,10 +32,10 @@ const bindings = {
'j': {handler: 'selectDown', anonymous: true},
'k': {handler: 'selectUp', anonymous: true},
'l': {click: '.topic-post.selected button.toggle-like'},
'm m': {click: 'div.notification-options li[data-id="0"] a'}, // mark topic as muted
'm r': {click: 'div.notification-options li[data-id="1"] a'}, // mark topic as regular
'm t': {click: 'div.notification-options li[data-id="2"] a'}, // mark topic as tracking
'm w': {click: 'div.notification-options li[data-id="3"] a'}, // mark topic as watching
'm m': {handler: 'setTrackingToMuted'}, // mark topic as muted
'm r': {handler: 'setTrackingToRegular'}, // mark topic as regular
'm t': {handler: 'setTrackingToTracking'}, // mark topic as tracking
'm w': {handler: 'setTrackingToWatching'}, // mark topic as watching
'o,enter': {click: '.topic-list tr.selected a.title', anonymous: true}, // open selected topic
'p': {handler: 'showCurrentUser'},
'q': {handler: 'quoteReply'},
@ -179,6 +179,22 @@ export default {
this.container.lookup('controller:application').send('showKeyboardShortcutsHelp');
},
setTrackingToMuted(event) {
this.appEvents.trigger('topic-notifications-button:keyboard-trigger', {type: 'notification', id: 0, event});
},
setTrackingToRegular(event) {
this.appEvents.trigger('topic-notifications-button:keyboard-trigger', {type: 'notification', id: 1, event});
},
setTrackingToTracking(event) {
this.appEvents.trigger('topic-notifications-button:keyboard-trigger', {type: 'notification', id: 2, event});
},
setTrackingToWatching(event) {
this.appEvents.trigger('topic-notifications-button:keyboard-trigger', {type: 'notification', id: 3, event});
},
sendToTopicListItemView(action) {
const elem = $('tr.selected.topic-list-item.ember-view')[0];
if (elem) {

View File

@ -86,5 +86,13 @@ export default createWidget('topic-notifications-button', {
notificationLevelChanged(id) {
this.state.expanded = false;
return this.attrs.topic.get('details').updateNotifications(id);
},
topicNotificationsButtonKeyboardTrigger(msg) {
switch(msg.type) {
case 'notification':
this.notificationLevelChanged(msg.id);
break;
}
}
});