Merge pull request #2219 from fantasticfears/notifications_button
set visual indicator for active notification level
This commit is contained in:
commit
01cf3cf0c8
|
@ -11,12 +11,13 @@ Discourse.DropdownButtonView = Discourse.View.extend({
|
||||||
shouldRerender: Discourse.View.renderIfChanged('text', 'longDescription'),
|
shouldRerender: Discourse.View.renderIfChanged('text', 'longDescription'),
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
|
var self = this;
|
||||||
// If there's a click handler, call it
|
// If there's a click handler, call it
|
||||||
if (this.clicked) {
|
if (self.clicked) {
|
||||||
var dropDownButtonView = this;
|
self.$('ul li').on('click.dropdown-button', function(e) {
|
||||||
this.$('ul li').on('click.dropdown-button', function(e) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
dropDownButtonView.clicked($(e.currentTarget).data('id'));
|
if ($(e.currentTarget).data('id') !== self.get('activeItem'))
|
||||||
|
self.clicked($(e.currentTarget).data('id'));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -27,26 +28,31 @@ Discourse.DropdownButtonView = Discourse.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function(buffer) {
|
render: function(buffer) {
|
||||||
buffer.push("<h4 class='title'>" + this.get('title') + "</h4>");
|
var self = this;
|
||||||
|
buffer.push("<h4 class='title'>" + self.get('title') + "</h4>");
|
||||||
buffer.push("<button class='btn standard dropdown-toggle' data-toggle='dropdown'>");
|
buffer.push("<button class='btn standard dropdown-toggle' data-toggle='dropdown'>");
|
||||||
buffer.push(this.get('text'));
|
buffer.push(self.get('text'));
|
||||||
buffer.push("</button>");
|
buffer.push("</button>");
|
||||||
buffer.push("<ul class='dropdown-menu'>");
|
buffer.push("<ul class='dropdown-menu'>");
|
||||||
|
|
||||||
_.each(this.get('dropDownContent'), function(row) {
|
_.each(self.get('dropDownContent'), function(row) {
|
||||||
var id = row[0],
|
var id = row[0],
|
||||||
textKey = row[1],
|
textKey = row[1],
|
||||||
|
iconClass = row[2],
|
||||||
title = I18n.t(textKey + ".title"),
|
title = I18n.t(textKey + ".title"),
|
||||||
description = I18n.t(textKey + ".description");
|
description = I18n.t(textKey + ".description"),
|
||||||
|
className = (self.get('activeItem') === id? 'disabled': '');
|
||||||
|
|
||||||
buffer.push("<li data-id=\"" + id + "\"><a href='#'>");
|
buffer.push("<li data-id=\"" + id + "\" class=\"" + className + "\"><a href='#'>");
|
||||||
buffer.push("<span class='title'>" + title + "</span>");
|
buffer.push("<span class='icon " + iconClass + "'></span>");
|
||||||
buffer.push("<span>" + description + "</span>");
|
buffer.push("<div><span class='title'>" + title + "</span>");
|
||||||
|
buffer.push("<span>" + description + "</span></div>");
|
||||||
buffer.push("</a></li>");
|
buffer.push("</a></li>");
|
||||||
});
|
});
|
||||||
|
|
||||||
buffer.push("</ul>");
|
buffer.push("</ul>");
|
||||||
|
|
||||||
var desc = this.get('longDescription');
|
var desc = self.get('longDescription');
|
||||||
if (desc) {
|
if (desc) {
|
||||||
buffer.push("<p>");
|
buffer.push("<p>");
|
||||||
buffer.push(desc);
|
buffer.push(desc);
|
||||||
|
|
|
@ -13,6 +13,7 @@ Discourse.NotificationsButton = Discourse.DropdownButtonView.extend({
|
||||||
topic: Em.computed.alias('controller.model'),
|
topic: Em.computed.alias('controller.model'),
|
||||||
hidden: Em.computed.alias('topic.deleted'),
|
hidden: Em.computed.alias('topic.deleted'),
|
||||||
isPrivateMessage: Em.computed.alias('topic.isPrivateMessage'),
|
isPrivateMessage: Em.computed.alias('topic.isPrivateMessage'),
|
||||||
|
activeItem: Em.computed.alias('topic.details.notification_level'),
|
||||||
|
|
||||||
dropDownContent: function() {
|
dropDownContent: function() {
|
||||||
var contents = [], postfix = '';
|
var contents = [], postfix = '';
|
||||||
|
@ -20,17 +21,18 @@ Discourse.NotificationsButton = Discourse.DropdownButtonView.extend({
|
||||||
if (this.get('isPrivateMessage')) { postfix = '_pm'; }
|
if (this.get('isPrivateMessage')) { postfix = '_pm'; }
|
||||||
|
|
||||||
_.each([
|
_.each([
|
||||||
['WATCHING', 'watching'],
|
['WATCHING', 'watching', 'fa fa-circle heatmap-high'],
|
||||||
['TRACKING', 'tracking'],
|
['TRACKING', 'tracking', 'fa fa-circle heatmap-low'],
|
||||||
['REGULAR', 'regular'],
|
['REGULAR', 'regular', ''],
|
||||||
['MUTED', 'muted']
|
['MUTED', 'muted', 'fa fa-times-circle']
|
||||||
], function(pair) {
|
], function(pair) {
|
||||||
|
|
||||||
if (postfix === '_pm' && pair[1] === 'regular') { return; }
|
if (postfix === '_pm' && pair[1] === 'regular') { return; }
|
||||||
|
|
||||||
contents.push([
|
contents.push([
|
||||||
Discourse.Topic.NotificationLevel[pair[0]],
|
Discourse.Topic.NotificationLevel[pair[0]],
|
||||||
'topic.notifications.' + pair[1] + postfix
|
'topic.notifications.' + pair[1] + postfix,
|
||||||
|
pair[2]
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -543,7 +543,7 @@ iframe {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.open>.dropdown-menu {
|
.open >.dropdown-menu {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,6 +866,10 @@ blockquote { /* solo quotes */
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
color: $primary_text_color;
|
color: $primary_text_color;
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
margin-left: 26px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.dropdown-menu li > a:hover,
|
.dropdown-menu li > a:hover,
|
||||||
.dropdown-menu .active > a,
|
.dropdown-menu .active > a,
|
||||||
|
@ -874,15 +878,32 @@ blockquote { /* solo quotes */
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
background-color: $emphasis_text_color;
|
background-color: $emphasis_text_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-menu .disabled > a,
|
||||||
|
.dropdown-menu .disabled > a:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: $primary_text_color;
|
||||||
|
background-color: $moderator_background_color;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu .icon {
|
||||||
|
margin-top: 3px;
|
||||||
|
float: left;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
.open > .dropdown-menu {
|
.open > .dropdown-menu {
|
||||||
display: block;
|
display: block;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fade {
|
.fade {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
-webkit-transition: opacity 0.15s linear;
|
-webkit-transition: opacity 0.15s linear;
|
||||||
transition: opacity 0.15s linear;
|
transition: opacity 0.15s linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fade.in {
|
.fade.in {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue