This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/views/buttons/notifications_button.js
Ryan Sullivan 5100c2bbd2 Add Global Keyboard Shortcuts
Not all of these have been fully implemented yet.

**Jump To**
* `g` then `h` - Home (Latest)
* `g` then `l` - Latest
* `g` then `n` - New
* `g` then `u` - Unread
* `g` then `f` - Favorited
* `g` then `c` - Categories List

**Navigation**
* `u` - Back to topic list
* `k` / `j` - Newer/Older conversation or post
* `o` or `Enter` - Open selected conversation
* <code>`</code> - Go to next section
* `~` - Go to previous section

**Application**
* `c` - Create a new topic
* `n` - Open notifications menu
* `/` - Search
* `?` - Open keyboard shortcut help

**Actions**
* `f` - Favorite topic
* `s` - Share topic
* `<Shift>` + `s` - Share selected post
* `r` - Reply to topic
* `<Shift>` + `r` - Reply to selected post
* `l` - Like selected post
* `!` - Flag selected post
* `b` - Bookmark selected post
* `e` - Edit selected post
* `d` - Delete selected post
* `m` then `m` - Mark topic as muted
* `m` then `r` - Mark topic as regular
* `m` then `t` - Mark topic as tracking
* `m` then `w` - Mark topic as watching
2013-12-22 12:16:42 -07:00

50 lines
1.8 KiB
JavaScript

/**
A button for favoriting a topic
@class NotificationsButton
@extends Discourse.DropdownButtonView
@namespace Discourse
@module Discourse
**/
Discourse.NotificationsButton = Discourse.DropdownButtonView.extend({
classNames: ['notification-options'],
title: I18n.t('topic.notifications.title'),
longDescriptionBinding: 'topic.details.notificationReasonText',
topic: Em.computed.alias('controller.model'),
hidden: Em.computed.alias('topic.deleted'),
dropDownContent: [
[Discourse.Topic.NotificationLevel.WATCHING, 'topic.notifications.watching'],
[Discourse.Topic.NotificationLevel.TRACKING, 'topic.notifications.tracking'],
[Discourse.Topic.NotificationLevel.REGULAR, 'topic.notifications.regular'],
[Discourse.Topic.NotificationLevel.MUTE, 'topic.notifications.muted']
],
text: function() {
var key = (function() {
switch (this.get('topic.details.notification_level')) {
case Discourse.Topic.NotificationLevel.WATCHING: return 'watching';
case Discourse.Topic.NotificationLevel.TRACKING: return 'tracking';
case Discourse.Topic.NotificationLevel.MUTE: return 'muted';
default: return 'regular';
}
}).call(this);
var icon = (function() {
switch (key) {
case 'watching': return '<i class="fa fa-circle heatmap-high"></i>&nbsp;';
case 'tracking': return '<i class="fa fa-circle heatmap-low"></i>&nbsp;';
case 'muted': return '<i class="fa fa-times-circle"></i>&nbsp;';
default: return '';
}
})();
return icon + (I18n.t("topic.notifications." + key + ".title")) + "<span class='caret'></span>";
}.property('topic.details.notification_level'),
clicked: function(id) {
return this.get('topic.details').updateNotifications(id);
}
});